dkist-processing-common 10.6.4__py3-none-any.whl → 10.7.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.
@@ -18,7 +18,7 @@ from dkist_fits_specifications import __version__ as spec_version
18
18
  from dkist_fits_specifications.utils.formatter import reformat_spec214_header
19
19
  from dkist_header_validator import spec214_validator
20
20
  from dkist_header_validator.translator import remove_extra_axis_keys
21
- from dkist_header_validator.translator import sanitize_to_spec214_level1
21
+ from dkist_header_validator.translator import remove_spec_122_keys_and_spec_214_l0_keys
22
22
  from dkist_spectral_lines.search import get_closest_spectral_line
23
23
  from dkist_spectral_lines.search import get_spectral_lines
24
24
  from scipy.stats import kurtosis
@@ -102,7 +102,9 @@ class WriteL1Frame(WorkflowTaskBase, MetadataStoreMixin, ABC):
102
102
 
103
103
  # Check that the written file passes spec 214 validation if requested
104
104
  if self.validate_l1_on_write:
105
- spec214_validator.validate(self.scratch.absolute_path(relative_path))
105
+ spec214_validator.validate(
106
+ self.scratch.absolute_path(relative_path), extra=False
107
+ )
106
108
 
107
109
  @cached_property
108
110
  def tile_size_param(self) -> int | None:
@@ -170,19 +172,21 @@ class WriteL1Frame(WorkflowTaskBase, MetadataStoreMixin, ABC):
170
172
  def add_stats_headers(header: fits.Header, data: np.ndarray) -> fits.Header:
171
173
  """Fill out the spec 214 statistics header table."""
172
174
  data = data.flatten()
173
- percentiles = np.nanpercentile(data, [1, 10, 25, 75, 90, 95, 98, 99])
175
+ percentiles = np.nanpercentile(data, [1, 2, 5, 10, 25, 75, 90, 95, 98, 99])
174
176
  header["DATAMIN"] = np.nanmin(data)
175
177
  header["DATAMAX"] = np.nanmax(data)
176
178
  header["DATAMEAN"] = np.nanmean(data)
177
179
  header["DATAMEDN"] = np.nanmedian(data)
178
- header["DATA01"] = percentiles[0]
179
- header["DATA10"] = percentiles[1]
180
- header["DATA25"] = percentiles[2]
181
- header["DATA75"] = percentiles[3]
182
- header["DATA90"] = percentiles[4]
183
- header["DATA95"] = percentiles[5]
184
- header["DATA98"] = percentiles[6]
185
- header["DATA99"] = percentiles[7]
180
+ header["DATAP01"] = percentiles[0]
181
+ header["DATAP02"] = percentiles[1]
182
+ header["DATAP05"] = percentiles[2]
183
+ header["DATAP10"] = percentiles[3]
184
+ header["DATAP25"] = percentiles[4]
185
+ header["DATAP75"] = percentiles[5]
186
+ header["DATAP90"] = percentiles[6]
187
+ header["DATAP95"] = percentiles[7]
188
+ header["DATAP98"] = percentiles[8]
189
+ header["DATAP99"] = percentiles[9]
186
190
  header["DATARMS"] = np.sqrt(np.nanmean(data**2))
187
191
  header["DATAKURT"] = kurtosis(data, nan_policy="omit")
188
192
  header["DATASKEW"] = skew(data, nan_policy="omit")
@@ -378,7 +382,7 @@ class WriteL1Frame(WorkflowTaskBase, MetadataStoreMixin, ABC):
378
382
  # Add the dataset headers (abstract - implement in instrument task)
379
383
  header = self.add_dataset_headers(header=header, stokes=stokes_param)
380
384
  # Remove any headers not contained in spec 214
381
- header = sanitize_to_spec214_level1(input_headers=header)
385
+ header = remove_spec_122_keys_and_spec_214_l0_keys(input_headers=header)
382
386
  # Remove any keys referring to axes that don't exist
383
387
  header = remove_extra_axis_keys(input_headers=header)
384
388
  return header
@@ -113,7 +113,7 @@ class CommonDataset(Spec122Dataset):
113
113
  self.add_constant_key("TELEVATN", 6.28)
