median module¶
A module providing facilities for creating and saving median images.
A median image for a date is created by collating all the images taken that night and finding the median greyscale value for every pixel position. A method is provided to save the median image. Two other methods are used to support the median creation: one implementing the median of medains algorithm and one that converts a list of lists to a list of tuples.
-
median.median_all_date(date, camera='KPNO', color=False)[source]¶ Find the median images for a given date.
Parameters: - date (str) – The date to find median images for.
- 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.
- color (bool, optional) – If true, finds the median images in color, otherwise works in grayscale. Defaults to False.
Returns: A dictionary mapping exposure times to their median images.
Return type: dict of ndarrays
See also
io_util.load_all_date()- Load images in color to find color medians.
-
median.median_of_medians(arr, i)[source]¶ Find the ith smallest element of a list using the median of medians algorithm.
Parameters: - arr (array_like) – An array_like object of floats.
- i (int) – The positional rank.
Returns: The ith smallest element of arr.
Return type: Notes
i = len(arr) // 2 corresponds to finding the median of arr. Details on the median of medians algorithm can be found at Wikipedia (https://en.wikipedia.org/wiki/Median_of_medians).
-
median.ndarray_to_tuplelist(arr)[source]¶ Convert an ndarray to a list of tuples.
For an ndarray of shape (y, x) returns a list of y tuples where each tuple is of length x.
Parameters: arr (ndarray) – A NumPy ndarray to be converted. Returns: A list of tuples. Return type: list
-
median.save_medians(medians, date, color=False)[source]¶ Save a dict of medians produced by median_all_date.
Parameters: See also
image.save_image()- Save an image.
median_all_date()- Generate median images for a given date.
Notes
Saves median images to Images/median/date/ if the medians are grayscale, and Images/median-color/date/ if the medians are in color.