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: object

Singleton 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: object

Singleton Green Bank Telescope EarthLocation object, using the Green Bank Observatory’s official coordinates for the site.

class dysh.coordinates.core.Observatory[source]#

Bases: object

Class 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:
lonLongitude or float

Earth East longitude. Can be anything that initialises an Angle object (if float, in degrees).

latLatitude or float

Earth latitude. Can be anything that initialises an Latitude object (if float, in degrees).

heightQuantity [‘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’.

Raises:
UnitsError

If the units on lon and lat are inconsistent with angular ones, or that on height with a length.

ValueError

If lon, lat, and height do not have the same shape, or if ellipsoid is not recognized as among the ones implemented.

Notes

See from_geodetic()

dysh.coordinates.core.change_ctype(ctype, toframe)[source]#
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 lon and lat.

locationEarthLocation

Observer location.

Returns:
altazAltAz

Horizontal coordinates.

dysh.coordinates.core.gb20m_location()[source]#

Create an astropy EarthLocation for the 20 Meter using the same established by GBO.

Returns:
gb20mEarthLocation

astropy EarthLocation for the GBT.

dysh.coordinates.core.gbt_location()[source]#

Create an astropy EarthLocation for the GBT using the same established by GBO. See page 3 of https://www.gb.nrao.edu/GBT/MC/doc/dataproc/gbtLOFits/gbtLOFits.pdf

  • latitude = 38d 25m 59.265s N

  • longitude = 79d 50m 23.419s W

  • height = 854.83 m

Note these differ from astropy’s “GBT” EarthLocation by several meters.

Returns:
gbtEarthLocation

astropy EarthLocation for the 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 target frame or toframe is ‘lsrk’ (LSRK),

done:

  • If proper motions attributes of target are not set, they will be set to zero.

  • Similarly, if distance attribute of target is 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 coord should 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_velocityQuantity

The radial velocity of the source in toframe

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 lon and lat.

locationEarthLocation

Observer location.

Returns:
eqSkyCoord

Celestial coordinates in frame.

dysh.coordinates.core.is_topocentric(veldef)[source]#
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:
targetSkyCoord

A SkyCoord object based on the input coordinates and radial velocity

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.replace_convention(veldef, doppler_convention)[source]#
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:
targetSkyCoordinate
The input Sky Coordinate
Returns:
sanitized_targetSkyCoordinate
Target with distance, radial velocity, and proper motion set.
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 coord should 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_velocityQuantity

The radial velocity of the source in toframe

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 velframe can’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 restfreq and veldef.