Exemple #1
0
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 = Attribute(default=None)
    array_direction = Attribute(default=None)
Exemple #2
0
class OpticalVelocity(BaseCoordinateFrame):
    default_representation = Cartesian1DRepresentation
    reference_position = FrameAttribute(default='BARYCENTER')
    rest = FrameAttribute()
    frame_specific_representation_info = {
        'cartesian1d': [RepresentationMapping('x', 'v', 'm/s')]
    }
Exemple #3
0
class TelescopeFrame(BaseCoordinateFrame):
    """
    Telescope coordinate frame.

    A Frame using a UnitSphericalRepresentation.
    This is basically the same as a HorizonCoordinate, but the
    origin is at the telescope's pointing direction.

    This is used to specify coordinates in the field of view of a
    telescope that is independent of the optical properties of the telescope.

    ``fov_lon`` is aligned with azimuth and ``fov_lat`` is aligned with altitude
    of the horizontal coordinate frame as implemented in ``astropy.coordinates.AltAz``.

    This is what astropy calls a SkyOffsetCoordinate.

    Attributes
    ----------

    telescope_pointing: SkyCoord[AltAz]
        Coordinate of the telescope pointing in AltAz
    obstime: Tiem
        Observation time
    location: EarthLocation
        Location of the telescope
    """

    frame_specific_representation_info = {
        UnitSphericalRepresentation: [
            RepresentationMapping("lon", "fov_lon"),
            RepresentationMapping("lat", "fov_lat"),
        ]
    }
    default_representation = UnitSphericalRepresentation

    telescope_pointing = CoordinateAttribute(default=None, frame=AltAz)

    obstime = TimeAttribute(default=None)
    location = EarthLocationAttribute(default=None)

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # make sure telescope coordinate is in range [-180°, 180°]
        if isinstance(self._data, UnitSphericalRepresentation):
            self._data.lon.wrap_angle = Angle(180, unit=u.deg)
Exemple #4
0
class EastingNorthingFrame(BaseCoordinateFrame):
    """GroundFrame but in standard Easting/Northing coordinates instead of
    SimTel/Corsika conventions

    Frame attributes: None

    """

    default_representation = CartesianRepresentation

    frame_specific_representation_info = {
        CartesianRepresentation: [
            RepresentationMapping("x", "easting"),
            RepresentationMapping("y", "northing"),
            RepresentationMapping("z", "height"),
        ]
    }
Exemple #5
0
class NominalFrame(BaseCoordinateFrame):
    """
    Nominal coordinate frame.

    A Frame using a UnitSphericalRepresentation.
    This is basically the same as a HorizonCoordinate, but the
    origin is at an arbitray position in the sky.
    This is what astropy calls a SkyOffsetCoordinate

    If the telescopes are in divergent pointing, this Frame can be
    used to transform to a common system.

    Attributes
    ----------

    origin: SkyCoord[AltAz]
        Origin of this frame as a HorizonCoordinate
    obstime: Tiem
        Observation time
    location: EarthLocation
        Location of the telescope
    """

    frame_specific_representation_info = {
        UnitSphericalRepresentation: [
            RepresentationMapping("lon", "fov_lon"),
            RepresentationMapping("lat", "fov_lat"),
        ]
    }
    default_representation = UnitSphericalRepresentation

    origin = CoordinateAttribute(default=None, frame=AltAz)

    obstime = TimeAttribute(default=None)
    location = EarthLocationAttribute(default=None)

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # make sure telescope coordinate is in range [-180°, 180°]
        if isinstance(self._data, UnitSphericalRepresentation):
            self._data.lon.wrap_angle = Angle(180, unit=u.deg)
