Coverage for src/spectroflat/base/smile_config.py: 100%
24 statements
« prev ^ index » next coverage.py v7.3.2, created at 2024-03-28 07:59 +0000
« prev ^ index » next coverage.py v7.3.2, created at 2024-03-28 07:59 +0000
1from dataclasses import dataclass
2from typing import Union
5@dataclass
6class SmileConfig:
7 """
8 DataItem for smile detection configuration.
10 This class holds all the tiny little configuration details
11 used during smile detection.
12 """
14 # --- Smoothing and Filtering ----
16 #: En-/disable post line removal smoothing of the gain-table
17 smooth: bool = True
19 # The polynomial degree for the global smudging
20 smoothing_degree: int = 11
22 # Sigma filter do remove outliers and only take the background variation
23 smoothing_filter: float = 1.5
25 # --- Line Detection ---
27 #: List of line centers to use for processing.
28 #: If none is given automatic detection will be used.
29 line_centers: list = None
31 #: Flag if the peaks are downwards (absorption lines, default) or upwards (emission lines, inverted)
32 emission_spectrum: bool = False
34 #: Maximum allowed error threshold allowed when fitting a line with a Gaussian or Lorentzian profile
35 error_threshold: float = 0.32
37 # --- Global Smile ---
39 #: Integer > 1 to define the minimum distance of two lines in pixels.
40 line_distance: int = 13
42 #: Minimal prominence factor of the lines to be regarded.
43 #: Especially useful in noisy data
44 line_prominence: float = 0
46 #: Minimum sigma * std deviation from mean to be regarded as line
47 height_sigma: float = 0.42
49 #: Minimum degree to allow in the minimization of the dispersion difference in the rows.
50 min_dispersion_deg: int = 1
52 #: Maximum degree to allow in the minimization of the dispersion difference in the rows.
53 max_dispersion_deg: int = 11
55 #: Expected smile degree in vertical (slit) direction.
56 smile_deg: int = 7
58 # -- rotation --
60 #: Rotation correction:
61 # - None (default): No correction
62 # - 'horizontal': Auto detect rotation angle to correct for based on horizontal lines
63 # - 'vertical': Auto detect rotation angle to correct for based on vertical lines
64 # - Number (float): Rotate by the given angle
65 rotation_correction: Union[float, str] = None
67 # -- general --
69 #: Flag to determine if all mod states shall have their own offset map or if the same
70 #: offsets shall be used for all.
71 state_aware: bool = False
73 # -- values below are detected by the algorithm --
75 # roi
76 roi: tuple = None
78 # Total rows
79 total_rows: int = 2048
80 # Total cols
81 total_cols: int = 2048
83 @staticmethod
84 def from_dict(data: dict):
85 """
86 Create a smile config from a dictionary.
88 All instance variable names are supported as keywords.
89 All keywords are optional, if the keyword is not present the default will be used.
91 ### Params
92 - data: the dictionary to parse
94 ### Returns
95 The created SmileConfig
96 """
97 return SmileConfig(**data)