pyreduce.instruments package¶
Submodules¶
pyreduce.instruments.common module¶
Abstract parent module for all other instruments Contains some general functionality, which may be overridden by the children of course
-
class
pyreduce.instruments.common.
Instrument
[source]¶ Bases:
object
Abstract parent class for all instruments Handles the handling of instrument specific information
-
add_header_info
(header, mode, **kwargs)[source]¶ read data from header and add it as REDUCE keyword back to the header
Parameters: - header (fits.header, dict) – header to read/write info from/to
- mode (str) – instrument mode
Returns: header – header with added information
Return type: fits.header, dict
-
apply_filters
(files, expected, allow_calibration_only=False)[source]¶ Determine the relevant files for a given set of expected values.
Parameters: - files (list(files)) – list if fits files
- expected (dict) – dictionary with expected header values for each reduction step
Returns: files – list of files. The first element of each tuple is the used setting, and the second are the files for each step.
Return type: list((dict, dict))
-
find_files
(input_dir)[source]¶ Find fits files in the given folder
Parameters: input_dir (string) – directory to look for fits and fits.gz files in, may include bash style wildcards Returns: files – absolute path filenames Return type: array(string)
-
get_wavecal_filename
(header, mode, **kwargs)[source]¶ Get the filename of the pre-existing wavelength solution for the current setting
Parameters: - header (fits.header, dict) – header of the wavelength calibration file
- mode (str) – instrument mode
Returns: filename – name of the wavelength solution file
Return type: str
-
info
= None¶ Information about the instrument
Type: dict
-
load_fits
(fname, mode, extension=None, mask=None, header_only=False, dtype=None)[source]¶ load fits file, REDUCE style
primary and extension header are combined modeinfo is applied to header data is clipnflipped mask is applied
Parameters: - fname (str) – filename
- instrument (str) – name of the instrument
- mode (str) – instrument mode
- extension (int) – data extension of the FITS file to load
- mask (array, optional) – mask to add to the data
- header_only (bool, optional) – only load the header, not the data
- dtype (str, optional) – numpy datatype to convert the read data to
Returns: - data (masked_array) – FITS data, clipped and flipped, and with mask
- header (fits.header) – FITS header (Primary and Extension + Modeinfo)
- ONLY the header is returned if header_only is True
-
load_info
()[source]¶ Load static instrument information Either as fits header keywords or static values
Returns: info – dictionary of REDUCE names for properties to Header keywords/static values Return type: dict(str:object)
-
name
= None¶ Name of the instrument (lowercase)
Type: str
-
populate_filters
(files)[source]¶ Extract values from the fits headers and store them in self.filters
Parameters: files (list(str)) – list of fits files Returns: filters – list of populated filters (identical to self.filters) Return type: list(Filter)
-
sort_files
(input_dir, target, night, *args, allow_calibration_only=False, **kwargs)[source]¶ Sort a set of fits files into different categories types are: bias, flat, wavecal, orderdef, spec
Parameters: - input_dir (str) – input directory containing the files to sort
- target (str) – name of the target as in the fits headers
- night (str) – observation night, possibly with wildcards
- mode (str) – instrument mode
Returns: - files_per_night (list[dict{str:dict{str:list[str]}}]) – a list of file sets, one entry per night, where each night consists of a dictionary with one entry per setting, each fileset has five lists of filenames: “bias”, “flat”, “order”, “wave”, “spec”, organised in another dict
- nights_out (list[datetime]) – a list of observation times, same order as files_per_night
-
-
pyreduce.instruments.common.
create_custom_instrument
(name, extension=0, info=None, mask_file=None, wavecal_file=None, hasModes=False)[source]¶
-
pyreduce.instruments.common.
find_first_index
(arr, value)[source]¶ find the first element equal to value in the array arr
-
class
pyreduce.instruments.common.
getter
(header, info, mode)[source]¶ Bases:
object
Get data from a header/dict, based on the given mode, and applies replacements
-
pyreduce.instruments.common.
observation_date_to_night
(observation_date)[source]¶ Convert an observation timestamp into the date of the observation night Nights start at 12am and end at 12 am the next day
Parameters: observation_date (datetime) – timestamp of the observation Returns: night – night of the observation Return type: datetime.date
pyreduce.instruments.harps module¶
Handles instrument specific info for the HARPS spectrograph
Mostly reading data from the header
-
class
pyreduce.instruments.harps.
FiberFilter
(keyword='ESO DPR TYPE')[source]¶ Bases:
pyreduce.instruments.filters.Filter
-
class
pyreduce.instruments.harps.
HARPS
[source]¶ Bases:
pyreduce.instruments.common.Instrument
-
add_header_info
(header, mode, **kwargs)[source]¶ read data from header and add it as REDUCE keyword back to the header
-
get_expected_values
(target, night, mode, fiber, polarimetry)[source]¶ Determine the default expected values in the headers for a given observation configuration
Any parameter may be None, to indicate that all values are allowed
Parameters: - target (str) – Name of the star / observation target
- night (str) – Observation night/nights
- fiber ("A", "B", "AB") – Which of the fibers should carry observation signal
- polarimetry ("none", "linear", "circular", bool) – Whether the instrument is used in HARPS or HARPSpol mode and which polarization is observed. Set to true for both kinds of polarisation.
Returns: expectations – Dictionary of expected header values, with one entry per step. The entries for each step refer to the filters defined in self.filters
Return type: dict
Raises: ValueError
– Invalid combination of parameters
-
pyreduce.instruments.instrument_info module¶
Interface for all instrument specific information The actual info is contained in the instruments/{name}.py modules/classes, which are all subclasses of “common”
-
pyreduce.instruments.instrument_info.
get_instrument_info
(instrument)[source]¶ Load instrument specific information
Parameters: instrument (str) – Name of the instrument Returns: dict{str – Dictionary with information Return type: obj}
-
pyreduce.instruments.instrument_info.
get_wavecal_filename
(header, instrument, mode, **kwargs)[source]¶ Get the filename of the pre-existing wavelength solution for the current settings
Parameters: - header (fits.header, dict) – header of the wavelength calibration file
- instrument (str) – instrument name
- mode (str) – instrument mode (e.g. red/blue for HARPS)
Returns: filename – wavelength solution file
Return type: str
-
pyreduce.instruments.instrument_info.
load_instrument
(instrument) → pyreduce.instruments.common.Instrument[source]¶ Load an python instrument module
Parameters: instrument (str) – name of the instrument Returns: instrument – Instance of the {instrument} class Return type: Instrument
-
pyreduce.instruments.instrument_info.
modeinfo
(header, instrument, mode, **kwargs)[source]¶ Add instrument specific information to a header/dict
Parameters: - header (fits.header, dict) – header to add information to
- instrument (str) – instrument name
- mode (str) – instrument mode (e.g. red/blue for HARPS)
Returns: header with added information
Return type: header
-
pyreduce.instruments.instrument_info.
sort_files
(input_dir, target, night, instrument, mode, **kwargs)[source]¶ Sort a list of files into different categories and discard files that are not used
Parameters: - input_dir (str) – directory containing all files (with tags for target, night, and instrument)
- target (str) – observation target name, as found in the files
- night (str) – observation night of interest, as found in the files
- instrument (str) – instrument name
- mode (str) – instrument mode, if applicable (e.g. red/blue for HARPS)
Returns: - biaslist (list(str)) – list of bias files
- flatlist (list(str)) – list of flat field files
- wavelist (list(str)) – list of wavelength calibration files
- orderlist (list(str)) – list of order definition files (for order tracing)
- speclist (list(str)) – list of science files, i.e. observations
pyreduce.instruments.uves module¶
Handles instrument specific info for the UVES spectrograph
Mostly reading data from the header
-
class
pyreduce.instruments.uves.
UVES
[source]¶