Exemple #6
0
class SPIFrame(BaseCoordinateFrame):
    """
    
    INTEGRAL SPI Frame
    Parameters
    ----------
    representation : `BaseRepresentation` or None
        A representation object or None to have no data (or use the other keywords)
  
    """
    default_representation = coord.SphericalRepresentation

    frame_specific_representation_info = {
        'spherical': [
            RepresentationMapping(reprname='lon',
                                  framename='lon',
                                  defaultunit=u.degree),
            RepresentationMapping(reprname='lat',
                                  framename='lat',
                                  defaultunit=u.degree),
            RepresentationMapping(reprname='distance',
                                  framename='DIST',
                                  defaultunit=None)
        ],
        'unitspherical': [
            RepresentationMapping(reprname='lon',
                                  framename='lon',
                                  defaultunit=u.degree),
            RepresentationMapping(reprname='lat',
                                  framename='lat',
                                  defaultunit=u.degree)
        ],
        'cartesian': [
            RepresentationMapping(reprname='x', framename='SCX'),
            RepresentationMapping(reprname='y', framename='SCY'),
            RepresentationMapping(reprname='z', framename='SCZ')
        ]
    }

    # Specify frame attributes required to fully specify the frame
    scx_ra = Attribute(default=None)
    scx_dec = Attribute(default=None)

    scy_ra = Attribute(default=None)
    scy_dec = Attribute(default=None)

    scz_ra = Attribute(default=None)
    scz_dec = Attribute(default=None)
Exemple #7
0
class TelescopeFrame(BaseCoordinateFrame):
    '''
    Telescope coordinate frame.

    A Frame using a UnitSphericalRepresentation.
    This is basically the same as a HorizonCoordinate, but the
    origin is at the telescope's pointing direction.
    This is what astropy calls a SkyOffsetCoordinate

    Attributes
    ----------

    telescope_pointing: SkyCoord[HorizonFrame]
        Coordinate of the telescope pointing in HorizonFrame
    obstime: Tiem
        Observation time
    location: EarthLocation
        Location of the telescope
    '''
    frame_specific_representation_info = {
        UnitSphericalRepresentation: [
            RepresentationMapping('lon', 'delta_az'),
            RepresentationMapping('lat', 'delta_alt'),
        ]
    }
    default_representation = UnitSphericalRepresentation

    telescope_pointing = CoordinateAttribute(default=None, frame=HorizonFrame)

    obstime = TimeAttribute(default=None)
    location = EarthLocationAttribute(default=None)

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # make sure telescope coordinate is in range [-180°, 180°]
        if isinstance(self._data, UnitSphericalRepresentation):
            self._data.lon.wrap_angle = Angle(180, unit=u.deg)
Exemple #8
0
class GBMFrame(BaseCoordinateFrame):
    """
    
    Fermi GBM Frame

    Parameters
    ----------
    representation : `BaseRepresentation` or None
        A representation object or None to have no data (or use the other keywords)
  
    """

    default_representation = coord.SphericalRepresentation

    frame_specific_representation_info = {
        "spherical": [
            RepresentationMapping(reprname="lon",
                                  framename="lon",
                                  defaultunit=u.degree),
            RepresentationMapping(reprname="lat",
                                  framename="lat",
                                  defaultunit=u.degree),
            RepresentationMapping(reprname="distance",
                                  framename="DIST",
                                  defaultunit=None),
        ],
        "unitspherical": [
            RepresentationMapping(reprname="lon",
                                  framename="lon",
                                  defaultunit=u.degree),
            RepresentationMapping(reprname="lat",
                                  framename="lat",
                                  defaultunit=u.degree),
        ],
        "cartesian": [
            RepresentationMapping(reprname="x", framename="SCX"),
            RepresentationMapping(reprname="y", framename="SCY"),
            RepresentationMapping(reprname="z", framename="SCZ"),
        ],
    }

    # Specify frame attributes required to fully specify the frame
    sc_pos_X = Attribute(default=None)
    sc_pos_Y = Attribute(default=None)
    sc_pos_Z = Attribute(default=None)

    quaternion_1 = Attribute(default=None)
    quaternion_2 = Attribute(default=None)
    quaternion_3 = Attribute(default=None)
    quaternion_4 = Attribute(default=None)

    # equinox = TimeFrameAttribute(default='J2000')

    @staticmethod
    def _set_quaternion(q1, q2, q3, q4):
        sc_matrix = np.zeros((3, 3))

        sc_matrix[0, 0] = q1**2 - q2**2 - q3**2 + q4**2
        sc_matrix[0, 1] = 2.0 * (q1 * q2 + q4 * q3)
        sc_matrix[0, 2] = 2.0 * (q1 * q3 - q4 * q2)
        sc_matrix[1, 0] = 2.0 * (q1 * q2 - q4 * q3)
        sc_matrix[1, 1] = -(q1**2) + q2**2 - q3**2 + q4**2
        sc_matrix[1, 2] = 2.0 * (q2 * q3 + q4 * q1)
        sc_matrix[2, 0] = 2.0 * (q1 * q3 + q4 * q2)
        sc_matrix[2, 1] = 2.0 * (q2 * q3 - q4 * q1)
        sc_matrix[2, 2] = -(q1**2) - q2**2 + q3**2 + q4**2

        return sc_matrix
