imap-processing 0.19.4__py3-none-any.whl → 1.0.0__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 imap-processing might be problematic. Click here for more details.

@@ -54,15 +54,6 @@ energy_label:
54
54
  FORMAT: A16
55
55
  DEPEND_1: energy
56
56
 
57
- epoch_delta:
58
- <<: *default_int64
59
- CATDESC: Number of nanoseconds covered by data included in this map product.
60
- FIELDNAM: epoch_delta
61
- UNITS: ns
62
- VAR_TYPE: support_data
63
- DISPLAY_TYPE: no_plot
64
- TIME_SCALE: Terrestrial Time
65
-
66
57
  energy_delta_minus:
67
58
  <<: *default_float32
68
59
  VAR_TYPE: support_data
@@ -87,29 +78,37 @@ energy_delta_plus:
87
78
  LABL_PTR_1: energy_label
88
79
  DICT_KEY: SPASE>Particle>ParticleType:Atom,ParticleQuantity:Energy,Qualifier:Uncertainty
89
80
 
81
+ epoch_delta:
82
+ <<: *default_int64
83
+ CATDESC: Number of nanoseconds covered by data included in this map product.
84
+ FIELDNAM: epoch_delta
85
+ UNITS: ns
86
+ VAR_TYPE: support_data
87
+ DISPLAY_TYPE: no_plot
88
+ TIME_SCALE: Terrestrial Time
89
+ DICT_KEY: SPASE>Support>SupportQuantity:Temporal
90
+
90
91
  # These two coordinates will be treated differently in the
91
92
  # HEALPix and rectangular tilings. They will be substantially overridden
92
93
  # in the tiling-specific YAML files.
93
94
  longitude:
94
95
  <<: *default_float32
95
- CATDESC: Pixel center longitude in range [0, 360].
96
- FIELDNAM: Longitude
97
- LABLAXIS: Longitude
96
+ CATDESC: "Pixel center longitude in {frame} reference frame in the range [0, 360]."
97
+ FIELDNAM: "{frame} Longitude"
98
+ LABLAXIS: "{frame} Longitude"
98
99
  UNITS: degrees
99
100
  VAR_TYPE: support_data
100
- DISPLAY_TYPE: no_plot
101
101
  VALIDMIN: 0
102
102
  VALIDMAX: 360
103
103
  DICT_KEY: SPASE>Support>SupportQuantity:Orientation,Qualifier:DirectionAngle.AzimuthAngle,CoordinateSystemName:HAE,CoordinateRepresentation:Spherical
104
104
 
105
105
  latitude:
106
106
  <<: *default_float32
107
- CATDESC: Pixel center latitude in range [-90, 90].
108
- FIELDNAM: Latitude
109
- LABLAXIS: Latitude
107
+ CATDESC: "Pixel center latitude in {frame} reference frame in the range [-90, 90]."
108
+ FIELDNAM: "{frame} Latitude"
109
+ LABLAXIS: "{frame} Latitude"
110
110
  UNITS: degrees
111
111
  VAR_TYPE: support_data
112
- DISPLAY_TYPE: no_plot
113
112
  VALIDMIN: -90
114
113
  VALIDMAX: 90
115
114
  DICT_KEY: SPASE>Support>SupportQuantity:Orientation,Qualifier:DirectionAngle.ElevationAngle,CoordinateSystemName:HAE,CoordinateRepresentation:Spherical
@@ -122,23 +121,23 @@ ena_intensity:
122
121
  CATDESC: Mono-energetic ENA intensity.
123
122
  FIELDNAM: Intensity
124
123
  UNITS: counts/(s * cm^2 * Sr * KeV)
125
- DELTA_MINUS_VAR: ena_intensity_stat_unc
126
- DELTA_PLUS_VAR: ena_intensity_stat_unc
124
+ DELTA_MINUS_VAR: ena_intensity_stat_uncert
125
+ DELTA_PLUS_VAR: ena_intensity_stat_uncert
127
126
  DEPEND_0: epoch
128
127
  VAR_TYPE: data
129
128
  LABLAXIS: Intensity
130
- DISPLAY_TYPE: image
129
+ DISPLAY_TYPE: map_image
131
130
  DICT_KEY: SPASE>Particle>ParticleType:Atom,ParticleQuantity:NumberFlux,Qualifier:Incident,CoordinateSystemName:HAE,CoordinateRepresentation:Spherical
