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

1from dataclasses import dataclass 

2from typing import Union 

3 

4 

5@dataclass 

6class SmileConfig: 

7 """ 

8 DataItem for smile detection configuration. 

9 

10 This class holds all the tiny little configuration details 

11 used during smile detection. 

12 """ 

13 

14 # --- Smoothing and Filtering ---- 

15 

16 #: En-/disable post line removal smoothing of the gain-table 

17 smooth: bool = True 

18 

19 # The polynomial degree for the global smudging 

20 smoothing_degree: int = 11 

21 

22 # Sigma filter do remove outliers and only take the background variation 

23 smoothing_filter: float = 1.5 

24 

25 # --- Line Detection --- 

26 

27 #: List of line centers to use for processing. 

28 #: If none is given automatic detection will be used. 

29 line_centers: list = None 

30 

31 #: Flag if the peaks are downwards (absorption lines, default) or upwards (emission lines, inverted) 

32 emission_spectrum: bool = False 

33 

34 #: Maximum allowed error threshold allowed when fitting a line with a Gaussian or Lorentzian profile 

35 error_threshold: float = 0.32 

36 

37 # --- Global Smile --- 

38 

39 #: Integer > 1 to define the minimum distance of two lines in pixels. 

40 line_distance: int = 13 

41 

42 #: Minimal prominence factor of the lines to be regarded. 

43 #: Especially useful in noisy data 

44 line_prominence: float = 0 

45 

46 #: Minimum sigma * std deviation from mean to be regarded as line 

47 height_sigma: float = 0.42 

48 

49 #: Minimum degree to allow in the minimization of the dispersion difference in the rows. 

50 min_dispersion_deg: int = 1 

51 

52 #: Maximum degree to allow in the minimization of the dispersion difference in the rows. 

53 max_dispersion_deg: int = 11 

54 

55 #: Expected smile degree in vertical (slit) direction. 

56 smile_deg: int = 7 

57 

58 # -- rotation -- 

59 

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 

66 

67 # -- general -- 

68 

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 

72 

73 # -- values below are detected by the algorithm -- 

74 

75 # roi 

76 roi: tuple = None 

77 

78 # Total rows 

79 total_rows: int = 2048 

80 # Total cols 

81 total_cols: int = 2048 

82 

83 @staticmethod 

84 def from_dict(data: dict): 

85 """ 

86 Create a smile config from a dictionary. 

87 

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. 

90 

91 ### Params 

92 - data: the dictionary to parse 

93 

94 ### Returns 

95 The created SmileConfig 

96 """ 

97 return SmileConfig(**data)