coordinates – Coordinates transformation

tangent_projection – Tangent projection transformation

Tangent projection transformation

tan_dir() and tan_inv() implementations are taken from sections 3.1.1 and 3.1.2 of [R1]

Examples

Example of use of this module:

>>> ra0 = 0.
>>> dec0 = 70.
>>> rot = 0.
>>> x_in, y_in = 10., 0.
>>> # multiply by -1 to make positive x point east for 0 Deg rotation
>>> ifu = IFUAstrom(ra0=ra0, dec0=dec0, rot=rot, x_scale= -1, y_scale=1)
>>> ra, dec = ifu.tan_inv(x_in, y_in)
>>> x_out, y_out = ifu.tan_dir(ra, dec)
>>> ra, dec
(-0.0081216788349454117, 69.999999814997963)
>>> x_out, y_out
(9.9999999999999964, 2.2899993733449891e-11)
>>> # Naive calculation
>>> import numpy as np
>>> -1. * (ra - ra0) * 3600. * np.cos(np.deg2rad(dec0))
9.9999999330230906
>>> (dec - dec0) * 3600.
-0.00066600733248378674

Todo

check the module and its the documentation

Tests for tan_dir() and tan_inv() need values obtain from external codes as reference

References

[R1]Eric W. Greisen, AIPS Memo 27, Non-linear Coordinate Systems in AIPS, Reissue of November 1983 version, 1993, ftp://ftp.aoc.nrao.edu/pub/software/aips/TEXT/PUBL/AIPSMEMO27.PS

Attributes

DEGPERRAD : float
Degrees per radians
class pyhetdex.coordinates.tangent_projection.IFUAstrom(ra0, dec0, rot, x_scale=-1.0, y_scale=1.0)[source]

Contains the necessary information to translate from on-sky RA and DEC coordinates to the IFUAstrom reference system.

Parameters:

ra0, dec0 : float

ra and dec coordinate that correspond to x=0 and y=0 in the IFUASTROM mapping file

rot : float

Rotation of the IFUASTROM, measured East of North such that a galaxy with a +10 Deg position angle on sky would be aligned with the y-axis in and IFUASTROM that is rotated by +10 Deg.

x_scale, y_scale : float, optional

IFUASTROM plate scale.

Notes

All the above parameters are saved into the corresponding attributes

When x_scale=-1 and y_scale=1 the IFUASTROM mapping file is perfect in arcseconds.

tan_dir(ra_in, dec_in)[source]

Direct tangent transform

Calculate x and y coordinates for positions in the IFUAstrom coordinate frame.

Parameters:

ra_in, dec_in : nd-array

ra and dec coordinate in degrees

Returns:

x_out, y_out : nd-arrays

x and y coordinates (in IFUAstrom coordinates, i.e. arcsec).

tan_inv(x_in, y_in)[source]

inverse tangent transform

Calculates RA and DEC coordinates for positions in the IFUAstrom coordinate frame.

Parameters:

x_in, y_in : nd-array

x and y coordinate in arcseconds

Returns:

ra_out, dec_out : nd-arrays

RA/DEC coordinates in degree

transformations – Celestial coordinate transformations

Coordinate transformations

Created on Oct 4, 2011

Notes

These routines are taken from astlib

Todo

decimal2dms(): the two external if branches are almost exact repetitions. Solution: save the sign of the input decDeg variable; convert the input as it were positive, the add the sign before returning. Also most of the internal if branches are either superfluous or repetitions that can be factored out.

Also decimal2hms() show a fair amount of repetitions, in big part similar to the above function.

Once the refactoring is finished, the tests should be updated to cover all the branches.

hms2decimal() tests fail: all the input values in the setup_class method are obtained with ned calculator. The values obtained with the function disagrees at the 7th digit level with the value from ned (should we consider it a failure?). Using only the hour, the values is wrong.

Should we use astropy.coordinates instead of this implementation?

pyhetdex.coordinates.transformations.decimal2dms(decDeg, delimiter=':')[source]

Converts decimal degrees to string in Degrees:Minutes:Seconds format with user specified delimiter.

Parameters:

decDeg : float

coordinate in decimal degrees

delimiter : string

delimiter character in returned string

Returns:

string

coordinate string in D:M:S format

Examples

>>> decimal2dms(40.42930556)
'+40:25:45.50'
pyhetdex.coordinates.transformations.decimal2hms(RADeg, delimiter=':')[source]

Converts decimal degrees to string in Hours:Minutes:Seconds format with user specified delimiter.

Parameters:

RADeg : float

coordinate in decimal degrees

delimiter : string

delimiter character in returned string

Returns:

string

coordinate string in Hour:Minutes:Seconds format

Examples

>>> decimal2hms(40.42930556)
'02:41:43.033'
pyhetdex.coordinates.transformations.dms2decimal(dec_string, delimiter=':')[source]

Converts a delimited string of Degrees:Minutes:Seconds format into decimal degrees.

Parameters:

dec_string : string

coordinate string in D :M:S format

delimiter : string

delimiter character in dec_string

Returns:

dec_deg : float

coordinate in decimal degrees

Examples

>>> dms2decimal("+40:25:45.50")
40.42930555555555
pyhetdex.coordinates.transformations.hms2decimal(ra_string, delimiter=':')[source]

Converts a delimited string of Hours:Minutes:Seconds format into decimal degrees.

Parameters:

ra_string : string

coordinate string in H :M:S format

delimiter : string

delimiter character in RAString

Returns:

ra_deg : float

coordinate in decimal degrees

Examples

>>> hms2decimal("02:41:43.033")
40.42930416666667

wcs – World coordinate system

World coordinate system

pyhetdex.coordinates.wcs.deg2pix(degree, scale=1.698)[source]

Convert degrees in pixels, given a pixel scale

Parameters:

degree : float

angle to convert

scale : float, optional

pixel scale

Returns:

float

number of pixels

distances – Angular coordinate distances

Distances on sky

This module contain functionalities to measure angular distances between objects

Todo

angular_separation_deg(): the test fails. Where it is possible to get a reference value? http://cads.iiap.res.in/tools/angularSeparation and http://www.asdc.asi.it/dist.html gives very different answers, and none of them agrees with the output of the function

pyhetdex.coordinates.distances.angular_separation_deg(ra1, dec1, ra2, dec2)[source]

Calculates the angular separation of two positions on the sky, assuming a tangent plane projection.

Parameters:

ra1 : float

R.A. in decimal degrees for position 1

dec1 : float

dec. in decimal degrees for position 1

ra2 : float or numpy array

R.A. in decimal degrees for position 2

dec1 : float or numpy array

dec. in decimal degrees for position 2

Returns:

r : float or numpy array

angular separation in decimal degrees

Notes

separation has to be less than 90 deg

Examples

>>> ra1, dec1 = 31.4324, 68.5432
>>> ra2, dec2 = 45.65, 23.452
>>> angular_separation_deg(ra1, dec1, ra2, dec2)
59.159481204617087