Distances on the sky

Calculate distances on the celestial sphere

Methods in here are required as helper functions for cross-matching sources by position. Different algorithms with different numerical stability are implemented, but usually you should not need to call this directly. See the source code of YSOVAR.atlas.dict_from_csv() for an example how how this works.

YSOVAR.great_circle_dist.Haversine(phi_0, lam_0, phi_1, lam_1)

Calculates the angular distance between point 0 and point 1

uses the Haversine function, is numerically stable, except for antipodal points http://en.wikipedia.org/wiki/Great-circle_distance

Parameters:

phi_0 : float or numpy array

lattitude phi of point 0

lam_0 : float or numpy array

longitude lambda of point 0

phi_1 : float or numpy array

lattitude phi of point 1

lam_1 : float or numpy array

longitude lambda of point 1

Returns:

dist : float or numpy array

angular distance on great circle

YSOVAR.great_circle_dist.Vincenty(phi_0, lam_0, phi_1, lam_1)

Calculates the angular distance between point 0 and point 1

uses a special case of the Vincenty formula (which is for ellipsoides) numerically accurate, but computationally intensive see http://en.wikipedia.org/wiki/Great-circle_distance

Parameters:

phi_0 : float or numpy array

lattitude phi of point 0

lam_0 : float or numpy array

longitude lambda of point 0

phi_1 : float or numpy array

lattitude phi of point 1

lam_1 : float or numpy array

longitude lambda of point 1

Returns:

dist : float or numpy array

angular distance on great circle

YSOVAR.great_circle_dist.dist(phi_0, lam_0, phi_1, lam_1, unit=None)

Calculates the angular distance between point 0 and point 1

see http://en.wikipedia.org/wiki/Great-circle_distance

Parameters:

phi_0 : float or numpy array

lattitude phi of point 0

lam_0 : float or numpy array

longitude lambda of point 0

phi_1 : float or numpy array

lattitude phi of point 1

lam_1 : float or numpy array

longitude lambda of point 1

Returns:

dist : float or numpy array

angular distance on great circle

YSOVAR.great_circle_dist.dist_radec(phi_0, lam_0, phi_1, lam_1, unit=None)

Calculates the angular distance between point 0 and point 1

see http://en.wikipedia.org/wiki/Great-circle_distance

Parameters:

ra0 : float or numpy array

RA of point 0

dec0 : float or numpy array

DEC of point 0

ra1 : float or numpy array

RA of point 1

dec1 : float or numpy array

DEC of point 1

Returns:

dist : float or numpy array

angluar distance on great circle

YSOVAR.great_circle_dist.dist_radec_fast(ra0, dec0, ra, dec, scale=inf, *arg, **kwargs)

Calculates the angular distance between point 0 and point 1

Only if delta_dec is < scale, the full trigonometric calculation is done, otherwise return np.inf

see http://en.wikipedia.org/wiki/Great-circle_distance

Parameters:

ra0 : float or numpy array

RA of point 0

dec0 : float or numpy array

DEC of point 0

ra1 : float or numpy array

RA of point 1

dec1 : float or numpy array

DEC of point 1

Returns:

dist : float or numpy array

angluar distance on great circle

..note:: :

To be done:
  • cut on RA as well, but that requires knowledge of scale and the decorator transforms ra, dec only
  • merge this with ra_dec_dist and do fast verion if scale != None
YSOVAR.great_circle_dist.simple(phi_0, lam_0, phi_1, lam_1)

Calculates the angular distance between point 0 and point 1

uses a very simple formula, prone to numeric inaccuracies see http://en.wikipedia.org/wiki/Great-circle_distance

Parameters:

phi_0 : float or numpy array

lattitude phi of point 0

lam_0 : float or numpy array

longitude lambda of point 0

phi_1 : float or numpy array

lattitude phi of point 1

lam_1 : float or numpy array

longitude lambda of point 1

Returns:

dist : float or numpy array

angluar distance on great circle

YSOVAR.great_circle_dist.simple_decorator(decorator)

This decorator can be used to turn simple functions into well-behaved decorators, so long as the decorators are fairly simple. If a decorator expects a function and returns a function (no descriptors), and if it doesn’t modify function attributes or docstring, then it is eligible to use this. Simply apply @simple_decorator to your decorator and it will automatically preserve the docstring and function attributes of functions to which it is applied.

YSOVAR.great_circle_dist.unitchecked(f)

Decorator to transfrom units of angles

This decorator transforms units of angle, before they are fed into any a function to calculate the angular distance. It expects the unit as a keyword and transforms two sets of angular coordinates (phi_0, lam_0, phi_1, lam_1) to radian, calls the function and converts the output (in radian) into the unit of choice.