transform module¶
A module providing facilities for converting all-sky images into map-style projections of the visible night sky.
Methods in this module are designed to build a projection of the visible night sky from an all-sky image. The predominant method, :func:~`transform`, performs the transformation from an all-sky image to an Eckert-IV projection. Additional methods are included that convert the all-sky image coordinates to a Mollweide projection. There are also methods that draw defining contours on top of the transformed image. One method draws altitude contours at 0, 30, and 60 degrees of altitude angle, and one method draws an outline of the DESI survey area.
-
transform.clockwise_sort(x, y, clockwise=True)[source]¶ Sort a set of coordinates clockwise, element-wise.
Parameters: - x (array_like) – The set of x coordinates.
- y (array_like) – The set of y coordinates.
- clockwise (bool, optional) – If True, sorts clockwise, otherwise sorts anti-clockwise. Defaults to True.
Returns: - x (array_like) – The sorted set of x coordinates.
- y (array_like) – The sorted set of y coordinates.
Notes
This method sorts a data set clockwise from the calculated center of the data. The center is found by taking the maximum of the sorted x and y values and then finding the midpoint between the two. While for some strange dataset this may not be the actual center (for example, a crescent moon), it is a reasonably fast approximation. The dataset will always be sorted by theta first, then radius. Points with the same angular distance from the sorting axis will be sorted by their radial distance.
The sort is done clockwise starting from the negative x axis, or anticlockwise from the positive x axis. The reason for this is due to how atan2 returns angles as between -pi and pi instead of between pi and 2pi.
-
transform.contours(axis, time)[source]¶ Add three altitude contours to an axis based on a given time.
Parameters: - axis (matplotlib.pyplot.axis) – An axis to add the contours to.
- time (astropy.time.Time) – A time and date.
Returns: New axis where the contours have been overlaid on top.
Return type: matplotlib.pyplot.axis
Notes
The contours added to the axis correspond to altitude angles of 0, 30 and 60 degrees.
-
transform.desi_patch()[source]¶ Create axis patches corresponding to the DESI survey areas.
Returns: List of matplotlib.patches.Patch objects representing the two DESI survey areas. Return type: list Notes
This method requires the file hull.txt to be in the module”s directory. This file can be downloaded from the kpno-allsky GitHub.
-
transform.eckertiv(ra, dec)[source]¶ Find an Eckert-IV representation of the given coordinates.
Parameters: - ra (array_like) – The right ascension (or longitude) coordinates of the data set.
- dec (array_like) – The declination (or latitude) coordinates of the data set.
Returns: - x (array_like) – The x coordinates corresponding to the given points.
- y (array_like) – The y coordinates corresponding to the given points.
See also
eckertiv_findtheta()- Newton’s method for finding each point”s auxiliary latitude value.
Notes
This method defines the x,y and latitude and longitude using the standard Eckert-IV definition. Wikipedia provides a simple form of the equations used in this method, including a defnition of the theta value that is found using Newton’s method. See here for more details: https://en.wikipedia.org/wiki/Eckert_IV_projection
-
transform.eckertiv_findtheta(dec, n)[source]¶ Find the auxiliary latitude (theta) value that defines a given latitude in the Eckert-IV projection.
Parameters: - dec (array_like) – The declination (or latitude) angular coordinates of the data set in radians.
- n (int) – The number of iterations to use in Newton’s method.
Returns: Array of auxiliary latitude values corresponding to the input latitude values.
Return type: Notes
This method finds the auxiliary latitude values using Newton’s method, and is thus recursive. Wikipedia provides a simple form of the equation that is iterated upon in this method. See here for more details: https://en.wikipedia.org/wiki/Eckert_IV_projection
-
transform.mollweide(ra, dec)[source]¶ Find a Mollweide representation of the given coordinates.
Parameters: - ra (array_like) – The right ascension (or longitude) coordinates of the data set.
- dec (array_like) – The declination (or latitude) coordinates of the data set.
Returns: - x (array_like) – The x coordinates corresponding to the given points.
- y (array_like) – The y coordinates corresponding to the given points.
See also
mollweide_findtheta()- Newton’s method for finding each point”s auxiliary latitdue (theta) value.
Notes
This method defines the x,y and latitude and longitude using the standard Mollweide definition. Wikipedia provides a simple form of the equations used in this method, including a defnition of the theta value that is found using Newton’s method. See here for more details: https://en.wikipedia.org/wiki/Mollweide_projection
-
transform.mollweide_findtheta(dec, n)[source]¶ Find the auxiliary latitude (theta) value that defines a given latitude in the Mollweide projection.
Parameters: - dec (array_like) – The declination (or latitude) angular coordinates of the data set in radians.
- n (int) – The number of iterations to use in Newton’s method.
Returns: Array of auxiliary latitude values corresponding to the input latitude values.
Return type: np.ndarray
Notes
This method finds the auxiliary latitude values using Newton’s method, and is thus recursive. Wikipedia provides a simple form of the equation that is iterated upon in this method. See here for more details: https://en.wikipedia.org/wiki/Mollweide_projection
-
transform.transform(img)[source]¶ Transform a circular all-sky image into an Eckert-IV projection of the visible night sky.
Parameters: img (image.AllSkyImage) – The image. See also
eckertiv()- Define the projection method.
Notes
First applies a mask generated from mask.generate_mask(). From there, lists of x and y pixels inside each image is built. These lists are converted to right ascension and declination representations of each pixel. These are passed to eckertiv(), which converts these points to x and y positions on the Eckert-IV projection. The map is then built as a scatter plot using these x and y positions, where the color of each dot is taken from the pixel originally used. Each point is the same size, which is a valid assumption since the Eckert-IV projection is an equal area projection. The plot is then saved to Images/transform/img.date/img.name.