114
114
  self.add_constant_key("TAZIMUTH", 3.14)
115
115
  self.add_constant_key("TTBLANGL", 1.23)
116
- self.add_constant_key("INST_FOO", "bar")
116
+ self.add_constant_key("VISP_012", "bar")
117
117
  self.add_constant_key("DKIST004", "observe")
118
118
  self.add_constant_key("ID___005", "ip id")
119
119
  self.add_constant_key("PAC__004", "Sapphire Polarizer")
@@ -22,19 +22,21 @@ def hdu_with_complete_common_header(complete_common_header):
22
22
  def hdu_with_special_keys(hdu_with_complete_common_header, request):
23
23
  """
24
24
  An HDU with data and a header that includes variations on the special keys that make headers
25
- different from dict's.
25
+ different from dicts.
26
+
27
+ The base complete_common_header already has history and comment cards so this fixture adds extras.
26
28
  """
27
29
  add_special = request.param
28
30
  hdu = hdu_with_complete_common_header
29
31
  if add_special == "history":
30
32
  hdu.header.add_history("test history")
31
- return hdu
33
+ return hdu, request.param
32
34
  if add_special == "comment":
33
- hdu.header.add_history("test comment")
34
- return hdu
35
+ hdu.header.add_comment("test comment")
36
+ return hdu, request.param
35
37
  if add_special == "continue":
36
38
  hdu.header["LONG_VAL"] = " " * 100
37
- return hdu
39
+ return hdu, request.param
38
40
 
39
41
 
40
42
  @pytest.fixture()
@@ -220,7 +222,7 @@ def test_as_subclass(hdu_with_complete_common_header):
220
222
  class InstFitsAccess(L0FitsAccess):
221
223
  def __init__(self, hdu, name):
222
224
  super().__init__(hdu, name)
223
- self.foo: str = self.header["INST_FOO"]
225
+ self.foo: str = self.header["VISP_012"]
224
226
 
225
227
  fits_obj = InstFitsAccess(hdu_with_complete_common_header, name="foo")
226
228
  assert fits_obj.foo == "bar"
@@ -282,11 +284,16 @@ def test_header_dict(hdu_with_special_keys):
282
284
  """
283
285
  Given: A FitsAccess object with data and a header including special header keys
284
286
  When: Accessing the header_dict method
285
- Then: The object's header is successfully exported as a dict of the same length as the header
287
+ Then: The object's header is successfully exported as a dict of the same length as the header when accounting for multiple HISTORY or COMMENT cards
286
288
  """
287
- fits_obj = FitsAccessBase(hdu_with_special_keys)
289
+ hdu, added_header_key = hdu_with_special_keys
290
+ fits_obj = FitsAccessBase(hdu)
288
291
  assert isinstance(fits_obj.header_dict, dict)
289
- assert len(fits_obj.header_dict) == len(fits_obj.header)
292
+ if added_header_key == "continue":
293
+ assert len(fits_obj.header_dict) == len(fits_obj.header)
294
+ if added_header_key in ["history", "comment"]:
295
+ # HISTORY and COMMENT keys get "squeezed"
296
+ assert len(fits_obj.header_dict) == len(fits_obj.header) - 1
290
297
 
291
298
 
