From 4d3a1d7eb1fa7e2e9430c8a42d28787ddca8d0a4 Mon Sep 17 00:00:00 2001 From: Veronica Martinez Date: Mon, 23 Jun 2025 12:46:07 -0600 Subject: [PATCH 1/2] Fix issue with sectorates dimensions. The data needs to be shaped as (zenith x azimuth) while decommutating the binary data since that is how the data is specified in the flight software, and then transposed for the data products. This ensures that the correct values end up where expected in the new shape (azimuth x zenith). --- imap_processing/hit/l0/constants.py | 2 +- imap_processing/hit/l0/decom_hit.py | 3 ++- imap_processing/hit/l1a/hit_l1a.py | 14 +++++++++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/imap_processing/hit/l0/constants.py b/imap_processing/hit/l0/constants.py index 961ff4b84c..a0fd3bb178 100644 --- a/imap_processing/hit/l0/constants.py +++ b/imap_processing/hit/l0/constants.py @@ -100,7 +100,7 @@ "penfgrates": HITPacking(16, 528, (33,)), # range 4 foreground rates "penbgrates": HITPacking(16, 240, (15,)), # range 4 background rates "ialirtrates": HITPacking(16, 320, (20,)), # ialirt rates - "sectorates": HITPacking(16, 1920, (15, 8)), # sectored rates + "sectorates": HITPacking(16, 1920, (8, 15)), # sectored rates "l4fgrates": HITPacking(16, 768, (48,)), # all range foreground rates "l4bgrates": HITPacking(16, 384, (24,)), # all range foreground rates } diff --git a/imap_processing/hit/l0/decom_hit.py b/imap_processing/hit/l0/decom_hit.py index bfea20e51a..542c5a366e 100644 --- a/imap_processing/hit/l0/decom_hit.py +++ b/imap_processing/hit/l0/decom_hit.py @@ -92,8 +92,9 @@ def parse_count_rates(sci_dataset: xr.Dataset) -> None: # Get dims for data variables (yaml file not created yet) if len(field_meta.shape) > 1: if "sectorates" in field: - # Reshape data to 15x8 for azimuth and zenith look directions + # Transpose data to 15x8 for azimuth and zenith look directions parsed_data = np.array(parsed_data).reshape((-1, *field_meta.shape)) + parsed_data = np.transpose(parsed_data, axes=(0, 2, 1)) dims = ["epoch", "azimuth", "zenith"] # Add angle values to coordinates sci_dataset.coords["zenith"] = xr.DataArray( diff --git a/imap_processing/hit/l1a/hit_l1a.py b/imap_processing/hit/l1a/hit_l1a.py index 9d1d074a64..ed165fd22d 100644 --- a/imap_processing/hit/l1a/hit_l1a.py +++ b/imap_processing/hit/l1a/hit_l1a.py @@ -13,7 +13,11 @@ get_datasets_by_apid, process_housekeeping_data, ) -from imap_processing.hit.l0.constants import MOD_10_MAPPING +from imap_processing.hit.l0.constants import ( + AZIMUTH_ANGLES, + MOD_10_MAPPING, + ZENITH_ANGLES, +) from imap_processing.hit.l0.decom_hit import decom_hit logger = logging.getLogger(__name__) @@ -104,12 +108,16 @@ def subcom_sectorates(sci_dataset: xr.Dataset) -> xr.Dataset: hdr_min_count_mod_10 = updated_dataset.hdr_minute_cnt.values % 10 # Reference mod 10 mapping to initialize data structure for species and - # energy ranges and add 15x8 arrays with fill values for each science frame. + # energy ranges and add arrays with fill values for each science frame. num_frames = len(hdr_min_count_mod_10) data_by_species_and_energy_range = { key: { **value, - "counts": np.full((num_frames, 15, 8), fill_value=fillval, dtype=np.int64), + "counts": np.full( + (num_frames, len(AZIMUTH_ANGLES), len(ZENITH_ANGLES)), + fill_value=fillval, + dtype=np.int64, + ), } for key, value in MOD_10_MAPPING.items() } From 61fbf631e2d610926064679c01206de6e071c994 Mon Sep 17 00:00:00 2001 From: Veronica Martinez Date: Mon, 23 Jun 2025 13:28:33 -0600 Subject: [PATCH 2/2] Update dimension angle comments for improved clarity --- imap_processing/hit/l0/constants.py | 4 +++- imap_processing/hit/l0/decom_hit.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/imap_processing/hit/l0/constants.py b/imap_processing/hit/l0/constants.py index a0fd3bb178..2ac855242a 100644 --- a/imap_processing/hit/l0/constants.py +++ b/imap_processing/hit/l0/constants.py @@ -100,7 +100,9 @@ "penfgrates": HITPacking(16, 528, (33,)), # range 4 foreground rates "penbgrates": HITPacking(16, 240, (15,)), # range 4 background rates "ialirtrates": HITPacking(16, 320, (20,)), # ialirt rates - "sectorates": HITPacking(16, 1920, (8, 15)), # sectored rates + "sectorates": HITPacking( + 16, 1920, (8, 15) + ), # sectored rates (8 zenith angles, 15 azimuth angles) "l4fgrates": HITPacking(16, 768, (48,)), # all range foreground rates "l4bgrates": HITPacking(16, 384, (24,)), # all range foreground rates } diff --git a/imap_processing/hit/l0/decom_hit.py b/imap_processing/hit/l0/decom_hit.py index 542c5a366e..571702a12d 100644 --- a/imap_processing/hit/l0/decom_hit.py +++ b/imap_processing/hit/l0/decom_hit.py @@ -92,8 +92,10 @@ def parse_count_rates(sci_dataset: xr.Dataset) -> None: # Get dims for data variables (yaml file not created yet) if len(field_meta.shape) > 1: if "sectorates" in field: - # Transpose data to 15x8 for azimuth and zenith look directions + # Reshape data into (num_frames, 8, 15) for zenith and azimuth + # look directions parsed_data = np.array(parsed_data).reshape((-1, *field_meta.shape)) + # Transpose data to (num_frames, 15, 8) for flipped look directions parsed_data = np.transpose(parsed_data, axes=(0, 2, 1)) dims = ["epoch", "azimuth", "zenith"] # Add angle values to coordinates