io module
Module to manage general information like path to data
- class darclight.io.DataCollection(path=None, reduced_path=None, ignore=None, filelist=None)[source]
Bases:
objectClass that organizes all files in a given directory.
- add_file(fname, reduced=False, row=None)[source]
adds a row to an existing table
- Parameters:
fname (str | Path) – filename to add
reduced (bool, optional) – if it should be added to the raw or reduced table, defaults to False
row (tuple | None, optional) – row informations, depends on raw or reduced what it should contain. If None the file will be read and the values are derived automatically, defaults to None
- bias(data=True, header=False, fname=False, **filter_kwds)[source]
Generator to get the data and/or header of the files in the raw bias frames.
- Parameters:
data (bool, optional) – whether or not the data of the file should be returned, defaults to True
header (bool, optional) – whether or not the header should be returned, defaults to False
fname (bool, optional) – whether or not the filename should be returned, defaults to False
- Raises:
ValueError – if both (data and header) are set to False. If you want only the filenames address the attribute directly.
- Yield:
tuple of the desired outputs in the order (data, header, filename)
- Return type:
Tuple
- property bias_files
- property dark_exposures: list[int]
List of exposure times where a dark frame is directly available.
- Returns:
list of exposure times
- Return type:
list[int]
- property dark_files
- darks(exposure, data=True, header=False, fname=False, **filter_kwds)[source]
- Generator to get the data and/or header of the files of the raw dark frames
for a specific exposure.
- Parameters:
exposure (int) – the exposure time of the dark frame
data (bool, optional) – whether or not the data of the file should be returned, defaults to True
header (bool, optional) – whether or not the header should be returned, defaults to False
fname (bool, optional) – whether or not the filename should be returned, defaults to False
- Raises:
ValueError – This error is raised if there is no dark frame with the given exposure registered. Try ‘update_raw()’ if you think there should be one
ValueError – if both (data and header) are set to False. If you want only the filenames address the attribute directly.
- Yield:
tuple of the desired outputs in the order (data, header, filename)
- Return type:
Tuple
- static file_data(filelist, data=True, header=False, fname=False, return_kwds=None, **filter_kwds)[source]
generator to get the data and/or header of the files in the provided list.
- Parameters:
filelist (list) – list of files to iterate over
data (bool, optional) – whether or not the data of the file should be returned, defaults to True
header (bool, optional) – whether or not the header should be returned, defaults to False
fname (bool, optional) – whether or not the filename should be returned, defaults to False
return_kwds (list[str] | None) – additional keywords that should be returned alongside the data/header, defaults to None
filter_kwds – additional keywords the returned data should be filtered for from the header
- Raises:
ValueError – if both (data and header) are set to False. If you want only the filenames address the attribute directly.
- Yield:
tuple of the desired outputs in the order (data, header, filename, return_kwd 1,…)
- Return type:
Tuple
- property flat_exposures: dict[str | None, set]
exposure times for each filter
- Returns:
dictionary of the form {filter:exposure, …}
- Return type:
dict[str|None,set]
- property flat_files
- flats(used_filter, data=True, header=False, fname=False, return_kwds=None, **filter_kwds)[source]
- Generator to get the data and/or header of the files of the raw flat frames
for a specific filter.
- Parameters:
used_filter (str | None) – the exposure time of the flat frame
data (bool, optional) – whether or not the data of the file should be returned, defaults to True
header (bool, optional) – whether or not the header should be returned, defaults to False
fname (bool, optional) – whether or not the filename should be returned, defaults to False
- Raises:
ValueError – This error is raised if there is no flat frame with the given filter registered. Try ‘update_raw()’ if you think there should be one
ValueError – if both (data and header) are set to False. If you want only the filenames address the attribute directly.
- Yield:
tuple of the desired outputs in the order (data, header, filename)
- Return type:
Tuple
- get_files(reduced=False, **filters)[source]
returns the filenames of the files specified
- Parameters:
reduced (bool, optional) – whether the desired files should be reduced or not, defaults to False
- Returns:
filenames satisfy the filters
- Return type:
np.ndarray
- get_master(imagetype, specifier=None, header=True)[source]
looks for a specific stacked master frame
- Parameters:
imagetype (str) – type of the image to check, use ‘bias’, ‘dark’, ‘flat’ or ‘light’
specifier (int | str | None, optional) – exposure time to look for, if imagetype=’dark’ or filter to look for if imagetype=’flat’ or target if imagetype=’light, defaults to None
- Returns:
data of the required file, None if it does not exist
- Return type:
np.ndarray | None
- static hdu_from_file(file)[source]
gives access to the data and header of a given file
- Parameters:
file (str) – name of the file
- Returns:
the data and header from that file
- Return type:
Tuple[np.ndarray,astropy.io.fits.header.Header]
- property light_meta: dict[str, set[Tuple[str, int]]]
Metadata for the light frames
- Returns:
dictionary of the form {target:[(filter,exposure),…],…}, for every target there is a set of tuples that each contain the filter and the corresponding exposure time.
- Return type:
dict[str,set[Tuple[str, int]]]
- lights(target, data=True, header=False, fname=False, return_kwds=None, reduced=False, **filter_kwds)[source]
- Generator to get the data and/or header of the files of the raw light frames
for a specific target.
- Parameters:
target (str) – the target of the light frame
data (bool, optional) – whether or not the data of the file should be returned, defaults to True
header (bool, optional) – whether or not the header should be returned, defaults to False
fname (bool, optional) – whether or not the filename should be returned, defaults to False
- Raises:
ValueError – This error is raised if there is no light frame with the given target registered. Try ‘update_raw()’ if you think there should be one
ValueError – if both (data and header) are set to False. If you want only the filenames address the attribute directly.
- Yield:
tuple of the desired outputs in the order (data, header, filename)
- Return type:
Tuple
- static save_file(filename, data, header=None)[source]
Saves the given data and header with the given filename in the reduced data directory.
- Parameters:
filename (str) – Desired name for the file
data (np.ndarray) – data that should be stored in the file
header (astropy.io.fits.header.Header, optional) – header for the file, defaults to None
- Return type:
None
- scan(raw=True, reduced=True)[source]
scans the directories from scractch
- Parameters:
raw (bool, optional) – whether or not the raw directory should be scaned, defaults to True
reduced (bool, optional) – whether or not the reduced directory should be scanned, defaults to True
- property targets: list[str]
List of targets captured.
- Returns:
list of targets
- Return type:
list[str]
- property used_filters: list[str]
List of used filters where a flat frame is available.
- Returns:
list of filters
- Return type:
list[str]