292
299
  @pytest.mark.parametrize(
@@ -135,6 +135,7 @@ def write_l1_task(request, recipe_run_id, tmp_path):
135
135
  stokes_params = ["I", "Q", "U", "V"]
136
136
  used_stokes_params = []
137
137
  hdu = fits.PrimaryHDU(data=np.random.random(size=(1, 128, 128)) * 10, header=header)
138
+ hdu.header["IPTASK"] = "level0_only key to be removed"
138
139
  hdul = fits.HDUList([hdu])
139
140
  for i in range(num_of_stokes_params):
140
141
  task.write(
@@ -279,6 +280,9 @@ def test_write_l1_frame(
279
280
  # Test that FRAMEVOL still has its comment
280
281
  assert hdu.header.comments["FRAMEVOL"]
281
282
 
283
+ # Test that 'level0_only' keys are being removed
284
+ assert "IPTASK" not in hdu.header.keys()
285
+
282
286
 
283
287
  def test_replace_header_values(write_l1_task):
284
288
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dkist-processing-common
3
- Version: 10.6.4
3
+ Version: 10.7.1
4
4
  Summary: Common task classes used by the DKIST science data processing pipelines
5
5
  Author-email: NSO / AURA <dkistdc@nso.edu>
6
6
  License: BSD-3-Clause
@@ -58,7 +58,7 @@ dkist_processing_common/tasks/teardown.py,sha256=e4LKnphJDYDVDAez2tH7MxpZgCmxYsK
58
58
  dkist_processing_common/tasks/transfer_input_data.py,sha256=afEW0glpCFMZRj90nFtQo_4XOQ4CuoOh86jahP6a-a0,5548
59
59
  dkist_processing_common/tasks/trial_catalog.py,sha256=Y3DKstRfMS8nWWtJFMB0MUVPlZ1jWS_2jhJGMWwxy50,8748
60
60
  dkist_processing_common/tasks/trial_output_data.py,sha256=aI_aRuu0qVO8zFGrr_9baxx9i3jUEHZSmsmbO6ytlkE,6960
61
- dkist_processing_common/tasks/write_l1.py,sha256=XhWLOw4hmql3n01SU26B0McPfYD_7oRKHna0Tswn8Lk,22494
61
+ dkist_processing_common/tasks/write_l1.py,sha256=Jw8zQjlYjBQru3m1SB_ZDmicMkDRiUihy9VdwehvZc0,22683
62
62
  dkist_processing_common/tasks/mixin/__init__.py,sha256=-g-DQbU7m1bclJYuFe3Yh757V-35GIDTbstardKQ7nU,68
63
63
  dkist_processing_common/tasks/mixin/globus.py,sha256=QAV8VElxMAqxJ2KSB_bJaraceovYfjHXjOdocrTCkIA,6592
64
64
  dkist_processing_common/tasks/mixin/input_dataset.py,sha256=dkW5vf_QPgWedHO_Lf9GjBxr1QrUCKs6gIXufUTi7GE,6813
@@ -69,14 +69,14 @@ dkist_processing_common/tasks/mixin/quality/__init__.py,sha256=Bgu-DHW7yXLiehgll
69
69
  dkist_processing_common/tasks/mixin/quality/_base.py,sha256=nZ9IC-O-hsLXa5-tk29B13CZyQIdhJCv0eO9cdkAhWc,8303
70
70
  dkist_processing_common/tasks/mixin/quality/_metrics.py,sha256=WenTfa12guIUfm0GzkrK2gduKaOHs03e6RhE6j37Les,54304
71
71
  dkist_processing_common/tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
72
- dkist_processing_common/tests/conftest.py,sha256=B4BtMYCStjy3zvqefwJB6-ntSNOicIyQwfE0YeapCEE,30160
72
+ dkist_processing_common/tests/conftest.py,sha256=h_ObhpXb1S0-db0Je8XoHNLkrXxXW_0B0TMhbnbDjMo,30160
73
73
  dkist_processing_common/tests/test_assemble_movie.py,sha256=XY_ruXSYP5k6s2gUAwlFdnhJ81eyWLSd2O9IkX4RXeo,4165
74
74
  dkist_processing_common/tests/test_assemble_quality.py,sha256=fWSHK4UdVqgNjvxQuD40NBUnXrtmthUP7PUbISPV4MQ,16897
75
75
  dkist_processing_common/tests/test_base.py,sha256=4ST3__jEHitEQaQs9-0OcqtyEJfIjZsk_6PRYZFV2-U,7124
76
76
  dkist_processing_common/tests/test_codecs.py,sha256=9Ln8FJs319rbHpCukO9lKLk3aDrdyDREjA4nCHsxDCA,20796
77
77
  dkist_processing_common/tests/test_constants.py,sha256=Kc9k5TdYy5QkRRlGav6kfI2dy5HHKqtpf9qOuaAfDZU,5903
78
78
  dkist_processing_common/tests/test_cs_step.py,sha256=RA0QD3D8eaL3YSOL_gIJ9wkngy14RQ2jbD-05KAziW4,2408
79
- dkist_processing_common/tests/test_fits_access.py,sha256=e1B_N13vz6hFCBup6FlGItaH59dAmqXvox7jQuSyOB0,10946
79
+ dkist_processing_common/tests/test_fits_access.py,sha256=tyUPNbUqoTPhQgzua_doWP9l9ee4ir_LLV-I9rHktcs,11393
80
80
  dkist_processing_common/tests/test_flower_pot.py,sha256=X9_UI3maa3ZQncV3jYHgovWnawDsdEkEB5vw6EAB96o,3151
81
81
  dkist_processing_common/tests/test_input_dataset.py,sha256=AI5uqaDea4kOwpwAU5qQdzUbxMpBwD20YCAvB7nzD5o,18766
82
82
  dkist_processing_common/tests/test_interservice_bus.py,sha256=M_iv2CLmx5TnCB1VUN4YjkQ2LEUjfCKk7-ZlkV62XEQ,3000
@@ -100,7 +100,7 @@ dkist_processing_common/tests/test_transfer_l1_output_data.py,sha256=27PifkyH3RZ
100
100
  dkist_processing_common/tests/test_trial_catalog.py,sha256=SZ-nyn0MXU9Lkg_94FbKER_cwiGoi06GYlzF_3AmvKg,6802
101
101
  dkist_processing_common/tests/test_trial_output_data.py,sha256=cBCj0kXyF5NEMzKh6zPVksdoXyE8ju1opJgWgjdcJWA,12790
102
102
  dkist_processing_common/tests/test_workflow_task_base.py,sha256=Z5aPW5LQtS0UWJiYho4X0r-2gPLfzpkmMwfmaoFLjMg,10517
103
- dkist_processing_common/tests/test_write_l1.py,sha256=P_ep0_T2ZDZXPzFQmN7GgNs-RK6c5G6_DssPUW_sW7Q,21773
103
+ dkist_processing_common/tests/test_write_l1.py,sha256=R_ljJdSC4hCHS_mLV6rKE7PVfpDWCaMXoN6n45QJNWM,21951
104
104
  docs/Makefile,sha256=qnlVz6PuBqE39NfHWuUnHhNEA-EFgT2-WJNNNy9ttfk,4598
105
105
  docs/changelog.rst,sha256=S2jPASsWlQxSlAPqdvNrYvhk9k3FcFWNXFNDYXBSjl4,120
106
106
  docs/conf.py,sha256=FkX575cqTqZGCcLAjg2MlvE8Buj1Vt3CpHNgZxG256E,1890
@@ -109,7 +109,7 @@ docs/landing_page.rst,sha256=aPAuXFhBx73lEZ59B6E6JXxkK0LlxzD0n-HXqHrfumQ,746
109
109
  docs/make.bat,sha256=mBAhtURwhQ7yc95pqwJzlhqBSvRknr1aqZ5s8NKvdKs,4513
110
110
  docs/requirements.txt,sha256=Kbl_X4c7RQZw035YTeNB63We6I7pvXFU4T0Uflp2yDY,29
111
111
  licenses/LICENSE.rst,sha256=piZaQplkzOMmH1NXg6QIdo9wwo9pPCoHkvm2-DmH76E,1462
112
- dkist_processing_common-10.6.4.dist-info/METADATA,sha256=xFPyZqrXkRO-vWgas9iUWZiduYlNn4qhPTOUCcfXigA,7154
113
- dkist_processing_common-10.6.4.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
114
- dkist_processing_common-10.6.4.dist-info/top_level.txt,sha256=LJhd1W-Vn90K8HnQDIE4r52YDpUjjMWDnllAWHBByW0,48
115
- dkist_processing_common-10.6.4.dist-info/RECORD,,
112
+ dkist_processing_common-10.7.1.dist-info/METADATA,sha256=7xA4uAWQZv0vUY7XMOiH-3g_G76q2YluFmK4967BK8s,7154
113
+ dkist_processing_common-10.7.1.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
114
+ dkist_processing_common-10.7.1.dist-info/top_level.txt,sha256=LJhd1W-Vn90K8HnQDIE4r52YDpUjjMWDnllAWHBByW0,48
115
+ dkist_processing_common-10.7.1.dist-info/RECORD,,