dkist-processing-visp 2.20.14__py3-none-any.whl → 5.1.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dkist_processing_visp/__init__.py +1 -0
- dkist_processing_visp/config.py +1 -0
- dkist_processing_visp/models/constants.py +61 -20
- dkist_processing_visp/models/fits_access.py +20 -0
- dkist_processing_visp/models/metric_code.py +10 -0
- dkist_processing_visp/models/parameters.py +129 -24
- dkist_processing_visp/models/tags.py +22 -1
- dkist_processing_visp/models/task_name.py +1 -0
- dkist_processing_visp/parsers/map_repeats.py +1 -0
- dkist_processing_visp/parsers/modulator_states.py +1 -0
- dkist_processing_visp/parsers/polarimeter_mode.py +4 -2
- dkist_processing_visp/parsers/raster_step.py +4 -1
- dkist_processing_visp/parsers/spectrograph_configuration.py +75 -0
- dkist_processing_visp/parsers/time.py +24 -14
- dkist_processing_visp/parsers/visp_l0_fits_access.py +19 -8
- dkist_processing_visp/parsers/visp_l1_fits_access.py +1 -0
- dkist_processing_visp/tasks/__init__.py +1 -0
- dkist_processing_visp/tasks/assemble_movie.py +1 -0
- dkist_processing_visp/tasks/background_light.py +2 -1
- dkist_processing_visp/tasks/dark.py +5 -4
- dkist_processing_visp/tasks/geometric.py +132 -20
- dkist_processing_visp/tasks/instrument_polarization.py +128 -18
- dkist_processing_visp/tasks/l1_output_data.py +203 -0
- dkist_processing_visp/tasks/lamp.py +53 -93
- dkist_processing_visp/tasks/make_movie_frames.py +8 -6
- dkist_processing_visp/tasks/mixin/beam_access.py +1 -0
- dkist_processing_visp/tasks/mixin/corrections.py +54 -4
- dkist_processing_visp/tasks/mixin/downsample.py +1 -0
- dkist_processing_visp/tasks/parse.py +50 -17
- dkist_processing_visp/tasks/quality_metrics.py +5 -4
- dkist_processing_visp/tasks/science.py +126 -46
- dkist_processing_visp/tasks/solar.py +896 -456
- dkist_processing_visp/tasks/visp_base.py +4 -3
- dkist_processing_visp/tasks/write_l1.py +38 -10
- dkist_processing_visp/tests/conftest.py +145 -47
- dkist_processing_visp/tests/header_models.py +157 -20
- dkist_processing_visp/tests/local_trial_workflows/l0_cals_only.py +21 -78
- dkist_processing_visp/tests/local_trial_workflows/l0_polcals_as_science.py +421 -0
- dkist_processing_visp/tests/local_trial_workflows/l0_solar_gain_as_science.py +387 -0
- dkist_processing_visp/tests/local_trial_workflows/l0_to_l1.py +18 -75
- dkist_processing_visp/tests/local_trial_workflows/local_trial_helpers.py +346 -14
- dkist_processing_visp/tests/test_assemble_movie.py +2 -3
- dkist_processing_visp/tests/test_assemble_quality.py +89 -4
- dkist_processing_visp/tests/test_background_light.py +51 -44
- dkist_processing_visp/tests/test_dark.py +4 -3
- dkist_processing_visp/tests/test_downsample.py +1 -0
- dkist_processing_visp/tests/test_fits_access.py +43 -0
- dkist_processing_visp/tests/test_geometric.py +45 -4
- dkist_processing_visp/tests/test_instrument_polarization.py +72 -9
- dkist_processing_visp/tests/test_lamp.py +22 -26
- dkist_processing_visp/tests/test_make_movie_frames.py +4 -4
- dkist_processing_visp/tests/test_map_repeats.py +3 -1
- dkist_processing_visp/tests/test_parameters.py +122 -21
- dkist_processing_visp/tests/test_parse.py +164 -18
- dkist_processing_visp/tests/test_quality.py +3 -4
- dkist_processing_visp/tests/test_science.py +113 -15
- dkist_processing_visp/tests/test_solar.py +318 -99
- dkist_processing_visp/tests/test_visp_constants.py +38 -8
- dkist_processing_visp/tests/test_workflows.py +1 -0
- dkist_processing_visp/tests/test_write_l1.py +22 -3
- dkist_processing_visp/workflows/__init__.py +1 -0
- dkist_processing_visp/workflows/l0_processing.py +10 -3
- dkist_processing_visp/workflows/trial_workflows.py +8 -2
- dkist_processing_visp-5.1.1.dist-info/METADATA +552 -0
- dkist_processing_visp-5.1.1.dist-info/RECORD +94 -0
- {dkist_processing_visp-2.20.14.dist-info → dkist_processing_visp-5.1.1.dist-info}/WHEEL +1 -1
- docs/conf.py +5 -1
- docs/gain_correction.rst +52 -44
- docs/science_calibration.rst +7 -0
- dkist_processing_visp/tasks/mixin/line_zones.py +0 -115
- dkist_processing_visp-2.20.14.dist-info/METADATA +0 -196
- dkist_processing_visp-2.20.14.dist-info/RECORD +0 -89
- {dkist_processing_visp-2.20.14.dist-info → dkist_processing_visp-5.1.1.dist-info}/top_level.txt +0 -0
dkist_processing_visp/config.py
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
"""Visp additions to common constants."""
|
|
2
|
+
|
|
2
3
|
from enum import Enum
|
|
3
4
|
|
|
4
|
-
|
|
5
|
+
import astropy.units as u
|
|
6
|
+
from astropy.units import Quantity
|
|
5
7
|
from dkist_processing_common.models.constants import ConstantsBase
|
|
6
8
|
|
|
7
9
|
|
|
8
10
|
class VispBudName(Enum):
|
|
9
11
|
"""Names to be used in Visp buds."""
|
|
10
12
|
|
|
13
|
+
arm_id = "ARM_ID"
|
|
11
14
|
num_raster_steps = "NUM_RASTER_STEPS"
|
|
12
15
|
polarimeter_mode = "POLARIMETER_MODE"
|
|
13
16
|
wavelength = "WAVELENGTH"
|
|
@@ -22,6 +25,10 @@ class VispBudName(Enum):
|
|
|
22
25
|
polcal_readout_exp_times = "POLCAL_READOUT_EXP_TIMES"
|
|
23
26
|
non_dark_task_readout_exp_times = "NON_DARK_TASK_READOUT_EXP_TIMES"
|
|
24
27
|
num_map_scans = "NUM_MAP_SCANS"
|
|
28
|
+
incident_light_angle_deg = "INCIDENT_LIGHT_ANGLE_DEG"
|
|
29
|
+
reflected_light_angle_deg = "REFLECTED_LIGHT_ANGLE_DEG"
|
|
30
|
+
grating_constant_inverse_mm = "GRATING_CONSTANT_INVERSE_MM"
|
|
31
|
+
solar_gain_ip_start_time = "SOLAR_GAIN_IP_START_TIME"
|
|
25
32
|
axis_1_type = "AXIS_1_TYPE"
|
|
26
33
|
axis_2_type = "AXIS_2_TYPE"
|
|
27
34
|
axis_3_type = "AXIS_3_TYPE"
|
|
@@ -31,6 +38,16 @@ class VispBudName(Enum):
|
|
|
31
38
|
class VispConstants(ConstantsBase):
|
|
32
39
|
"""Visp specific constants to add to the common constants."""
|
|
33
40
|
|
|
41
|
+
@property
|
|
42
|
+
def arm_id(self) -> str:
|
|
43
|
+
"""
|
|
44
|
+
Return the current ViSP arm ID.
|
|
45
|
+
|
|
46
|
+
Arm IDs are ints in the headers, but we convert them to str here because that's what downstream machinery expects
|
|
47
|
+
the type to be.
|
|
48
|
+
"""
|
|
49
|
+
return str(self._db_dict[VispBudName.arm_id])
|
|
50
|
+
|
|
34
51
|
@property
|
|
35
52
|
def wavelength(self) -> float:
|
|
36
53
|
"""Wavelength."""
|
|
@@ -41,11 +58,6 @@ class VispConstants(ConstantsBase):
|
|
|
41
58
|
"""Return the start time of the observe IP."""
|
|
42
59
|
return self._db_dict[VispBudName.obs_ip_start_time.value]
|
|
43
60
|
|
|
44
|
-
@property
|
|
45
|
-
def num_modstates(self):
|
|
46
|
-
"""Find the number of modulation states."""
|
|
47
|
-
return self._db_dict[BudName.num_modstates.value]
|
|
48
|
-
|
|
49
61
|
@property
|
|
50
62
|
def num_beams(self):
|
|
51
63
|
"""
|
|
@@ -55,11 +67,6 @@ class VispConstants(ConstantsBase):
|
|
|
55
67
|
"""
|
|
56
68
|
return 2
|
|
57
69
|
|
|
58
|
-
@property
|
|
59
|
-
def num_cs_steps(self):
|
|
60
|
-
"""Find the number of calibration sequence steps."""
|
|
61
|
-
return self._db_dict[BudName.num_cs_steps.value]
|
|
62
|
-
|
|
63
70
|
@property
|
|
64
71
|
def num_raster_steps(self):
|
|
65
72
|
"""Find the number of raster steps."""
|
|
@@ -76,17 +83,27 @@ class VispConstants(ConstantsBase):
|
|
|
76
83
|
return self._db_dict[VispBudName.polarimeter_mode.value] == "observe_polarimetric"
|
|
77
84
|
|
|
78
85
|
@property
|
|
79
|
-
def
|
|
86
|
+
def pac_init_set(self):
|
|
87
|
+
"""Return the label for the initial set of parameter values used when fitting demodulation matrices."""
|
|
88
|
+
retarder_name = self.retarder_name
|
|
89
|
+
match retarder_name:
|
|
90
|
+
case "SiO2 OC":
|
|
91
|
+
return "OCCal_VIS"
|
|
92
|
+
case _:
|
|
93
|
+
raise ValueError(f"No init set known for {retarder_name = }")
|
|
94
|
+
|
|
95
|
+
@property
|
|
96
|
+
def lamp_exposure_times(self) -> list[float]:
|
|
80
97
|
"""Find the lamp exposure time."""
|
|
81
98
|
return self._db_dict[VispBudName.lamp_exposure_times.value]
|
|
82
99
|
|
|
83
100
|
@property
|
|
84
|
-
def solar_exposure_times(self) -> [float]:
|
|
101
|
+
def solar_exposure_times(self) -> list[float]:
|
|
85
102
|
"""Find the solar exposure time."""
|
|
86
103
|
return self._db_dict[VispBudName.solar_exposure_times.value]
|
|
87
104
|
|
|
88
105
|
@property
|
|
89
|
-
def polcal_exposure_times(self) -> [float]:
|
|
106
|
+
def polcal_exposure_times(self) -> list[float]:
|
|
90
107
|
"""Find the polarization calibration exposure time."""
|
|
91
108
|
if self.correct_for_polarization:
|
|
92
109
|
return self._db_dict[VispBudName.polcal_exposure_times.value]
|
|
@@ -94,22 +111,22 @@ class VispConstants(ConstantsBase):
|
|
|
94
111
|
return []
|
|
95
112
|
|
|
96
113
|
@property
|
|
97
|
-
def observe_exposure_times(self) -> [float]:
|
|
114
|
+
def observe_exposure_times(self) -> list[float]:
|
|
98
115
|
"""Find the observation exposure time."""
|
|
99
116
|
return self._db_dict[VispBudName.observe_exposure_times.value]
|
|
100
117
|
|
|
101
118
|
@property
|
|
102
|
-
def lamp_readout_exp_times(self) -> [float]:
|
|
119
|
+
def lamp_readout_exp_times(self) -> list[float]:
|
|
103
120
|
"""Find the lamp readout exposure time."""
|
|
104
121
|
return self._db_dict[VispBudName.lamp_readout_exp_times.value]
|
|
105
122
|
|
|
106
123
|
@property
|
|
107
|
-
def solar_readout_exp_times(self) -> [float]:
|
|
124
|
+
def solar_readout_exp_times(self) -> list[float]:
|
|
108
125
|
"""Find the solar readout exposure time."""
|
|
109
126
|
return self._db_dict[VispBudName.solar_readout_exp_times.value]
|
|
110
127
|
|
|
111
128
|
@property
|
|
112
|
-
def polcal_readout_exp_times(self) -> [float]:
|
|
129
|
+
def polcal_readout_exp_times(self) -> list[float]:
|
|
113
130
|
"""Find the polarization calibration readout exposure time."""
|
|
114
131
|
if self.correct_for_polarization:
|
|
115
132
|
return self._db_dict[VispBudName.polcal_readout_exp_times.value]
|
|
@@ -117,7 +134,7 @@ class VispConstants(ConstantsBase):
|
|
|
117
134
|
return []
|
|
118
135
|
|
|
119
136
|
@property
|
|
120
|
-
def non_dark_task_readout_exp_times(self) -> [float]:
|
|
137
|
+
def non_dark_task_readout_exp_times(self) -> list[float]:
|
|
121
138
|
"""
|
|
122
139
|
Find all readout exposure times that *need* to exist in a dark IP.
|
|
123
140
|
|
|
@@ -127,10 +144,34 @@ class VispConstants(ConstantsBase):
|
|
|
127
144
|
return self._db_dict[VispBudName.non_dark_task_readout_exp_times.value]
|
|
128
145
|
|
|
129
146
|
@property
|
|
130
|
-
def observe_readout_exp_times(self) -> [float]:
|
|
147
|
+
def observe_readout_exp_times(self) -> list[float]:
|
|
131
148
|
"""Find the observation readout exposure time."""
|
|
132
149
|
return self._db_dict[VispBudName.observe_readout_exp_times.value]
|
|
133
150
|
|
|
151
|
+
@property
|
|
152
|
+
def incident_light_angle_deg(self) -> Quantity:
|
|
153
|
+
"""Return the spectrograph incident light angle [deg]."""
|
|
154
|
+
return self._db_dict[VispBudName.incident_light_angle_deg] * u.deg
|
|
155
|
+
|
|
156
|
+
@property
|
|
157
|
+
def reflected_light_angle_deg(self) -> Quantity:
|
|
158
|
+
"""
|
|
159
|
+
Return the spectrograph reflected light angle [deg].
|
|
160
|
+
|
|
161
|
+
This angle is the incident light angle plus the angular position of the ViSP arm.
|
|
162
|
+
"""
|
|
163
|
+
return self._db_dict[VispBudName.reflected_light_angle_deg] * u.deg
|
|
164
|
+
|
|
165
|
+
@property
|
|
166
|
+
def grating_constant_inverse_mm(self) -> Quantity:
|
|
167
|
+
"""Return the spectrograph grating constant [1/mm]."""
|
|
168
|
+
return self._db_dict[VispBudName.grating_constant_inverse_mm] / u.mm
|
|
169
|
+
|
|
170
|
+
@property
|
|
171
|
+
def solar_gain_ip_start_time(self) -> str:
|
|
172
|
+
"""Return the start time of the SOLAR GAIN Instrument Program."""
|
|
173
|
+
return self._db_dict[VispBudName.solar_gain_ip_start_time]
|
|
174
|
+
|
|
134
175
|
@property
|
|
135
176
|
def axis_1_type(self) -> str:
|
|
136
177
|
"""Find the type of the first array axis."""
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""ViSP control of FITS key names and values."""
|
|
2
|
+
|
|
3
|
+
from enum import StrEnum
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class VispMetadataKey(StrEnum):
|
|
7
|
+
"""Controlled list of names for FITS metadata header keys."""
|
|
8
|
+
|
|
9
|
+
arm_id = "VSPARMID"
|
|
10
|
+
number_of_modulator_states = "VSPNUMST"
|
|
11
|
+
raster_scan_step = "VSPSTP"
|
|
12
|
+
total_raster_steps = "VSPNSTP"
|
|
13
|
+
modulator_state = "VSPSTNUM"
|
|
14
|
+
polarimeter_mode = "VISP_006"
|
|
15
|
+
grating_angle_deg = "VSPGRTAN"
|
|
16
|
+
arm_position_deg = "VSPARMPS"
|
|
17
|
+
grating_constant_inverse_mm = "VSPGRTCN"
|
|
18
|
+
axis_1_type = "CTYPE1"
|
|
19
|
+
axis_2_type = "CTYPE2"
|
|
20
|
+
axis_3_type = "CTYPE3"
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""Controlled list of quality metric codes."""
|
|
2
|
+
|
|
3
|
+
from enum import StrEnum
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class VispMetricCode(StrEnum):
|
|
7
|
+
"""Controlled list of quality metric codes."""
|
|
8
|
+
|
|
9
|
+
solar_first_vignette = "SOLAR_CAL_FIRST_VIGNETTE"
|
|
10
|
+
solar_final_vignette = "SOLAR_CAL_FINAL_VIGNETTE"
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
"""Visp calibration pipeline parameters."""
|
|
2
|
+
|
|
2
3
|
from datetime import datetime
|
|
4
|
+
from random import randint
|
|
5
|
+
from typing import Any
|
|
3
6
|
|
|
7
|
+
import astropy.units as u
|
|
8
|
+
from dkist_processing_common.models.parameters import ParameterArmIdMixin
|
|
4
9
|
from dkist_processing_common.models.parameters import ParameterBase
|
|
5
10
|
from dkist_processing_common.models.parameters import ParameterWavelengthMixin
|
|
11
|
+
from solar_wavelength_calibration import DownloadConfig
|
|
6
12
|
|
|
7
13
|
|
|
8
14
|
class VispParsingParameters(ParameterBase):
|
|
@@ -21,7 +27,7 @@ class VispParsingParameters(ParameterBase):
|
|
|
21
27
|
)
|
|
22
28
|
|
|
23
29
|
|
|
24
|
-
class VispParameters(ParameterBase, ParameterWavelengthMixin):
|
|
30
|
+
class VispParameters(ParameterBase, ParameterWavelengthMixin, ParameterArmIdMixin):
|
|
25
31
|
"""Put all Visp parameters parsed from the input dataset document in a single property."""
|
|
26
32
|
|
|
27
33
|
@property
|
|
@@ -68,7 +74,7 @@ class VispParameters(ParameterBase, ParameterWavelengthMixin):
|
|
|
68
74
|
|
|
69
75
|
@property
|
|
70
76
|
def hairline_mask_spatial_smoothing_width_px(self) -> float:
|
|
71
|
-
"""Amount to smooth the
|
|
77
|
+
"""Amount to smooth the hairline mask in the spatial direction.
|
|
72
78
|
|
|
73
79
|
This helps capture the higher-flux wings of the hairlines that would otherwise require a `hairline_fraction`
|
|
74
80
|
that was so low it captures other optical features.
|
|
@@ -133,9 +139,34 @@ class VispParameters(ParameterBase, ParameterWavelengthMixin):
|
|
|
133
139
|
return self._find_most_recent_past_value("visp_geo_poly_fit_order")
|
|
134
140
|
|
|
135
141
|
@property
|
|
136
|
-
def
|
|
142
|
+
def geo_zone_prominence(self):
|
|
143
|
+
"""Relative peak prominence threshold used to identify strong spectral features."""
|
|
144
|
+
return self._find_parameter_closest_wavelength("visp_geo_zone_prominence")
|
|
145
|
+
|
|
146
|
+
@property
|
|
147
|
+
def geo_zone_width(self):
|
|
148
|
+
"""Pixel width used to search for strong spectral features."""
|
|
149
|
+
return self._find_parameter_closest_wavelength("visp_geo_zone_width")
|
|
150
|
+
|
|
151
|
+
@property
|
|
152
|
+
def geo_zone_bg_order(self):
|
|
153
|
+
"""Order of polynomial fit used to remove continuum when identifying strong spectral features."""
|
|
154
|
+
return self._find_parameter_closest_wavelength("visp_geo_zone_bg_order")
|
|
155
|
+
|
|
156
|
+
@property
|
|
157
|
+
def geo_zone_normalization_percentile(self):
|
|
158
|
+
"""Fraction of CDF to use for normalizing spectrum when search for strong features."""
|
|
159
|
+
return self._find_parameter_closest_wavelength("visp_geo_zone_normalization_percentile")
|
|
160
|
+
|
|
161
|
+
@property
|
|
162
|
+
def geo_zone_rel_height(self):
|
|
163
|
+
"""Relative height at which to compute the width of strong spectral features."""
|
|
164
|
+
return self._find_most_recent_past_value("visp_geo_zone_rel_height")
|
|
165
|
+
|
|
166
|
+
@property
|
|
167
|
+
def solar_spatial_median_filter_width_px(self):
|
|
137
168
|
"""Pixel width of spatial median filter used to compute characteristic solar spectra."""
|
|
138
|
-
return self._find_parameter_closest_wavelength("
|
|
169
|
+
return self._find_parameter_closest_wavelength("visp_solar_spatial_median_filter_width_px")
|
|
139
170
|
|
|
140
171
|
@property
|
|
141
172
|
def solar_characteristic_spatial_normalization_percentile(self) -> float:
|
|
@@ -145,29 +176,108 @@ class VispParameters(ParameterBase, ParameterWavelengthMixin):
|
|
|
145
176
|
)
|
|
146
177
|
|
|
147
178
|
@property
|
|
148
|
-
def
|
|
149
|
-
"""
|
|
150
|
-
|
|
179
|
+
def solar_vignette_initial_continuum_poly_fit_order(self) -> int:
|
|
180
|
+
"""
|
|
181
|
+
Define the order of polynomial to use when fitting the initial continuum function.
|
|
182
|
+
|
|
183
|
+
Note that "initial" in this context does not refer to an initial guess in the wavecal fitter, but rather the
|
|
184
|
+
fact that this represents the initial estimate of the vignette signal.
|
|
185
|
+
"""
|
|
186
|
+
return self._find_most_recent_past_value(
|
|
187
|
+
"visp_solar_vignette_initial_continuum_poly_fit_order"
|
|
188
|
+
)
|
|
151
189
|
|
|
152
190
|
@property
|
|
153
|
-
def
|
|
154
|
-
"""
|
|
155
|
-
|
|
191
|
+
def solar_vignette_crval_bounds_px(self) -> float:
|
|
192
|
+
"""
|
|
193
|
+
Define the bounds (in *pixels*) on crval when fitting the initial vignette signal.
|
|
194
|
+
|
|
195
|
+
The actual bounds on the value of crval are equal to ± the initial dispersion times this number. Note that the
|
|
196
|
+
total range searched by the fitting algorithm will be twice this number (in pixels).
|
|
197
|
+
"""
|
|
198
|
+
return self._find_most_recent_past_value("visp_solar_vignette_crval_bounds_px") * u.pix
|
|
156
199
|
|
|
157
200
|
@property
|
|
158
|
-
def
|
|
159
|
-
"""
|
|
160
|
-
|
|
201
|
+
def solar_vignette_dispersion_bounds_fraction(self) -> float:
|
|
202
|
+
"""
|
|
203
|
+
Define the ± fraction away from the initial value for bounds on dispersion when fitting the initial vignette signal.
|
|
204
|
+
|
|
205
|
+
This value should be between 0 and 1. For example, the minimum bound is `init_value * (1 - solar_vignette_dispersion_bounds_fraction)`.
|
|
206
|
+
"""
|
|
207
|
+
return self._find_most_recent_past_value("visp_solar_vignette_dispersion_bounds_fraction")
|
|
161
208
|
|
|
162
209
|
@property
|
|
163
|
-
def
|
|
164
|
-
"""
|
|
165
|
-
|
|
210
|
+
def solar_vignette_wavecal_fit_kwargs(self) -> dict[str, Any]:
|
|
211
|
+
"""Define extra keyword arguments to pass to the wavelength calibration fitter."""
|
|
212
|
+
doc_dict = self._find_most_recent_past_value("visp_solar_vignette_wavecal_fit_kwargs")
|
|
213
|
+
rng_kwarg = dict()
|
|
214
|
+
fitting_method = doc_dict.get("method", False)
|
|
215
|
+
if fitting_method in ["basinhopping", "differential_evolution", "dual_annealing"]:
|
|
216
|
+
rng = randint(1, 1_000_000)
|
|
217
|
+
rng_kwarg["rng"] = rng
|
|
218
|
+
|
|
219
|
+
# The order here allows us to override `rng` in a parameter value
|
|
220
|
+
fit_kwargs = rng_kwarg | doc_dict
|
|
221
|
+
return fit_kwargs
|
|
166
222
|
|
|
167
223
|
@property
|
|
168
|
-
def
|
|
169
|
-
"""
|
|
170
|
-
return self._find_most_recent_past_value("
|
|
224
|
+
def solar_vignette_spectral_poly_fit_order(self) -> int:
|
|
225
|
+
"""Define the order of spectral polynomial used when computing the full, 2D vignette signal."""
|
|
226
|
+
return self._find_most_recent_past_value("visp_solar_vignette_spectral_poly_fit_order")
|
|
227
|
+
|
|
228
|
+
@property
|
|
229
|
+
def solar_vignette_min_samples(self) -> float:
|
|
230
|
+
"""Return fractional number of samples required for the RANSAC regressor used to fit the 2D vignette signal."""
|
|
231
|
+
return self._find_most_recent_past_value("visp_solar_vignette_min_samples")
|
|
232
|
+
|
|
233
|
+
@property
|
|
234
|
+
def wavecal_camera_lens_parameters(self) -> list[u.Quantity]:
|
|
235
|
+
r"""
|
|
236
|
+
Define the 2nd order polynomial coefficients for computing the total camera focal length as a function of wavelength.
|
|
237
|
+
|
|
238
|
+
The total focal length of the lens is :math:`f = a_0 + a_1\lambda + a_2\lambda^2` where this property is
|
|
239
|
+
:math:`[a_0, a_1, a_2]`
|
|
240
|
+
"""
|
|
241
|
+
value_list = self._find_parameter_for_arm("visp_wavecal_camera_lens_parameters")
|
|
242
|
+
unit_list = [u.m, u.m / u.nm, u.m / u.nm**2]
|
|
243
|
+
return [v * u for v, u in zip(value_list, unit_list)]
|
|
244
|
+
|
|
245
|
+
@property
|
|
246
|
+
def wavecal_pixel_pitch_micron_per_pix(self) -> u.Quantity:
|
|
247
|
+
"""Define the physical size of ViSP detector pixels."""
|
|
248
|
+
return (
|
|
249
|
+
self._find_most_recent_past_value("visp_wavecal_pixel_pitch_micron_per_pix")
|
|
250
|
+
* u.micron
|
|
251
|
+
/ u.pix
|
|
252
|
+
)
|
|
253
|
+
|
|
254
|
+
@property
|
|
255
|
+
def wavecal_atlas_download_config(self) -> DownloadConfig:
|
|
256
|
+
"""Define the `~solar_wavelength_calibration.DownloadConfig` used to grab the Solar atlas used for wavelength calibration."""
|
|
257
|
+
config_dict = self._find_most_recent_past_value("visp_wavecal_atlas_download_config")
|
|
258
|
+
return DownloadConfig.model_validate(config_dict)
|
|
259
|
+
|
|
260
|
+
@property
|
|
261
|
+
def wavecal_init_crval_guess_normalization_percentile(self) -> float | None:
|
|
262
|
+
"""Define the CDF percentage used to normalize the Atlas to the input spectrum level when computing an initial CRVAL guess."""
|
|
263
|
+
return self._find_most_recent_past_value(
|
|
264
|
+
"visp_wavecal_init_crval_guess_normalization_percentile"
|
|
265
|
+
)
|
|
266
|
+
|
|
267
|
+
@property
|
|
268
|
+
def wavecal_init_resolving_power(self) -> int:
|
|
269
|
+
"""Define the initial guess for ViSP resolving power in wavecal fits."""
|
|
270
|
+
return self._find_most_recent_past_value("visp_wavecal_init_resolving_power")
|
|
271
|
+
|
|
272
|
+
@property
|
|
273
|
+
def wavecal_init_straylight_fraction(self) -> float:
|
|
274
|
+
"""Define the initial guess for straylight fraction in wavecal fits."""
|
|
275
|
+
return self._find_most_recent_past_value("visp_wavecal_init_straylight_fraction")
|
|
276
|
+
|
|
277
|
+
@property
|
|
278
|
+
def wavecal_init_opacity_factor(self) -> float:
|
|
279
|
+
"""Define the initial guess for opacity factor in wavecal fits."""
|
|
280
|
+
return self._find_most_recent_past_value("visp_wavecal_init_opacity_factor")
|
|
171
281
|
|
|
172
282
|
@property
|
|
173
283
|
def polcal_spatial_median_filter_width_px(self) -> int:
|
|
@@ -213,8 +323,3 @@ class VispParameters(ParameterBase, ParameterWavelengthMixin):
|
|
|
213
323
|
def pac_fit_mode(self):
|
|
214
324
|
"""Name of set of fitting flags to use during PAC Calibration Unit parameter fits."""
|
|
215
325
|
return self._find_most_recent_past_value("visp_pac_fit_mode")
|
|
216
|
-
|
|
217
|
-
@property
|
|
218
|
-
def pac_init_set(self):
|
|
219
|
-
"""Name of set of initial values for Calibration Unit parameter fit."""
|
|
220
|
-
return self._find_most_recent_past_value("visp_pac_init_set")
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""ViSP tags."""
|
|
2
|
+
|
|
2
3
|
from enum import Enum
|
|
3
4
|
|
|
4
5
|
from dkist_processing_common.models.tags import Tag
|
|
@@ -76,7 +77,7 @@ class VispTag(Tag):
|
|
|
76
77
|
@classmethod
|
|
77
78
|
def intermediate_frame_dark(
|
|
78
79
|
cls,
|
|
79
|
-
beam:
|
|
80
|
+
beam: int,
|
|
80
81
|
readout_exp_time: float,
|
|
81
82
|
) -> list[str]:
|
|
82
83
|
"""Tag by intermediate_frame composite tag, task_dark, and readout_exposure_time."""
|
|
@@ -86,3 +87,23 @@ class VispTag(Tag):
|
|
|
86
87
|
cls.readout_exp_time(readout_exp_time),
|
|
87
88
|
]
|
|
88
89
|
return tag_list
|
|
90
|
+
|
|
91
|
+
@classmethod
|
|
92
|
+
def intermediate_frame_polcal_dark(cls, beam: int, readout_exp_time: float) -> list[str]:
|
|
93
|
+
"""Return tag list for averaged polcal dark frames."""
|
|
94
|
+
tag_list = [
|
|
95
|
+
cls.intermediate_frame(beam),
|
|
96
|
+
cls.task_polcal_dark(),
|
|
97
|
+
cls.readout_exp_time(readout_exp_time),
|
|
98
|
+
]
|
|
99
|
+
return tag_list
|
|
100
|
+
|
|
101
|
+
@classmethod
|
|
102
|
+
def intermediate_frame_polcal_gain(cls, beam: int, readout_exp_time: float) -> list[str]:
|
|
103
|
+
"""Return tag list for averaged polcal gain frames."""
|
|
104
|
+
tag_list = [
|
|
105
|
+
cls.intermediate_frame(beam),
|
|
106
|
+
cls.task_polcal_gain(),
|
|
107
|
+
cls.readout_exp_time(readout_exp_time),
|
|
108
|
+
]
|
|
109
|
+
return tag_list
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"""ViSP polarimeter mode parser."""
|
|
2
|
+
|
|
2
3
|
from dkist_processing_common.models.task_name import TaskName
|
|
3
4
|
from dkist_processing_common.parsers.unique_bud import TaskUniqueBud
|
|
4
5
|
|
|
5
6
|
from dkist_processing_visp.models.constants import VispBudName
|
|
7
|
+
from dkist_processing_visp.models.fits_access import VispMetadataKey
|
|
6
8
|
|
|
7
9
|
|
|
8
10
|
class PolarimeterModeBud(TaskUniqueBud):
|
|
@@ -11,6 +13,6 @@ class PolarimeterModeBud(TaskUniqueBud):
|
|
|
11
13
|
def __init__(self):
|
|
12
14
|
super().__init__(
|
|
13
15
|
constant_name=VispBudName.polarimeter_mode.value,
|
|
14
|
-
metadata_key=
|
|
15
|
-
|
|
16
|
+
metadata_key=VispMetadataKey.polarimeter_mode,
|
|
17
|
+
ip_task_types=TaskName.observe.value,
|
|
16
18
|
)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""Copies of UniqueBud and SingleValueSingleKeyFlower from common that only activate if the frames are "observe" task."""
|
|
2
|
+
|
|
2
3
|
from typing import Type
|
|
3
4
|
|
|
4
5
|
from dkist_processing_common.models.flower_pot import SpilledDirt
|
|
@@ -9,6 +10,7 @@ from dkist_processing_common.parsers.single_value_single_key_flower import (
|
|
|
9
10
|
)
|
|
10
11
|
|
|
11
12
|
from dkist_processing_visp.models.constants import VispBudName
|
|
13
|
+
from dkist_processing_visp.models.fits_access import VispMetadataKey
|
|
12
14
|
from dkist_processing_visp.models.tags import VispStemName
|
|
13
15
|
from dkist_processing_visp.parsers.visp_l0_fits_access import VispL0FitsAccess
|
|
14
16
|
|
|
@@ -68,7 +70,8 @@ class RasterScanStepFlower(SingleValueSingleKeyFlower):
|
|
|
68
70
|
|
|
69
71
|
def __init__(self):
|
|
70
72
|
super().__init__(
|
|
71
|
-
tag_stem_name=VispStemName.raster_step.value,
|
|
73
|
+
tag_stem_name=VispStemName.raster_step.value,
|
|
74
|
+
metadata_key=VispMetadataKey.raster_scan_step,
|
|
72
75
|
)
|
|
73
76
|
|
|
74
77
|
def setter(self, fits_obj: VispL0FitsAccess):
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"""Buds for parsing the incident and reflected light angles of the ViSP spectrograph."""
|
|
2
|
+
|
|
3
|
+
from dkist_processing_common.models.flower_pot import SpilledDirt
|
|
4
|
+
from dkist_processing_common.models.flower_pot import Stem
|
|
5
|
+
from dkist_processing_common.models.task_name import TaskName
|
|
6
|
+
from dkist_processing_common.parsers.task import parse_header_ip_task_with_gains
|
|
7
|
+
from dkist_processing_common.parsers.unique_bud import TaskUniqueBud
|
|
8
|
+
|
|
9
|
+
from dkist_processing_visp.models.constants import VispBudName
|
|
10
|
+
from dkist_processing_visp.models.fits_access import VispMetadataKey
|
|
11
|
+
from dkist_processing_visp.parsers.visp_l0_fits_access import VispL0FitsAccess
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def convert_grating_angle_to_incident_light_angle(grating_angle: float) -> float:
|
|
15
|
+
"""Convert the raw header "grating angle" to the incident light angle expected by the solar wavecal library."""
|
|
16
|
+
return -1 * grating_angle
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class IncidentLightAngleBud(TaskUniqueBud):
|
|
20
|
+
"""Special case of `TaskUniqueBud` so we can apply the sign shift to the header incident light angle values."""
|
|
21
|
+
|
|
22
|
+
def __init__(self):
|
|
23
|
+
super().__init__(
|
|
24
|
+
constant_name=VispBudName.incident_light_angle_deg.value,
|
|
25
|
+
metadata_key=VispMetadataKey.grating_angle_deg,
|
|
26
|
+
ip_task_types=[TaskName.observe.value, TaskName.solar_gain.value],
|
|
27
|
+
task_type_parsing_function=parse_header_ip_task_with_gains,
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
def setter(self, fits_obj: VispL0FitsAccess) -> float | type[SpilledDirt]:
|
|
31
|
+
"""Apply a sign flip to the raw header value for incident light angle."""
|
|
32
|
+
grating_angle = super().setter(fits_obj)
|
|
33
|
+
|
|
34
|
+
if grating_angle is SpilledDirt:
|
|
35
|
+
return grating_angle
|
|
36
|
+
|
|
37
|
+
return convert_grating_angle_to_incident_light_angle(grating_angle)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class ReflectedLightAngleBud(Stem):
|
|
41
|
+
"""Bud that combines the incident light angle and arm position header values to compute the reflected light angle."""
|
|
42
|
+
|
|
43
|
+
key_to_petal_dict: dict[str, float]
|
|
44
|
+
|
|
45
|
+
def __init__(self):
|
|
46
|
+
super().__init__(stem_name=VispBudName.reflected_light_angle_deg.value)
|
|
47
|
+
self.ip_task_types = [
|
|
48
|
+
task.casefold() for task in [TaskName.observe.value, TaskName.solar_gain.value]
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
def setter(self, fits_obj: VispL0FitsAccess) -> float | type[SpilledDirt]:
|
|
52
|
+
"""
|
|
53
|
+
Compute the reflected light angle.
|
|
54
|
+
|
|
55
|
+
The reflected light angle is `-1 * fits_objs.grating_angle_deg + fits_obj.arm_position_deg`.
|
|
56
|
+
"""
|
|
57
|
+
task = parse_header_ip_task_with_gains(fits_obj)
|
|
58
|
+
|
|
59
|
+
if task.casefold() in self.ip_task_types:
|
|
60
|
+
incident_light_angle = convert_grating_angle_to_incident_light_angle(
|
|
61
|
+
fits_obj.grating_angle_deg
|
|
62
|
+
)
|
|
63
|
+
arm_position = fits_obj.arm_position_deg
|
|
64
|
+
return incident_light_angle + arm_position
|
|
65
|
+
|
|
66
|
+
return SpilledDirt
|
|
67
|
+
|
|
68
|
+
def getter(self, key: str) -> float:
|
|
69
|
+
"""Get the value for the reflected light angle and raise an error if it is not unique."""
|
|
70
|
+
value_set = set(self.key_to_petal_dict.values())
|
|
71
|
+
if len(value_set) > 1:
|
|
72
|
+
raise ValueError(
|
|
73
|
+
f"Multiple {self.stem_name} values found for key {key}. Values: {value_set}"
|
|
74
|
+
)
|
|
75
|
+
return value_set.pop()
|