Exemple #9
0
class GBMFrame(BaseCoordinateFrame):
    """
    
    Fermi GBM Frame

    Parameters
    ----------
    representation : `BaseRepresentation` or None
        A representation object or None to have no data (or use the other keywords)
  
    """
    default_representation = coord.SphericalRepresentation

    frame_specific_representation_info = {
        'spherical': [
            RepresentationMapping(reprname='lon',
                                  framename='lon',
                                  defaultunit=u.degree),
            RepresentationMapping(reprname='lat',
                                  framename='lat',
                                  defaultunit=u.degree),
            RepresentationMapping(reprname='distance',
                                  framename='DIST',
                                  defaultunit=None)
        ],
        'unitspherical': [
            RepresentationMapping(reprname='lon',
                                  framename='lon',
                                  defaultunit=u.degree),
            RepresentationMapping(reprname='lat',
                                  framename='lat',
                                  defaultunit=u.degree)
        ],
        'cartesian': [
            RepresentationMapping(reprname='x', framename='SCX'),
            RepresentationMapping(reprname='y', framename='SCY'),
            RepresentationMapping(reprname='z', framename='SCZ')
        ]
    }

    # Specify frame attributes required to fully specify the frame
    sc_pos_X = Attribute(default=None)
    sc_pos_Y = Attribute(default=None)
    sc_pos_Z = Attribute(default=None)

    quaternion_1 = Attribute(default=None)
    quaternion_2 = Attribute(default=None)
    quaternion_3 = Attribute(default=None)
    quaternion_4 = Attribute(default=None)

    # equinox = TimeFrameAttribute(default='J2000')

    @staticmethod
    def _set_quaternion(q1, q2, q3, q4):
        sc_matrix = np.zeros((3, 3))

        sc_matrix[0, 0] = (q1**2 - q2**2 - q3**2 + q4**2)
        sc_matrix[0, 1] = 2.0 * (q1 * q2 + q4 * q3)
        sc_matrix[0, 2] = 2.0 * (q1 * q3 - q4 * q2)
        sc_matrix[1, 0] = 2.0 * (q1 * q2 - q4 * q3)
        sc_matrix[1, 1] = (-q1**2 + q2**2 - q3**2 + q4**2)
        sc_matrix[1, 2] = 2.0 * (q2 * q3 + q4 * q1)
        sc_matrix[2, 0] = 2.0 * (q1 * q3 + q4 * q2)
        sc_matrix[2, 1] = 2.0 * (q2 * q3 - q4 * q1)
        sc_matrix[2, 2] = (-q1**2 - q2**2 + q3**2 + q4**2)

        return sc_matrix
Exemple #10
0
class Frequency(BaseCoordinateFrame):
    default_representation = Cartesian1DRepresentation
    reference_position = FrameAttribute(default='BARYCENTER')
    frame_specific_representation_info = {
        'cartesian1d': [RepresentationMapping('x', 'freq', 'Hz')]
    }
Exemple #11
0
class Wavelength(BaseCoordinateFrame):
    default_representation = Cartesian1DRepresentation
    reference_position = FrameAttribute(default='BARYCENTER')
    frame_specific_representation_info = {
        'cartesian1d': [RepresentationMapping('x', 'lambda', 'm')]
    }