Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions imap_processing/hit/l1b/hit_l1b.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from imap_processing.hit.l1b.constants import (
FILLVAL_FLOAT32,
FILLVAL_INT64,
LIVESTIM_PULSES,
SECTORS,
SUMMED_PARTICLE_ENERGY_RANGE_MAPPING,
)
Expand Down Expand Up @@ -108,8 +107,18 @@ def process_science_data(
logical_source = None

# Calculate fractional livetime from the livetime counter
livetime = l1a_counts_dataset["livetime_counter"] / LIVESTIM_PULSES
livetime = livetime.rename("livetime")
livetime = l1a_counts_dataset["livetime_counter"]
livetime_fraction = xr.zeros_like(livetime, dtype=np.float32)

# Equation 8 in section 6.2 of the algorithm document
livetime1 = livetime <= 4101
livetime2 = (livetime > 4101) & (livetime <= 16000)
livetime3 = livetime > 16000
livetime_fraction[livetime1] = livetime[livetime1] * 3.41e-5 + 0.14
livetime_fraction[livetime2] = livetime[livetime2] * 6.827e-5
livetime_fraction[livetime3] = livetime[livetime3] * 1.04e-9

livetime = livetime_fraction.rename("livetime")
Comment on lines +110 to +121
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice implementation of the different calculations using boolean masks. Putting this in a function would make it easier to write a unit test for it

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks to me to be in the right place, but @vmartinez-cu can confirm.


# Process counts data to an L1B dataset based on the descriptor
if descriptor == "standard-rates":
Expand Down
Loading