coordinates module

A module providing facilities for coordinate conversion.

This module provides methods that allow for conversion between the Cartesian (x, y) image coordinates and two different astrophysical coordinate systems: Horizontal (alt, az) and Equatorial (ra, dec). Two methods account for irregularities in the lens during these conversions. One method finds stars, and another finds the difference between the expected and actual locations of an star in an image. These two methods are used to verify the methods that correct for irregularities in the lens.

coordinates.altaz_to_radec(alt, az, time, camera='KPNO')[source]

Convert a set of (alt, az) coordinates to (ra, dec) coordinates, element-wise.

Parameters:
  • alt (array_like) – The altitude coordinates.
  • az (array_like) – The azimuth coordinates.
  • time (astropy.time.core.aptime.Time) – The time and date to use in the conversion.
Returns:

  • ra (array_like) – The right-ascension coordinates. This is a scalar if alt and az are scalars.
  • dec (array_like) – The declination coordinates. This is a scalar if alt and az are scalars.

See also

timestring_to_obj()
Convert a date and filename to an astropy.Time object.

Notes

The time parameter is used for the mapping from altitude and azimuth to right ascension and declination. Astropy is used to perform this conversion.

coordinates.altaz_to_xy(alt, az, camera='KPNO')[source]

Convert a set of (alt, az) coordinates to (x, y) coordinates, element-wise.

Parameters:
  • alt (array_like) – The altitude coordinates.
  • az (array_like) – The azimuth coordinates.
  • camera ({"KPNO" "SW"}) – The camera used to take the image. “KPNO” represents the all-sky camera at Kitt-Peak. “SW” represents the spacewatch all-sky camera. Defaults to “KPNO”.
Returns:

  • x (array_like) – The x coordinates. This is a scalar if alt and az are scalars.
  • y (array_like) – The y coordinates. This is a scalar if alt and az are scalars.

Notes

The altitude and azimuthal angles corresponding to each (x, y) position are determined using the position of the all-sky camera at the Kitt Peak National Observatory.

coordinates.camera_conv(x, y, az)[source]

Convert from image coordinates to expected galactic coordinates accounting for distortions in the camera lens.

Parameters:
  • x (array_like) – The x coordinates.
  • y (array_like) – The y coordiantes.
  • az (array_like) – The azimuth coordinates.
Returns:

  • x (array_like) – The x coordinates. This is a scalar if x, y, and az are scalars.
  • y (array_like) – The y coordinates. This is a scalar if x, y, and az are scalars.

Notes

This method uses a model that depends on x, y and radial distance to correct for distortions in the fisheye lens. The radial distance is calculated from the x and y positions. Before the computation is performed, the azimuthal angle is decreased by 0.94444 to account for a mismatch between true north and north on the image.

The exact mathematical model is as follows:

\[az_{new} = az - 0.731*\cos(0.993*(az + 34.5)) + 0.181\]
\[r_{new} = r + 2.358*\cos(0.99*(az - 40.8)) - 0.729\]

where the azimuthal angle is in radians. This conversion is performed in this order, and the corrected aziumthal angle is used in calculating the new radial distance.

coordinates.delta_r(img, centerx, centery)[source]

Find the difference between the calculated radial position of a star and the true radial position of the star.

Parameters:
  • img (numpy.ndarray) – A greyscale image.
  • centerx (float) – The x coordinate of the star’s center.
  • centery (float) – The y coordinate of the star’s center.
Returns:

  • rexpected (float) – The radial position of the star as calculated from its true position.
  • ractual (float) – The radial position of the star as it appears in the image.
  • deltar (float) – The difference between rexpected and ractual.

See also

find_star()
Find a star near a given coordinate.

Notes

find_star is used to find the position of the star in the image using the true position of the star as the initial guess.

This method is useful when performing a chi-squared analysis. Modifications to the model representing the irregularities in the lens will change the difference between the true radial distance and the radial distance in the saved image.

coordinates.find_star(img, centerx, centery, square=6)[source]

Find a star near a given (x, y) coordinate.

The search area for this method is defined as a square, centered at centerx and centery, with a sidelength of double the square parameter.

Parameters:
  • img (numpy.ndarray) – A greyscale image.
  • centerx (float) – The x coordinate of the center of the search box.
  • centery (float) – The y coordinate of the center of the search box.
  • square (int, optional) – Half of the side length of the square to search within. Defaults to 6.
Returns:

  • x (float) – The x coordinate of the star.
  • y (float) – The y coordinate of the star.

Notes

This method uses a center of mass formula to search for a star. The search area is defined as a square of size 2* square centered on centerx and centery. The pixel values within this square are increased according to the formula:

\[w = \exp(v/10)\]

where w is defined as the “weight” of the pixel and v is the greyscale pixel value. The average weight of all the pixels within the search square is calculated. Any weights that fall below the average are set to 0. Finally, the method finds the center of mass of the weights, which approximates the center of the star very well.

In order to increase the method”s accuracy, it runs recursively. The discovered position of the star is used as the centerx and centery guesses for the next iteration. The size of the square is decreased by 2 with each iteration until it is less than 2. At this point the final position of the star is returned.

coordinates.galactic_conv(x, y, az)[source]

Convert from expected galactic coordinates to image coordinates accounting for distortions in the camera lens.

