Spatial and Velocity Coordinates and Reference Frames#
This subpackage contains classes and functions related to spatial and spectral coordinates
Core Functions and Classes#
Core functions/classes for spatial and velocity coordinates and reference frames
- class dysh.coordinates.core.GB20M[source]#
Bases:
objectSingleton Green Bank 20 Meter Telescope EarthLocation object, using the Green Bank Observatory’s official coordinates for the site.
- class dysh.coordinates.core.GBT[source]#
Bases:
objectSingleton Green Bank Telescope EarthLocation object, using the Green Bank Observatory’s official coordinates for the site.
- class dysh.coordinates.core.Observatory[source]#
Bases:
objectClass that returns (latitude, longitude, altitude) of known observatories, using
astropy.coordinates.EarthLocation. This can be used for instance in transforming velocities between different reference frames.Methods
get_earth_location(latitude[, height, ellipsoid])Location on Earth, initialized from geodetic coordinates.
Examples
obs = Observatory() print(obs['GBT']) print(obs['ALMA'])
Alternatively, you can treat Observatory like a dict:
gbt = Observatory["GBT"]
- get_earth_location(latitude, height=0.0, ellipsoid=None)[source]#
Location on Earth, initialized from geodetic coordinates.
- Parameters:
- lon
Longitudeor float Earth East longitude. Can be anything that initialises an
Angleobject (if float, in degrees).- lat
Latitudeor float Earth latitude. Can be anything that initialises an
Latitudeobject (if float, in degrees).- height
Quantity[‘length’] or float, optional Height above reference ellipsoid (if float, in meters; default: 0).
- ellipsoidstr, optional
Name of the reference ellipsoid to use (default: ‘WGS84’). Available ellipsoids are: ‘WGS84’, ‘GRS80’, ‘WGS72’.
- lon
- Raises:
UnitsErrorIf the units on
lonandlatare inconsistent with angular ones, or that onheightwith a length.- ValueError
If
lon,lat, andheightdo not have the same shape, or ifellipsoidis not recognized as among the ones implemented.
Notes
See
from_geodetic()
- dysh.coordinates.core.decode_veldef(veldef)[source]#
Parse the SDFITS VELDEF value into its two components, the velocity definition and velocity reference frame. This value must contain no more than 8 characters where the first 4 characters describe the velocity definition and the last 4 characters describe the reference frame.
- Parameters:
- veldefstr
The definition string, consisting of a velocity convention and a velocity frame, e.g., ‘OPTI-LSR’
- Returns:
- A str tuple of velocity convention and velocity frame type, e.g., (‘radio’, ‘LSRK’)
- dysh.coordinates.core.eq2hor(lon, lat, frame, date_obs, unit='deg', location=<EarthLocation (882593.9465029, -4924896.36541728, 3943748.74743984) m>)[source]#
Equatorial to horizontal coordinate conversion.
- Parameters:
- lonfloat
Longitude coordinate. E.g., RA or Galactic longitude.
- latfloat
Latitude coordinate. E.g., Dec or Galactic latitude.
- framestr
Input coordinate frame. Must be recognized by
coordinates- date_obsstr
Date of observations. Must be a format compatible with
Time.- unitstr
Units of
lonandlat.- location
EarthLocation Observer location.
- Returns:
- altaz
AltAz Horizontal coordinates.
- altaz
- dysh.coordinates.core.gb20m_location()[source]#
Create an astropy EarthLocation for the 20 Meter using the same established by GBO.
- Returns:
- gb20m
EarthLocation astropy EarthLocation for the GBT.
- gb20m
- dysh.coordinates.core.gbt_location()[source]#
Create an astropy
EarthLocationfor the GBT using the same established by GBO. See page 3 of https://www.gb.nrao.edu/GBT/MC/doc/dataproc/gbtLOFits/gbtLOFits.pdflatitude = 38d 25m 59.265s N
longitude = 79d 50m 23.419s W
height = 854.83 m
Note these differ from astropy’s “GBT”
EarthLocationby several meters.- Returns:
- gbt
EarthLocation astropy EarthLocation for the GBT
- gbt
- dysh.coordinates.core.get_velocity_in_frame(target, toframe, observer=None, obstime=None)[source]#
Compute the radial velocity of a source in a new velocity frame.
- Parameters:
- target: `~astropy.coordinates.SkyCoord`
The sky coordinates of the object including proper motion and distance. Note: In order to get around a bug in astropy (link), if the
targetframe ortoframeis ‘lsrk’ (LSRK),done:
If proper motions attributes of
targetare not set, they will be set to zero.Similarly, if distance attribute of
targetis not set, it will be set to a very large number.This is done on a copy of the coordinate so as not to change the input object.
- toframe: str
The frame into which
coordshould be transformed, e.g., ‘icrs’, ‘lsrk’, ‘hcrs’. The string ‘topo’ is interpreted as ‘itrs’. See astropy-supported reference frames (link)- observer: `~astropy.coordinates.EarthLocation`
The location of the observer required for certain transformations (e.g. to/from GCRS or ITRS)
- obstime: `~astropy.time.Time`
The time of the observation, required for for certain transformations (e.g. to/from GCRS or ITRS)
- Returns:
- radial_velocity
Quantity The radial velocity of the source in
toframe
- radial_velocity
- dysh.coordinates.core.hor2eq(az, alt, frame, date_obs, unit='deg', location=<EarthLocation (882593.9465029, -4924896.36541728, 3943748.74743984) m>)[source]#
Horizontal to Equatorial coordinate conversion.
- Parameters:
- azfloat
Azimuth coordinate.
- altfloat
Altitude or elevation coordinate.
- framestr
Output coordinate frame. Must be recognized by
coordinates- date_obsstr
Date of observations. Must be a format compatible with
Time.- unitstr
Units of
lonandlat.- location
EarthLocation Observer location.
- Returns:
- eq
SkyCoord Celestial coordinates in
frame.
- eq
- dysh.coordinates.core.make_target(header)[source]#
Create a SkyCoord object from a SDFITS header dictionary CRVAL2, CRVAL3 are assumed to be the latitude-like and longitude-like coordinates. VELOCITY is taken to be the radial velocity. Coordinate frame is determined from RADESYS.
- Parameters:
- headerdict
The SDFITS header keyword dictionary
- Returns:
- target
SkyCoord A SkyCoord object based on the input coordinates and radial velocity
- target
- dysh.coordinates.core.ra2ha(lst, ra)[source]#
Take LST (sec) and RA (deg) and output wrapped HA (hr). Follows GBTIDL implementation (with the hour conversion included)
- dysh.coordinates.core.sanitize_skycoord(target)[source]#
Method to enforce certain attributes of input SkyCoordinate in order to workaround astropy bug that distance and proper motions need to be explicitly set for certain coordinate conversions, even if they are zero. See https://community.openastronomy.org/t/exception-raised-when-converting-from-lsrk-to-other-frames/841/2
- Parameters:
- target
SkyCoordinate - The input Sky Coordinate
- target
- Returns:
- sanitized_target
SkyCoordinate - Target with distance, radial velocity, and proper motion set.
- sanitized_target
- dysh.coordinates.core.topocentric_velocity_to_frame(target, toframe, observer, obstime)[source]#
Compute the difference in topocentric velocity and the velocity in the input frame.
- Parameters:
- target: `~astropy.coordinates.SkyCoord`
The sky coordinates of the object including proper motion and distance. Must be in ICRS
- target: `~astropy.coordinates.SkyCoord`
The sky coordinates of the object including proper motion and distance. Must be in ICRS
- toframe: str
The frame into which
coordshould be transformed, e.g., ‘icrs’, ‘lsrk’, ‘hcrs’. The string ‘topo’ is interpreted as ‘itrs’. See astropy-supported reference frames (link)- observer: `~astropy.coordinates.EarthLocation`
The location of the observer
- obstime: `~astropy.time.Time`
The time of the observation
- Returns:
- radial_velocity
Quantity The radial velocity of the source in
toframe
- radial_velocity
- dysh.coordinates.core.veldef_to_convention(veldef)[source]#
given a VELDEF, return the velocity convention expected by Spectrum(1D)
- Parameters:
- veldefstr
Velocity definition from FITS header, e.g., ‘OPTI-HELO’, ‘VELO-LSR’
- Returns:
- conventionstr
Velocity convention string, one of {‘radio’, ‘optical’, ‘relativistic’} or None if
velframecan’t be parsed
- dysh.coordinates.core.veltofreq(velocity, restfreq, veldef)[source]#
Convert velocity to frequency using the given rest frequency and velocity definition.
- Parameters:
- velocity: `~astropy.units.Quantity`
The velocity values
- restfreq: `~astropy.units.Quantity`
The rest frequency
- veldefstr
Velocity definition from FITS header, e.g., ‘OPTI-HELO’, ‘VELO-LSR’.
- Returns:
- frequency:
Quantity The velocity values converted to frequency using
restfreqandveldef.
- frequency: