Skip to content

Commit

Permalink
Merge pull request #3 from maxinelasp/fix_glows_cdf
Browse files Browse the repository at this point in the history
Fix glows cdf
  • Loading branch information
maxinelasp authored Oct 1, 2024
2 parents d9738b8 + e02e895 commit 724fc90
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 178 deletions.
2 changes: 2 additions & 0 deletions imap_processing/cdf/config/imap_constant_attrs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ epoch:
TIME_BASE: J2000
TIME_SCALE: Terrestrial Time
REFERENCE_POSITION: Rotating Earth Geoid
RESOLUTION: ' '
DISPLAY_TYPE: time_series

# <=== Data Variables ===>
# Default Attrs for all metadata variables unless overridden
Expand Down
156 changes: 59 additions & 97 deletions imap_processing/cdf/config/imap_glows_l1b_variable_attrs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@ support_data_defaults: &support_data_defaults
FORMAT: I10
RESOLUTION: ISO8601

time_data_defaults: &time_data_defaults
<<: *support_data_defaults
FILLVAL: *int_fillval
FORMAT: F16.6
UNITS: seconds
VALIDMAX: 4294967295.0
VALIDMIN: 0.0

flag_data_defaults: &flag_data_defaults
<<: *support_data_defaults
FILLVAL: -128
FORMAT: I2
LABLAXIS: Flag

bins_attrs:
<<: *default_attrs
VALIDMIN: 0
Expand All @@ -41,14 +55,15 @@ bins_attrs:

flag_dim:
<<: *default_attrs
VALIDMIN: 0
VALIDMAX: 1
FILLVAL: -1
CATDESC: Flags for histogram information
FIELDNAM: Flags for histogram information
UNITS: ' '
FORMAT: I2
LABLAXIS: Flags
VALIDMAX: 1
VALIDMIN: 0
VAR_TYPE: support_data
UNITS: ' '

within_the_second: # Used to be per_second_attrs
<<: *default_attrs
Expand All @@ -61,6 +76,17 @@ within_the_second: # Used to be per_second_attrs
DISPLAY_TYPE: time_series
LABLAXIS: Direct Events

direct_event_components_attrs:
<<: *default_attrs
VALIDMIN: 0
VALIDMAX: 3
CATDESC: Components of a direct event (seconds, subseconds, impulse_length, multi_event)
FIELDNAM: Direct event components
FORMAT: I2
VAR_TYPE: support_data
LABLAXIS: Components
FILLVAL: 255

direct_events:
<<: *default_attrs
DEPEND_O: epoch
Expand Down Expand Up @@ -121,59 +147,36 @@ last_spin_id:
VALIDMAX: *max_uint32_min_one

imap_start_time:
<<: *support_data_defaults
<<: *time_data_defaults
CATDESC: Histogram start time, IMAP-clock seconds
FIELDNAM: Histogram start time, IMAP-clock seconds
# TODO: Presumably float64 max or min should be here?
FILLVAL: *int_fillval
FORMAT: F16.6
UNITS: seconds
LABLAXIS: Start time
VALIDMAX: 4294967295.0
VALIDMIN: 0.0

imap_time_offset:
<<: *support_data_defaults
<<: *time_data_defaults
CATDESC: Accumulation time in seconds for GLOWS histogram
FIELDNAM: Histogram accumulation time
# TODO: Presumably float64 max or min should be here?
FILLVAL: *int_fillval
FORMAT: F12.6
UNITS: seconds
LABLAXIS: Duration
VALIDMAX: 4000.0
VALIDMIN: 0.0

glows_start_time:
<<: *support_data_defaults
<<: *time_data_defaults
CATDESC: Histogram start time, GLOWS-clock seconds
FIELDNAM: Histogram start time, GLOWS-clock seconds
FILLVAL: *int_fillval
FORMAT: F16.6
UNITS: seconds
LABLAXIS: Start time
VALIDMAX: 4294967295.0
VALIDMIN: 0.0

glows_time_offset:
<<: *support_data_defaults
<<: *time_data_defaults
CATDESC: Accumulation time in seconds for GLOWS histogram
FIELDNAM: Histogram accumulation time
FILLVAL: *int_fillval
FORMAT: F12.6
UNITS: seconds
LABLAXIS: Duration
VALIDMAX: 4000.0 # 15.38 s per spin x 256 spins = 3937.3 s, then rounded up
VALIDMIN: 0.0

is_generated_on_ground:
<<: *support_data_defaults
<<: *flag_data_defaults
CATDESC: Flag indicating where histogram data was generated (1 - on the ground, 0 - onboard)
FIELDNAM: Histogram-creation-site flag
FILLVAL: -128
FORMAT: I2
LABLAXIS: Flag
VALIDMAX: 1

number_of_spins_per_block:
<<: *support_data_defaults
Expand Down Expand Up @@ -410,67 +413,47 @@ number_of_de_packets:

# data_every_second in glows_l1a.py
imap_time_last_pps:
<<: *support_data_defaults
<<: *time_data_defaults
CATDESC: IMAP-clock time for last PPS
FIELDNAM: IMAP-clock time for last PPS
FILLVAL: *max_uint32
FORMAT: F16.6
LABLAXIS: IMAP seconds
UNITS: seconds
VALIDMAX: *max_uint32_min_one

glows_time_last_pps:
<<: *support_data_defaults
<<: *time_data_defaults
CATDESC: GLOWS-clock time for last PPS
FIELDNAM: GLOWS-clock time for last PPS
DISPLAY_TYPE: no_plot
FILLVAL: *max_uint32
FORMAT: F16.6
LABLAXIS: GLOWS seconds
UNITS: seconds
VALIDMAX: *max_uint32_min_one

imap_time_next_pps:
<<: *support_data_defaults
<<: *time_data_defaults
CATDESC: IMAP-clock time for next PPS
FIELDNAM: IMAP-clock time for next PPS
FILLVAL: *max_uint32
FORMAT: F16.6
LABLAXIS: IMAP seconds
UNITS: seconds
VALIDMAX: *max_uint32_min_one

catbed_heater_active:
<<: *support_data_defaults
<<: *flag_data_defaults
CATDESC: Catbed-heater activity flag (1 - active, 0 - not active)
FIELDNAM: Catbed-heater activity flag
FILLVAL: -128
FORMAT: I2
LABLAXIS: Flag

spin_period_valid:
<<: *support_data_defaults
<<: *flag_data_defaults
CATDESC: Spin-period-validity flag (1 - valid, 0 - invalid)
FIELDNAM: Spin-period-validity flag
FILLVAL: -128
FORMAT: I2
LABLAXIS: Flag

spin_phase_at_next_pps_valid:
<<: *support_data_defaults
<<: *flag_data_defaults
CATDESC: Spin-phase-at-next-PPS validity flag (1 - valid, 0 - invalid)
FIELDNAM: Spin-phase-at-next-PPS validity flag
FILLVAL: -128
FORMAT: I2
LABLAXIS: Flag

spin_period_source:
<<: *support_data_defaults
<<: *flag_data_defaults
CATDESC: Spin-period-source flag (0 - from ITF, 1 - estimated by GLOWS AppSW)
FIELDNAM: Spin-period-source flag
FILLVAL: -128
FORMAT: I2
LABLAXIS: Flag

spin_period:
<<: *support_data_defaults
Expand Down Expand Up @@ -529,78 +512,58 @@ hv_voltage:
VALIDMAX: *max_uint16

glows_time_on_pps_valid:
<<: *support_data_defaults
<<: *flag_data_defaults
CATDESC: GLOWS-time-on-PPS-arrival validity flag (1 - valid, 0 - not valid)
FIELDNAM: GLOWS time validity flag
FILLVAL: -128
FORMAT: I2
LABLAXIS: Flag

time_status_valid:
<<: *support_data_defaults
<<: *flag_data_defaults
CATDESC: Time-status-data-structure-validity flag (1 - valid, 0 - invalid)
FIELDNAM: Time-status-structure-validity flag
FILLVAL: -128
FORMAT: I2
LABLAXIS: Flag

housekeeping_valid:
<<: *support_data_defaults
<<: *flag_data_defaults
CATDESC: GLOWS housekeeping validity flag (1 - valid, 0 - invalid)
FIELDNAM: Housekeeping validity flag
FILLVAL: -128
FORMAT: I2
LABLAXIS: Flag

is_pps_autogenerated:
<<: *support_data_defaults
<<: *flag_data_defaults
CATDESC: Flag indicating whether PPS is autogenerated (1 - autogenerated, 0 - external)
FIELDNAM: Autogenerated-PPS flag
FILLVAL: -128
FORMAT: I2
LABLAXIS: Flag

hv_test_in_progress:
<<: *support_data_defaults
<<: *flag_data_defaults
CATDESC: HV-test-in-progress flag (1 - test is on, 0 - test is off)
FIELDNAM: HV-test-in-progress flag
FILLVAL: -128
FORMAT: I2
LABLAXIS: Flag

pulse_test_in_progress:
<<: *support_data_defaults
<<: *flag_data_defaults
CATDESC: Pulse-test-in-progress flag (1 - test is on, 0 - test is off)
FIELDNAM: Pulse-test-in-progress flag
FILLVAL: -128 # int8_min
FORMAT: I2
LABLAXIS: Flag

memory_error_detected:
<<: *support_data_defaults
<<: *flag_data_defaults
CATDESC: Memory-error flag (1 - error detected, 0 - no error)
FIELDNAM: Memory-error flag
FILLVAL: -128
FORMAT: I2
LABLAXIS: Flag
# End of data_every_second