132
131
 
133
- ena_intensity_stat_unc:
132
+ ena_intensity_stat_uncert:
134
133
  <<: *default_float32
135
134
  CATDESC: ENA intensity statistical uncertainty.
136
135
  FIELDNAM: Intensity stat unc
137
136
  UNITS: counts/(s * cm^2 * Sr * KeV)
138
137
  DEPEND_0: epoch
139
- VAR_TYPE: data
138
+ VAR_TYPE: support_data
140
139
  LABLAXIS: Statistical Unc
141
- DISPLAY_TYPE: image
140
+ DISPLAY_TYPE: map_image
142
141
  DICT_KEY: SPASE>Particle>ParticleType:Atom,ParticleQuantity:NumberFlux,Qualifier:Uncertainty,CoordinateSystemName:HAE,CoordinateRepresentation:Spherical
143
142
 
144
143
  ena_intensity_sys_err:
@@ -147,9 +146,9 @@ ena_intensity_sys_err:
147
146
  FIELDNAM: Intensity non-stat error
148
147
  UNITS: counts/(s * cm^2 * Sr * KeV)
149
148
  DEPEND_0: epoch
150
- VAR_TYPE: data
149
+ VAR_TYPE: support_data
151
150
  LABLAXIS: Non-Statistical Err
152
- DISPLAY_TYPE: image
151
+ DISPLAY_TYPE: map_image
153
152
  DICT_KEY: SPASE>Particle>ParticleType:Atom,ParticleQuantity:NumberFlux,Qualifier:Uncertainty,CoordinateSystemName:HAE,CoordinateRepresentation:Spherical
154
153
 
155
154
  ena_rate:
@@ -160,7 +159,7 @@ ena_rate:
160
159
  DEPEND_0: epoch
161
160
  VAR_TYPE: data
162
161
  LABLAXIS: Rate
163
- DISPLAY_TYPE: image
162
+ DISPLAY_TYPE: map_image
164
163
  DICT_KEY: SPASE>Particle>ParticleType:Atom,ParticleQuantity:NumberFlux,Qualifier:Incident,CoordinateSystemName:HAE,CoordinateRepresentation:Spherical
165
164
 
166
165
  bg_rate:
@@ -171,7 +170,7 @@ bg_rate:
171
170
  DEPEND_0: epoch
172
171
  VAR_TYPE: data
173
172
  LABLAXIS: Rate
174
- DISPLAY_TYPE: image
173
+ DISPLAY_TYPE: map_image
175
174
  DICT_KEY: SPASE>Particle>ParticleType:Atom,ParticleQuantity:NumberFlux,Qualifier:Incident,CoordinateSystemName:HAE,CoordinateRepresentation:Spherical
176
175
 
177
176
  ena_count:
@@ -182,7 +181,7 @@ ena_count:
182
181
  DEPEND_0: epoch
183
182
  VAR_TYPE: data
184
183
  LABLAXIS: Count
185
- DISPLAY_TYPE: image
184
+ DISPLAY_TYPE: map_image
186
185
  DICT_KEY: SPASE>Particle>ParticleType:Atom,ParticleQuantity:NumberFlux,Qualifier:Incident,CoordinateSystemName:HAE,CoordinateRepresentation:Spherical
187
186
 
188
187
  sensitivity:
@@ -192,7 +191,7 @@ sensitivity:
192
191
  UNITS: cm^2
193
192
  VAR_TYPE: support_data
194
193
  LABLAXIS: sensitivity
195
- DISPLAY_TYPE: image
194
+ DISPLAY_TYPE: no_plot
196
195
  DICT_KEY: SPASE>Particle>ParticleType:Atom,ParticleQuantity:GeometricFactor,Qualifier:Directional,CoordinateSystemName:HAE,CoordinateRepresentation:Spherical
197
196
 
198
197
  exposure_factor: &exposure_factor
@@ -204,7 +203,7 @@ exposure_factor: &exposure_factor
204
203
  VAR_TYPE: data
205
204
  LABLAXIS: Exposure
206
205
  DISPLAY_TYPE: no_plot
207
- DICT_KEY: SPASE>TemporalDescription:Exposure,Qualifier:Directional,CoordinateSystemName:HAE,CoordinateRepresentation:Spherical
206
+ DICT_KEY: SPASE>Support>SupportQuantity:Temporal
208
207
 
