Coverage for src/susi/base/config/reduc.py: 81%
21 statements
« prev ^ index » next coverage.py v7.5.0, created at 2025-08-22 09:20 +0000
« prev ^ index » next coverage.py v7.5.0, created at 2025-08-22 09:20 +0000
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3"""
4Module to specify configuration of various reduction steps
6@author: iglesias
7"""
8from dataclasses import dataclass
9from ..exceptions import MissConfigurationException
12@dataclass
13class Reduc:
15 # ====== Smile correction ======
16 #: Spectral offset between offset map (smile) and sci data (float in nm).
17 #: If not None, then the offset map will be shifted and cropped accordingly. See block M
18 #: positive means the soft flat is shifted to longer wavelengths (right in SP1)
19 offset_map_wl_offset = None
21 # ====== wl calibration incl. prefilter ======
22 #: Spectral offset between soft flat field and sci data (float in nm).
23 #: If not None, then the soft flat (and prefilter) map will be shifted and cropped accordingly. See block F
24 #: positive means the soft flat is shifted to longer wavelengths (right in SP1)
25 soft_flat_wl_offset = None
27 # ====== Slit flat field ======
28 #: Order of the polinomial to fit the slit flat shift
29 slit_ff_smooth_par: int = 2
30 #: Number of frames to average when estimating the slit flat shift
31 slit_ff_avg_frm: int = 60 * 47 # 1 minutes at 47 fps
32 #: initial value for the global shift [px]. TODO use None to auto estimate it
33 slit_ff_global_ini = 0
34 #: sci data wl range to use [px], None to use the full range
35 slit_ff_wl_roi = None
36 #: sci data slit range to use [px], None to use the full range
37 slit_ff_slit_roi = None
39 def __repr__(self) -> str:
40 txt = f'== {self.__class__.__name__} ==\n'
41 txt += '\n'.join(['{:<21} = {}'.format(k, v) for k, v in self.__dict__.items()])
42 return txt
44 def amend_from_dict(self, data: dict):
45 """
46 Overwrites the parameters with the values from the given dictionary.
47 All instance variable names are supported as keywords.
48 All keywords are optional, if the keyword is not present the previous value will be kept.
50 ### Params
51 - data: The dictionary to parse.
52 - c_name: The name of the camera to set defaults for.
54 ### Returns
55 the created Config
56 """
57 for k, v in data.items():
58 if not hasattr(self, k):
59 raise MissConfigurationException(f'{self.__class__.__name__} config has no attribute {k}')
60 setattr(self, k, v)