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.COMMON[source]¶
Bases:
Instrument
- class pyreduce.instruments.common.Instrument[source]¶
Bases:
objectAbstract parent class for all instruments Handles the instrument specific information
- add_header_info(header, channel, **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
channel (str) – instrument channel
- Returns:
header – header with added information
- Return type:
fits.header, dict
- apply_filters(files, expected, steps=None)[source]¶
Determine the relevant files for a given set of expected values.
- Parameters:
- 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))
- assemble_amplifiers(hdu, amp_extensions, channel)[source]¶
Assemble multi-amplifier readout into single frame.
Reads data from multiple FITS extensions, each representing one amplifier’s readout region, and assembles them into a single frame using DATASEC/DETSEC mappings.
- Parameters:
hdu (HDUList) – Open FITS file
amp_extensions (list) – List of extension names to read
channel (str) – Instrument channel
- Returns:
data (ndarray) – Assembled frame (float32)
header (fits.Header) – Combined header with per-amplifier e_gain{n}, e_readn{n}
- property channels: list[str] | None¶
Available instrument channels.
- config¶
Validated configuration model dict: Information about the instrument (for backward compatibility)
- Type:
- discover_channels(input_dir)[source]¶
Discover available channels from files in the input directory.
Override in subclasses for instruments that require channel specification. The base implementation returns [None] which means no channel filtering.
- Parameters:
input_dir (str) – Directory containing input files
- Returns:
channels – List of channel identifiers found in the data
- Return type:
list
- property extension: int | str | list¶
FITS extension(s) to read.
- 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_amplifier_extensions(header)[source]¶
Get list of amplifier extensions if multi-amp mode is configured.
- Parameters:
header (fits.Header) – Primary FITS header
- Returns:
List of extension names/indices if multi-amp, None otherwise
- Return type:
list or None
- get_settings_fallbacks(channel)[source]¶
Return channel names to try when looking up settings files.
Searched in order: most specific first, least specific last. The base settings.json is always the final fallback (handled by the caller).
Override in subclasses for instruments with composite channel names.
- get_wavecal_filename(header, channel, **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
channel (str) – instrument channel
- Returns:
filename – name of the wavelength solution file
- Return type:
str
- property id_instrument: str¶
Instrument identifier for header matching.
- info¶
Validated configuration model dict: Information about the instrument (for backward compatibility)
- Type:
- load_fits(fname, channel, extension=None, mask=None, header_only=False, dtype=None)[source]¶
load fits file, REDUCE style
primary and extension header are combined channel-specific info is applied to header data is clipnflipped mask is applied
For multi-amplifier instruments, data from multiple extensions is assembled into a single frame before clipnflip.
- Parameters:
fname (str) – filename
instrument (str) – name of the instrument
channel (str) – instrument channel
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 + channel info)
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:
config (InstrumentConfig) – Validated Pydantic model
info (dict(str:object)) – dictionary of REDUCE names for properties to Header keywords/static values
- name¶
Name of the instrument (lowercase)
- Type:
str
- property orientation: int | list[int]¶
Detector orientation code(s).
- 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, steps=None, **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
channel (str) – instrument channel
steps (list, optional) – list of steps that will be run. If provided, warnings about missing files are only shown for these steps.
- 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, **overrides)[source]¶
Create a custom instrument for reducing data from unsupported spectrographs.
- Parameters:
name (str) – Instrument name (used for output file naming)
extension (int or str) – FITS extension to read data from (default: 0)
info (dict or str, optional) – Instrument properties as a dict, or path to a config file (JSON/YAML). If None, uses sensible defaults. Dict values can be literal numbers or FITS header keyword strings (looked up at runtime).
mask_file (str, optional) – Path to bad pixel mask FITS file
wavecal_file (str, optional) – Path to wavelength calibration file
**overrides – Additional instrument properties, e.g.
gain=1.1,readnoise=5,orientation=4. These override values from the info dict. Seeinstruments/defaults/config.yamlfor available keys.
- Returns:
Configured instrument instance
- Return type:
- 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, channel)[source]¶
Bases:
objectGet data from a header/dict, based on the given channel, 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.common.parse_iraf_section(section_str)[source]¶
Parse IRAF-style section string into pixel coordinates.
IRAF format: [x1:x2,y1:y2] where coordinates are 1-based inclusive.
- Parameters:
section_str (str) – Section string like “[28:1179,1:4616]”
- Returns:
x1, x2, y1, y2 – 1-based inclusive pixel coordinates
- Return type:
int
pyreduce.instruments.models module¶
Pydantic models for instrument configuration validation.
These models provide type-safe validation for instrument configuration files. Currently validates the flat YAML structure; will evolve toward the nested structure described in REDESIGN.md.
- class pyreduce.instruments.models.AmplifierConfig(*, id: str, gain: float | dict[str, str], readnoise: float | dict[str, str], region: dict[str, list[int]] | None = None, linearity: dict | None = None, bad_pixel_mask: str | None = None)[source]¶
Bases:
BaseModelConfiguration for a detector readout amplifier.
- bad_pixel_mask: str | None¶
- gain: float | dict[str, str]¶
- id: str¶
- linearity: dict | None¶
- model_config = {'extra': 'forbid'}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- readnoise: float | dict[str, str]¶
- region: dict[str, list[int]] | None¶
- class pyreduce.instruments.models.AmplifiersConfig(*, extension_template: str, count: str | int, gain: str = 'GAIN', readnoise: str = 'RDNOISE', datasec: str = 'DATASEC', detsec: str = 'DETSEC')[source]¶
Bases:
BaseModelConfiguration for multi-amplifier readout assembly.
Used when detector data is split across multiple FITS extensions, each with its own gain/readnoise and region mapping.
- count: str | int¶
- datasec: str¶
- detsec: str¶
- extension_template: str¶
- gain: str¶
- model_config = {'extra': 'forbid'}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- readnoise: str¶
- class pyreduce.instruments.models.BeamArmConfig(*, name: str, polarization: str | None = None, wavelength_shift: float = 0.0, trace_offset: float = 0.0)[source]¶
Bases:
BaseModelConfiguration for a beam-splitter arm.
- model_config = {'extra': 'forbid'}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str¶
- polarization: str | None¶
- trace_offset: float¶
- wavelength_shift: float¶
- class pyreduce.instruments.models.DetectorConfig(*, name: str, naxis: tuple[int, int] | list[int], orientation: int = 0, prescan: dict[str, list[int] | None] | None = None, overscan: dict[str, list[int] | None] | None = None, amplifiers: list[AmplifierConfig] = [], bad_pixel_mask: str | None = None)[source]¶
Bases:
BaseModelConfiguration for a physical detector.
- amplifiers: list[AmplifierConfig]¶
- bad_pixel_mask: str | None¶
- model_config = {'extra': 'forbid'}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str¶
- naxis: tuple[int, int] | list[int]¶
- orientation: int¶
- overscan: dict[str, list[int] | None] | None¶
- prescan: dict[str, list[int] | None] | None¶
- class pyreduce.instruments.models.DimensionConfig(*, values: list[str], header_key: str | None = None, optional: bool = False)[source]¶
Bases:
BaseModelConfiguration for a varying dimension (mode, fiber, etc.).
- header_key: str | None¶
- model_config = {'extra': 'forbid'}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- optional: bool¶
- values: list[str]¶
- class pyreduce.instruments.models.FiberBundleConfig(*, size: int, count: int | None = None, merge: str | list[int] = 'center', height: str | float | None = 'derived', bundle_centers: dict[int, float] | None = None, bundle_centers_file: str | list[str] | None = None)[source]¶
Bases:
BaseModelConfiguration for repeating fiber bundles.
For instruments where fibers are organized in repeating bundles (e.g., 7 fibers per IFU target), this defines the bundle structure.
Bundle assignment can use either: - Fixed size division (n_traces must be divisible by size) - bundle_centers: assign each trace to nearest bundle center (handles missing fibers)
- bundle_centers: dict[int, float] | None¶
- bundle_centers_file: str | list[str] | None¶
- classmethod convert_bundle_centers_keys(v)[source]¶
Convert string keys to int (YAML loads int keys as strings).
- count: int | None¶
- height: str | float | None¶
- merge: str | list[int]¶
- model_config = {'extra': 'forbid'}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- size: int¶
- class pyreduce.instruments.models.FiberGroupConfig(*, range: tuple[int, int], merge: str | list[int] = 'center', height: float | Literal['derived'] | None = None)[source]¶
Bases:
BaseModelConfiguration for a named fiber group.
Defines a range of physical fibers that form a logical group (e.g., “A”, “cal”, “B”). The merged trace can be the average, center, or specific fiber(s) from the group.
The height parameter specifies extraction height for this group: - float: explicit pixel value (or fraction if < 3) - “derived”: compute from trace positions as span + fiber_diameter - None: use settings.json extraction_height (default)
- height: float | Literal['derived'] | None¶
- merge: str | list[int]¶
- model_config = {'extra': 'forbid'}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- range: tuple[int, int]¶
- class pyreduce.instruments.models.FibersConfig(*, groups: dict[str, FiberGroupConfig] | None = None, bundles: FiberBundleConfig | None = None, use: dict[str, Literal['groups', 'per_fiber'] | list[str]] | None = None, trace_by: str | None = None, fibers_per_order: int | list[int] | None = None, order_centers: dict[int, float] | None = None, order_centers_file: str | list[str] | None = None)[source]¶
Bases:
BaseModelConfiguration for multi-fiber instruments.
Defines how physical fiber traces are organized into groups and which traces to use for each reduction step.
For multi-order instruments (echelle), set fibers_per_order and provide order_centers to apply grouping within each spectral order.
For multi-channel instruments, per-order fields can be lists indexed by channel (same pattern as orientation, extension, etc.).
- bundles: FiberBundleConfig | None¶
- classmethod convert_order_centers_keys(v)[source]¶
Convert string keys to int (YAML loads int keys as strings).
- fibers_per_order: int | list[int] | None¶
- groups: dict[str, FiberGroupConfig] | None¶
- model_config = {'extra': 'forbid'}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- order_centers: dict[int, float] | None¶
- order_centers_file: str | list[str] | None¶
- property per_order: bool¶
Whether per-order grouping is enabled (derived from fibers_per_order).
- trace_by: str | None¶
- use: dict[str, TraceSelection] | None¶
- class pyreduce.instruments.models.FileClassification(*, kw_bias: str | None = None, kw_flat: str | None = None, kw_curvature: str | None = None, kw_scatter: str | None = None, kw_orders: str | None = None, kw_wave: str | None = None, kw_comb: str | None = None, kw_spec: str | None = None, id_bias: str | None = None, id_flat: str | None = None, id_curvature: str | None = None, id_scatter: str | None = None, id_orders: str | None = None, id_wave: str | None = None, id_comb: str | None = None, id_spec: str | None = None, **extra_data: Any)[source]¶
Bases:
BaseModelKeywords and patterns for file type classification.
- id_bias: str | None¶
- id_comb: str | None¶
- id_curvature: str | None¶
- id_flat: str | None¶
- id_orders: str | None¶
- id_scatter: str | None¶
- id_spec: str | None¶
- id_wave: str | None¶
- kw_bias: str | None¶
- kw_comb: str | None¶
- kw_curvature: str | None¶
- kw_flat: str | None¶
- kw_orders: str | None¶
- kw_scatter: str | None¶
- kw_spec: str | None¶
- kw_wave: str | None¶
- model_config = {'extra': 'allow'}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class pyreduce.instruments.models.HeaderRef(*, key: str)[source]¶
Bases:
BaseModelReference to a FITS header keyword.
- key: str¶
- model_config = {'extra': 'forbid'}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class pyreduce.instruments.models.InstrumentConfig(*, instrument: str, id_instrument: str, telescope: str | None = None, date: str = 'DATE-OBS', date_format: str = 'fits', channels: list[str] | None = None, channels_id: list[str] | None = None, kw_channel: str | None = None, id_channel: list[str] | None = None, extension: int | str | list[int | str] = 0, orientation: int | list[int] = 0, transpose: bool = False, amplifiers: AmplifiersConfig | None = None, fibers: FibersConfig | None = None, naxis_x: str | int = 'NAXIS1', naxis_y: str | int = 'NAXIS2', prescan_x: int | str = 0, overscan_x: int | str = 0, prescan_y: int | str = 0, overscan_y: int | str = 0, gain: float | int | str = 1, readnoise: float | int | str = 0, dark: float | int | str = 0, sky: float | int | str = 0, exposure_time: str = 'EXPTIME', ra: str | None = 'RA', dec: str | None = 'DEC', longitude: float | str | None = None, latitude: float | str | None = None, altitude: float | str | None = None, target: str = 'OBJECT', observation_type: str | None = None, category: str | None = None, image_type: str | None = None, instrument_mode: str | None = None, kw_bias: str | None = None, kw_flat: str | None = None, kw_curvature: str | None = None, kw_scatter: str | None = None, kw_orders: str | None = None, kw_wave: str | None = None, kw_comb: str | None = None, kw_spec: str | None = None, id_bias: str | None = None, id_flat: str | None = None, id_curvature: str | None = None, id_scatter: str | None = None, id_orders: str | None = None, id_wave: str | None = None, id_comb: str | None = None, id_spec: str | None = None, wavelength_range: list | None = None, wavecal_specifier: str | None = None, **extra_data: Any)[source]¶
Bases:
BaseModelConfiguration for an astronomical instrument.
This model validates the flat YAML structure used by instrument configs. It allows extra fields for instrument-specific parameters.
- altitude: float | str | None¶
- amplifiers: AmplifiersConfig | None¶
- category: str | None¶
- channels: list[str] | None¶
- channels_id: list[str] | None¶
- dark: float | int | str¶
- date: str¶
- date_format: str¶
- dec: str | None¶
- exposure_time: str¶
- extension: int | str | list[int | str]¶
- fibers: FibersConfig | None¶
- gain: float | int | str¶
- id_bias: str | None¶
- id_channel: list[str] | None¶
- id_comb: str | None¶
- id_curvature: str | None¶
- id_flat: str | None¶
- id_instrument: str¶
- id_orders: str | None¶
- id_scatter: str | None¶
- id_spec: str | None¶
- id_wave: str | None¶
- image_type: str | None¶
- instrument: str¶
- instrument_mode: str | None¶
- kw_bias: str | None¶
- kw_channel: str | None¶
- kw_comb: str | None¶
- kw_curvature: str | None¶
- kw_flat: str | None¶
- kw_orders: str | None¶
- kw_scatter: str | None¶
- kw_spec: str | None¶
- kw_wave: str | None¶
- latitude: float | str | None¶
- longitude: float | str | None¶
- model_config = {'extra': 'allow', 'populate_by_name': True, 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- naxis_x: str | int¶
- naxis_y: str | int¶
- observation_type: str | None¶
- orientation: int | list[int]¶
- overscan_x: int | str¶
- overscan_y: int | str¶
- prescan_x: int | str¶
- prescan_y: int | str¶
- ra: str | None¶
- readnoise: float | int | str¶
- sky: float | int | str¶
- target: str¶
- telescope: str | None¶
- transpose: bool¶
- wavecal_specifier: str | None¶
- wavelength_range: list | None¶
- class pyreduce.instruments.models.InstrumentConfigV2(*, instrument: str, telescope: str | None = None, id_instrument: str, detectors: list[DetectorConfig] = [], optical_paths: list[OpticalPathConfig] = [], dimensions: dict[str, DimensionConfig] = {}, headers: dict[str, str] = {}, file_types: dict[str, dict[str, str]] = {}, **extra_data: Any)[source]¶
Bases:
BaseModelFuture nested instrument configuration structure.
This model represents the target architecture from REDESIGN.md. Not yet used - will be activated when migrating instruments.
- detectors: list[DetectorConfig]¶
- dimensions: dict[str, DimensionConfig]¶
- file_types: dict[str, dict[str, str]]¶
- headers: dict[str, str]¶
- id_instrument: str¶
- instrument: str¶
- model_config = {'extra': 'allow'}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- optical_paths: list[OpticalPathConfig]¶
- telescope: str | None¶
- class pyreduce.instruments.models.OpticalPathConfig(*, name: str, beam_arms: list[BeamArmConfig] | None = None)[source]¶
Bases:
BaseModelConfiguration for an optical path (fiber, slit position).
- beam_arms: list[BeamArmConfig] | None¶
- model_config = {'extra': 'forbid'}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- name: str¶
- pyreduce.instruments.models.validate_instrument_config(data: dict[str, Any]) InstrumentConfig[source]¶
Validate instrument configuration data.
- Parameters:
data (dict) – Raw configuration data (from YAML or JSON)
- Returns:
Validated configuration
- Return type:
- Raises:
pydantic.ValidationError – If validation fails
pyreduce.instruments.filters module¶
- class pyreduce.instruments.filters.ChannelFilter(keyword, dtype='U20', wildcards=False, regex=False, flags=0, unique=True, ignorecase=True, replacement=None)[source]¶
Bases:
Filter
- class pyreduce.instruments.filters.Filter(keyword, dtype='U20', wildcards=False, regex=False, flags=0, unique=True, ignorecase=True)[source]¶
Bases:
object
- class pyreduce.instruments.filters.InstrumentFilter(keyword='INSTRUME', **kwargs)[source]¶
Bases:
Filter
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.channelinfo(header, instrument, channel, **kwargs)[source]¶
Add instrument specific information to a header/dict
- Parameters:
header (fits.header, dict) – header to add information to
instrument (str) – instrument name
channel (str) – instrument channel (e.g. BLUE/RED for HARPS)
- Returns:
header with added information
- Return type:
- 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, channel, **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
channel (str) – instrument channel (e.g. BLUE/RED for HARPS)
- Returns:
filename – wavelength solution file
- Return type:
str
- pyreduce.instruments.instrument_info.load_instrument(instrument) Instrument[source]¶
Load an python instrument module
- Parameters:
instrument (str) – name of the instrument
- Returns:
instrument – Instance of the {instrument} class
- Return type:
- pyreduce.instruments.instrument_info.sort_files(input_dir, target, night, instrument, channel, **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
channel (str) – instrument channel (e.g. BLUE/RED 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
Instrument Subpackages¶
ANDES R-band (RIZ) instrument.
- class pyreduce.instruments.ANDES_RIZ.ANDES_RIZ[source]¶
Bases:
InstrumentANDES R-band spectrograph (E2E simulation data).
ANDES blue arm (U/B/V bands, 66 fibers).
- class pyreduce.instruments.ANDES_UBV.ANDES_UBV[source]¶
Bases:
Instrument
ANDES_YJH instrument - ANDES near-infrared echelle spectrograph with 75 fibers per order.
Three channels (selected by BAND header): - Y: ~0.95-1.12 µm - J: ~1.12-1.35 µm - H: ~1.45-1.8 µm
- class pyreduce.instruments.ANDES_YJH.ANDES_YJH[source]¶
Bases:
Instrument
CRIRES+ instrument - upgraded CRIRES at ESO VLT.
Cross-dispersed IR spectrograph for YJHKLM bands with 3 detectors. Channels are {setting}_{detector}, e.g. J1228_det1.
- class pyreduce.instruments.CRIRES_PLUS.CRIRES_PLUS[source]¶
Bases:
Instrument- add_header_info(header, channel, **kwargs)[source]¶
read data from header and add it as REDUCE keyword back to the header
- discover_channels(input_dir)[source]¶
Discover available channels from CRIRES+ files.
Extracts wavelength setting from headers and combines with detector numbers from extension names to form channel identifiers.
- get_settings_fallbacks(channel)[source]¶
Return channel names to try when looking up settings files.
Searched in order: most specific first, least specific last. The base settings.json is always the final fallback (handled by the caller).
Override in subclasses for instruments with composite channel names.
Handles instrument specific info for the HARPS spectrograph
Mostly reading data from the header
- class pyreduce.instruments.HARPS.HARPS[source]¶
Bases:
Instrument- add_header_info(header, channel, **kwargs)[source]¶
read data from header and add it as REDUCE keyword back to the header
- get_expected_values(target, night, channel=None, mode=None, fiber=None, polarimetry=None, **kwargs)[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
- class pyreduce.instruments.HARPS.PolarizationFilter(keyword='ESO INS RET?? POS')[source]¶
Bases:
Filter
Handles instrument specific info for the HARPN spectrograph
Mostly reading data from the header
- class pyreduce.instruments.HARPN.HARPN[source]¶
Bases:
Instrument- add_header_info(header, channel, **kwargs)[source]¶
read data from header and add it as REDUCE keyword back to the header
- get_expected_values(target, night, channel=None, mode=None, fiber=None, **kwargs)[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
- 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
Handles instrument specific info for the HARPSpol (HARPS polarimeter) spectrograph.
HARPSpol uses a Wollaston prism that splits each echelle order into two beams on the detector. The two beams are treated as fiber groups “upper” and “lower” using PyReduce’s fibers_per_order auto-pairing mode.
- class pyreduce.instruments.HARPSPOL.HARPSPOL[source]¶
Bases:
Instrument- add_header_info(header, channel, **kwargs)[source]¶
Read data from header and add it as REDUCE keyword back to the header.
Handles instrument specific info for the HARPS spectrograph
Mostly reading data from the header
- class pyreduce.instruments.JWST_MIRI.JWST_MIRI[source]¶
Bases:
Instrument
Handles instrument specific info for the HARPS spectrograph
Mostly reading data from the header
- class pyreduce.instruments.JWST_NIRISS.JWST_NIRISS[source]¶
Bases:
Instrument- add_header_info(header, channel, **kwargs)[source]¶
read data from header and add it as REDUCE keyword back to the header
- get_wavecal_filename(header, channel, **kwargs)[source]¶
Get the filename of the wavelength calibration config file
- sort_files(input_dir, target, night, channel, **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
channel (str) – instrument channel
steps (list, optional) – list of steps that will be run. If provided, warnings about missing files are only shown for these steps.
- 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
Handles instrument specific info for the HARPS spectrograph
Mostly reading data from the header
- class pyreduce.instruments.LICK_APF.LICK_APF[source]¶
Bases:
Instrument
Handles instrument specific info for the HARPS spectrograph
Mostly reading data from the header
- class pyreduce.instruments.MCDONALD.MCDONALD[source]¶
Bases:
Instrument
METIS IFU instrument - ELT/METIS integral field unit spectrograph.
L/M band IFU with ~100 wavelength settings and 4 detectors. Channels are {wavelength}_{detector}, e.g. 4.555_det1.
- class pyreduce.instruments.METIS_IFU.METIS_IFU[source]¶
Bases:
Instrument- add_header_info(header, channel, **kwargs)[source]¶
Read data from header and add it as REDUCE keyword back to the header.
- discover_channels(input_dir)[source]¶
Discover available channels from METIS IFU files.
Extracts wavelength setting from headers and combines with detector numbers from extension names to form channel identifiers.
- get_expected_values(target, night, channel)[source]¶
Get expected header values for file classification.
- get_supported_channels()[source]¶
Return sample channels for testing.
Can’t enumerate all ~400 channels; actual channels are discovered dynamically via discover_channels().
Handles instrument specific info for the METIS_LSS LSS spectrograph
Mostly reading data from the header
- class pyreduce.instruments.METIS_LSS.METIS_LSS[source]¶
Bases:
Instrument
Handles instrument specific info for the MICADO spectrograph
Mostly reading data from the header
- class pyreduce.instruments.MICADO.MICADO[source]¶
Bases:
Instrument
MOSAIC instrument - ELT multi-object spectrograph with 630 fibers.
NIR channel: 90 fiber groups (7 fibers each), 4096x4096 H4RG detector. VIS channel: 4 quadrants (VIS1-VIS4) from a 12788x12394 mosaic detector. Fibers split into two halves with a gap in the middle.
- class pyreduce.instruments.MOSAIC.MOSAIC[source]¶
Bases:
Instrument- VIS_QUADRANTS = {'VIS1': {'xhi': 6144, 'xlo': 0, 'yhi': 6000, 'ylo': 1780}, 'VIS2': {'xhi': 12393, 'xlo': 6249, 'yhi': 6005, 'ylo': 1810}, 'VIS3': {'xhi': 6144, 'xlo': 0, 'yhi': 10990, 'ylo': 6775}, 'VIS4': {'xhi': 12393, 'xlo': 6249, 'yhi': 10945, 'ylo': 6644}}¶
Handles instrument specific info for the NEID spectrograph
NEID is a fiber-fed, high-resolution (R~110,000) spectrograph on the WIYN 3.5m telescope at Kitt Peak. It has three fibers: - Science fiber (SCI-OBJ): Target or calibration light - Calibration fiber (CAL-OBJ): Simultaneous calibration (Etalon, LFC, etc.) - Sky fiber (SKY-OBJ): Sky background or calibration
L0 data has 16 amplifiers stored in separate FITS extensions.
- class pyreduce.instruments.NEID.NEID[source]¶
Bases:
Instrument- get_expected_values(target, night, channel=None, mode='HR', **kwargs)[source]¶
Determine the expected header values for file classification.
- Parameters:
target (str) – Name of the observation target
night (str) – Observation night(s)
channel (str) – Instrument channel (HR mode only for now)
mode (str) – Observation mode (HR or HE)
- Returns:
expectations – Expected header values per reduction step
- Return type:
dict
Handles instrument specific info for the UVES spectrograph
Mostly reading data from the header
- class pyreduce.instruments.NIRSPEC.NIRSPEC[source]¶
Bases:
Instrument- add_header_info(header, channel, **kwargs)[source]¶
read data from header and add it as REDUCE keyword back to the header
- get_wavecal_filename(header, channel, **kwargs)[source]¶
Get the filename of the wavelength calibration config file
- sort_files(input_dir, target, night, channel, calibration_dir, **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
channel (str) – instrument channel
- 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
Handles instrument specific info for the NTE spectrograph
Mostly reading data from the header
- class pyreduce.instruments.NTE.NTE[source]¶
Bases:
Instrument- add_header_info(header, channel, **kwargs)[source]¶
read data from header and add it as REDUCE keyword back to the header
Handles instrument specific info for the UVES spectrograph
Mostly reading data from the header
- class pyreduce.instruments.UVES.UVES[source]¶
Bases:
Instrument
Handles instrument specific info for the UVES spectrograph
Mostly reading data from the header
- class pyreduce.instruments.XSHOOTER.XSHOOTER[source]¶
Bases:
Instrument