209
208
  geometric_function:
210
209
  <<: *default_float32
@@ -253,9 +252,9 @@ obs_date: &obs_date
253
252
  FIELDNAM: J2000 Nanoseconds
254
253
  UNITS: ns
255
254
  DEPEND_0: epoch
256
- VAR_TYPE: data
255
+ VAR_TYPE: support_data
257
256
  LABLAXIS: epoch
258
- DISPLAY_TYPE: image
257
+ DISPLAY_TYPE: no_plot
259
258
  DICT_KEY: SPASE>TemporalDescription:TimeSpan,Qualifier:Directional,CoordinateSystemName:HAE,CoordinateRepresentation:Spherical
260
259
 
261
260
  obs_date_range:
@@ -265,10 +264,11 @@ obs_date_range:
265
264
  FIELDNAM: Observation date range
266
265
  UNITS: ns
267
266
  DEPEND_0: epoch
268
- VAR_TYPE: data
267
+ VAR_TYPE: support_data
269
268
  LABLAXIS: epoch
270
- DISPLAY_TYPE: image
269
+ DISPLAY_TYPE: no_plot
271
270
  TIME_SCALE: Terrestrial Time
271
+ DICT_KEY: SPASE>Support>SupportQuantity:Temporal
272
272
 
273
273
  # These copied metadata vars will allow for variables
274
274
  # to be either energy-dependent or independent.
@@ -284,12 +284,11 @@ obs_date_range_energy_independent:
284
284
 
285
285
  solid_angle:
286
286
  <<: *default_float32
287
- VAR_TYPE: support_data
288
287
  CATDESC: Solid angle subtended by each pixel.
289
288
  FIELDNAM: Solid Angle
290
289
  DEPEND_0: epoch
290
+ VAR_TYPE: support_data
291
291
  UNITS: sr
292
- VAR_TYPE: data
293
292
  LABLAXIS: Solid Angle
294
- DISPLAY_TYPE: image
293
+ DISPLAY_TYPE: no_plot
295
294
  DICT_KEY: SPASE>Support>SupportQuantity:Other
@@ -52,9 +52,8 @@ ena_intensity:
52
52
  DEPEND_2: pixel_index
53
53
  LABL_PTR_1: energy_label
54
54
  LABL_PTR_2: pixel_index_label
55
- DISPLAY_TYPE: image
56
55
 
57
- ena_intensity_stat_unc:
56
+ ena_intensity_stat_uncert:
58
57
  DEPEND_1: energy
59
58
  DEPEND_2: pixel_index
60
59
  LABL_PTR_1: energy_label
@@ -19,9 +19,10 @@ longitude_label:
19
19
  DEPEND_1: longitude
20
20
 
21
21
  longitude_delta:
22
- VAR_TYPE: metadata
22
+ VAR_TYPE: support_data
23
23
  dtype: float32
24
24
  CATDESC: Half-width of longitude pixel
25
+ DEPEND_1: longitude
25
26
  FORMAT: F12.6
26
27
  UNITS: degrees
27
28
  FIELDNAM: longitude delta
@@ -35,9 +36,10 @@ latitude_label:
35
36
  DEPEND_1: latitude
36
37
 
37
38
  latitude_delta:
38
- VAR_TYPE: metadata
39
+ VAR_TYPE: support_data
39
40
  dtype: float32
40
41
  CATDESC: Half-width of latitude pixel
42
+ DEPEND_1: latitude
41
43
  FORMAT: F12.6
42
44
  UNITS: degrees
43
45
  FIELDNAM: latitude delta
@@ -65,7 +67,7 @@ ena_intensity:
65
67
  LABL_PTR_2: longitude_label
66
68
  LABL_PTR_3: latitude_label
67
69
 
68
- ena_intensity_stat_unc:
70
+ ena_intensity_stat_uncert:
69
71
  DEPEND_1: energy
70
72
  DEPEND_2: longitude
71
73
  DEPEND_3: latitude
@@ -89,7 +89,7 @@ class CoDICEL1aPipeline:
89
89
  self.plan_step = plan_step
90
90
  self.view_id = view_id
91
91
 
