Skip to content

Commit

Permalink
Cdf attribute tests (#637)
Browse files Browse the repository at this point in the history
* Adding tests for the CdfAttributeManager class, and ImapCdfAttributes class
  • Loading branch information
anamanica authored Jun 25, 2024
1 parent c12487b commit d012a9b
Show file tree
Hide file tree
Showing 14 changed files with 1,272 additions and 23 deletions.
25 changes: 21 additions & 4 deletions imap_processing/cdf/imap_cdf_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,28 @@


class ImapCdfAttributes(CdfAttributeManager):
"""Contains IMAP specific tools and settings for CDF management."""
"""
Contains IMAP specific tools and settings for CDF management.
def __init__(self):
"""Set the path to the config directory."""
super().__init__(Path(__file__).parent / "config")
Parameters
----------
source_dir : Path or None
Source directory.
"""

def __init__(self, source_dir=None):
"""
Set the path to the config directory.
Parameters
----------
source_dir : Path or None
Source directory.
"""
if source_dir is None:
super().__init__(Path(__file__).parent / "config")
else:
super().__init__(source_dir)

def add_instrument_global_attrs(self, instrument: str):
"""
Expand Down
Empty file.
8 changes: 8 additions & 0 deletions imap_processing/cdf/tests/imap_default_global_cdf_attrs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Project: STP>Solar-Terrestrial Physics
Source_name: IMAP>Interstellar Mapping and Acceleration Probe
Discipline: Solar Physics>Heliospheric Physics
# TODO: CDF docs say this value should be IMAP
Mission_group: IMAP>Interstellar Mapping and Acceleration Probe
PI_name: Dr. David J. McComas
PI_affiliation: Princeton Plasma Physics Laboratory, 100 Stellarator Road, Princeton, NJ 08540
File_naming_convention: source_descriptor_datatype_yyyyMMdd_vNNN
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Project: STP>Solar-Terrestrial Physics
Source_name: IMAP>Interstellar Mapping and Acceleration Probe
Mission_group: Dysfunctional Cats
PI_name: Ana Manica
PI_affiliation: LASP, CU
Data_version: 002
DOI: test
14 changes: 14 additions & 0 deletions imap_processing/cdf/tests/imap_instrument1_global_cdf_attrs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Descriptor: &desc
TEST>Testinstrument
TEXT: &txt >
This file is nothing more than a test yamal. This description? This is a test description.
This Testinstrument will contribute to our understanding of the cdf_attribute_manager.py file.
This test file is led by me, Ana Manica. Lasp undergraduate employee.
I don't have a website. Sorry.

imap_test_T1_test:
Descriptor: *desc
TEXT: *txt
Data_type: T1_test-one>Test-1 test one
Logical_source: imap_test_T1_test
Logical_source_description: IMAP Mission TEST one document Level-T1.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
default_attrs: &default
# Assumed values for all variable attrs unless overwritten
DEPEND_0: test_depend
DISPLAY_TYPE: test_display_type
FILLVAL: -10
FORMAT: I1
VALIDMIN: 0
VALIDMAX: 10
VAR_TYPE: test_var_type

test_field_1:
<<: *default
CATDESC: test time
FIELDNAM: test_field_1
LABLAXIS: test_labaxis
UNITS: test_units
VAR_TYPE: test_variable_type
SCALETYP: test_scaletyp
MONOTON: test_monoton
TIME_BASE: 10
TIME_SCALE: test_time_scale
REFERENCE_POSITION: test_reference_position
NOT_REQUIRED: test_not_required
23 changes: 23 additions & 0 deletions imap_processing/cdf/tests/imap_instrument2_global_cdf_attrs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
instrument_base: &instrument_base
Descriptor: SWE>Solar Wind Electron
TEXT: >
The IMAP Solar Wind Electron (SWE) instrument measures the solar wind electrons
in the heliosphere. SWE will contribute to our understanding of the acceleration
and transport of charged particles in the heliosphere.
SWE design and assembly is led by the Princeton Plasma Physics Laboratory. See
https://imap.princeton.edu/instruments/swe for more details.
Instrument_type: "Particles (space)"

imap_swe_l1a_sci:
<<: *instrument_base
Data_level: 1A
Data_type: L1A_SCI>Level-1A Science data
Logical_source: imap_swe_l1a_sci
Logical_source_description: SWE Instrument Level-1A Science Data

imap_swe_l1b_sci:
<<: *instrument_base
Data_level: 1A
Data_type: L1B_SCI>Level-1B Science data
Logical_source: imap_swe_l1b_sci
Logical_source_description: SWE Instrument Level-1B Science Data
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
default_attrs: &default
# Assumed values for all variable attrs unless overwritten
DEPEND_0: epoch
DISPLAY_TYPE: time_series
FILLVAL: -9223372036854775808
FORMAT: I19
VALIDMIN: 0
VALIDMAX: 9223372036854775807
VAR_TYPE: data

epoch:
<<: *default
CATDESC: Time, number of nanoseconds since J2000 with leap seconds included
FIELDNAM: epoch
LABLAXIS: epoch
UNITS: ns
VAR_TYPE: support_data
SCALETYP: linear
MONOTON: INCREASE
TIME_BASE: J2000
TIME_SCALE: Terrestrial Time
REFERENCE_POSITION: Rotating Earth Geoid

x_front:
<<: *default
CATDESC: x front position
FIELDNAM: Event x-position on front foil
LABLAXIS: x front position
# TODO: come back to format
UNITS: mm
26 changes: 26 additions & 0 deletions imap_processing/cdf/tests/imap_test_global.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Descriptor: &desc
TEST>Testinstrument
TEXT: &txt >
This file is nothing more than a test yamal. This description? This is a test description.
This Testinstrument will contribute to our understanding of the cdf_attribute_manager.py file.
This test file is led by me, Ana Manica. Lasp undergraduate employee.
I don't have a website. Sorry.

imap_test_T1_test:
Descriptor: *desc
TEXT: *txt
Data_type: T1_test-one>Test-1 test one
Logical_source: imap_test_T1_test
Logical_source_description: IMAP Mission TEST one document Level-T1.

imap_test_T2_test:
Descriptor: *desc
TEXT: *txt
Data_type: T2_test-two>Test-2 test two
Logical_source: imap_test_T2_test
Logical_source_description: IMAP Mission TEST two document Level-T2.
LINK_TEXT: Test two additional info

imap_test_T3_test:
Descriptor: *desc
TEXT: *txt
36 changes: 36 additions & 0 deletions imap_processing/cdf/tests/imap_test_variable.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
default_attrs: &default
# Assumed values for all variable attrs unless overwritten
DEPEND_0: test_depend
DISPLAY_TYPE: test_display_type
FILLVAL: -10
FORMAT: I1
VALIDMIN: 0
VALIDMAX: 10
VAR_TYPE: test_var_type

test_field_1:
<<: *default
CATDESC: test time
FIELDNAM: test_field_1
LABLAXIS: test_labaxis
UNITS: test_units
VAR_TYPE: test_variable_type
SCALETYP: test_scaletyp
MONOTON: test_monoton
TIME_BASE: 10
TIME_SCALE: test_time_scale
REFERENCE_POSITION: test_reference_position
NOT_REQUIRED: test_not_required

test_field_2:
<<: *default
CATDESC: test time 2
FIELDNAM: test_field_2
LABLAXIS: test_labaxis_2
UNITS: test_units_2
VAR_TYPE: test_variable_type_2
SCALETYP: test_scaletyp_2
MONOTON: test_monoton_2
TIME_BASE: 11
TIME_SCALE: test_time_scale_2
REFERENCE_POSITION: test_reference_position_2
Loading

0 comments on commit d012a9b

Please sign in to comment.