Skip to content

Commit 03e1337

Browse files
authored
Lo and HIT - SIT-4 Bug fixes (IMAP-Science-Operations-Center#1818)
* fixed l1a dependency check * fixed hit cli
1 parent 360406a commit 03e1337

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

imap_processing/cli.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -791,25 +791,23 @@ def do_processing(
791791

792792
dependency_list = dependencies.processing_input
793793
if self.data_level == "l1a":
794-
if len(dependency_list) > 1:
794+
# 1 science files and 2 spice files
795+
if len(dependency_list) > 3:
795796
raise ValueError(
796797
f"Unexpected dependencies found for HIT L1A:"
797798
f"{dependency_list}. Expected only one dependency."
798799
)
799800
# process data to L1A products
800-
science_files = dependencies.get_file_paths(source="hit")
801+
science_files = dependencies.get_file_paths(source="hit", descriptor="raw")
801802
datasets = hit_l1a(science_files[0])
802803

803804
elif self.data_level == "l1b":
804-
if len(dependency_list) > 1:
805-
raise ValueError(
806-
f"Unexpected dependencies found for HIT L1B:"
807-
f"{dependency_list}. Expected only one dependency."
808-
)
809805
data_dict = {}
810-
# TODO: Check this and update with new features as needed.
806+
# TODO: Sean removed the file number error handling to work with the
807+
# new SPICE dependencies for SIT-4. Need to review and make changes
808+
# if needed.
811809
l0_files = dependencies.get_file_paths(source="hit", descriptor="raw")
812-
l1a_files = dependencies.get_file_paths(source="hit")
810+
l1a_files = dependencies.get_file_paths(source="hit", data_type="l1a")
813811
if len(l0_files) > 0:
814812
# Add path to CCSDS file to process housekeeping
815813
data_dict["imap_hit_l0_raw"] = l0_files[0]
@@ -948,21 +946,21 @@ def do_processing(
948946
"""
949947
print(f"Processing IMAP-Lo {self.data_level}")
950948
datasets: list[xr.Dataset] = []
951-
dependency_list = dependencies.processing_input
952949
if self.data_level == "l1a":
953950
# L1A packet / products are 1 to 1. Should only have
954951
# one dependency file
955-
if len(dependency_list) > 1:
952+
science_files = dependencies.get_file_paths(source="lo", data_type="l0")
953+
if len(science_files) > 1:
956954
raise ValueError(
957955
f"Unexpected dependencies found for IMAP-Lo L1A:"
958-
f"{dependency_list}. Expected only one dependency."
956+
f"{science_files}. Expected only one dependency."
959957
)
960-
science_files = dependencies.get_file_paths(source="lo")
961958
datasets = lo_l1a.lo_l1a(science_files[0])
962959

963960
elif self.data_level == "l1b":
964961
data_dict = {}
965962
science_files = dependencies.get_file_paths(source="lo", data_type="l1a")
963+
logger.info(f"Science files for L1B: {science_files}")
966964
for file in science_files:
967965
dataset = load_cdf(file)
968966
data_dict[dataset.attrs["Logical_source"]] = dataset

imap_processing/lo/l1b/lo_l1b.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""IMAP-Lo L1B Data Processing."""
22

3+
import logging
34
from dataclasses import Field
45
from pathlib import Path
56
from typing import Any, Union
@@ -17,6 +18,9 @@
1718
from imap_processing.spice.geometry import SpiceFrame, instrument_pointing
1819
from imap_processing.spice.time import met_to_ttj2000ns, ttj2000ns_to_et
1920

21+
logger = logging.getLogger(__name__)
22+
logger.setLevel(logging.INFO)
23+
2024

2125
def lo_l1b(dependencies: dict) -> list[Path]:
2226
"""
@@ -39,9 +43,10 @@ def lo_l1b(dependencies: dict) -> list[Path]:
3943
# create the attribute manager to access L1A fillval attributes
4044
attr_mgr_l1a = ImapCdfAttributes()
4145
attr_mgr_l1a.add_instrument_variable_attrs(instrument="lo", level="l1a")
42-
46+
logger.info(f"\n Dependencies: {list(dependencies.keys())}\n")
4347
# if the dependencies are used to create Annotated Direct Events
4448
if "imap_lo_l1a_de" in dependencies and "imap_lo_l1a_spin" in dependencies:
49+
logger.info("\nProcessing IMAP-Lo L1B Direct Events...")
4550
logical_source = "imap_lo_l1b_de"
4651
# get the dependency dataset for l1b direct events
4752
l1a_de = dependencies["imap_lo_l1a_de"]

imap_processing/lo/l1c/lo_l1c.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ def create_datasets(
326326
# and relative L1A DE time to calculate the absolute DE time,
327327
# this epoch conversion will go away and the time in the DE dataclass
328328
# can be used direction
329-
epoch_converted_time = [met_to_ttj2000ns(1)]
329+
epoch_converted_time = [1]
330330

331331
# Create a data array for the epoch time
332332
# TODO: might need to update the attrs to use new YAML file

0 commit comments

Comments
 (0)