Tangent projection transformation
tan_dir() and tan_inv() implementations are taken from sections 3.1.1 and 3.1.2 of [R1]
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
[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 |
Contains the necessary information to translate from on-sky RA and DEC coordinates to the IFUAstrom reference system.
Parameters: | ra0, dec0 : float
rot : float
x_scale, y_scale : float, optional
|
---|
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.
Coordinate transformations
Created on Oct 4, 2011
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?
Converts decimal degrees to string in Degrees:Minutes:Seconds format with user specified delimiter.
Parameters: | decDeg : float
delimiter : string
|
---|---|
Returns: | string
|
Examples
>>> decimal2dms(40.42930556)
'+40:25:45.50'
Converts decimal degrees to string in Hours:Minutes:Seconds format with user specified delimiter.
Parameters: | RADeg : float
delimiter : string
|
---|---|
Returns: | string
|
Examples
>>> decimal2hms(40.42930556)
'02:41:43.033'
Converts a delimited string of Degrees:Minutes:Seconds format into decimal degrees.
Parameters: | dec_string : string
delimiter : string
|
---|---|
Returns: | dec_deg : float
|
Examples
>>> dms2decimal("+40:25:45.50")
40.42930555555555
Converts a delimited string of Hours:Minutes:Seconds format into decimal degrees.
Parameters: | ra_string : string
delimiter : string
|
---|---|
Returns: | ra_deg : float
|
Examples
>>> hms2decimal("02:41:43.033")
40.42930416666667
World coordinate system
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
Calculates the angular separation of two positions on the sky, assuming a tangent plane projection.
Parameters: | ra1 : float
dec1 : float
ra2 : float or numpy array
dec1 : float or numpy array
|
---|---|
Returns: | r : float or numpy array
|
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