direct_event_glows_times:
<<: *support_data_defaults
<<: *time_data_defaults
DEPEND_1: within_the_second
CATDESC: IMAP-clock time for direct events
FIELDNAM: IMAP-clock time for direct_events
LABLAXIS: Seconds
FILLVAL: *max_uint32
FORMAT: F16.6
LABLAXIS: seconds
UNITS: seconds
VALIDMAX: *max_uint32_min_one

# TODO: review
direct_event_pulse_lengths:
<<: *default_attrs
<<: *support_data_defaults
DEPEND_1: within_the_second
VAR_TYPE: data
CATDESC: Pulse lengths for direct events
FIELDNAM: Pulse lengths for direct events
LABLAXIS: Pulse lengths

missing_packets_sequence: # Used to be missing_packets_sequence
<<: *support_data_defaults
Expand Down Expand Up @@ -632,18 +595,17 @@ flags_set_onboard:

# TODO review this
histogram_flag_array:
<<: *support_data_defaults
<<: *flag_data_defaults
VALIDMIN: 0
VALIDMAX: 1
FORMAT: I1
FILLVAL: 0

de_flags:
<<: *support_data_defaults
<<: *flag_data_defaults
DEPEND_1: flag_dim
CATDESC: Flags for direct events
FIELDNAM: Flags for direct events
VALIDMIN: 0
VALIDMAX: 1
FORMAT: I1
FILLVAL: 0

flags:
<<: *support_data_defaults
Expand Down
8 changes: 4 additions & 4 deletions imap_processing/glows/l1a/glows_l1a.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ def generate_de_dataset(
direct_event = xr.DataArray(
# Corresponds to DirectEvent (seconds, subseconds, impulse_length, multi_event)
np.arange(4),
name="direct_event",
dims=["direct_event"],
name="direct_event_components",
dims=["direct_event_components"],
attrs=glows_cdf_attributes.get_variable_attributes(
"direct_event_components_attrs"
),
Expand All @@ -255,11 +255,11 @@ def generate_de_dataset(
de = xr.DataArray(
direct_events,
name="direct_events",
dims=["epoch", "within_the_second", "direct_event"],
dims=["epoch", "within_the_second", "direct_event_components"],
coords={
"epoch": epoch_time,
"within_the_second": within_the_second,
"direct_event": direct_event,
"direct_event_components": direct_event,
},
attrs=glows_cdf_attributes.get_variable_attributes("direct_events"),
)
Expand Down
2 changes: 1 addition & 1 deletion imap_processing/glows/l1b/glows_l1b.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def process_de(l1a: xr.Dataset) -> tuple[xr.DataArray]:

# Set the two direct event dimensions. This is the only multi-dimensional L1A
# (input) variable.
input_dims[0] = ["within_the_second", "direct_event"]
input_dims[0] = ["within_the_second", "direct_event_components"]

l1b_fields: tuple = xr.apply_ufunc(
lambda *args: tuple(dataclasses.asdict(DirectEventL1B(*args)).values()),
Expand Down
18 changes: 9 additions & 9 deletions imap_processing/glows/l1b/glows_l1b_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ class HistogramL1B:
number_of_events
total number of events/counts in histogram
imap_spin_angle_bin_cntr
IMAP spin angle ψ for bin centers, see Sec. -
IMAP spin angle ψ for bin centers
filter_temperature_average
block-averaged value, decoded to Celsius degrees using Eq. (47)
filter_temperature_variance
Expand All @@ -432,24 +432,24 @@ class HistogramL1B:
pulse_length_variance
standard deviation (1 sigma), decoded to μs using Eq. (51)
glows_start_time
GLOWS clock, subseconds as decimal part of float, see Sec. -.1
GLOWS clock, subseconds as decimal part of float
glows_time_offset
GLOWS clock, subseconds as decimal part of float, see Sec. -.1
GLOWS clock, subseconds as decimal part of float
imap_start_time
IMAP clock, subseconds as decimal part of float, see Sec. -.1
IMAP clock, subseconds as decimal part of float
imap_time_offset
IMAP clock, subseconds as decimal part of float, see Sec. -.1
IMAP clock, subseconds as decimal part of float
histogram_flag_array
flags for bad-time information per bin, consisting of [is_close_to_uv_source,
is_inside_excluded_region, is_excluded_by_instr_team, is_suspected_transient]
spin_period_ground_average
block-averaged value computed on ground, see Sec. -.1
block-averaged value computed on ground
spin_period_ground_variance
standard deviation (1 sigma), see Sec. -.1
standard deviation (1 sigma)
position_angle_offset_average
block-averaged value in degrees, see Sec. - and -.1
block-averaged value in degrees
position_angle_offset_variance
standard deviation (1 sigma), see Sec. - and -.1
standard deviation (1 sigma)
spin_axis_orientation_variance
standard deviation( 1 sigma): ∆λ, ∆φ for ⟨λ⟩, ⟨φ⟩
spin_axis_orientation_average
Expand Down
Loading

0 comments on commit 724fc90

Please sign in to comment.