-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENH/MNT: Add a common initial dataset creation routine (#687)
* ENH/MNT: Add a common initial dataset creation routine This adds a common interface for returning xarray datasets from a packet file. There is one dataset per apid, sorted by time, with derived values automatically converted. * Update Hi and SWAPI to use this new feature
- Loading branch information
Showing
9 changed files
with
147 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,26 @@ | ||
"""Unpack IMAP-Hi housekeeping data.""" | ||
|
||
import xarray as xr | ||
from space_packet_parser.parser import Packet | ||
|
||
from imap_processing.hi.hi_cdf_attrs import ( | ||
hi_hk_l1a_attrs, | ||
) | ||
from imap_processing.utils import create_dataset, update_epoch_to_datetime | ||
|
||
|
||
def process_housekeeping(packets: list[Packet]) -> xr.Dataset: | ||
def process_housekeeping(dataset: xr.Dataset) -> xr.Dataset: | ||
""" | ||
Create dataset for each metadata field. | ||
Parameters | ||
---------- | ||
packets : list[space_packet_parser.ParsedPacket] | ||
Packet list. | ||
dataset : xarray.Dataset | ||
Packet input dataset. | ||
Returns | ||
------- | ||
dataset : xarray.Dataset | ||
Dataset with all metadata field data in xr.DataArray. | ||
""" | ||
dataset = create_dataset( | ||
packets=packets, spacecraft_time_key="ccsds_met", skip_keys=["INSTR_SPECIFIC"] | ||
) | ||
# Update epoch to datetime | ||
dataset = update_epoch_to_datetime(dataset) | ||
|
||
# Add datalevel attrs | ||
dataset.attrs.update(hi_hk_l1a_attrs.output()) | ||
return dataset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.