92
- def apply_despinning(self) -> None:
92
+ def apply_despinning(self) -> None: # noqa: PLR0912 (too many branches)
93
93
  """
94
94
  Apply the despinning algorithm to lo- angular and priority products.
95
95
 
@@ -108,10 +108,10 @@ class CoDICEL1aPipeline:
108
108
  # The dimensions are dependent on the specific data product
109
109
  if "angular" in self.config["dataset_name"]:
110
110
  despun_dims: tuple[int, ...] = (
111
+ num_counters,
111
112
  num_energies,
112
113
  num_positions,
113
114
  num_spins,
114
- num_counters,
115
115
  )
116
116
  elif "priority" in self.config["dataset_name"]:
117
117
  despun_dims = (num_energies, num_spins, num_counters)
@@ -130,23 +130,33 @@ class CoDICEL1aPipeline:
130
130
  for energy_index in range(num_energies):
131
131
  pixel_orientation = constants.PIXEL_ORIENTATIONS[energy_index]
132
132
  for spin_sector_index in range(num_spin_sectors):
133
- for azimuth_index in range(num_spins):
134
- if pixel_orientation == "A" and azimuth_index < 12:
133
+ for azimuth_index in range(num_positions):
134
+ if "-sw-" in self.config["dataset_name"]:
135
+ # do something
136
+ position_index = constants.SW_INDEX_TO_POSITION[
137
+ azimuth_index
138
+ ]
139
+ elif "-nsw-" in self.config["dataset_name"]:
140
+ position_index = constants.NSW_INDEX_TO_POSITION[
141
+ azimuth_index
142
+ ]
143
+
144
+ if pixel_orientation == "A" and position_index < 12:
135
145
  despun_spin_sector = spin_sector_index
136
- elif pixel_orientation == "A" and azimuth_index >= 12:
146
+ elif pixel_orientation == "A" and position_index >= 12:
137
147
  despun_spin_sector = spin_sector_index + 12
138
- elif pixel_orientation == "B" and azimuth_index < 12:
148
+ elif pixel_orientation == "B" and position_index < 12:
139
149
  despun_spin_sector = spin_sector_index + 12
140
- elif pixel_orientation == "B" and azimuth_index >= 12:
150
+ elif pixel_orientation == "B" and position_index >= 12:
141
151
  despun_spin_sector = spin_sector_index
142
152
 
143
153
  if "angular" in self.config["dataset_name"]:
144
154
  spin_data = epoch_data[
145
- energy_index, :, spin_sector_index, :
146
- ] # (5, 4)
147
- despun_data[i][energy_index, :, despun_spin_sector, :] = (
148
- spin_data
149
- )
155
+ :, energy_index, azimuth_index, spin_sector_index
156
+ ]
157
+ despun_data[i][
158
+ :, energy_index, azimuth_index, despun_spin_sector
159
+ ] = spin_data
150
160
  elif "priority" in self.config["dataset_name"]:
151
161
  spin_data = epoch_data[energy_index, spin_sector_index, :]
152
162
  despun_data[i][energy_index, despun_spin_sector, :] = (
@@ -327,7 +337,7 @@ class CoDICEL1aPipeline:
327
337
  # each counter's data can be placed in a separate CDF data variable.
328
338
  # For Lo SW species, all_data has shape (9, 16, 128, 1) -> (epochs,
329
339
  # num_counters, num_energy_steps, num_spin_sectors)
330
- if self._is_lo_species_dataset():
340
+ if self._is_different_dimension():
331
341
  # For Lo species datasets, counters are the second dimension (index 1)
332
342
  num_counters = all_data.shape[1]
333
343
  else:
@@ -338,8 +348,10 @@ class CoDICEL1aPipeline:
338
348
  range(num_counters), self.config["variable_names"], strict=False
339
349
  ):
340
350
  # Extract the counter data
341
- if self._is_lo_species_dataset():
351
+ if self._is_different_dimension():
342
352
  counter_data = all_data[:, counter, :, :]
353
+ elif "sectored" in self.config["dataset_name"]:
354
+ counter_data = all_data[:, counter, :, :, :]
343
355
  else:
344
356
  counter_data = all_data[..., counter]
345
357
 
@@ -720,18 +732,25 @@ class CoDICEL1aPipeline:
720
732
 
721
733
  # Reshape the data based on how it is written to the data array of
722
734
  # the packet data. The number of counters is the last dimension / axis.
723
- if self._is_lo_species_dataset():
735
+ if self._is_different_dimension():
724
736
  # For Lo species datasets, counters are the first dimension
725
737
  reshape_dims = (
726
738
  self.config["num_counters"],
727
739
  *self.config["dims"].values(),
728
740
  )
741
+ elif "sectored" in self.config["dataset_name"]:
742
+ # For sectored datasets, counters are the second dimension
743
+ reshape_dims = (
744
+ self.config["num_counters"],
745
+ *self.config["dims"].values(),
746
+ )
729
747
  else:
730
748
  # For all other datasets, counters are the last dimension
731
749
  reshape_dims = (
732
750
  *self.config["dims"].values(),
733
751
  self.config["num_counters"],
734
752
  )
753
+
735
754
  for packet_data in self.raw_data:
736
755
  reshaped_packet_data = np.array(packet_data, dtype=np.uint32).reshape(
737
756
  reshape_dims
@@ -745,7 +764,7 @@ class CoDICEL1aPipeline:
745
764
  # No longer need to keep the raw data around
746
765
  del self.raw_data
747
766
 
748
- def _is_lo_species_dataset(self) -> bool:
767
+ def _is_different_dimension(self) -> bool:
749
768
  """
