Module: analysis_utils#
- class kbmod.analysis_utils.Interface[source]#
This class manages the KBMOD interface with the local filesystem, the cpp KBMOD code, and the PostProcess python filtering functions. It is responsible for loading in data from .fits files, initializing the kbmod object, loading results from the kbmod object into python, and saving results to file.
Methods
gen_results_dict
()Return an empty results dictionary.
load_images
(im_filepath, time_file, ...[, ...])This function loads images and ingests them into a search object.
save_results
(res_filepath, out_suffix, keep, ...)This function saves results from a given search method.
- load_images(im_filepath, time_file, psf_file, mjd_lims, default_psf, verbose=False)[source]#
This function loads images and ingests them into a search object.
- Parameters:
- im_filepathstring
Image file path from which to load images.
- time_filestring
File name containing image times.
- psf_filestring
File name containing the image-specific PSFs. If set to None the code will use the provided default psf for all images.
- mjd_limslist of ints
Optional MJD limits on the images to search.
- default_psfpsf
The default PSF in case no image-specific PSF is provided.
- verbosebool
Use verbose output (mainly for debugging).
- Returns:
- stackkbmod.image_stack
The stack of images loaded.
- img_infoImageInfo
The information for the images loaded.
- save_results(res_filepath, out_suffix, keep, all_times)[source]#
This function saves results from a given search method.
- Parameters:
- res_filepathstring
The filepath for the results.
- out_suffixstring
Suffix to append to the output file name
- keepResultList
ResultList object containing the values to keep and print to file.
- all_timeslist
A list of times.
- class kbmod.analysis_utils.PostProcess(config, mjds)[source]#
This class manages the post-processing utilities used to filter out and otherwise remove false positives from the KBMOD search. This includes, for example, kalman filtering to remove outliers, stamp filtering to remove results with non-Gaussian postage stamps, and clustering to remove similar results.
Methods
apply_clipped_sigmaG
(result_list)This function applies a clipped median filter to the results of a KBMOD search using sigmaG as a robust estimater of standard deviation.
apply_clustering
(result_list, cluster_params)This function clusters results that have similar trajectories.
apply_mask
(stack[, mask_num_images, ...])This function applys a mask to the images in a KBMOD stack.
apply_stamp_filter
(result_list, search[, ...])This function filters result postage stamps based on their Gaussian Moments.
gen_results_dict
()Return an empty results dictionary.
get_all_stamps
(result_list, search, stamp_radius)Get the stamps for the final results from a kbmod search.
load_and_filter_results
(search, lh_level[, ...])This function loads results that are output by the gpu grid search.
- apply_clipped_sigmaG(result_list)[source]#
This function applies a clipped median filter to the results of a KBMOD search using sigmaG as a robust estimater of standard deviation.
- Parameters:
- result_listResultList
The values from trajectories. This data gets modified directly by the filtering.
- apply_clustering(result_list, cluster_params)[source]#
This function clusters results that have similar trajectories.
- Parameters:
- result_listResultList
The values from trajectories. This data gets modified directly by the filtering.
- cluster_paramsdict
Contains values concerning the image and search settings including: x_size, y_size, vel_lims, ang_lims, and mjd.
- apply_mask(stack, mask_num_images=2, mask_threshold=None, mask_grow=10)[source]#
This function applys a mask to the images in a KBMOD stack. This mask sets a high variance for masked pixels
- Parameters:
- stackkbmod.image_stack
The stack before the masks have been applied.
- mask_num_imagesint
The minimum number of images in which a masked pixel must appear in order for it to be masked out. E.g. if masked_num_images = 2, then an object must appear in the same place in at least two images in order for the variance at that location to be increased.
- mask_thresholdfloat
Any pixel with a flux greater than mask_threshold is masked out.
- mask_growint
The number of pixels by which to grow the mask.
- Returns:
- stackkbmod.image_stack
The stack after the masks have been applied.
- apply_stamp_filter(result_list, search, center_thresh=0.03, peak_offset=[2.0, 2.0], mom_lims=[35.5, 35.5, 1.0, 0.25, 0.25], chunk_size=1000000, stamp_type='sum', stamp_radius=10)[source]#
This function filters result postage stamps based on their Gaussian Moments. Results with stamps that are similar to a Gaussian are kept.
- Parameters:
- result_listResultList
The values from trajectories. This data gets modified directly by the filtering.
- searchkbmod.stack_search
The search object.
- center_threshfloat
The fraction of the total flux that must be contained in a single central pixel.
- peak_offsetlist of floats
How far the brightest pixel in the stamp can be from the central pixel.
- mom_limslist of floats
The maximum limit of the xx, yy, xy, x, and y central moments of the stamp.
- chunk_sizeint
How many stamps to load and filter at a time.
- stamp_typestring
Which method to use to generate stamps. One of ‘median’, ‘cpp_median’, ‘mean’, ‘cpp_mean’, or ‘sum’.
- stamp_radiusint
The radius of the stamp.
- get_all_stamps(result_list, search, stamp_radius)[source]#
Get the stamps for the final results from a kbmod search.
- Parameters:
- result_listResultList
The values from trajectories. The stamps are inserted into this data structure.
- searchkbmod.stack_search
The search object
- stamp_radiusint
The radius of the stamps to create.
- load_and_filter_results(search, lh_level, chunk_size=500000, max_lh=1000000000.0)[source]#
This function loads results that are output by the gpu grid search. Results are loaded in chunks and evaluated to see if the minimum likelihood level has been reached. If not, another chunk of results is fetched. The results are filtered using a clipped-sigmaG filter as they are loaded and only the passing results are kept.
- Parameters:
- searchkbmod.search
The search function object.
- lh_levelfloat
The minimum likelihood theshold for an acceptable result. Results below this likelihood level will be discarded.
- chunk_sizeint
The number of results to load at a given time from search.
- max_lhfloat
The maximum likelihood threshold for an acceptable results. Results ABOVE this likelihood level will be discarded.
- Returns:
- keepResultList
A ResultList object containing values from trajectories.