class HorizonFrame(BaseCoordinateFrame): """Horizon coordinate frame. Spherical system used to describe the direction of a given position, in terms of the altitude and azimuth of the system. In practice this is functionally identical as the astropy AltAz system, but this implementation allows us to pass array pointing information, allowing us to directly transform to the Horizon Frame from the Camera system. The Following attributes are carried over from the telescope frame to allow a direct transformation from the camera frame Frame attributes: * ``array_direction`` Alt,Az direction of the array pointing * ``pointing_direction`` Alt,Az direction of the telescope pointing """ default_representation = UnitSphericalRepresentation frame_specific_representation_info = { 'spherical': [ RepresentationMapping('lon', 'az'), RepresentationMapping('lat', 'alt') ], } frame_specific_representation_info[ 'unitspherical'] = frame_specific_representation_info['spherical'] pointing_direction = FrameAttribute(default=None) array_direction = FrameAttribute(default=None)
class NominalFrame(BaseCoordinateFrame): """Nominal coordinate frame. Cartesian system to describe the angular offset of a given position in reference to pointing direction of a nominal array pointing position. In most cases this frame is the same as the telescope frame, however in the case of divergent pointing they will differ. Event reconstruction should be performed in this system Frame attributes: * ``pointing_direction`` Alt,Az direction of the array pointing The Following attributes are carried over from the telescope frame to allow a direct transformation from the camera frame * ``focal_length`` Focal length of the telescope * ``rotation`` Rotation angle of the camera (0 in most cases) [deg] * ``pointing_direction`` Alt,Az direction of the telescope pointing """ default_representation = CartesianRepresentation array_direction = FrameAttribute(default=None) pointing_direction = FrameAttribute(default=None) rotation = FrameAttribute(default=0 * u.deg) focal_length = FrameAttribute(default=None)
class OpticalVelocity(BaseCoordinateFrame): default_representation = Cartesian1DRepresentation reference_position = FrameAttribute(default='BARYCENTER') rest = FrameAttribute() frame_specific_representation_info = { 'cartesian1d': [RepresentationMapping('x', 'v', 'm/s')] }
class TiltedTelescopeFrame(BaseCoordinateFrame): """Tilted telescope coordinate frame. """ default_representation = CartesianRepresentation # Is this the right frame for these attributes? pointing_direction = FrameAttribute(default=None) telescope_location = FrameAttribute(default=None)
class Heliocentric(BaseCoordinateFrame): """ A coordinate or frame in the Heliocentric system. This frame may either be specified in Cartesian or cylindrical representation. Cylindrical representation replaces (x, y) with (rho, psi) where rho is the impact parameter and psi is the position angle in degrees. Parameters ---------- representation: `~astropy.coordinates.BaseRepresentation` or None. A representation object. If specified, other parameters must be in keyword form and if x, y and z are specified, it must be None. x: `Quantity` object. X-axis coordinate, optional, must be keyword. y: `Quantity` object. Y-axis coordinate, optional, must be keyword. z: `Quantity` object. Shared by both representations. Z-axis coordinate, optional, must be keyword. D0: `Quantity` object. Represents the distance between the observer and the Sun center. Defaults to 1AU. Examples -------- >>> from astropy.coordinates import SkyCoord, CartesianRepresentation >>> import sunpy.coordinates >>> import astropy.units as u >>> sc = SkyCoord(CartesianRepresentation(10*u.km, 1*u.km, 2*u.km), ... dateobs="2011/01/05T00:00:50", frame="heliocentric") >>> sc <SkyCoord (HelioCentric): dateobs=2011-01-05 00:00:50, D0=149597870.7 km, x=10.0 km, y=1.0 km, z=2.0 km> >>> sc = SkyCoord([1,2]*u.km, [3,4]*u.m, [5,6]*u.cm, frame="heliocentric", dateobs="2011/01/01T00:00:54") >>> sc <SkyCoord (HelioCentric): dateobs=2011-01-01 00:00:54, D0=149597870.7 km, (x, y, z) in (km, m, cm) [(1.0, 3.0, 5.0), (2.0, 4.0, 6.0)]> """ default_representation = CartesianRepresentation _frame_specific_representation_info = { 'cylindrical': [RepresentationMapping('phi', 'psi', u.deg)] } # d = FrameAttribute(default=(1*u.au).to(u.km)) D0 = FrameAttribute(default=(1 * u.au).to(u.km)) dateobs = TimeFrameAttributeSunPy() L0 = FrameAttribute(default=0 * u.deg) B0 = FrameAttribute(default=0 * u.deg)
class CameraFrame(BaseCoordinateFrame): """Camera coordinate frame. The camera frame is a simple physical cartesian frame, describing the 2 dimensional position of objects in the focal plane of the telescope Most Typically this will be used to describe the positions of the pixels in the focal plane Frame attributes: * ``focal_length`` Focal length of the telescope as a unit quantity (usually meters) * ``rotation`` Rotation angle of the camera (0 deg in most cases) """ default_representation = CartesianRepresentation focal_length = FrameAttribute(default=None) rotation = FrameAttribute(default=0 * u.deg) pointing_direction = FrameAttribute(default=None) array_direction = FrameAttribute(default=None)
class TelescopeFrame(BaseCoordinateFrame): """Telescope coordinate frame. Cartesian system to describe the angular offset of a given position in reference to pointing direction of a given telescope When pointing corrections become available they should be applied to the transformation between this frame and the camera frame Frame attributes: - Focal length: Focal length of the telescope [m] - Rotation: Rotation angle of the camera (should be 0 in most cases) [deg] - Pointing Direction: Alt,Az direction of the telescope pointing """ default_representation = CartesianRepresentation focal_length = FrameAttribute(default=None) rotation = FrameAttribute(default=0*u.deg) pointing_direction = FrameAttribute(default=None)
class NominalFrame(BaseCoordinateFrame): """Nominal coordinate frame. Cartesian system to describe the angular offset of a given position in reference to pointing direction of a nominal array pointing position. In most cases this frame is the same as the telescope frame, however in the case of divergent pointing they will differ. Event reconstruction should be performed in this system Frame attributes: * ``array_direction`` Alt,Az direction of the array pointing * ``pointing_direction`` Alt,Az direction of the telescope pointing """ default_representation = PlanarRepresentation pointing_direction = FrameAttribute(default=None) array_direction = FrameAttribute(default=None)
class TelescopeFrame(BaseCoordinateFrame): """Telescope coordinate frame. Frame attributes: - Focal length """ default_representation = CartesianRepresentation # TODO: probably this should not have a default! focal_length = FrameAttribute(default=15.*u.m)
class TelescopeFrame(BaseCoordinateFrame): """Telescope coordinate frame. Cartesian system to describe the angular offset of a given position in reference to pointing direction of a given telescope When pointing corrections become available they should be applied to the transformation between this frame and the camera frame Frame attributes: * ``focal_length`` Focal length of the telescope as a unit quantity (usually meters) * ``rotation`` Rotation angle of the camera (0 deg in most cases) * ``pointing_direction`` Alt,Az direction of the telescope pointing """ default_representation = CartesianRepresentation focal_length = FrameAttribute(default=None) # focal_length rotation = FrameAttribute(default=0 * u.deg) pointing_direction = FrameAttribute(default=None)
class GroundFrame(BaseCoordinateFrame): """Ground coordinate frame. The ground coordinate frame is a simple cartesian frame describing the 3 dimensional position of objects compared to the array ground level in relation to the nomial centre of the array. Typically this frame will be used for describing the position on telescopes and equipment Frame attributes: None """ default_representation = CartesianRepresentation # Pointing direction of the tilted system (alt,az), # could be the telescope pointing direction or the reconstructed shower # direction pointing_direction = FrameAttribute(default=None)
class TiltedGroundFrame(BaseCoordinateFrame): """Tilted ground coordinate frame. The tilted ground coordinate frame is a cartesian system describing the 2 dimensional projected positions of objects in a tilted plane described by pointing_direction Typically this frame will be used for the reconstruction of the shower core position Frame attributes: pointing_direction - Alt,Az direction of the tilted reference plane """ default_representation = CartesianRepresentation # Pointing direction of the tilted system (alt,az), # could be the telescope pointing direction or the reconstructed shower direction pointing_direction = FrameAttribute(default=None)
class Helioprojective(BaseCoordinateFrame): """ A coordinate or frame in the Helioprojective (Cartesian) system. This is a projective coordinate system centered around the observer. It is a full spherical coordinate system with position given as longitude theta_x and latitude theta_y. Parameters ---------- representation: `~astropy.coordinates.BaseRepresentation` or None. A representation object. If specified, other parameters must be in keyword form. Tx: `~astropy.coordinates.Angle` or `~astropy.units.Quantity` X-axis coordinate. Ty: `~astropy.coordinates.Angle` or `~astropy.units.Quantity` Y-axis coordinate. distance: `~astropy.units.Quantity` The radial distance from the observer to the coordinate point. L0: `~astropy.coordinates.Angle` The Heliographic (Stonyhurst) Longitude of the observer. B0: `~astropy.coordinates.Angle` or `~astropy.units.Quantity` The Heliographic (Stonyhurst) Latitude of the observer. D0: `Quantity` object. Represents the distance between observer and solar center. **Defaults to 1 AU**. Examples -------- >>> from astropy.coordinates import SkyCoord >>> import astropy.units as u >>> sc = SkyCoord(0*u.deg, 0*u.deg, 5*u.km, dateobs="2010/01/01T00:00:00", ... frame="helioprojective") >>> sc <SkyCoord (HelioProjective): dateobs=2010-01-01 00:00:00, D0=149597870.7 km , Tx=0.0 arcsec, Ty=0.0 arcsec, distance=5.0 km> >>> sc = SkyCoord(0*u.deg, 0*u.deg, dateobs="2010/01/01T00:00:00", frame="helioprojective") >>> sc <SkyCoord (HelioProjective): dateobs=2010-01-01 00:00:00, D0=149597870.7 km , Tx=0.0 arcsec, Ty=0.0 arcsec, distance=149597870.7 km> """ default_representation = SphericalWrap180Representation _frame_specific_representation_info = { 'spherical': [ RepresentationMapping('lon', 'Tx', u.arcsec), RepresentationMapping('lat', 'Ty', u.arcsec), RepresentationMapping('distance', 'distance', u.km) ], 'sphericalwrap180': [ RepresentationMapping('lon', 'Tx', u.arcsec), RepresentationMapping('lat', 'Ty', u.arcsec), RepresentationMapping('distance', 'distance', u.km) ], 'unitspherical': [ RepresentationMapping('lon', 'Tx', u.arcsec), RepresentationMapping('lat', 'Ty', u.arcsec) ], 'unitsphericalwrap180': [ RepresentationMapping('lon', 'Tx', u.arcsec), RepresentationMapping('lat', 'Ty', u.arcsec) ] } D0 = FrameAttribute(default=(1 * u.au).to(u.km)) dateobs = TimeFrameAttributeSunPy() L0 = FrameAttribute(default=0 * u.deg) B0 = FrameAttribute(default=0 * u.deg) rsun = FrameAttribute(default=RSUN_METERS.to(u.km)) def __init__(self, *args, **kwargs): _rep_kwarg = kwargs.get('representation', None) BaseCoordinateFrame.__init__(self, *args, **kwargs) # Convert from Spherical to SphericalWrap180 # If representation was explicitly passed, do not change the rep. if not _rep_kwarg: # The base __init__ will make this a UnitSphericalRepresentation # This makes it Wrap180 instead if isinstance(self._data, UnitSphericalRepresentation): self._data = UnitSphericalWrap180Representation( lat=self._data.lat, lon=self._data.lon) self.representation = UnitSphericalWrap180Representation # Make a Spherical Wrap180 instead elif isinstance(self._data, SphericalRepresentation): self._data = SphericalWrap180Representation( lat=self._data.lat, lon=self._data.lon, distance=self._data.distance) self.representation = SphericalWrap180Representation def calculate_distance(self): """ This method calculates the third coordnate of the Helioprojective frame. It assumes that the coordinate point is on the disk of the Sun at the rsun radius. If a point in the frame is off limb then NaN will be returned. Returns ------- new_frame : `~sunpy.coordinates.frames.HelioProjective` A new frame instance with all the attributes of the original but now with a third coordinate. """ # Skip if we already are 3D if isinstance(self._data, SphericalRepresentation): return self rep = self.represent_as(UnitSphericalWrap180Representation) lat, lon = rep.lat, rep.lon alpha = np.arccos(np.cos(lat) * np.cos(lon)).to(lat.unit) c = self.D0**2 - self.rsun**2 b = -2 * self.D0.to(u.m) * np.cos(alpha) d = ((-1 * b) - np.sqrt(b**2 - 4 * c)) / 2 return self.realize_frame( SphericalWrap180Representation(lon=lon, lat=lat, distance=d))
class GroundFrame(BaseCoordinateFrame): """Ground coordinate frame. """ default_representation = CartesianRepresentation observatory_location = FrameAttribute(default=None)
class Frequency(BaseCoordinateFrame): default_representation = Cartesian1DRepresentation reference_position = FrameAttribute(default='BARYCENTER') frame_specific_representation_info = { 'cartesian1d': [RepresentationMapping('x', 'freq', 'Hz')] }
class Wavelength(BaseCoordinateFrame): default_representation = Cartesian1DRepresentation reference_position = FrameAttribute(default='BARYCENTER') frame_specific_representation_info = { 'cartesian1d': [RepresentationMapping('x', 'lambda', 'm')] }