750
769
  Check if the current dataset is a Lo species dataset.
751
770
 
@@ -761,6 +780,8 @@ class CoDICEL1aPipeline:
761
780
  return self.config["dataset_name"] in [
762
781
  "imap_codice_l1a_lo-sw-species",
763
782
  "imap_codice_l1a_lo-nsw-species",
783
+ "imap_codice_l1a_lo-sw-angular",
784
+ "imap_codice_l1a_lo-nsw-angular",
764
785
  ]
765
786
 
766
787
  def set_data_product_config(self, apid: int, dataset: xr.Dataset) -> None:
@@ -1653,23 +1674,23 @@ def process_codice_l1a(file_path: Path) -> list[xr.Dataset]:
1653
1674
  # Housekeeping data
1654
1675
  if apid == CODICEAPID.COD_NHK:
1655
1676
  processed_dataset = create_hskp_dataset(dataset)
1656
- logger.info(f"\nFinal data product:\n{processed_dataset}\n")
1677
+ logger.info(f"\nProcessed {CODICEAPID(apid).name} packet\n")
1657
1678
 
1658
1679
  # Event data
1659
1680
  elif apid in [CODICEAPID.COD_LO_PHA, CODICEAPID.COD_HI_PHA]:
1660
1681
  processed_dataset = create_direct_event_dataset(apid, dataset)
1661
- logger.info(f"\nFinal data product:\n{processed_dataset}\n")
1682
+ logger.info(f"\nProcessed {CODICEAPID(apid).name} packet\n")
1662
1683
 
1663
1684
  # I-ALiRT data
1664
1685
  elif apid in [CODICEAPID.COD_LO_IAL, CODICEAPID.COD_HI_IAL]:
1665
1686
  processed_dataset = create_ialirt_dataset(apid, dataset)
1666
- logger.info(f"\nFinal data product:\n{processed_dataset}\n")
1687
+ logger.info(f"\nProcessed {CODICEAPID(apid).name} packet\n")
1667
1688
 
1668
1689
  # hi-omni data
1669
1690
  elif apid == CODICEAPID.COD_HI_OMNI_SPECIES_COUNTS:
1670
1691
  science_values = [packet.data for packet in dataset.data]
1671
1692
  processed_dataset = create_binned_dataset(apid, dataset, science_values)
1672
- logger.info(f"\nFinal data product:\n{processed_dataset}\n")
1693
+ logger.info(f"\nProcessed {CODICEAPID(apid).name} packet\n")
1673
1694
 
1674
1695
  # Everything else
1675
1696
  elif apid in constants.APIDS_FOR_SCIENCE_PROCESSING:
@@ -1687,7 +1708,7 @@ def process_codice_l1a(file_path: Path) -> list[xr.Dataset]:
1687
1708
  pipeline.define_coordinates()
1688
1709
  processed_dataset = pipeline.define_data_variables()
1689
1710
 
1690
- logger.info(f"\nFinal data product:\n{processed_dataset}\n")
1711
+ logger.info(f"\nProcessed {CODICEAPID(apid).name} packet\n")
1691
1712
 
1692
1713
  # For APIDs that don't require processing
1693
1714
  else: