'Generate and return a new representation of this frame\'s `data`
as a Representation object.
Note: In order to make an in-place change of the representation
of a Frame or SkyCoord object, set the ``representation``
attribute of that object to the desired new representation, or
use the ``set_representation_cls`` method to also set the differential.
Parameters
base : subclass of BaseRepresentation or string
The type of representation to generate.  Must be a *class*
(not an instance), or the string name of the representation
class.
s : subclass of `~astropy.coordinates.BaseDifferential`, str, optional
Class in which any velocities should be represented. Must be
a *class* (not an instance), or the string name of the
differential class.  If equal to \'base\' (default), inferred from
the base class.  If `None`, all velocity information is dropped.
in_frame_units : bool, keyword only
Force the representation units to match the specified units
particular to this frame
Returns
newrep : BaseRepresentation-derived object
A new representation object of this frame\'s `data`.
Raises
AttributeError
If this object had no `data`
Examples
>>> from astropy import units as u
>>> from astropy.coordinates import SkyCoord, CartesianRepresentation
>>> coord = SkyCoord(0*u.deg, 0*u.deg)
>>> coord.represent_as(CartesianRepresentation)
<CartesianRepresentation (x, y, z) [dimensionless]
( 1.,  0.,  0.)>
>>> coord.representation = CartesianRepresentation
>>> coord
<SkyCoord (ICRS): (x, y, z) [dimensionless]
( 1.,  0.,  0.)>'

def represent_as(self, base, s=u'base', in_frame_units=False):

    if isinstance(s, bool):
        warnings.warn(u'The    argument    position    for    `in_frame_units`    in    `represent_as`    has    changed.    Use    as    a    keyword    argument    if    needed.', AstropyWarning)
        in_frame_units = s
        s = u'base'
    repr_classes = _get_repr_classes(base=base, s=s)
    representation_cls = repr_classes[u'base']
    if (u's' in self.data.differentials):
        differential_cls = repr_classes[u's']
    elif ((s is None) or (s == u'base')):
        differential_cls = None
    else:
        raise TypeError(u'Frame    data    has    no    associated    differentials    (i.e.    the    frame    has    no    velocity    data)    -    represent_as()    only    accepts    a    new    representation.')
    if differential_cls:
        cache_key = (representation_cls.__name__, differential_cls.__name__, in_frame_units)
    else:
        cache_key = (representation_cls.__name__, in_frame_units)
    cached_repr = self.cache[u'representation'].get(cache_key)
    if (not cached_repr):
        if differential_cls:
            data = self.data.represent_as(representation_cls, differential_cls)
            diff = data.differentials[u's']
        else:
            data = self.data.represent_as(representation_cls)
        new_attrs = self.representation_info.get(representation_cls)
        if (new_attrs and in_frame_units):
            datakwargs = dict(((comp, getattr(data, comp)) for comp in data.components))
            for (comp, new_attr_unit) in zip(data.components, new_attrs[u'units']):
                if new_attr_unit:
                    datakwargs[comp] = datakwargs[comp].to(new_attr_unit)
            data = data.__class__(copy=False, **datakwargs)
        if differential_cls:
            data_diff = self.data.differentials[u's']
            new_attrs = self.representation_info.get(differential_cls)
            if (new_attrs and in_frame_units):
                diffkwargs = dict(((comp, getattr(diff, comp)) for comp in diff.components))
                for (comp, new_attr_unit) in zip(diff.components, new_attrs[u'units']):
                    if (isinstance(data_diff, (r.UnitSphericalDifferential, r.UnitSphericalCosLatDifferential)) and (comp not in data_diff.__class__.attr_classes)):
                        continue
                    elif (isinstance(data_diff, r.RadialDifferential) and (comp not in data_diff.__class__.attr_classes)):
                        continue
                    if (new_attr_unit and hasattr(diff, comp)):
                        diffkwargs[comp] = diffkwargs[comp].to(new_attr_unit)
                diff = diff.__class__(copy=False, **diffkwargs)
                data._differentials.update({u's': diff})
        self.cache[u'representation'][cache_key] = data
    return self.cache[u'representation'][cache_key]
