dkist-processing-cryonirsp 1.13.1__py3-none-any.whl → 1.14.1rc1__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.
Potentially problematic release.
This version of dkist-processing-cryonirsp might be problematic. Click here for more details.
- changelog/223.misc.rst +1 -0
- dkist_processing_cryonirsp/tasks/bad_pixel_map.py +5 -5
- dkist_processing_cryonirsp/tasks/beam_boundaries_base.py +8 -10
- dkist_processing_cryonirsp/tasks/dark.py +4 -4
- dkist_processing_cryonirsp/tasks/gain.py +6 -6
- dkist_processing_cryonirsp/tasks/instrument_polarization.py +15 -15
- dkist_processing_cryonirsp/tasks/make_movie_frames.py +2 -2
- dkist_processing_cryonirsp/tasks/quality_metrics.py +14 -14
- dkist_processing_cryonirsp/tasks/science_base.py +5 -5
- dkist_processing_cryonirsp/tasks/sp_geometric.py +9 -9
- dkist_processing_cryonirsp/tasks/sp_solar_gain.py +14 -12
- dkist_processing_cryonirsp/tasks/sp_wavelength_calibration.py +5 -5
- dkist_processing_cryonirsp/tests/header_models.py +36 -3
- dkist_processing_cryonirsp/tests/local_trial_workflows/l0_cals_only.py +0 -21
- dkist_processing_cryonirsp/tests/local_trial_workflows/l0_to_l1.py +0 -20
- dkist_processing_cryonirsp/tests/test_parse.py +7 -0
- {dkist_processing_cryonirsp-1.13.1.dist-info → dkist_processing_cryonirsp-1.14.1rc1.dist-info}/METADATA +143 -50
- {dkist_processing_cryonirsp-1.13.1.dist-info → dkist_processing_cryonirsp-1.14.1rc1.dist-info}/RECORD +20 -19
- {dkist_processing_cryonirsp-1.13.1.dist-info → dkist_processing_cryonirsp-1.14.1rc1.dist-info}/WHEEL +0 -0
- {dkist_processing_cryonirsp-1.13.1.dist-info → dkist_processing_cryonirsp-1.14.1rc1.dist-info}/top_level.txt +0 -0
changelog/223.misc.rst
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Update `dkist-processing-common` to v11.7.0, which makes constants for the dataset extras.
|
|
@@ -49,11 +49,11 @@ class BadPixelMapCalibration(CryonirspTaskBase):
|
|
|
49
49
|
None
|
|
50
50
|
|
|
51
51
|
"""
|
|
52
|
-
with self.
|
|
52
|
+
with self.telemetry_span(f"Compute average uncorrected solar gain image"):
|
|
53
53
|
average_solar_gain_array = self.compute_average_gain_array()
|
|
54
54
|
|
|
55
|
-
with self.
|
|
56
|
-
with self.
|
|
55
|
+
with self.telemetry_span(f"Compute the bad pixel map"):
|
|
56
|
+
with self.telemetry_span("Smooth array with median filter"):
|
|
57
57
|
filter_size = self.parameters.bad_pixel_map_median_filter_size
|
|
58
58
|
filtered_array = spnd.median_filter(
|
|
59
59
|
average_solar_gain_array,
|
|
@@ -62,7 +62,7 @@ class BadPixelMapCalibration(CryonirspTaskBase):
|
|
|
62
62
|
cval=np.nanmedian(average_solar_gain_array),
|
|
63
63
|
)
|
|
64
64
|
|
|
65
|
-
with self.
|
|
65
|
+
with self.telemetry_span("Identify bad pixels"):
|
|
66
66
|
thresh = self.parameters.bad_pixel_map_threshold_factor
|
|
67
67
|
|
|
68
68
|
diff = filtered_array - average_solar_gain_array
|
|
@@ -72,7 +72,7 @@ class BadPixelMapCalibration(CryonirspTaskBase):
|
|
|
72
72
|
zeros = np.where(average_solar_gain_array == 0.0)
|
|
73
73
|
bad_pixel_map[zeros] = 1
|
|
74
74
|
|
|
75
|
-
with self.
|
|
75
|
+
with self.telemetry_span("Writing bad pixel map"):
|
|
76
76
|
self.write(
|
|
77
77
|
data=bad_pixel_map,
|
|
78
78
|
tags=[CryonirspTag.intermediate_frame(), CryonirspTag.task_bad_pixel_map()],
|
|
@@ -62,11 +62,11 @@ class BeamBoundariesCalibrationBase(CryonirspTaskBase):
|
|
|
62
62
|
|
|
63
63
|
"""
|
|
64
64
|
# Step 1:
|
|
65
|
-
with self.
|
|
65
|
+
with self.telemetry_span(f"Compute average solar gain image"):
|
|
66
66
|
average_solar_gain_array = self.compute_average_gain_array()
|
|
67
67
|
|
|
68
68
|
# Step 2:
|
|
69
|
-
with self.
|
|
69
|
+
with self.telemetry_span(f"Retrieve bad pixel map"):
|
|
70
70
|
bad_pixel_map = next(
|
|
71
71
|
self.read(
|
|
72
72
|
tags=[CryonirspTag.intermediate_frame(), CryonirspTag.task_bad_pixel_map()],
|
|
@@ -78,21 +78,19 @@ class BeamBoundariesCalibrationBase(CryonirspTaskBase):
|
|
|
78
78
|
)
|
|
79
79
|
|
|
80
80
|
# Step 3
|
|
81
|
-
with self.
|
|
81
|
+
with self.telemetry_span(f"Smooth the array to get good segmentation"):
|
|
82
82
|
smoothed_solar_gain_array = self.smooth_gain_array(corrected_solar_gain_array)
|
|
83
83
|
|
|
84
84
|
# Step 4
|
|
85
|
-
with self.
|
|
85
|
+
with self.telemetry_span(f"Split the beam horizontally"):
|
|
86
86
|
split_beams = self.split_beams(smoothed_solar_gain_array)
|
|
87
87
|
|
|
88
88
|
# Step 5
|
|
89
|
-
with self.
|
|
90
|
-
f"Segment the beams into illuminated and non-illuminated pixels"
|
|
91
|
-
):
|
|
89
|
+
with self.telemetry_span(f"Segment the beams into illuminated and non-illuminated pixels"):
|
|
92
90
|
segmented_beams = self.segment_arrays(split_beams)
|
|
93
91
|
|
|
94
92
|
# Step 6:
|
|
95
|
-
with self.
|
|
93
|
+
with self.telemetry_span(
|
|
96
94
|
f"Compute the inscribed rectangular extents of the illuminated portions of the sensor"
|
|
97
95
|
):
|
|
98
96
|
illuminated_boundaries = self.compute_boundaries_of_beam_illumination_regions(
|
|
@@ -100,14 +98,14 @@ class BeamBoundariesCalibrationBase(CryonirspTaskBase):
|
|
|
100
98
|
)
|
|
101
99
|
|
|
102
100
|
# Steps 7 - 9:
|
|
103
|
-
with self.
|
|
101
|
+
with self.telemetry_span(f"Compute the boundaries of the illuminated beams"):
|
|
104
102
|
split_beams_float = [split_beam.astype(float) for split_beam in split_beams]
|
|
105
103
|
boundaries = self.compute_final_beam_boundaries(
|
|
106
104
|
split_beams_float, illuminated_boundaries
|
|
107
105
|
)
|
|
108
106
|
|
|
109
107
|
# Step 10:
|
|
110
|
-
with self.
|
|
108
|
+
with self.telemetry_span("Writing beam boundaries"):
|
|
111
109
|
for beam, bounds in enumerate(boundaries, start=1):
|
|
112
110
|
self.write(
|
|
113
111
|
data=bounds.beam_boundaries_array,
|
|
@@ -58,7 +58,7 @@ class DarkCalibration(CryonirspTaskBase):
|
|
|
58
58
|
)
|
|
59
59
|
|
|
60
60
|
logger.info(f"{target_exposure_conditions = }")
|
|
61
|
-
with self.
|
|
61
|
+
with self.telemetry_span(
|
|
62
62
|
f"Calculating dark frames for {self.constants.num_beams} beams and {len(target_exposure_conditions)} exp times"
|
|
63
63
|
):
|
|
64
64
|
total_dark_frames_used = 0
|
|
@@ -90,12 +90,12 @@ class DarkCalibration(CryonirspTaskBase):
|
|
|
90
90
|
beam_boundary=beam_boundary,
|
|
91
91
|
)
|
|
92
92
|
|
|
93
|
-
with self.
|
|
93
|
+
with self.telemetry_span(
|
|
94
94
|
f"Calculating dark for {exposure_conditions = } and {beam = }"
|
|
95
95
|
):
|
|
96
96
|
averaged_dark_array = average_numpy_arrays(linearized_dark_arrays)
|
|
97
97
|
|
|
98
|
-
with self.
|
|
98
|
+
with self.telemetry_span(
|
|
99
99
|
f"Writing dark for {exposure_conditions = } {beam = }"
|
|
100
100
|
):
|
|
101
101
|
self.write(
|
|
@@ -109,7 +109,7 @@ class DarkCalibration(CryonirspTaskBase):
|
|
|
109
109
|
encoder=fits_array_encoder,
|
|
110
110
|
)
|
|
111
111
|
|
|
112
|
-
with self.
|
|
112
|
+
with self.telemetry_span("Computing and logging quality metrics"):
|
|
113
113
|
no_of_raw_dark_frames: int = self.scratch.count_all(
|
|
114
114
|
tags=[
|
|
115
115
|
CryonirspTag.linearized_frame(),
|
|
@@ -81,7 +81,7 @@ class GainCalibrationBase(CryonirspTaskBase):
|
|
|
81
81
|
target_exposure_conditions = self.exposure_conditions
|
|
82
82
|
|
|
83
83
|
logger.info(f"{target_exposure_conditions = }")
|
|
84
|
-
with self.
|
|
84
|
+
with self.telemetry_span(
|
|
85
85
|
f"Generate {self.gain_type} for {len(target_exposure_conditions)} exposure times"
|
|
86
86
|
):
|
|
87
87
|
for beam in range(1, self.constants.num_beams + 1):
|
|
@@ -96,7 +96,7 @@ class GainCalibrationBase(CryonirspTaskBase):
|
|
|
96
96
|
|
|
97
97
|
for exposure_conditions in target_exposure_conditions:
|
|
98
98
|
apm_str = f"{beam = } and {exposure_conditions = }"
|
|
99
|
-
with self.
|
|
99
|
+
with self.telemetry_span(f"Remove dark signal for {apm_str}"):
|
|
100
100
|
dark_array = next(
|
|
101
101
|
self.read(
|
|
102
102
|
tags=[
|
|
@@ -117,7 +117,7 @@ class GainCalibrationBase(CryonirspTaskBase):
|
|
|
117
117
|
subtract_array_from_arrays(avg_gain_array, dark_array)
|
|
118
118
|
)
|
|
119
119
|
|
|
120
|
-
with self.
|
|
120
|
+
with self.telemetry_span(f"Correct bad pixels for {apm_str}"):
|
|
121
121
|
bad_pixel_map = next(
|
|
122
122
|
self.read(
|
|
123
123
|
tags=[
|
|
@@ -133,12 +133,12 @@ class GainCalibrationBase(CryonirspTaskBase):
|
|
|
133
133
|
)
|
|
134
134
|
|
|
135
135
|
if self.normalize_gain_switch:
|
|
136
|
-
with self.
|
|
136
|
+
with self.telemetry_span(f"Normalize final gain for {apm_str}"):
|
|
137
137
|
normalized_gain_array = self.normalize_gain(bad_pixel_corrected_array)
|
|
138
138
|
else:
|
|
139
139
|
normalized_gain_array = bad_pixel_corrected_array
|
|
140
140
|
|
|
141
|
-
with self.
|
|
141
|
+
with self.telemetry_span(
|
|
142
142
|
f"Writing gain array for {beam = } and {exposure_conditions = }"
|
|
143
143
|
):
|
|
144
144
|
self.write(
|
|
@@ -152,7 +152,7 @@ class GainCalibrationBase(CryonirspTaskBase):
|
|
|
152
152
|
encoder=fits_array_encoder,
|
|
153
153
|
)
|
|
154
154
|
|
|
155
|
-
with self.
|
|
155
|
+
with self.telemetry_span("Computing and logging quality metrics"):
|
|
156
156
|
no_of_raw_gain_frames: int = self.scratch.count_all(
|
|
157
157
|
tags=[
|
|
158
158
|
CryonirspTag.linearized_frame(),
|
|
@@ -88,10 +88,10 @@ class InstrumentPolarizationCalibrationBase(CryonirspTaskBase, ABC):
|
|
|
88
88
|
f"Demodulation matrices will span FOV with shape {(self.parameters.polcal_num_spatial_bins, self.parameters.polcal_num_spatial_bins)}"
|
|
89
89
|
)
|
|
90
90
|
for beam in range(1, self.constants.num_beams + 1):
|
|
91
|
-
with self.
|
|
91
|
+
with self.telemetry_span(f"Reducing CS steps for {beam = }"):
|
|
92
92
|
local_reduced_arrays, global_reduced_arrays = self.reduce_cs_steps(beam)
|
|
93
93
|
|
|
94
|
-
with self.
|
|
94
|
+
with self.telemetry_span(f"Fit CU parameters for {beam = }"):
|
|
95
95
|
local_dresser = Dresser()
|
|
96
96
|
local_dresser.add_drawer(Drawer(local_reduced_arrays))
|
|
97
97
|
global_dresser = Dresser()
|
|
@@ -104,7 +104,7 @@ class InstrumentPolarizationCalibrationBase(CryonirspTaskBase, ABC):
|
|
|
104
104
|
fit_TM=False,
|
|
105
105
|
)
|
|
106
106
|
|
|
107
|
-
with self.
|
|
107
|
+
with self.telemetry_span(f"Resampling demodulation matrices for {beam = }"):
|
|
108
108
|
demod_matrices = pac_fitter.demodulation_matrices
|
|
109
109
|
# Reshaping the demodulation matrix to get rid of unit length dimensions
|
|
110
110
|
logger.info(f"Resampling demodulation matrices for {beam = }")
|
|
@@ -113,7 +113,7 @@ class InstrumentPolarizationCalibrationBase(CryonirspTaskBase, ABC):
|
|
|
113
113
|
f"Shape of resampled demodulation matrices for {beam = }: {demod_matrices.shape}"
|
|
114
114
|
)
|
|
115
115
|
|
|
116
|
-
with self.
|
|
116
|
+
with self.telemetry_span(f"Writing demodulation matrices for {beam = }"):
|
|
117
117
|
self.write(
|
|
118
118
|
data=demod_matrices,
|
|
119
119
|
tags=[
|
|
@@ -123,10 +123,10 @@ class InstrumentPolarizationCalibrationBase(CryonirspTaskBase, ABC):
|
|
|
123
123
|
encoder=fits_array_encoder,
|
|
124
124
|
)
|
|
125
125
|
|
|
126
|
-
with self.
|
|
126
|
+
with self.telemetry_span("Computing and recording polcal quality metrics"):
|
|
127
127
|
self.record_polcal_quality_metrics(beam, polcal_fitter=pac_fitter)
|
|
128
128
|
|
|
129
|
-
with self.
|
|
129
|
+
with self.telemetry_span("Computing and logging quality metrics"):
|
|
130
130
|
no_of_raw_polcal_frames: int = self.scratch.count_all(
|
|
131
131
|
tags=[
|
|
132
132
|
CryonirspTag.linearized_frame(),
|
|
@@ -271,11 +271,11 @@ class InstrumentPolarizationCalibrationBase(CryonirspTaskBase, ABC):
|
|
|
271
271
|
avg_inst_pol_cal_header = next(pol_cal_headers)
|
|
272
272
|
avg_inst_pol_cal_array = average_numpy_arrays(pol_cal_arrays)
|
|
273
273
|
|
|
274
|
-
with self.
|
|
274
|
+
with self.telemetry_span(f"Apply basic corrections for {apm_str}"):
|
|
275
275
|
dark_corrected_array = subtract_array_from_arrays(avg_inst_pol_cal_array, dark_array)
|
|
276
276
|
gain_corrected_array = next(divide_arrays_by_array(dark_corrected_array, gain_array))
|
|
277
277
|
|
|
278
|
-
with self.
|
|
278
|
+
with self.telemetry_span(f"Extract macro pixels from {apm_str}"):
|
|
279
279
|
self.set_original_beam_size(gain_corrected_array)
|
|
280
280
|
output_shape = (
|
|
281
281
|
self.parameters.polcal_num_spatial_bins,
|
|
@@ -284,7 +284,7 @@ class InstrumentPolarizationCalibrationBase(CryonirspTaskBase, ABC):
|
|
|
284
284
|
local_binned_array = next(resize_arrays(gain_corrected_array, output_shape))
|
|
285
285
|
global_binned_array = next(resize_arrays(gain_corrected_array, (1, 1)))
|
|
286
286
|
|
|
287
|
-
with self.
|
|
287
|
+
with self.telemetry_span(f"Create reduced CryonirspL0FitsAccess for {apm_str}"):
|
|
288
288
|
local_result = CryonirspL0FitsAccess(
|
|
289
289
|
fits.ImageHDU(local_binned_array[:, :], avg_inst_pol_cal_header),
|
|
290
290
|
auto_squeeze=False,
|
|
@@ -349,7 +349,7 @@ class InstrumentPolarizationCalibrationBase(CryonirspTaskBase, ABC):
|
|
|
349
349
|
self, target_exposure_conditions_list: [ExposureConditions]
|
|
350
350
|
):
|
|
351
351
|
"""Compute the polcal dark calibration."""
|
|
352
|
-
with self.
|
|
352
|
+
with self.telemetry_span(
|
|
353
353
|
f"Calculating dark frames for {len(target_exposure_conditions_list)} exp times"
|
|
354
354
|
):
|
|
355
355
|
for beam in range(1, self.constants.num_beams + 1):
|
|
@@ -361,7 +361,7 @@ class InstrumentPolarizationCalibrationBase(CryonirspTaskBase, ABC):
|
|
|
361
361
|
)
|
|
362
362
|
beam_boundary = BeamBoundary(*beam_array)
|
|
363
363
|
for exposure_conditions in target_exposure_conditions_list:
|
|
364
|
-
with self.
|
|
364
|
+
with self.telemetry_span(
|
|
365
365
|
f"Calculating polcal dark array(s) for {exposure_conditions = } and {beam = }"
|
|
366
366
|
):
|
|
367
367
|
linearized_dark_arrays = self.read(
|
|
@@ -376,7 +376,7 @@ class InstrumentPolarizationCalibrationBase(CryonirspTaskBase, ABC):
|
|
|
376
376
|
beam_boundary=beam_boundary,
|
|
377
377
|
)
|
|
378
378
|
averaged_dark_array = average_numpy_arrays(linearized_dark_arrays)
|
|
379
|
-
with self.
|
|
379
|
+
with self.telemetry_span(
|
|
380
380
|
f"Writing dark for {exposure_conditions = } and {beam = }"
|
|
381
381
|
):
|
|
382
382
|
self.write(
|
|
@@ -392,7 +392,7 @@ class InstrumentPolarizationCalibrationBase(CryonirspTaskBase, ABC):
|
|
|
392
392
|
|
|
393
393
|
def generate_polcal_gain_calibration(self, exposure_conditions_list: [ExposureConditions]):
|
|
394
394
|
"""Compute the polcal gain calibration."""
|
|
395
|
-
with self.
|
|
395
|
+
with self.telemetry_span(
|
|
396
396
|
f"Generate gains for {len(exposure_conditions_list)} exposure conditions"
|
|
397
397
|
):
|
|
398
398
|
for beam in range(1, self.constants.num_beams + 1):
|
|
@@ -423,7 +423,7 @@ class InstrumentPolarizationCalibrationBase(CryonirspTaskBase, ABC):
|
|
|
423
423
|
raise ValueError(
|
|
424
424
|
f"No matching polcal dark found for {exposure_conditions = } s and {beam = }"
|
|
425
425
|
) from e
|
|
426
|
-
with self.
|
|
426
|
+
with self.telemetry_span(
|
|
427
427
|
f"Calculating polcal gain array(s) for {exposure_conditions = } and {beam = }"
|
|
428
428
|
):
|
|
429
429
|
linearized_gain_arrays = self.read(
|
|
@@ -460,7 +460,7 @@ class InstrumentPolarizationCalibrationBase(CryonirspTaskBase, ABC):
|
|
|
460
460
|
bad_pixel_corrected_array
|
|
461
461
|
)
|
|
462
462
|
|
|
463
|
-
with self.
|
|
463
|
+
with self.telemetry_span(
|
|
464
464
|
f"Writing gain array for exposure time {exposure_conditions} and {beam = }"
|
|
465
465
|
):
|
|
466
466
|
self.write(
|
|
@@ -23,10 +23,10 @@ class MakeCryonirspMovieFramesBase(CryonirspTaskBase, ABC):
|
|
|
23
23
|
def run(self):
|
|
24
24
|
"""Create movie frames using all stokes states if they exist, otherwise only use intensity."""
|
|
25
25
|
if self.constants.correct_for_polarization:
|
|
26
|
-
with self.
|
|
26
|
+
with self.telemetry_span("Make full stokes movie"):
|
|
27
27
|
self.make_full_stokes_movie_frames()
|
|
28
28
|
else:
|
|
29
|
-
with self.
|
|
29
|
+
with self.telemetry_span("Make intensity only movie"):
|
|
30
30
|
self.make_intensity_movie_frames()
|
|
31
31
|
|
|
32
32
|
@abstractmethod
|
|
@@ -108,26 +108,26 @@ class CryonirspL1QualityMetrics(CryonirspTaskBase, QualityMixin):
|
|
|
108
108
|
def run(self) -> None:
|
|
109
109
|
"""Calculate sensitivity and noise quality metrics."""
|
|
110
110
|
if self.constants.correct_for_polarization:
|
|
111
|
-
with self.
|
|
112
|
-
"Calculating L1 Sensitivity metrics for all stokes states"
|
|
113
|
-
):
|
|
111
|
+
with self.telemetry_span("Calculating L1 Sensitivity metrics for all stokes states"):
|
|
114
112
|
self.compute_full_stokes_sensitivity()
|
|
115
|
-
with self.
|
|
113
|
+
with self.telemetry_span(
|
|
114
|
+
"Calculating L1 Cryonirsp noise metrics for all stokes states"
|
|
115
|
+
):
|
|
116
116
|
self.compute_full_stokes_noise()
|
|
117
117
|
else:
|
|
118
|
-
with self.
|
|
118
|
+
with self.telemetry_span("Calculating L1 Sensitivity metrics for intensity only"):
|
|
119
119
|
self.compute_intensity_only_sensitivity()
|
|
120
|
-
with self.
|
|
120
|
+
with self.telemetry_span("Calculating L1 Cryonirsp noise metrics for intensity only"):
|
|
121
121
|
self.compute_intensity_only_noise()
|
|
122
122
|
|
|
123
123
|
def compute_full_stokes_sensitivity(self):
|
|
124
124
|
"""Compute the sensitivities of each map scan for each stokes state."""
|
|
125
125
|
for stokes_state in self.constants.stokes_params:
|
|
126
|
-
with self.
|
|
126
|
+
with self.telemetry_span(f"Calculating sensitivity for stokes = {stokes_state}"):
|
|
127
127
|
quality_data = self.calculate_sensitivity_for_stokes_state(
|
|
128
128
|
stokes_state=stokes_state
|
|
129
129
|
)
|
|
130
|
-
with self.
|
|
130
|
+
with self.telemetry_span(f"Writing sensitivity data for stokes = {stokes_state}"):
|
|
131
131
|
self.quality_store_sensitivity(
|
|
132
132
|
stokes=stokes_state,
|
|
133
133
|
datetimes=quality_data.datetimes,
|
|
@@ -136,9 +136,9 @@ class CryonirspL1QualityMetrics(CryonirspTaskBase, QualityMixin):
|
|
|
136
136
|
|
|
137
137
|
def compute_intensity_only_sensitivity(self):
|
|
138
138
|
"""Compute the sensitivities of each map scan for the intensity stokes state only."""
|
|
139
|
-
with self.
|
|
139
|
+
with self.telemetry_span(f"Calculating sensitivity for intensity only"):
|
|
140
140
|
quality_data = self.calculate_sensitivity_for_stokes_state(stokes_state="I")
|
|
141
|
-
with self.
|
|
141
|
+
with self.telemetry_span("Writing sensitivity data for intensity only"):
|
|
142
142
|
self.quality_store_sensitivity(
|
|
143
143
|
stokes="I", datetimes=quality_data.datetimes, values=quality_data.values
|
|
144
144
|
)
|
|
@@ -146,9 +146,9 @@ class CryonirspL1QualityMetrics(CryonirspTaskBase, QualityMixin):
|
|
|
146
146
|
def compute_full_stokes_noise(self):
|
|
147
147
|
"""Compute noise in data broken down by each stokes state."""
|
|
148
148
|
for stokes in self.constants.stokes_params:
|
|
149
|
-
with self.
|
|
149
|
+
with self.telemetry_span(f"Compile noise values for {stokes=}"):
|
|
150
150
|
noise_data = self.compile_noise_data(stokes=stokes)
|
|
151
|
-
with self.
|
|
151
|
+
with self.telemetry_span(f"Write noise values for {stokes=}"):
|
|
152
152
|
self.quality_store_noise(
|
|
153
153
|
datetimes=noise_data.datetimes, values=noise_data.values, stokes=stokes
|
|
154
154
|
)
|
|
@@ -156,9 +156,9 @@ class CryonirspL1QualityMetrics(CryonirspTaskBase, QualityMixin):
|
|
|
156
156
|
def compute_intensity_only_noise(self):
|
|
157
157
|
"""Compute noise in data for the intensity stokes state only."""
|
|
158
158
|
stokes = "I"
|
|
159
|
-
with self.
|
|
159
|
+
with self.telemetry_span(f"Compile noise values for {stokes=}"):
|
|
160
160
|
noise_data = self.compile_noise_data(stokes=stokes)
|
|
161
|
-
with self.
|
|
161
|
+
with self.telemetry_span(f"Write noise values for {stokes=}"):
|
|
162
162
|
self.quality_store_noise(
|
|
163
163
|
datetimes=noise_data.datetimes, values=noise_data.values, stokes=stokes
|
|
164
164
|
)
|
|
@@ -70,17 +70,17 @@ class ScienceCalibrationBase(CryonirspTaskBase, ABC):
|
|
|
70
70
|
None
|
|
71
71
|
|
|
72
72
|
"""
|
|
73
|
-
with self.
|
|
73
|
+
with self.telemetry_span("Loading calibration objects"):
|
|
74
74
|
calibrations = self.collect_calibration_objects()
|
|
75
75
|
|
|
76
|
-
with self.
|
|
76
|
+
with self.telemetry_span(
|
|
77
77
|
f"Calibrating Science Frames for "
|
|
78
78
|
f"{self.constants.num_map_scans} map scans and "
|
|
79
79
|
f"{self.constants.num_scan_steps} scan steps"
|
|
80
80
|
):
|
|
81
81
|
self.calibrate_and_write_frames(calibrations=calibrations)
|
|
82
82
|
|
|
83
|
-
with self.
|
|
83
|
+
with self.telemetry_span("Computing and logging quality metrics"):
|
|
84
84
|
no_of_raw_science_frames: int = self.scratch.count_all(
|
|
85
85
|
tags=[
|
|
86
86
|
CryonirspTag.linearized_frame(),
|
|
@@ -227,7 +227,7 @@ class ScienceCalibrationBase(CryonirspTaskBase, ABC):
|
|
|
227
227
|
array_stack = np.zeros(array_shape + (self.constants.num_modstates,))
|
|
228
228
|
header_stack = []
|
|
229
229
|
|
|
230
|
-
with self.
|
|
230
|
+
with self.telemetry_span(f"Correcting {self.constants.num_modstates} modstates"):
|
|
231
231
|
for modstate in range(1, self.constants.num_modstates + 1):
|
|
232
232
|
# Correct the arrays
|
|
233
233
|
corrected_array, corrected_header = self.apply_basic_corrections(
|
|
@@ -243,7 +243,7 @@ class ScienceCalibrationBase(CryonirspTaskBase, ABC):
|
|
|
243
243
|
array_stack[:, :, modstate - 1] = corrected_array
|
|
244
244
|
header_stack.append(corrected_header)
|
|
245
245
|
|
|
246
|
-
with self.
|
|
246
|
+
with self.telemetry_span("Applying instrument polarization correction"):
|
|
247
247
|
intermediate_array = self.polarization_correction(
|
|
248
248
|
array_stack, calibrations.demod_matrices[CryonirspTag.beam(beam)]
|
|
249
249
|
)
|
|
@@ -71,39 +71,39 @@ class SPGeometricCalibration(CryonirspTaskBase, ShiftMeasurementsMixin):
|
|
|
71
71
|
"""
|
|
72
72
|
# The basic corrections are done outside the loop structure below as it makes these loops much
|
|
73
73
|
# simpler than they would be otherwise. See the comments in do_basic_corrections for more details.
|
|
74
|
-
with self.
|
|
74
|
+
with self.telemetry_span("Basic corrections"):
|
|
75
75
|
self.do_basic_corrections()
|
|
76
76
|
|
|
77
77
|
for beam in range(1, self.constants.num_beams + 1):
|
|
78
|
-
with self.
|
|
79
|
-
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 = }"):
|
|
80
80
|
angle = self.compute_beam_angle(beam=beam)
|
|
81
81
|
self.write_angle(angle=angle, beam=beam)
|
|
82
82
|
|
|
83
|
-
with self.
|
|
83
|
+
with self.telemetry_span(f"Removing angle from {beam = }"):
|
|
84
84
|
angle_corr_array = self.remove_beam_angle(angle=angle, beam=beam)
|
|
85
85
|
|
|
86
|
-
with self.
|
|
86
|
+
with self.telemetry_span(f"Computing offset for {beam = }"):
|
|
87
87
|
beam_offset = self.compute_offset(
|
|
88
88
|
array=angle_corr_array,
|
|
89
89
|
beam=beam,
|
|
90
90
|
)
|
|
91
91
|
self.write_beam_offset(offset=beam_offset, beam=beam)
|
|
92
92
|
|
|
93
|
-
with self.
|
|
93
|
+
with self.telemetry_span(f"Removing offset for {beam = }"):
|
|
94
94
|
self.remove_beam_offset(
|
|
95
95
|
array=angle_corr_array,
|
|
96
96
|
offset=beam_offset,
|
|
97
97
|
beam=beam,
|
|
98
98
|
)
|
|
99
99
|
|
|
100
|
-
with self.
|
|
100
|
+
with self.telemetry_span(f"Computing spectral shifts for {beam = }"):
|
|
101
101
|
spec_shifts = self.compute_spectral_shifts(beam=beam)
|
|
102
102
|
|
|
103
|
-
with self.
|
|
103
|
+
with self.telemetry_span(f"Writing spectral shifts for {beam = }"):
|
|
104
104
|
self.write_spectral_shifts(shifts=spec_shifts, beam=beam)
|
|
105
105
|
|
|
106
|
-
with self.
|
|
106
|
+
with self.telemetry_span("Computing and logging quality metrics"):
|
|
107
107
|
no_of_raw_geo_frames: int = self.scratch.count_all(
|
|
108
108
|
tags=[
|
|
109
109
|
CryonirspTag.linearized_frame(),
|
|
@@ -60,29 +60,31 @@ class SPSolarGainCalibration(CryonirspTaskBase):
|
|
|
60
60
|
"""
|
|
61
61
|
target_exposure_conditions = self.constants.solar_gain_exposure_conditions_list
|
|
62
62
|
|
|
63
|
-
with self.
|
|
63
|
+
with self.telemetry_span(
|
|
64
|
+
f"Computing SP gain calibrations for {target_exposure_conditions=}"
|
|
65
|
+
):
|
|
64
66
|
for exposure_conditions in target_exposure_conditions:
|
|
65
67
|
for beam in range(1, self.constants.num_beams + 1):
|
|
66
|
-
with self.
|
|
68
|
+
with self.telemetry_span(
|
|
67
69
|
f"Perform initial corrections for {beam = } and {exposure_conditions = }"
|
|
68
70
|
):
|
|
69
71
|
spectral_corrected_solar_array = self.do_initial_corrections(
|
|
70
72
|
beam=beam, exposure_conditions=exposure_conditions
|
|
71
73
|
)
|
|
72
74
|
|
|
73
|
-
with self.
|
|
75
|
+
with self.telemetry_span(
|
|
74
76
|
f"Compute the characteristic spectrum for {beam = } and {exposure_conditions = }"
|
|
75
77
|
):
|
|
76
78
|
char_spectrum = self.compute_char_spectrum(
|
|
77
79
|
array=spectral_corrected_solar_array, beam=beam
|
|
78
80
|
)
|
|
79
81
|
|
|
80
|
-
with self.
|
|
82
|
+
with self.telemetry_span(
|
|
81
83
|
f"Re-apply the spectral and geometric distortions for {beam = } and {exposure_conditions = }"
|
|
82
84
|
):
|
|
83
85
|
distorted_char_spectrum = self.distort_char_spectrum(char_spectrum)
|
|
84
86
|
|
|
85
|
-
with self.
|
|
87
|
+
with self.telemetry_span(
|
|
86
88
|
f"Remove the solar spectrum for {beam = } and {exposure_conditions = }"
|
|
87
89
|
):
|
|
88
90
|
# This is the final gain image, as we do not normalize
|
|
@@ -93,7 +95,7 @@ class SPSolarGainCalibration(CryonirspTaskBase):
|
|
|
93
95
|
)
|
|
94
96
|
|
|
95
97
|
if self.parameters.fringe_correction_on:
|
|
96
|
-
with self.
|
|
98
|
+
with self.telemetry_span(
|
|
97
99
|
f"Computing final solar gain based on fringe-corrected flux-scaled lamp gain for {beam = } and {exposure_conditions = }"
|
|
98
100
|
):
|
|
99
101
|
# Compute a solar gain based on a fringe-corrected lamp gain
|
|
@@ -101,7 +103,7 @@ class SPSolarGainCalibration(CryonirspTaskBase):
|
|
|
101
103
|
beam, exposure_conditions
|
|
102
104
|
)
|
|
103
105
|
|
|
104
|
-
with self.
|
|
106
|
+
with self.telemetry_span(
|
|
105
107
|
f"Writing the final solar gain array for {beam = } and {exposure_conditions = }"
|
|
106
108
|
):
|
|
107
109
|
self.write_solar_gain_calibration(
|
|
@@ -109,7 +111,7 @@ class SPSolarGainCalibration(CryonirspTaskBase):
|
|
|
109
111
|
beam=beam,
|
|
110
112
|
)
|
|
111
113
|
|
|
112
|
-
with self.
|
|
114
|
+
with self.telemetry_span("Computing and logging quality metrics"):
|
|
113
115
|
no_of_raw_solar_frames: int = self.scratch.count_all(
|
|
114
116
|
tags=[
|
|
115
117
|
CryonirspTag.linearized_frame(),
|
|
@@ -449,18 +451,18 @@ class SPSolarGainCalibration(CryonirspTaskBase):
|
|
|
449
451
|
"""
|
|
450
452
|
apm_str = f"{beam = } and {exposure_conditions = }"
|
|
451
453
|
|
|
452
|
-
with self.
|
|
454
|
+
with self.telemetry_span(f"Perform initial corrections for {apm_str}"):
|
|
453
455
|
corrected_solar_array = self.do_dark_and_bad_pixel_corrections(
|
|
454
456
|
beam=beam, exposure_conditions=exposure_conditions
|
|
455
457
|
)
|
|
456
458
|
|
|
457
|
-
with self.
|
|
459
|
+
with self.telemetry_span(f"Compute the flux-scaled lamp gain for {apm_str}"):
|
|
458
460
|
scaled_lamp_array = self.compute_flux_scaled_lamp_gain(corrected_solar_array, beam)
|
|
459
461
|
|
|
460
|
-
with self.
|
|
462
|
+
with self.telemetry_span(f"Apply spectral filtering for {apm_str}"):
|
|
461
463
|
filtered_lamp_array = self.apply_spectral_and_spatial_filtering(scaled_lamp_array)
|
|
462
464
|
|
|
463
|
-
with self.
|
|
465
|
+
with self.telemetry_span(f"Isolate and remove fringes for {apm_str}"):
|
|
464
466
|
final_gain_array = self.isolate_and_remove_fringes(
|
|
465
467
|
filtered_lamp_array, scaled_lamp_array
|
|
466
468
|
)
|
|
@@ -62,7 +62,7 @@ class SPWavelengthCalibration(CryonirspTaskBase):
|
|
|
62
62
|
-------
|
|
63
63
|
None
|
|
64
64
|
"""
|
|
65
|
-
with self.
|
|
65
|
+
with self.telemetry_span("Load input spectrum and wavelength"):
|
|
66
66
|
logger.info("Loading input spectrum")
|
|
67
67
|
input_spectrum = next(
|
|
68
68
|
self.read(
|
|
@@ -99,7 +99,7 @@ class SPWavelengthCalibration(CryonirspTaskBase):
|
|
|
99
99
|
resolving_power = self.get_resolving_power()
|
|
100
100
|
logger.info(f"{resolving_power = }")
|
|
101
101
|
|
|
102
|
-
with self.
|
|
102
|
+
with self.telemetry_span("Compute brute-force CRVAL initial guess"):
|
|
103
103
|
atlas = Atlas(config=self.parameters.wavecal_atlas_download_config)
|
|
104
104
|
crval = calculate_initial_crval_guess(
|
|
105
105
|
input_wavelength_vector=input_wavelength_vector,
|
|
@@ -111,7 +111,7 @@ class SPWavelengthCalibration(CryonirspTaskBase):
|
|
|
111
111
|
)
|
|
112
112
|
logger.info(f"{crval = !s}")
|
|
113
113
|
|
|
114
|
-
with self.
|
|
114
|
+
with self.telemetry_span("Set up wavelength fit"):
|
|
115
115
|
logger.info("Setting bounds")
|
|
116
116
|
bounds = BoundsModel(
|
|
117
117
|
crval=LengthBoundRange(min=crval - (5 * u.nm), max=crval + (5 * u.nm)),
|
|
@@ -158,14 +158,14 @@ class SPWavelengthCalibration(CryonirspTaskBase):
|
|
|
158
158
|
|
|
159
159
|
logger.info(f"Input parameters: {input_parameters.lmfit_parameters.pretty_repr()}")
|
|
160
160
|
|
|
161
|
-
with self.
|
|
161
|
+
with self.telemetry_span("Run wavelength solution fit"):
|
|
162
162
|
fit_result = fitter(
|
|
163
163
|
input_wavelength_vector=input_wavelength_vector,
|
|
164
164
|
input_spectrum=input_spectrum,
|
|
165
165
|
spectral_weights=weights,
|
|
166
166
|
)
|
|
167
167
|
|
|
168
|
-
with self.
|
|
168
|
+
with self.telemetry_span("Save wavelength solution and quality metrics"):
|
|
169
169
|
self.write(
|
|
170
170
|
data=fit_result.wavelength_parameters.to_header(
|
|
171
171
|
axis_num=1, add_alternate_keys=True
|