corgidrp.caldb#
Calibration tracking system. Modified from kpicdrp caldb implmentation (Copyright (c) 2024, KPIC Team)
Attributes#
Classes#
Database for tracking calibration files saved to disk. Modified from the kpicdrp version |
Functions#
Creates default calibrations and caldb if it doesn't exist |
Module Contents#
- corgidrp.caldb.column_names = ['Filepath', 'Type', 'MJD', 'EXPTIME', 'Files Used', 'Date Created', 'Hash', 'DRPVERSN',...[source]#
- class corgidrp.caldb.CalDB(filepath='')[source]#
Database for tracking calibration files saved to disk. Modified from the kpicdrp version
Note that database is not parallelism-safe, but should be ok in most cases. (Jason: look at using posix_ipc to guarantee thread safety if we really need it)
- Parameters:
filepath (str) – [optional] filepath to a CSV file with an existing database
- Fields:
columns (list): column names of dataframe filepath(str): full filepath to data
- create_entry(entry, to_disk=True)[source]#
Add a new entry to or update an existing one in the database. Note that function by default will load and save db to disk
- Parameters:
entry (corgidrp.data.Image subclass) – calibration frame to add to the database
to_disk (bool) – True by default, will update DB from disk before adding entry and saving it back to disk
- remove_entry(entry, to_disk=True)[source]#
Remove an entry from the database. Removes the entire row
- Parameters:
entry (corgidrp.data.Image subclass) – calibration frame to add to the database
to_disk (bool) – True by default, will update DB from disk before adding entry and saving it back to disk
- get_calib(frame, dtype, to_disk=True)[source]#
Outputs the best calibration file of the given type for the input science frame.
- Parameters:
frame (corgidrp.data.Image) – an image frame to request a calibration for. If None is passed in, looks for the most recently created calibration.
dtype (corgidrp.data Class) – for example: corgidrp.data.Dark (TODO: document the entire list of options)
to_disk (bool) – True by default, will update DB from disk before matching
- Returns:
an instance of the appropriate calibration type (Exact type depends on calibration type)
- Return type:
corgidrp.data.*
- scan_dir_for_new_entries(filedir, look_in_subfolders=True, to_disk=True)[source]#
Scan a folder and subfolder for calibration files and add them all to the caldb
- Parameters:
filedir (str) – path to folder to scan (includes all subfolders by default)
look_in_subfolders (bool) – whether to look in subfolders for files. True by default
to_disk (bool) – True by default, will update DB from disk before adding entry and saving it back to disk
- filter_calib(calibdf, col_name, value, err_if_none=True)[source]#
Takes in a calibration dataframe, filters them so that only the files with matching header values are returned. If none is found, this function is omitted and the original list is returned or an error is thrown depending on the err_if_none parameter.
- Parameters:
calibdf (pd.DataFrame) – database containing the potential calibration files
col_name (string) – name of the column that we want to look for matches in
value (string/float/int) – value of the column entry to filter by
err_if_none (optional, boolean) – tells the function whether to throw an error
found. (or not if no matches are)
- Returns:
database containing only the calibration files with matching values, or the original database if no matches are found and err_if_none is set to false.
- Return type:
filtered_calibdf (pd.DataFrame)