Parameters:
  • x (array_like) – The x coordinates.
  • y (array_like) – The y coordiantes.
  • az (array_like) – The azimuth coordinates.
Returns:

  • x (array_like) – The x coordinates. This is a scalar if x, y, and az are scalars.
  • y (array_like) – The y coordinates. This is a scalar if x, y, and az are scalars.

Notes

This method uses a model that depends on x, y and radial distance to correct for distortions in the fisheye lens. The radial distance is calculated from the x and y positions. Before the computation is performed, the azimuthal angle is decreased by 0.94444 to account for a mismatch between true north and north on the image.

The exact mathematical model is as follows:

\[r_{new} = r + 2.369*\cos(0.997*(az - 42.088)) + 0.699\]
\[az_{new} = az + 0.716*\cos(1.015*(az + 31.358)) - 0.181\]

where the azimuthal angle is in radians.

coordinates.radec_to_altaz(ra, dec, time)[source]

Convert a set of (ra, dec) coordinates to (alt, az) coordinates, element-wise.

Parameters:
  • ra (array_like) – The right ascension coordinates.
  • dec (array_like) – The declination coordinates.
  • time (astropy.time.core.aptime.Time) – The time and date to use in the conversion.
Returns:

  • alt (array_like) – The altitude coordinates. This is a scalar if ra and dec are scalars.
  • az (array_like) – The azimuth coordinates. This is a scalar if ra and dec are scalars.

See also

timestring_to_obj()
Convert a date and filename to an astropy.Time object.

Notes

The time parameter is used for the mapping from altitude and azimuth to right ascension and declination. Astropy is used to perform this conversion.

coordinates.radec_to_xy(ra, dec, time, camera='KPNO')[source]

Convert a set of (ra, dec) coordinates to (x, y) coordinates, element-wise.

Parameters:
  • ra (array_like) – The right ascension coordinates.
  • dec (array_like) – The declination coordinates.
  • camera ({"KPNO" "SW"}) – The camera used to take the image. “KPNO” represents the all-sky camera at Kitt-Peak. “SW” represents the spacewatch all-sky camera. Defaults to “KPNO”.
  • time (astropy.time.core.aptime.Time) – The time and date to use in the conversion.
Returns:

  • x (array_like) – The x coordinates. This is a scalar if ra and dec are scalars.
  • y (array_like) – The y coordinates. This is a scalar if ra and dec are scalars.

See also

timestring_to_obj()
Convert a date and filename to an astropy.Time object.
galactic_conv()
Convert from expected galactic coordinates to image coordinates accounting for distortions in the camera lens.

Notes

The time parameter is used for the mapping from altitude and azimuth to right ascension and declination.

This method first converts the right ascension and declination coordinates to altitude and azimuth using radec_to_altaz. It then converts the altitude and azimuth coordinates to x and y using altaz_to_xy. From there, lens distortion is corrected for by using galactic_conv, and the final x and y coordinates are returned.

coordinates.timestring_to_obj(date, filename)[source]

Convert a date and filename to an astropy Time object.

Parameters:
  • date (str) – The date on which the image was taken in yyyymmdd format.
  • filename (str) – The image”s filename.
Returns:

When the image was taken.

Return type:

astropy.time.core.aptime.Time

coordinates.xy_to_altaz(x, y, camera='KPNO')[source]

Convert a set of (x, y) coordinates to (alt, az) coordinates, element-wise.

Parameters:
  • x (array_like) – The x coordinates.
  • y (array_like) – The y coordinates.
  • camera ({"KPNO", "SW"}) – The camera used to take the image. “KPNO” represents the all-sky camera at Kitt-Peak. “SW” represents the spacewatch all-sky camera. Defaults to “KPNO”.
Returns:

  • alt (array_like) – The altitude coordinates. This is a scalar if x and y are scalars.
  • az (array_like) – The azimuth coordinates. This is a scalar if x and y are scalars.

Notes

The altitude and azimuthal angles corresponding to each (x, y) position are determined using the position of the all-sky camera at the Kitt Peak National Observatory.

coordinates.xy_to_radec(x, y, time, camera='KPNO')[source]

Convert a set of (x, y) coordinates to (ra, dec) coordinates, element-wise.

Parameters:
  • x (array_like) – The x coordinates.
  • y (array_like) – The y coordinates.
  • camera ({"KPNO" "SW"}) – The camera used to take the image. “KPNO” represents the all-sky camera at Kitt-Peak. “SW” represents the spacewatch all-sky camera. Defaults to “KPNO”.
  • time (astropy.time.core.aptime.Time) – The time and date at which the image was taken.
Returns:

  • ra (array_like) – The right-ascension coordinates. This is a scalar if x and y are scalars.
  • dec (array_like) – The declination coordinates. This is a scalar if x and y are scalars.

See also

timestring_to_obj()
Convert a date and filename to an astropy.Time object.
camera_conv()
Convert from image coordinates to expected galactic coordinates accounting for distortions in the camera lens.

Notes

The time parameter is used for the mapping from altitude and azimuth to right ascension and declination.

This method first converts the x and y coordinates to altitude and azimuth using xy_to_altaz. It then converts the altitude and azimuth coordinates to x and y using camera_conv to correct for distortions in the fisheye lens. The x and y coordinates are converted once again to altitude and azimuth using xy_to_altaz, which are then converted final to right ascension and declination using altaz_to_radec.