Skip to content

Commit

Permalink
Adding flag constant
Browse files Browse the repository at this point in the history
  • Loading branch information
maxinelasp committed Jan 14, 2025
1 parent f807094 commit e520bb7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
3 changes: 3 additions & 0 deletions imap_processing/glows/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
__version__ = "v001"

# Quality flag list length. Used in L1B and L2.
FLAG_LENGTH = 17
3 changes: 2 additions & 1 deletion imap_processing/glows/l1b/glows_l1b.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import xarray as xr

from imap_processing.cdf.imap_cdf_manager import ImapCdfAttributes
from imap_processing.glows import FLAG_LENGTH
from imap_processing.glows.l1b.glows_l1b_data import DirectEventL1B, HistogramL1B


Expand Down Expand Up @@ -45,7 +46,7 @@ def glows_l1b(input_dataset: xr.Dataset, data_version: str) -> xr.Dataset:

if "hist" in logical_source:
flag_data = xr.DataArray(
np.arange(17),
np.arange(FLAG_LENGTH),
name="flag_dim",
dims=["flag_dim"],
attrs=cdf_attrs.get_variable_attributes("flag_dim"),
Expand Down
3 changes: 2 additions & 1 deletion imap_processing/glows/l1b/glows_l1b_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import numpy as np

from imap_processing.glows import FLAG_LENGTH
from imap_processing.glows.utils.constants import TimeTuple


Expand Down Expand Up @@ -595,7 +596,7 @@ def __post_init__(
# self.unique_block_identifier = np.datetime_as_string(
# np.datetime64(int(self.imap_start_time), "ns"), "s"
# )
self.flags = np.ones((17,), dtype=np.uint8)
self.flags = np.ones((FLAG_LENGTH,), dtype=np.uint8)

def output_data(self) -> tuple:
"""
Expand Down
7 changes: 4 additions & 3 deletions imap_processing/glows/l2/glows_l2.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from numpy.typing import NDArray

from imap_processing.cdf.imap_cdf_manager import ImapCdfAttributes
from imap_processing.glows import FLAG_LENGTH
from imap_processing.glows.l1b.glows_l1b_data import HistogramL1B
from imap_processing.glows.l2.glows_l2_data import DailyLightcurve, HistogramL2

Expand Down Expand Up @@ -60,7 +61,7 @@ def generate_l2(l1b_dataset: xr.Dataset) -> HistogramL2:
"""
# most of the values from L1B are averaged over a day
good_data = l1b_dataset.isel(
epoch=return_good_times(l1b_dataset["flags"], np.ones((17,)))
epoch=return_good_times(l1b_dataset["flags"], np.ones((FLAG_LENGTH,)))
)
# todo: bad angle filter
# TODO filter bad bins out. Needs to happen here while everything is still
Expand All @@ -78,7 +79,7 @@ def generate_l2(l1b_dataset: xr.Dataset) -> HistogramL2:
# TODO replace post-filter
"identifier": 100, # TODO: retrieve from spin table
# TODO fill this in
"bad_time_flag_occurrences": np.zeros((1, 17)),
"bad_time_flag_occurrences": np.zeros((1, FLAG_LENGTH)),
# Accumulate all the histograms from good times from the day into one
"daily_lightcurve": daily_lightcurve,
}
Expand Down Expand Up @@ -217,7 +218,7 @@ def create_l2_dataset(
)

flags = xr.DataArray(
np.ones(17),
np.ones(FLAG_LENGTH),
dims=["flags"],
attrs=attrs.get_variable_attributes("flags_dim", check_schema=False),
)
Expand Down

0 comments on commit e520bb7

Please sign in to comment.