dkist-processing-cryonirsp 1.10.0rc1__py3-none-any.whl → 1.14.9rc1__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.
- changelog/232.misc.rst +1 -0
- dkist_processing_cryonirsp/__init__.py +1 -0
- dkist_processing_cryonirsp/codecs/fits.py +1 -0
- dkist_processing_cryonirsp/config.py +1 -0
- dkist_processing_cryonirsp/models/beam_boundaries.py +1 -0
- dkist_processing_cryonirsp/models/constants.py +8 -30
- dkist_processing_cryonirsp/models/exposure_conditions.py +6 -5
- dkist_processing_cryonirsp/models/fits_access.py +40 -0
- dkist_processing_cryonirsp/models/parameters.py +1 -0
- dkist_processing_cryonirsp/models/tags.py +1 -0
- dkist_processing_cryonirsp/models/task_name.py +1 -0
- dkist_processing_cryonirsp/parsers/check_for_gains.py +1 -0
- dkist_processing_cryonirsp/parsers/cryonirsp_l0_fits_access.py +40 -48
- dkist_processing_cryonirsp/parsers/cryonirsp_l1_fits_access.py +1 -0
- dkist_processing_cryonirsp/parsers/exposure_conditions.py +14 -13
- dkist_processing_cryonirsp/parsers/map_repeats.py +1 -0
- dkist_processing_cryonirsp/parsers/measurements.py +29 -16
- dkist_processing_cryonirsp/parsers/modstates.py +5 -1
- dkist_processing_cryonirsp/parsers/optical_density_filters.py +1 -0
- dkist_processing_cryonirsp/parsers/polarimetric_check.py +18 -7
- dkist_processing_cryonirsp/parsers/scan_step.py +12 -4
- dkist_processing_cryonirsp/parsers/time.py +7 -7
- dkist_processing_cryonirsp/parsers/wavelength.py +6 -1
- dkist_processing_cryonirsp/tasks/__init__.py +1 -0
- dkist_processing_cryonirsp/tasks/assemble_movie.py +1 -0
- dkist_processing_cryonirsp/tasks/bad_pixel_map.py +6 -5
- dkist_processing_cryonirsp/tasks/beam_boundaries_base.py +9 -10
- dkist_processing_cryonirsp/tasks/ci_beam_boundaries.py +1 -0
- dkist_processing_cryonirsp/tasks/ci_science.py +1 -0
- dkist_processing_cryonirsp/tasks/cryonirsp_base.py +1 -0
- dkist_processing_cryonirsp/tasks/dark.py +5 -4
- dkist_processing_cryonirsp/tasks/gain.py +7 -6
- dkist_processing_cryonirsp/tasks/instrument_polarization.py +16 -15
- dkist_processing_cryonirsp/tasks/l1_output_data.py +1 -0
- dkist_processing_cryonirsp/tasks/linearity_correction.py +1 -0
- dkist_processing_cryonirsp/tasks/make_movie_frames.py +3 -2
- dkist_processing_cryonirsp/tasks/mixin/corrections.py +1 -0
- dkist_processing_cryonirsp/tasks/mixin/shift_measurements.py +1 -0
- dkist_processing_cryonirsp/tasks/parse.py +66 -61
- dkist_processing_cryonirsp/tasks/quality_metrics.py +15 -14
- dkist_processing_cryonirsp/tasks/science_base.py +8 -6
- dkist_processing_cryonirsp/tasks/sp_beam_boundaries.py +2 -1
- dkist_processing_cryonirsp/tasks/sp_geometric.py +11 -10
- dkist_processing_cryonirsp/tasks/sp_science.py +1 -0
- dkist_processing_cryonirsp/tasks/sp_solar_gain.py +15 -12
- dkist_processing_cryonirsp/tasks/sp_wavelength_calibration.py +9 -9
- dkist_processing_cryonirsp/tasks/write_l1.py +36 -7
- dkist_processing_cryonirsp/tests/conftest.py +6 -7
- dkist_processing_cryonirsp/tests/header_models.py +40 -3
- dkist_processing_cryonirsp/tests/local_trial_workflows/l0_cals_only.py +11 -31
- dkist_processing_cryonirsp/tests/local_trial_workflows/l0_to_l1.py +11 -30
- dkist_processing_cryonirsp/tests/local_trial_workflows/linearize_only.py +3 -3
- dkist_processing_cryonirsp/tests/local_trial_workflows/local_trial_helpers.py +3 -2
- dkist_processing_cryonirsp/tests/test_assemble_movie.py +4 -5
- dkist_processing_cryonirsp/tests/test_assemble_qualilty.py +5 -1
- dkist_processing_cryonirsp/tests/test_bad_pixel_maps.py +3 -4
- dkist_processing_cryonirsp/tests/test_ci_beam_boundaries.py +3 -4
- dkist_processing_cryonirsp/tests/test_ci_science.py +3 -4
- dkist_processing_cryonirsp/tests/test_corrections.py +3 -3
- dkist_processing_cryonirsp/tests/test_cryo_base.py +3 -5
- dkist_processing_cryonirsp/tests/test_cryo_constants.py +1 -2
- dkist_processing_cryonirsp/tests/test_dark.py +5 -6
- dkist_processing_cryonirsp/tests/test_fits_access.py +44 -0
- dkist_processing_cryonirsp/tests/test_gain.py +5 -6
- dkist_processing_cryonirsp/tests/test_instrument_polarization.py +9 -6
- dkist_processing_cryonirsp/tests/test_linearity_correction.py +4 -3
- dkist_processing_cryonirsp/tests/test_make_movie_frames.py +2 -3
- dkist_processing_cryonirsp/tests/test_parameters.py +3 -4
- dkist_processing_cryonirsp/tests/test_parse.py +14 -8
- dkist_processing_cryonirsp/tests/test_quality.py +2 -3
- dkist_processing_cryonirsp/tests/test_sp_beam_boundaries.py +4 -4
- dkist_processing_cryonirsp/tests/test_sp_geometric.py +3 -4
- dkist_processing_cryonirsp/tests/test_sp_make_movie_frames.py +2 -3
- dkist_processing_cryonirsp/tests/test_sp_science.py +3 -4
- dkist_processing_cryonirsp/tests/test_sp_solar.py +5 -4
- dkist_processing_cryonirsp/tests/test_sp_wavelength_calibration.py +4 -5
- dkist_processing_cryonirsp/tests/test_trial_create_quality_report.py +1 -1
- dkist_processing_cryonirsp/tests/test_workflows.py +1 -0
- dkist_processing_cryonirsp/tests/test_write_l1.py +12 -16
- dkist_processing_cryonirsp/workflows/__init__.py +1 -0
- dkist_processing_cryonirsp/workflows/ci_l0_processing.py +6 -5
- dkist_processing_cryonirsp/workflows/sp_l0_processing.py +6 -5
- dkist_processing_cryonirsp/workflows/trial_workflows.py +9 -8
- dkist_processing_cryonirsp-1.14.9rc1.dist-info/METADATA +552 -0
- dkist_processing_cryonirsp-1.14.9rc1.dist-info/RECORD +115 -0
- docs/conf.py +1 -0
- docs/wavelength_calibration.rst +1 -1
- changelog/167.feature.rst +0 -1
- dkist_processing_cryonirsp-1.10.0rc1.dist-info/METADATA +0 -458
- dkist_processing_cryonirsp-1.10.0rc1.dist-info/RECORD +0 -113
- {dkist_processing_cryonirsp-1.10.0rc1.dist-info → dkist_processing_cryonirsp-1.14.9rc1.dist-info}/WHEEL +0 -0
- {dkist_processing_cryonirsp-1.10.0rc1.dist-info → dkist_processing_cryonirsp-1.14.9rc1.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"""Parse CryoNIRSP data."""
|
|
2
|
+
|
|
2
3
|
from typing import TypeVar
|
|
3
4
|
|
|
5
|
+
from dkist_processing_common.models.fits_access import MetadataKey
|
|
4
6
|
from dkist_processing_common.models.flower_pot import Stem
|
|
5
7
|
from dkist_processing_common.models.tags import Tag
|
|
6
8
|
from dkist_processing_common.models.task_name import TaskName
|
|
@@ -11,17 +13,18 @@ from dkist_processing_common.parsers.retarder import RetarderNameBud
|
|
|
11
13
|
from dkist_processing_common.parsers.single_value_single_key_flower import (
|
|
12
14
|
SingleValueSingleKeyFlower,
|
|
13
15
|
)
|
|
14
|
-
from dkist_processing_common.parsers.task import parse_header_ip_task_with_gains
|
|
15
16
|
from dkist_processing_common.parsers.task import PolcalTaskFlower
|
|
16
17
|
from dkist_processing_common.parsers.task import TaskTypeFlower
|
|
18
|
+
from dkist_processing_common.parsers.task import parse_header_ip_task_with_gains
|
|
17
19
|
from dkist_processing_common.parsers.time import ObsIpStartTimeBud
|
|
18
20
|
from dkist_processing_common.parsers.unique_bud import TaskUniqueBud
|
|
19
21
|
from dkist_processing_common.parsers.unique_bud import UniqueBud
|
|
22
|
+
from dkist_processing_common.tasks import ParseDataBase
|
|
20
23
|
from dkist_processing_common.tasks import default_constant_bud_factory
|
|
21
24
|
from dkist_processing_common.tasks import default_tag_flower_factory
|
|
22
|
-
from dkist_processing_common.tasks import ParseDataBase
|
|
23
25
|
|
|
24
26
|
from dkist_processing_cryonirsp.models.constants import CryonirspBudName
|
|
27
|
+
from dkist_processing_cryonirsp.models.fits_access import CryonirspMetadataKey
|
|
25
28
|
from dkist_processing_cryonirsp.models.parameters import CryonirspParsingParameters
|
|
26
29
|
from dkist_processing_cryonirsp.models.tags import CryonirspStemName
|
|
27
30
|
from dkist_processing_cryonirsp.models.tags import CryonirspTag
|
|
@@ -53,11 +56,10 @@ from dkist_processing_cryonirsp.parsers.optical_density_filters import OpticalDe
|
|
|
53
56
|
from dkist_processing_cryonirsp.parsers.polarimetric_check import PolarimetricCheckingUniqueBud
|
|
54
57
|
from dkist_processing_cryonirsp.parsers.scan_step import NumberOfScanStepsBud
|
|
55
58
|
from dkist_processing_cryonirsp.parsers.scan_step import ScanStepNumberFlower
|
|
56
|
-
from dkist_processing_cryonirsp.parsers.time import
|
|
59
|
+
from dkist_processing_cryonirsp.parsers.time import CryonirspSolarGainTimeObsBud
|
|
57
60
|
from dkist_processing_cryonirsp.parsers.time import CryonirspTimeObsBud
|
|
58
61
|
from dkist_processing_cryonirsp.parsers.wavelength import ObserveWavelengthBud
|
|
59
62
|
|
|
60
|
-
|
|
61
63
|
__all__ = [
|
|
62
64
|
"ParseL0CryonirspRampData",
|
|
63
65
|
"ParseL0CryonirspLinearizedData",
|
|
@@ -92,13 +94,15 @@ class ParseL0CryonirspRampData(ParseDataBase):
|
|
|
92
94
|
"""Add CryoNIRSP specific constants to common constants."""
|
|
93
95
|
return [
|
|
94
96
|
UniqueBud(
|
|
95
|
-
constant_name=CryonirspBudName.camera_readout_mode
|
|
96
|
-
metadata_key=
|
|
97
|
+
constant_name=CryonirspBudName.camera_readout_mode,
|
|
98
|
+
metadata_key=CryonirspMetadataKey.camera_readout_mode,
|
|
97
99
|
),
|
|
98
100
|
# Time Obs is the unique identifier for each ramp in the data set
|
|
99
101
|
CryonirspTimeObsBud(),
|
|
100
102
|
# This is used to determine which set of linearity correction tables to use.
|
|
101
|
-
UniqueBud(
|
|
103
|
+
UniqueBud(
|
|
104
|
+
constant_name=CryonirspBudName.arm_id, metadata_key=CryonirspMetadataKey.arm_id
|
|
105
|
+
),
|
|
102
106
|
# Need wavelength to do filter compensation
|
|
103
107
|
ObserveWavelengthBud(),
|
|
104
108
|
# Need the optical density filter name for early failure detection
|
|
@@ -107,16 +111,20 @@ class ParseL0CryonirspRampData(ParseDataBase):
|
|
|
107
111
|
ObsIpStartTimeBud(),
|
|
108
112
|
# Get the ROI 1 size and origin
|
|
109
113
|
UniqueBud(
|
|
110
|
-
constant_name=CryonirspBudName.roi_1_origin_x
|
|
114
|
+
constant_name=CryonirspBudName.roi_1_origin_x,
|
|
115
|
+
metadata_key=CryonirspMetadataKey.roi_1_origin_x,
|
|
111
116
|
),
|
|
112
117
|
UniqueBud(
|
|
113
|
-
constant_name=CryonirspBudName.roi_1_origin_y
|
|
118
|
+
constant_name=CryonirspBudName.roi_1_origin_y,
|
|
119
|
+
metadata_key=CryonirspMetadataKey.roi_1_origin_y,
|
|
114
120
|
),
|
|
115
121
|
UniqueBud(
|
|
116
|
-
constant_name=CryonirspBudName.roi_1_size_x
|
|
122
|
+
constant_name=CryonirspBudName.roi_1_size_x,
|
|
123
|
+
metadata_key=CryonirspMetadataKey.roi_1_size_x,
|
|
117
124
|
),
|
|
118
125
|
UniqueBud(
|
|
119
|
-
constant_name=CryonirspBudName.roi_1_size_y
|
|
126
|
+
constant_name=CryonirspBudName.roi_1_size_y,
|
|
127
|
+
metadata_key=CryonirspMetadataKey.roi_1_size_y,
|
|
120
128
|
),
|
|
121
129
|
]
|
|
122
130
|
|
|
@@ -125,13 +133,13 @@ class ParseL0CryonirspRampData(ParseDataBase):
|
|
|
125
133
|
"""Add CryoNIRSP specific tags to common tags."""
|
|
126
134
|
return [
|
|
127
135
|
SingleValueSingleKeyFlower(
|
|
128
|
-
tag_stem_name=CryonirspStemName.curr_frame_in_ramp
|
|
129
|
-
metadata_key=
|
|
136
|
+
tag_stem_name=CryonirspStemName.curr_frame_in_ramp,
|
|
137
|
+
metadata_key=CryonirspMetadataKey.curr_frame_in_ramp,
|
|
130
138
|
),
|
|
131
139
|
# time_obs is a unique identifier for all raw frames in a single ramp
|
|
132
140
|
SingleValueSingleKeyFlower(
|
|
133
|
-
tag_stem_name=CryonirspStemName.time_obs
|
|
134
|
-
metadata_key=
|
|
141
|
+
tag_stem_name=CryonirspStemName.time_obs,
|
|
142
|
+
metadata_key=MetadataKey.time_obs,
|
|
135
143
|
),
|
|
136
144
|
]
|
|
137
145
|
|
|
@@ -186,35 +194,44 @@ class ParseL0CryonirspLinearizedData(ParseDataBase):
|
|
|
186
194
|
NumMapScansBud(),
|
|
187
195
|
NumberOfScanStepsBud(),
|
|
188
196
|
NumberOfMeasurementsBud(),
|
|
189
|
-
|
|
197
|
+
CryonirspSolarGainTimeObsBud(),
|
|
190
198
|
CheckSolarGainFramesPickyBud(),
|
|
191
199
|
NumCSStepBud(self.parameters.max_cs_step_time_sec),
|
|
192
200
|
CryonirspTaskExposureConditionsBud(
|
|
193
|
-
stem_name=CryonirspBudName.dark_frame_exposure_conditions_list
|
|
194
|
-
ip_task_type=TaskName.dark
|
|
201
|
+
stem_name=CryonirspBudName.dark_frame_exposure_conditions_list,
|
|
202
|
+
ip_task_type=TaskName.dark,
|
|
195
203
|
),
|
|
196
204
|
CryonirspTaskExposureConditionsBud(
|
|
197
|
-
stem_name=CryonirspBudName.solar_gain_exposure_conditions_list
|
|
198
|
-
ip_task_type=TaskName.solar_gain
|
|
205
|
+
stem_name=CryonirspBudName.solar_gain_exposure_conditions_list,
|
|
206
|
+
ip_task_type=TaskName.solar_gain,
|
|
199
207
|
),
|
|
200
208
|
CryonirspTaskExposureConditionsBud(
|
|
201
|
-
stem_name=CryonirspBudName.observe_exposure_conditions_list
|
|
202
|
-
ip_task_type=TaskName.observe
|
|
209
|
+
stem_name=CryonirspBudName.observe_exposure_conditions_list,
|
|
210
|
+
ip_task_type=TaskName.observe,
|
|
203
211
|
),
|
|
204
212
|
CryonirspTaskExposureConditionsBud(
|
|
205
|
-
stem_name=CryonirspBudName.polcal_exposure_conditions_list
|
|
206
|
-
ip_task_type=TaskName.polcal
|
|
213
|
+
stem_name=CryonirspBudName.polcal_exposure_conditions_list,
|
|
214
|
+
ip_task_type=TaskName.polcal,
|
|
215
|
+
),
|
|
216
|
+
UniqueBud(
|
|
217
|
+
constant_name=CryonirspBudName.axis_1_type,
|
|
218
|
+
metadata_key=CryonirspMetadataKey.axis_1_type,
|
|
219
|
+
),
|
|
220
|
+
UniqueBud(
|
|
221
|
+
constant_name=CryonirspBudName.axis_2_type,
|
|
222
|
+
metadata_key=CryonirspMetadataKey.axis_2_type,
|
|
223
|
+
),
|
|
224
|
+
UniqueBud(
|
|
225
|
+
constant_name=CryonirspBudName.axis_3_type,
|
|
226
|
+
metadata_key=CryonirspMetadataKey.axis_3_type,
|
|
207
227
|
),
|
|
208
|
-
UniqueBud(constant_name=CryonirspBudName.axis_1_type.value, metadata_key="axis_1_type"),
|
|
209
|
-
UniqueBud(constant_name=CryonirspBudName.axis_2_type.value, metadata_key="axis_2_type"),
|
|
210
|
-
UniqueBud(constant_name=CryonirspBudName.axis_3_type.value, metadata_key="axis_3_type"),
|
|
211
228
|
PolarimetricCheckingUniqueBud(
|
|
212
|
-
constant_name=CryonirspBudName.num_modstates
|
|
213
|
-
metadata_key=
|
|
229
|
+
constant_name=CryonirspBudName.num_modstates,
|
|
230
|
+
metadata_key=CryonirspMetadataKey.number_of_modulator_states,
|
|
214
231
|
),
|
|
215
232
|
PolarimetricCheckingUniqueBud(
|
|
216
|
-
constant_name=CryonirspBudName.modulator_spin_mode
|
|
217
|
-
metadata_key=
|
|
233
|
+
constant_name=CryonirspBudName.modulator_spin_mode,
|
|
234
|
+
metadata_key=CryonirspMetadataKey.modulator_spin_mode,
|
|
218
235
|
),
|
|
219
236
|
RetarderNameBud(),
|
|
220
237
|
]
|
|
@@ -231,7 +248,7 @@ class ParseL0CryonirspLinearizedData(ParseDataBase):
|
|
|
231
248
|
ScanStepNumberFlower(),
|
|
232
249
|
MeasurementNumberFlower(),
|
|
233
250
|
SingleValueSingleKeyFlower(
|
|
234
|
-
tag_stem_name=CryonirspStemName.exposure_conditions
|
|
251
|
+
tag_stem_name=CryonirspStemName.exposure_conditions,
|
|
235
252
|
metadata_key="exposure_conditions",
|
|
236
253
|
),
|
|
237
254
|
]
|
|
@@ -245,53 +262,41 @@ class ParseL0CryonirspSPLinearizedData(ParseL0CryonirspLinearizedData):
|
|
|
245
262
|
"""Add CryoNIRSP-SP specific constants to common constants."""
|
|
246
263
|
return super().constant_buds + [
|
|
247
264
|
TaskNearFloatBud(
|
|
248
|
-
constant_name=CryonirspBudName.grating_position_deg
|
|
249
|
-
metadata_key=
|
|
250
|
-
ip_task_types=[TaskName.observe
|
|
265
|
+
constant_name=CryonirspBudName.grating_position_deg,
|
|
266
|
+
metadata_key=CryonirspMetadataKey.grating_position_deg,
|
|
267
|
+
ip_task_types=[TaskName.observe, TaskName.solar_gain],
|
|
251
268
|
task_type_parsing_function=parse_header_ip_task_with_gains,
|
|
252
269
|
tolerance=0.01,
|
|
253
270
|
),
|
|
254
271
|
TaskNearFloatBud(
|
|
255
|
-
constant_name=CryonirspBudName.grating_littrow_angle_deg
|
|
256
|
-
metadata_key=
|
|
257
|
-
ip_task_types=[TaskName.observe
|
|
272
|
+
constant_name=CryonirspBudName.grating_littrow_angle_deg,
|
|
273
|
+
metadata_key=CryonirspMetadataKey.grating_littrow_angle_deg,
|
|
274
|
+
ip_task_types=[TaskName.observe, TaskName.solar_gain],
|
|
258
275
|
task_type_parsing_function=parse_header_ip_task_with_gains,
|
|
259
276
|
tolerance=0.01,
|
|
260
277
|
),
|
|
261
278
|
TaskUniqueBud(
|
|
262
|
-
constant_name=CryonirspBudName.grating_constant
|
|
263
|
-
metadata_key=
|
|
264
|
-
ip_task_types=[TaskName.observe
|
|
265
|
-
task_type_parsing_function=parse_header_ip_task_with_gains,
|
|
266
|
-
),
|
|
267
|
-
TaskUniqueBud(
|
|
268
|
-
constant_name=CryonirspBudName.wave_min.value,
|
|
269
|
-
metadata_key="wave_min",
|
|
270
|
-
ip_task_types=TaskName.solar_gain.value,
|
|
271
|
-
task_type_parsing_function=parse_header_ip_task_with_gains,
|
|
272
|
-
),
|
|
273
|
-
TaskUniqueBud(
|
|
274
|
-
constant_name=CryonirspBudName.wave_max.value,
|
|
275
|
-
metadata_key="wave_max",
|
|
276
|
-
ip_task_types=TaskName.solar_gain.value,
|
|
279
|
+
constant_name=CryonirspBudName.grating_constant,
|
|
280
|
+
metadata_key=CryonirspMetadataKey.grating_constant,
|
|
281
|
+
ip_task_types=[TaskName.observe, TaskName.solar_gain],
|
|
277
282
|
task_type_parsing_function=parse_header_ip_task_with_gains,
|
|
278
283
|
),
|
|
279
284
|
TaskUniqueBud(
|
|
280
|
-
constant_name=CryonirspBudName.center_wavelength
|
|
281
|
-
metadata_key=
|
|
282
|
-
ip_task_types=[TaskName.observe
|
|
285
|
+
constant_name=CryonirspBudName.center_wavelength,
|
|
286
|
+
metadata_key=CryonirspMetadataKey.center_wavelength,
|
|
287
|
+
ip_task_types=[TaskName.observe, TaskName.solar_gain],
|
|
283
288
|
task_type_parsing_function=parse_header_ip_task_with_gains,
|
|
284
289
|
),
|
|
285
290
|
TaskUniqueBud(
|
|
286
|
-
constant_name=CryonirspBudName.slit_width
|
|
287
|
-
metadata_key=
|
|
288
|
-
ip_task_types=[TaskName.observe
|
|
291
|
+
constant_name=CryonirspBudName.slit_width,
|
|
292
|
+
metadata_key=CryonirspMetadataKey.slit_width,
|
|
293
|
+
ip_task_types=[TaskName.observe, TaskName.solar_gain],
|
|
289
294
|
task_type_parsing_function=parse_header_ip_task_with_gains,
|
|
290
295
|
),
|
|
291
296
|
CheckLampGainFramesPickyBud(),
|
|
292
297
|
CryonirspTaskExposureConditionsBud(
|
|
293
|
-
stem_name=CryonirspBudName.lamp_gain_exposure_conditions_list
|
|
294
|
-
ip_task_type=TaskName.lamp_gain
|
|
298
|
+
stem_name=CryonirspBudName.lamp_gain_exposure_conditions_list,
|
|
299
|
+
ip_task_type=TaskName.lamp_gain,
|
|
295
300
|
),
|
|
296
301
|
CryonirspSPConditionalTaskExposureConditionsBud(),
|
|
297
302
|
CryonirspSPPickyDarkExposureConditionsBud(),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""Cryonirsp quality metrics task."""
|
|
2
|
+
|
|
2
3
|
from dataclasses import dataclass
|
|
3
4
|
from dataclasses import field
|
|
4
5
|
from typing import Generator
|
|
@@ -107,26 +108,26 @@ class CryonirspL1QualityMetrics(CryonirspTaskBase, QualityMixin):
|
|
|
107
108
|
def run(self) -> None:
|
|
108
109
|
"""Calculate sensitivity and noise quality metrics."""
|
|
109
110
|
if self.constants.correct_for_polarization:
|
|
110
|
-
with self.
|
|
111
|
-
"Calculating L1 Sensitivity metrics for all stokes states"
|
|
112
|
-
):
|
|
111
|
+
with self.telemetry_span("Calculating L1 Sensitivity metrics for all stokes states"):
|
|
113
112
|
self.compute_full_stokes_sensitivity()
|
|
114
|
-
with self.
|
|
113
|
+
with self.telemetry_span(
|
|
114
|
+
"Calculating L1 Cryonirsp noise metrics for all stokes states"
|
|
115
|
+
):
|
|
115
116
|
self.compute_full_stokes_noise()
|
|
116
117
|
else:
|
|
117
|
-
with self.
|
|
118
|
+
with self.telemetry_span("Calculating L1 Sensitivity metrics for intensity only"):
|
|
118
119
|
self.compute_intensity_only_sensitivity()
|
|
119
|
-
with self.
|
|
120
|
+
with self.telemetry_span("Calculating L1 Cryonirsp noise metrics for intensity only"):
|
|
120
121
|
self.compute_intensity_only_noise()
|
|
121
122
|
|
|
122
123
|
def compute_full_stokes_sensitivity(self):
|
|
123
124
|
"""Compute the sensitivities of each map scan for each stokes state."""
|
|
124
125
|
for stokes_state in self.constants.stokes_params:
|
|
125
|
-
with self.
|
|
126
|
+
with self.telemetry_span(f"Calculating sensitivity for stokes = {stokes_state}"):
|
|
126
127
|
quality_data = self.calculate_sensitivity_for_stokes_state(
|
|
127
128
|
stokes_state=stokes_state
|
|
128
129
|
)
|
|
129
|
-
with self.
|
|
130
|
+
with self.telemetry_span(f"Writing sensitivity data for stokes = {stokes_state}"):
|
|
130
131
|
self.quality_store_sensitivity(
|
|
131
132
|
stokes=stokes_state,
|
|
132
133
|
datetimes=quality_data.datetimes,
|
|
@@ -135,9 +136,9 @@ class CryonirspL1QualityMetrics(CryonirspTaskBase, QualityMixin):
|
|
|
135
136
|
|
|
136
137
|
def compute_intensity_only_sensitivity(self):
|
|
137
138
|
"""Compute the sensitivities of each map scan for the intensity stokes state only."""
|
|
138
|
-
with self.
|
|
139
|
+
with self.telemetry_span(f"Calculating sensitivity for intensity only"):
|
|
139
140
|
quality_data = self.calculate_sensitivity_for_stokes_state(stokes_state="I")
|
|
140
|
-
with self.
|
|
141
|
+
with self.telemetry_span("Writing sensitivity data for intensity only"):
|
|
141
142
|
self.quality_store_sensitivity(
|
|
142
143
|
stokes="I", datetimes=quality_data.datetimes, values=quality_data.values
|
|
143
144
|
)
|
|
@@ -145,9 +146,9 @@ class CryonirspL1QualityMetrics(CryonirspTaskBase, QualityMixin):
|
|
|
145
146
|
def compute_full_stokes_noise(self):
|
|
146
147
|
"""Compute noise in data broken down by each stokes state."""
|
|
147
148
|
for stokes in self.constants.stokes_params:
|
|
148
|
-
with self.
|
|
149
|
+
with self.telemetry_span(f"Compile noise values for {stokes=}"):
|
|
149
150
|
noise_data = self.compile_noise_data(stokes=stokes)
|
|
150
|
-
with self.
|
|
151
|
+
with self.telemetry_span(f"Write noise values for {stokes=}"):
|
|
151
152
|
self.quality_store_noise(
|
|
152
153
|
datetimes=noise_data.datetimes, values=noise_data.values, stokes=stokes
|
|
153
154
|
)
|
|
@@ -155,9 +156,9 @@ class CryonirspL1QualityMetrics(CryonirspTaskBase, QualityMixin):
|
|
|
155
156
|
def compute_intensity_only_noise(self):
|
|
156
157
|
"""Compute noise in data for the intensity stokes state only."""
|
|
157
158
|
stokes = "I"
|
|
158
|
-
with self.
|
|
159
|
+
with self.telemetry_span(f"Compile noise values for {stokes=}"):
|
|
159
160
|
noise_data = self.compile_noise_data(stokes=stokes)
|
|
160
|
-
with self.
|
|
161
|
+
with self.telemetry_span(f"Write noise values for {stokes=}"):
|
|
161
162
|
self.quality_store_noise(
|
|
162
163
|
datetimes=noise_data.datetimes, values=noise_data.values, stokes=stokes
|
|
163
164
|
)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""Base frameworks for Cryonirsp science calibration."""
|
|
2
|
+
|
|
2
3
|
from abc import ABC
|
|
3
4
|
from abc import abstractmethod
|
|
4
5
|
from collections.abc import Iterable
|
|
@@ -9,6 +10,7 @@ from astropy.io import fits
|
|
|
9
10
|
from astropy.time import Time
|
|
10
11
|
from astropy.time import TimeDelta
|
|
11
12
|
from dkist_processing_common.codecs.fits import fits_hdulist_encoder
|
|
13
|
+
from dkist_processing_common.models.fits_access import MetadataKey
|
|
12
14
|
from dkist_processing_common.models.task_name import TaskName
|
|
13
15
|
from dkist_processing_math.arithmetic import divide_arrays_by_array
|
|
14
16
|
from dkist_processing_math.arithmetic import subtract_array_from_arrays
|
|
@@ -69,17 +71,17 @@ class ScienceCalibrationBase(CryonirspTaskBase, ABC):
|
|
|
69
71
|
None
|
|
70
72
|
|
|
71
73
|
"""
|
|
72
|
-
with self.
|
|
74
|
+
with self.telemetry_span("Loading calibration objects"):
|
|
73
75
|
calibrations = self.collect_calibration_objects()
|
|
74
76
|
|
|
75
|
-
with self.
|
|
77
|
+
with self.telemetry_span(
|
|
76
78
|
f"Calibrating Science Frames for "
|
|
77
79
|
f"{self.constants.num_map_scans} map scans and "
|
|
78
80
|
f"{self.constants.num_scan_steps} scan steps"
|
|
79
81
|
):
|
|
80
82
|
self.calibrate_and_write_frames(calibrations=calibrations)
|
|
81
83
|
|
|
82
|
-
with self.
|
|
84
|
+
with self.telemetry_span("Computing and logging quality metrics"):
|
|
83
85
|
no_of_raw_science_frames: int = self.scratch.count_all(
|
|
84
86
|
tags=[
|
|
85
87
|
CryonirspTag.linearized_frame(),
|
|
@@ -226,7 +228,7 @@ class ScienceCalibrationBase(CryonirspTaskBase, ABC):
|
|
|
226
228
|
array_stack = np.zeros(array_shape + (self.constants.num_modstates,))
|
|
227
229
|
header_stack = []
|
|
228
230
|
|
|
229
|
-
with self.
|
|
231
|
+
with self.telemetry_span(f"Correcting {self.constants.num_modstates} modstates"):
|
|
230
232
|
for modstate in range(1, self.constants.num_modstates + 1):
|
|
231
233
|
# Correct the arrays
|
|
232
234
|
corrected_array, corrected_header = self.apply_basic_corrections(
|
|
@@ -242,7 +244,7 @@ class ScienceCalibrationBase(CryonirspTaskBase, ABC):
|
|
|
242
244
|
array_stack[:, :, modstate - 1] = corrected_array
|
|
243
245
|
header_stack.append(corrected_header)
|
|
244
246
|
|
|
245
|
-
with self.
|
|
247
|
+
with self.telemetry_span("Applying instrument polarization correction"):
|
|
246
248
|
intermediate_array = self.polarization_correction(
|
|
247
249
|
array_stack, calibrations.demod_matrices[CryonirspTag.beam(beam)]
|
|
248
250
|
)
|
|
@@ -395,7 +397,7 @@ class ScienceCalibrationBase(CryonirspTaskBase, ABC):
|
|
|
395
397
|
date_end = (Time(sorted_obj_list[-1].time_obs) + exp_time).isot
|
|
396
398
|
|
|
397
399
|
header = sorted_obj_list[0].header
|
|
398
|
-
header[
|
|
400
|
+
header[MetadataKey.time_obs] = date_beg
|
|
399
401
|
header["DATE-END"] = date_end
|
|
400
402
|
|
|
401
403
|
return header
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""Cryonirsp SP beam boundaries task."""
|
|
2
|
+
|
|
2
3
|
import math
|
|
3
4
|
|
|
4
5
|
import numpy as np
|
|
@@ -6,9 +7,9 @@ from dkist_service_configuration.logging import logger
|
|
|
6
7
|
|
|
7
8
|
from dkist_processing_cryonirsp.models.beam_boundaries import BeamBoundary
|
|
8
9
|
from dkist_processing_cryonirsp.tasks.beam_boundaries_base import BeamBoundariesCalibrationBase
|
|
9
|
-
from dkist_processing_cryonirsp.tasks.mixin.shift_measurements import ShiftMeasurementsMixin
|
|
10
10
|
from dkist_processing_cryonirsp.tasks.mixin.shift_measurements import SPATIAL
|
|
11
11
|
from dkist_processing_cryonirsp.tasks.mixin.shift_measurements import SPECTRAL
|
|
12
|
+
from dkist_processing_cryonirsp.tasks.mixin.shift_measurements import ShiftMeasurementsMixin
|
|
12
13
|
|
|
13
14
|
__all__ = ["SPBeamBoundariesCalibration"]
|
|
14
15
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""Cryo SP geometric task."""
|
|
2
|
+
|
|
2
3
|
import math
|
|
3
4
|
|
|
4
5
|
import numpy as np
|
|
@@ -19,9 +20,9 @@ from dkist_processing_cryonirsp.parsers.cryonirsp_l0_fits_access import (
|
|
|
19
20
|
CryonirspLinearizedFitsAccess,
|
|
20
21
|
)
|
|
21
22
|
from dkist_processing_cryonirsp.tasks.cryonirsp_base import CryonirspTaskBase
|
|
22
|
-
from dkist_processing_cryonirsp.tasks.mixin.shift_measurements import ShiftMeasurementsMixin
|
|
23
23
|
from dkist_processing_cryonirsp.tasks.mixin.shift_measurements import SPATIAL
|
|
24
24
|
from dkist_processing_cryonirsp.tasks.mixin.shift_measurements import SPECTRAL
|
|
25
|
+
from dkist_processing_cryonirsp.tasks.mixin.shift_measurements import ShiftMeasurementsMixin
|
|
25
26
|
|
|
26
27
|
__all__ = ["SPGeometricCalibration"]
|
|
27
28
|
|
|
@@ -70,39 +71,39 @@ class SPGeometricCalibration(CryonirspTaskBase, ShiftMeasurementsMixin):
|
|
|
70
71
|
"""
|
|
71
72
|
# The basic corrections are done outside the loop structure below as it makes these loops much
|
|
72
73
|
# simpler than they would be otherwise. See the comments in do_basic_corrections for more details.
|
|
73
|
-
with self.
|
|
74
|
+
with self.telemetry_span("Basic corrections"):
|
|
74
75
|
self.do_basic_corrections()
|
|
75
76
|
|
|
76
77
|
for beam in range(1, self.constants.num_beams + 1):
|
|
77
|
-
with self.
|
|
78
|
-
with self.
|
|
78
|
+
with self.telemetry_span(f"Generating geometric calibrations for {beam = }"):
|
|
79
|
+
with self.telemetry_span(f"Computing and writing angle for {beam = }"):
|
|
79
80
|
angle = self.compute_beam_angle(beam=beam)
|
|
80
81
|
self.write_angle(angle=angle, beam=beam)
|
|
81
82
|
|
|
82
|
-
with self.
|
|
83
|
+
with self.telemetry_span(f"Removing angle from {beam = }"):
|
|
83
84
|
angle_corr_array = self.remove_beam_angle(angle=angle, beam=beam)
|
|
84
85
|
|
|
85
|
-
with self.
|
|
86
|
+
with self.telemetry_span(f"Computing offset for {beam = }"):
|
|
86
87
|
beam_offset = self.compute_offset(
|
|
87
88
|
array=angle_corr_array,
|
|
88
89
|
beam=beam,
|
|
89
90
|
)
|
|
90
91
|
self.write_beam_offset(offset=beam_offset, beam=beam)
|
|
91
92
|
|
|
92
|
-
with self.
|
|
93
|
+
with self.telemetry_span(f"Removing offset for {beam = }"):
|
|
93
94
|
self.remove_beam_offset(
|
|
94
95
|
array=angle_corr_array,
|
|
95
96
|
offset=beam_offset,
|
|
96
97
|
beam=beam,
|
|
97
98
|
)
|
|
98
99
|
|
|
99
|
-
with self.
|
|
100
|
+
with self.telemetry_span(f"Computing spectral shifts for {beam = }"):
|
|
100
101
|
spec_shifts = self.compute_spectral_shifts(beam=beam)
|
|
101
102
|
|
|
102
|
-
with self.
|
|
103
|
+
with self.telemetry_span(f"Writing spectral shifts for {beam = }"):
|
|
103
104
|
self.write_spectral_shifts(shifts=spec_shifts, beam=beam)
|
|
104
105
|
|
|
105
|
-
with self.
|
|
106
|
+
with self.telemetry_span("Computing and logging quality metrics"):
|
|
106
107
|
no_of_raw_geo_frames: int = self.scratch.count_all(
|
|
107
108
|
tags=[
|
|
108
109
|
CryonirspTag.linearized_frame(),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""Cryo SP solar gain task."""
|
|
2
|
+
|
|
2
3
|
import numpy as np
|
|
3
4
|
import scipy.ndimage as spnd
|
|
4
5
|
from dkist_processing_common.codecs.fits import fits_array_encoder
|
|
@@ -59,29 +60,31 @@ class SPSolarGainCalibration(CryonirspTaskBase):
|
|
|
59
60
|
"""
|
|
60
61
|
target_exposure_conditions = self.constants.solar_gain_exposure_conditions_list
|
|
61
62
|
|
|
62
|
-
with self.
|
|
63
|
+
with self.telemetry_span(
|
|
64
|
+
f"Computing SP gain calibrations for {target_exposure_conditions=}"
|
|
65
|
+
):
|
|
63
66
|
for exposure_conditions in target_exposure_conditions:
|
|
64
67
|
for beam in range(1, self.constants.num_beams + 1):
|
|
65
|
-
with self.
|
|
68
|
+
with self.telemetry_span(
|
|
66
69
|
f"Perform initial corrections for {beam = } and {exposure_conditions = }"
|
|
67
70
|
):
|
|
68
71
|
spectral_corrected_solar_array = self.do_initial_corrections(
|
|
69
72
|
beam=beam, exposure_conditions=exposure_conditions
|
|
70
73
|
)
|
|
71
74
|
|
|
72
|
-
with self.
|
|
75
|
+
with self.telemetry_span(
|
|
73
76
|
f"Compute the characteristic spectrum for {beam = } and {exposure_conditions = }"
|
|
74
77
|
):
|
|
75
78
|
char_spectrum = self.compute_char_spectrum(
|
|
76
79
|
array=spectral_corrected_solar_array, beam=beam
|
|
77
80
|
)
|
|
78
81
|
|
|
79
|
-
with self.
|
|
82
|
+
with self.telemetry_span(
|
|
80
83
|
f"Re-apply the spectral and geometric distortions for {beam = } and {exposure_conditions = }"
|
|
81
84
|
):
|
|
82
85
|
distorted_char_spectrum = self.distort_char_spectrum(char_spectrum)
|
|
83
86
|
|
|
84
|
-
with self.
|
|
87
|
+
with self.telemetry_span(
|
|
85
88
|
f"Remove the solar spectrum for {beam = } and {exposure_conditions = }"
|
|
86
89
|
):
|
|
87
90
|
# This is the final gain image, as we do not normalize
|
|
@@ -92,7 +95,7 @@ class SPSolarGainCalibration(CryonirspTaskBase):
|
|
|
92
95
|
)
|
|
93
96
|
|
|
94
97
|
if self.parameters.fringe_correction_on:
|
|
95
|
-
with self.
|
|
98
|
+
with self.telemetry_span(
|
|
96
99
|
f"Computing final solar gain based on fringe-corrected flux-scaled lamp gain for {beam = } and {exposure_conditions = }"
|
|
97
100
|
):
|
|
98
101
|
# Compute a solar gain based on a fringe-corrected lamp gain
|
|
@@ -100,7 +103,7 @@ class SPSolarGainCalibration(CryonirspTaskBase):
|
|
|
100
103
|
beam, exposure_conditions
|
|
101
104
|
)
|
|
102
105
|
|
|
103
|
-
with self.
|
|
106
|
+
with self.telemetry_span(
|
|
104
107
|
f"Writing the final solar gain array for {beam = } and {exposure_conditions = }"
|
|
105
108
|
):
|
|
106
109
|
self.write_solar_gain_calibration(
|
|
@@ -108,7 +111,7 @@ class SPSolarGainCalibration(CryonirspTaskBase):
|
|
|
108
111
|
beam=beam,
|
|
109
112
|
)
|
|
110
113
|
|
|
111
|
-
with self.
|
|
114
|
+
with self.telemetry_span("Computing and logging quality metrics"):
|
|
112
115
|
no_of_raw_solar_frames: int = self.scratch.count_all(
|
|
113
116
|
tags=[
|
|
114
117
|
CryonirspTag.linearized_frame(),
|
|
@@ -448,18 +451,18 @@ class SPSolarGainCalibration(CryonirspTaskBase):
|
|
|
448
451
|
"""
|
|
449
452
|
apm_str = f"{beam = } and {exposure_conditions = }"
|
|
450
453
|
|
|
451
|
-
with self.
|
|
454
|
+
with self.telemetry_span(f"Perform initial corrections for {apm_str}"):
|
|
452
455
|
corrected_solar_array = self.do_dark_and_bad_pixel_corrections(
|
|
453
456
|
beam=beam, exposure_conditions=exposure_conditions
|
|
454
457
|
)
|
|
455
458
|
|
|
456
|
-
with self.
|
|
459
|
+
with self.telemetry_span(f"Compute the flux-scaled lamp gain for {apm_str}"):
|
|
457
460
|
scaled_lamp_array = self.compute_flux_scaled_lamp_gain(corrected_solar_array, beam)
|
|
458
461
|
|
|
459
|
-
with self.
|
|
462
|
+
with self.telemetry_span(f"Apply spectral filtering for {apm_str}"):
|
|
460
463
|
filtered_lamp_array = self.apply_spectral_and_spatial_filtering(scaled_lamp_array)
|
|
461
464
|
|
|
462
|
-
with self.
|
|
465
|
+
with self.telemetry_span(f"Isolate and remove fringes for {apm_str}"):
|
|
463
466
|
final_gain_array = self.isolate_and_remove_fringes(
|
|
464
467
|
filtered_lamp_array, scaled_lamp_array
|
|
465
468
|
)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""Cryo SP wavelength calibration task. See :doc:`this page </wavelength_calibration>` for more information."""
|
|
2
|
+
|
|
2
3
|
import math
|
|
3
4
|
|
|
4
5
|
import astropy.units as u
|
|
@@ -16,8 +17,8 @@ from solar_wavelength_calibration.fitter.parameters import DispersionBoundRange
|
|
|
16
17
|
from solar_wavelength_calibration.fitter.parameters import LengthBoundRange
|
|
17
18
|
from solar_wavelength_calibration.fitter.parameters import UnitlessBoundRange
|
|
18
19
|
from solar_wavelength_calibration.fitter.parameters import WavelengthCalibrationParameters
|
|
19
|
-
from solar_wavelength_calibration.fitter.wavelength_fitter import calculate_initial_crval_guess
|
|
20
20
|
from solar_wavelength_calibration.fitter.wavelength_fitter import WavelengthParameters
|
|
21
|
+
from solar_wavelength_calibration.fitter.wavelength_fitter import calculate_initial_crval_guess
|
|
21
22
|
from sunpy.coordinates import HeliocentricInertial
|
|
22
23
|
|
|
23
24
|
from dkist_processing_cryonirsp.codecs.fits import cryo_fits_array_decoder
|
|
@@ -61,7 +62,7 @@ class SPWavelengthCalibration(CryonirspTaskBase):
|
|
|
61
62
|
-------
|
|
62
63
|
None
|
|
63
64
|
"""
|
|
64
|
-
with self.
|
|
65
|
+
with self.telemetry_span("Load input spectrum and wavelength"):
|
|
65
66
|
logger.info("Loading input spectrum")
|
|
66
67
|
input_spectrum = next(
|
|
67
68
|
self.read(
|
|
@@ -98,7 +99,7 @@ class SPWavelengthCalibration(CryonirspTaskBase):
|
|
|
98
99
|
resolving_power = self.get_resolving_power()
|
|
99
100
|
logger.info(f"{resolving_power = }")
|
|
100
101
|
|
|
101
|
-
with self.
|
|
102
|
+
with self.telemetry_span("Compute brute-force CRVAL initial guess"):
|
|
102
103
|
atlas = Atlas(config=self.parameters.wavecal_atlas_download_config)
|
|
103
104
|
crval = calculate_initial_crval_guess(
|
|
104
105
|
input_wavelength_vector=input_wavelength_vector,
|
|
@@ -110,7 +111,7 @@ class SPWavelengthCalibration(CryonirspTaskBase):
|
|
|
110
111
|
)
|
|
111
112
|
logger.info(f"{crval = !s}")
|
|
112
113
|
|
|
113
|
-
with self.
|
|
114
|
+
with self.telemetry_span("Set up wavelength fit"):
|
|
114
115
|
logger.info("Setting bounds")
|
|
115
116
|
bounds = BoundsModel(
|
|
116
117
|
crval=LengthBoundRange(min=crval - (5 * u.nm), max=crval + (5 * u.nm)),
|
|
@@ -157,14 +158,13 @@ class SPWavelengthCalibration(CryonirspTaskBase):
|
|
|
157
158
|
|
|
158
159
|
logger.info(f"Input parameters: {input_parameters.lmfit_parameters.pretty_repr()}")
|
|
159
160
|
|
|
160
|
-
with self.
|
|
161
|
+
with self.telemetry_span("Run wavelength solution fit"):
|
|
161
162
|
fit_result = fitter(
|
|
162
|
-
input_wavelength_vector=input_wavelength_vector,
|
|
163
163
|
input_spectrum=input_spectrum,
|
|
164
164
|
spectral_weights=weights,
|
|
165
165
|
)
|
|
166
166
|
|
|
167
|
-
with self.
|
|
167
|
+
with self.telemetry_span("Save wavelength solution and quality metrics"):
|
|
168
168
|
self.write(
|
|
169
169
|
data=fit_result.wavelength_parameters.to_header(
|
|
170
170
|
axis_num=1, add_alternate_keys=True
|
|
@@ -259,9 +259,9 @@ class SPWavelengthCalibration(CryonirspTaskBase):
|
|
|
259
259
|
|
|
260
260
|
Positive values refer to when DKIST is moving away from the sun.
|
|
261
261
|
"""
|
|
262
|
-
coord = location_of_dkist.get_gcrs(obstime=Time(self.constants.
|
|
262
|
+
coord = location_of_dkist.get_gcrs(obstime=Time(self.constants.solar_gain_start_time))
|
|
263
263
|
heliocentric_coord = coord.transform_to(
|
|
264
|
-
HeliocentricInertial(obstime=Time(self.constants.
|
|
264
|
+
HeliocentricInertial(obstime=Time(self.constants.solar_gain_start_time))
|
|
265
265
|
)
|
|
266
266
|
obs_vr_kms = heliocentric_coord.d_distance
|
|
267
267
|
return obs_vr_kms
|