imap-processing 0.9.0__py3-none-any.whl → 0.11.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of imap-processing might be problematic. Click here for more details.
- imap_processing/_version.py +2 -2
- imap_processing/cdf/config/imap_codice_l1a_variable_attrs.yaml +749 -442
- imap_processing/cdf/config/imap_glows_global_cdf_attrs.yaml +7 -0
- imap_processing/cdf/config/imap_glows_l1a_variable_attrs.yaml +8 -2
- imap_processing/cdf/config/imap_glows_l1b_variable_attrs.yaml +0 -1
- imap_processing/cdf/config/imap_glows_l2_variable_attrs.yaml +358 -0
- imap_processing/cdf/config/imap_hi_variable_attrs.yaml +59 -25
- imap_processing/cdf/config/imap_hit_global_cdf_attrs.yaml +22 -0
- imap_processing/cdf/config/imap_idex_l1a_variable_attrs.yaml +32 -8
- imap_processing/cdf/config/imap_idex_l1b_variable_attrs.yaml +94 -5
- imap_processing/cdf/config/imap_lo_l1a_variable_attrs.yaml +65 -37
- imap_processing/cdf/config/imap_swapi_variable_attrs.yaml +16 -1
- imap_processing/cdf/config/imap_swe_global_cdf_attrs.yaml +7 -0
- imap_processing/cdf/config/imap_swe_l1a_variable_attrs.yaml +14 -14
- imap_processing/cdf/config/imap_swe_l1b_variable_attrs.yaml +25 -24
- imap_processing/cdf/config/imap_swe_l2_variable_attrs.yaml +238 -0
- imap_processing/cdf/config/imap_ultra_l1b_variable_attrs.yaml +100 -92
- imap_processing/cdf/utils.py +2 -2
- imap_processing/cli.py +45 -9
- imap_processing/codice/codice_l1a.py +104 -58
- imap_processing/codice/constants.py +111 -155
- imap_processing/codice/data/esa_sweep_values.csv +256 -256
- imap_processing/codice/data/lo_stepping_values.csv +128 -128
- imap_processing/ena_maps/ena_maps.py +519 -0
- imap_processing/ena_maps/utils/map_utils.py +145 -0
- imap_processing/ena_maps/utils/spatial_utils.py +226 -0
- imap_processing/glows/__init__.py +3 -0
- imap_processing/glows/ancillary/imap_glows_pipeline_settings_v001.json +52 -0
- imap_processing/glows/l1a/glows_l1a.py +72 -14
- imap_processing/glows/l1b/glows_l1b.py +2 -1
- imap_processing/glows/l1b/glows_l1b_data.py +25 -1
- imap_processing/glows/l2/glows_l2.py +324 -0
- imap_processing/glows/l2/glows_l2_data.py +156 -51
- imap_processing/hi/l1a/science_direct_event.py +57 -51
- imap_processing/hi/l1b/hi_l1b.py +43 -28
- imap_processing/hi/l1c/hi_l1c.py +225 -42
- imap_processing/hi/utils.py +20 -3
- imap_processing/hit/l0/constants.py +2 -2
- imap_processing/hit/l0/decom_hit.py +1 -1
- imap_processing/hit/l1a/hit_l1a.py +94 -13
- imap_processing/hit/l1b/hit_l1b.py +158 -9
- imap_processing/ialirt/l0/process_codicehi.py +156 -0
- imap_processing/ialirt/l0/process_codicelo.py +5 -2
- imap_processing/ialirt/packet_definitions/ialirt.xml +28 -20
- imap_processing/ialirt/packet_definitions/ialirt_codicehi.xml +241 -0
- imap_processing/ialirt/packet_definitions/ialirt_swapi.xml +170 -0
- imap_processing/ialirt/packet_definitions/ialirt_swe.xml +258 -0
- imap_processing/ialirt/process_ephemeris.py +72 -40
- imap_processing/idex/decode.py +241 -0
- imap_processing/idex/idex_l1a.py +143 -81
- imap_processing/idex/idex_l1b.py +244 -10
- imap_processing/lo/l0/lo_science.py +61 -0
- imap_processing/lo/l1a/lo_l1a.py +98 -10
- imap_processing/lo/l1b/lo_l1b.py +2 -2
- imap_processing/lo/l1c/lo_l1c.py +2 -2
- imap_processing/lo/packet_definitions/lo_xtce.xml +1082 -9178
- imap_processing/mag/l0/decom_mag.py +2 -2
- imap_processing/mag/l1a/mag_l1a.py +7 -7
- imap_processing/mag/l1a/mag_l1a_data.py +62 -30
- imap_processing/mag/l1b/mag_l1b.py +11 -6
- imap_processing/quality_flags.py +18 -3
- imap_processing/spice/geometry.py +149 -177
- imap_processing/spice/kernels.py +26 -26
- imap_processing/spice/spin.py +233 -0
- imap_processing/spice/time.py +96 -31
- imap_processing/swapi/l1/swapi_l1.py +60 -31
- imap_processing/swapi/packet_definitions/swapi_packet_definition.xml +363 -384
- imap_processing/swe/l1a/swe_l1a.py +8 -3
- imap_processing/swe/l1a/swe_science.py +24 -24
- imap_processing/swe/l1b/swe_l1b.py +2 -1
- imap_processing/swe/l1b/swe_l1b_science.py +181 -122
- imap_processing/swe/l2/swe_l2.py +337 -70
- imap_processing/swe/utils/swe_utils.py +28 -0
- imap_processing/tests/cdf/test_utils.py +2 -2
- imap_processing/tests/codice/conftest.py +20 -17
- imap_processing/tests/codice/data/validation/imap_codice_l1a_hskp_20241110193622_v0.0.0.cdf +0 -0
- imap_processing/tests/codice/data/validation/imap_codice_l1a_lo-counters-aggregated_20241110193700_v0.0.0.cdf +0 -0
- imap_processing/tests/codice/data/validation/imap_codice_l1a_lo-counters-singles_20241110193700_v0.0.0.cdf +0 -0
- imap_processing/tests/codice/data/validation/imap_codice_l1a_lo-nsw-angular_20241110193700_v0.0.0.cdf +0 -0
- imap_processing/tests/codice/data/validation/imap_codice_l1a_lo-nsw-priority_20241110193700_v0.0.0.cdf +0 -0
- imap_processing/tests/codice/data/validation/imap_codice_l1a_lo-nsw-species_20241110193700_v0.0.0.cdf +0 -0
- imap_processing/tests/codice/data/validation/imap_codice_l1a_lo-sw-angular_20241110193700_v0.0.0.cdf +0 -0
- imap_processing/tests/codice/data/validation/imap_codice_l1a_lo-sw-priority_20241110193700_v0.0.0.cdf +0 -0
- imap_processing/tests/codice/data/validation/imap_codice_l1a_lo-sw-species_20241110193700_v0.0.0.cdf +0 -0
- imap_processing/tests/codice/test_codice_l0.py +55 -121
- imap_processing/tests/codice/test_codice_l1a.py +147 -59
- imap_processing/tests/conftest.py +81 -22
- imap_processing/tests/ena_maps/test_ena_maps.py +309 -0
- imap_processing/tests/ena_maps/test_map_utils.py +286 -0
- imap_processing/tests/ena_maps/test_spatial_utils.py +161 -0
- imap_processing/tests/glows/conftest.py +7 -1
- imap_processing/tests/glows/test_glows_l1a_cdf.py +3 -7
- imap_processing/tests/glows/test_glows_l1a_data.py +34 -6
- imap_processing/tests/glows/test_glows_l1b_data.py +29 -17
- imap_processing/tests/glows/test_glows_l2.py +101 -0
- imap_processing/tests/hi/conftest.py +3 -3
- imap_processing/tests/hi/data/l1/imap_hi_l1b_45sensor-de_20250415_v999.cdf +0 -0
- imap_processing/tests/hi/data/l1/imap_his_pset-calibration-prod-config_20240101_v001.csv +31 -0
- imap_processing/tests/hi/test_hi_l1b.py +14 -9
- imap_processing/tests/hi/test_hi_l1c.py +136 -36
- imap_processing/tests/hi/test_l1a.py +0 -2
- imap_processing/tests/hi/test_science_direct_event.py +18 -14
- imap_processing/tests/hi/test_utils.py +16 -11
- imap_processing/tests/hit/helpers/__init__.py +0 -0
- imap_processing/tests/hit/helpers/l1_validation.py +405 -0
- imap_processing/tests/hit/test_data/sci_sample.ccsds +0 -0
- imap_processing/tests/hit/test_decom_hit.py +8 -10
- imap_processing/tests/hit/test_hit_l1a.py +117 -180
- imap_processing/tests/hit/test_hit_l1b.py +149 -55
- imap_processing/tests/hit/validation_data/hit_l1b_standard_sample2_nsrl_v4_3decimals.csv +62 -0
- imap_processing/tests/hit/validation_data/sci_sample_raw.csv +62 -0
- imap_processing/tests/ialirt/test_data/l0/20240827095047_SWE_IALIRT_packet.bin +0 -0
- imap_processing/tests/ialirt/test_data/l0/BinLog CCSDS_FRAG_TLM_20240826_152323Z_IALIRT_data_for_SDC.bin +0 -0
- imap_processing/tests/ialirt/test_data/l0/eu_SWP_IAL_20240826_152033.csv +644 -0
- imap_processing/tests/ialirt/test_data/l0/hi_fsw_view_1_ccsds.bin +0 -0
- imap_processing/tests/ialirt/test_data/l0/idle_export_eu.SWE_IALIRT_20240827_093852.csv +914 -0
- imap_processing/tests/ialirt/test_data/l0/imap_codice_l1a_hi-ialirt_20240523200000_v0.0.0.cdf +0 -0
- imap_processing/tests/ialirt/unit/test_process_codicehi.py +106 -0
- imap_processing/tests/ialirt/unit/test_process_ephemeris.py +33 -5
- imap_processing/tests/ialirt/unit/test_process_swapi.py +85 -0
- imap_processing/tests/ialirt/unit/test_process_swe.py +106 -0
- imap_processing/tests/idex/conftest.py +29 -1
- imap_processing/tests/idex/test_data/compressed_2023_102_14_24_55.pkts +0 -0
- imap_processing/tests/idex/test_data/non_compressed_2023_102_14_22_26.pkts +0 -0
- imap_processing/tests/idex/test_idex_l0.py +6 -3
- imap_processing/tests/idex/test_idex_l1a.py +151 -1
- imap_processing/tests/idex/test_idex_l1b.py +124 -2
- imap_processing/tests/lo/test_lo_l1a.py +62 -2
- imap_processing/tests/lo/test_lo_science.py +85 -0
- imap_processing/tests/lo/validation_data/Instrument_FM1_T104_R129_20240803_ILO_SPIN_EU.csv +2 -0
- imap_processing/tests/mag/conftest.py +16 -0
- imap_processing/tests/mag/test_mag_decom.py +6 -4
- imap_processing/tests/mag/test_mag_l1a.py +36 -7
- imap_processing/tests/mag/test_mag_l1b.py +55 -4
- imap_processing/tests/mag/test_mag_validation.py +148 -0
- imap_processing/tests/mag/validation/L1a/T001/all_p_ones.txt +19200 -0
- imap_processing/tests/mag/validation/L1a/T001/mag-l0-l1a-t001-in.bin +0 -0
- imap_processing/tests/mag/validation/L1a/T001/mag-l0-l1a-t001-out.csv +17 -0
- imap_processing/tests/mag/validation/L1a/T002/all_n_ones.txt +19200 -0
- imap_processing/tests/mag/validation/L1a/T002/mag-l0-l1a-t002-in.bin +0 -0
- imap_processing/tests/mag/validation/L1a/T002/mag-l0-l1a-t002-out.csv +17 -0
- imap_processing/tests/mag/validation/L1a/T003/field_like.txt +19200 -0
- imap_processing/tests/mag/validation/L1a/T003/mag-l0-l1a-t003-in.bin +0 -0
- imap_processing/tests/mag/validation/L1a/T003/mag-l0-l1a-t003-out.csv +17 -0
- imap_processing/tests/mag/validation/L1a/T004/field_like.txt +19200 -0
- imap_processing/tests/mag/validation/L1a/T004/mag-l0-l1a-t004-in.bin +0 -0
- imap_processing/tests/mag/validation/L1a/T004/mag-l0-l1a-t004-out.csv +17 -0
- imap_processing/tests/mag/validation/L1a/T005/field_like_range_change.txt +19200 -0
- imap_processing/tests/mag/validation/L1a/T005/mag-l0-l1a-t005-in.bin +0 -0
- imap_processing/tests/mag/validation/L1a/T005/mag-l0-l1a-t005-out.csv +17 -0
- imap_processing/tests/mag/validation/L1a/T006/hdr_field.txt +19200 -0
- imap_processing/tests/mag/validation/L1a/T006/mag-l0-l1a-t006-in.bin +0 -0
- imap_processing/tests/mag/validation/L1a/T006/mag-l0-l1a-t006-out.csv +17 -0
- imap_processing/tests/mag/validation/L1a/T007/hdr_field_and_range_change.txt +19200 -0
- imap_processing/tests/mag/validation/L1a/T007/mag-l0-l1a-t007-in.bin +0 -0
- imap_processing/tests/mag/validation/L1a/T007/mag-l0-l1a-t007-out.csv +17 -0
- imap_processing/tests/mag/validation/L1a/T008/field_like_range_change.txt +19200 -0
- imap_processing/tests/mag/validation/L1a/T008/mag-l0-l1a-t008-in.bin +0 -0
- imap_processing/tests/mag/validation/L1a/T008/mag-l0-l1a-t008-out.csv +17 -0
- imap_processing/tests/mag/validation/L1b/T009/data.bin +0 -0
- imap_processing/tests/mag/validation/L1b/T009/field_like_all_ranges.txt +19200 -0
- imap_processing/tests/mag/validation/L1b/T009/mag-l1a-l1b-t009-in.csv +17 -0
- imap_processing/tests/mag/validation/L1b/T009/mag-l1a-l1b-t009-magi-out.csv +17 -0
- imap_processing/tests/mag/validation/L1b/T009/mag-l1a-l1b-t009-mago-out.csv +17 -0
- imap_processing/tests/mag/validation/L1b/T010/data.bin +0 -0
- imap_processing/tests/mag/validation/L1b/T010/field_like_all_ranges.txt +19200 -0
- imap_processing/tests/mag/validation/L1b/T010/mag-l1a-l1b-t010-in.csv +17 -0
- imap_processing/tests/mag/validation/L1b/T010/mag-l1a-l1b-t010-magi-out.csv +17 -0
- imap_processing/tests/mag/validation/L1b/T010/mag-l1a-l1b-t010-mago-out.csv +17 -0
- imap_processing/tests/mag/validation/L1b/T011/data.bin +0 -0
- imap_processing/tests/mag/validation/L1b/T011/field_like_all_ranges.txt +19200 -0
- imap_processing/tests/mag/validation/L1b/T011/mag-l1a-l1b-t011-in.csv +17 -0
- imap_processing/tests/mag/validation/L1b/T011/mag-l1a-l1b-t011-magi-out.csv +17 -0
- imap_processing/tests/mag/validation/L1b/T011/mag-l1a-l1b-t011-mago-out.csv +17 -0
- imap_processing/tests/spice/test_geometry.py +128 -133
- imap_processing/tests/spice/test_kernels.py +37 -37
- imap_processing/tests/spice/test_spin.py +184 -0
- imap_processing/tests/spice/test_time.py +43 -20
- imap_processing/tests/swapi/test_swapi_l1.py +11 -10
- imap_processing/tests/swapi/test_swapi_l2.py +13 -3
- imap_processing/tests/swe/test_swe_l1a.py +1 -1
- imap_processing/tests/swe/test_swe_l1b.py +20 -3
- imap_processing/tests/swe/test_swe_l1b_science.py +54 -35
- imap_processing/tests/swe/test_swe_l2.py +148 -5
- imap_processing/tests/test_cli.py +39 -7
- imap_processing/tests/test_quality_flags.py +19 -19
- imap_processing/tests/test_utils.py +3 -2
- imap_processing/tests/ultra/test_data/l0/ultra45_raw_sc_ultrarawimg_withFSWcalcs_FM45_40P_Phi28p5_BeamCal_LinearScan_phi2850_theta-000_20240207T102740.csv +3314 -3314
- imap_processing/tests/ultra/test_data/mock_data.py +161 -0
- imap_processing/tests/ultra/unit/conftest.py +73 -0
- imap_processing/tests/ultra/unit/test_badtimes.py +58 -0
- imap_processing/tests/ultra/unit/test_cullingmask.py +87 -0
- imap_processing/tests/ultra/unit/test_de.py +61 -60
- imap_processing/tests/ultra/unit/test_ultra_l1a.py +3 -3
- imap_processing/tests/ultra/unit/test_ultra_l1b.py +51 -77
- imap_processing/tests/ultra/unit/test_ultra_l1b_annotated.py +5 -5
- imap_processing/tests/ultra/unit/test_ultra_l1b_culling.py +114 -0
- imap_processing/tests/ultra/unit/test_ultra_l1b_extended.py +86 -26
- imap_processing/tests/ultra/unit/test_ultra_l1c.py +1 -1
- imap_processing/tests/ultra/unit/test_ultra_l1c_pset_bins.py +3 -3
- imap_processing/ultra/constants.py +11 -1
- imap_processing/ultra/l1a/ultra_l1a.py +2 -2
- imap_processing/ultra/l1b/badtimes.py +22 -5
- imap_processing/ultra/l1b/cullingmask.py +31 -5
- imap_processing/ultra/l1b/de.py +32 -37
- imap_processing/ultra/l1b/extendedspin.py +44 -20
- imap_processing/ultra/l1b/ultra_l1b.py +21 -22
- imap_processing/ultra/l1b/ultra_l1b_culling.py +190 -0
- imap_processing/ultra/l1b/ultra_l1b_extended.py +81 -30
- imap_processing/ultra/l1c/histogram.py +6 -2
- imap_processing/ultra/l1c/pset.py +6 -2
- imap_processing/ultra/l1c/ultra_l1c.py +2 -3
- imap_processing/ultra/l1c/ultra_l1c_pset_bins.py +4 -3
- imap_processing/ultra/utils/ultra_l1_utils.py +70 -14
- imap_processing/utils.py +2 -2
- {imap_processing-0.9.0.dist-info → imap_processing-0.11.0.dist-info}/METADATA +7 -2
- {imap_processing-0.9.0.dist-info → imap_processing-0.11.0.dist-info}/RECORD +235 -152
- imap_processing/tests/codice/data/eu_unit_lookup_table.csv +0 -101
- imap_processing/tests/codice/data/idle_export_eu.COD_NHK_20230822_122700 2.csv +0 -100
- imap_processing/tests/codice/data/idle_export_raw.COD_NHK_20230822_122700.csv +0 -100
- imap_processing/tests/codice/data/imap_codice_l0_raw_20241110_v001.pkts +0 -0
- imap_processing/tests/hi/test_data/l1a/imap_hi_l1a_45sensor-de_20250415_v000.cdf +0 -0
- imap_processing/tests/hit/test_data/sci_sample1.ccsds +0 -0
- imap_processing/tests/ultra/unit/test_spatial_utils.py +0 -125
- imap_processing/ultra/utils/spatial_utils.py +0 -221
- /imap_processing/tests/hi/{test_data → data}/l0/20231030_H45_APP_NHK.bin +0 -0
- /imap_processing/tests/hi/{test_data → data}/l0/20231030_H45_APP_NHK.csv +0 -0
- /imap_processing/tests/hi/{test_data → data}/l0/20231030_H45_SCI_CNT.bin +0 -0
- /imap_processing/tests/hi/{test_data → data}/l0/20231030_H45_SCI_DE.bin +0 -0
- /imap_processing/tests/hi/{test_data → data}/l0/H90_NHK_20241104.bin +0 -0
- /imap_processing/tests/hi/{test_data → data}/l0/H90_sci_cnt_20241104.bin +0 -0
- /imap_processing/tests/hi/{test_data → data}/l0/H90_sci_de_20241104.bin +0 -0
- /imap_processing/tests/hi/{test_data → data}/l0/README.txt +0 -0
- /imap_processing/tests/idex/{imap_idex_l0_raw_20231214_v001.pkts → test_data/imap_idex_l0_raw_20231214_v001.pkts} +0 -0
- /imap_processing/tests/idex/{impact_14_tof_high_data.txt → test_data/impact_14_tof_high_data.txt} +0 -0
- /imap_processing/tests/mag/{imap_mag_l1a_norm-magi_20251017_v001.cdf → validation/imap_mag_l1a_norm-magi_20251017_v001.cdf} +0 -0
- /imap_processing/tests/mag/{mag_l0_test_data.pkts → validation/mag_l0_test_data.pkts} +0 -0
- /imap_processing/tests/mag/{mag_l0_test_output.csv → validation/mag_l0_test_output.csv} +0 -0
- /imap_processing/tests/mag/{mag_l1_test_data.pkts → validation/mag_l1_test_data.pkts} +0 -0
- /imap_processing/tests/mag/{mag_l1a_test_output.csv → validation/mag_l1a_test_output.csv} +0 -0
- {imap_processing-0.9.0.dist-info → imap_processing-0.11.0.dist-info}/LICENSE +0 -0
- {imap_processing-0.9.0.dist-info → imap_processing-0.11.0.dist-info}/WHEEL +0 -0
- {imap_processing-0.9.0.dist-info → imap_processing-0.11.0.dist-info}/entry_points.txt +0 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"""Mock expected data for use in some tests."""
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
import spiceypy as spice
|
|
5
|
+
import xarray as xr
|
|
6
|
+
|
|
7
|
+
from imap_processing.spice.kernels import ensure_spice
|
|
8
|
+
from imap_processing.ultra.l1c.ultra_l1c_pset_bins import build_energy_bins
|
|
9
|
+
|
|
10
|
+
DEFAULT_SPACING_DEG_L1C = 0.5
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def mock_l1c_pset_product(
|
|
14
|
+
spacing_deg: float = DEFAULT_SPACING_DEG_L1C,
|
|
15
|
+
stripe_center_lon: int = 0,
|
|
16
|
+
timestr: str = "2025-01-01T00:00:00",
|
|
17
|
+
head: str = "45",
|
|
18
|
+
) -> xr.Dataset:
|
|
19
|
+
"""
|
|
20
|
+
Mock the L1C PSET product with recognizable but unrealistic counts.
|
|
21
|
+
|
|
22
|
+
This is not meant to perfectly mimic the real data, but to provide a
|
|
23
|
+
recognizable structure for L2 testing purposes.
|
|
24
|
+
Function will produce an xarray.Dataset with at least the variables and shapes:
|
|
25
|
+
counts: (num_lat_bins, num_lon_bins, num_energy_bins)
|
|
26
|
+
exposure_time: (num_lat_bins, num_lon_bins)
|
|
27
|
+
sensitivity: (num_lat_bins, num_lon_bins, num_energy_bins)
|
|
28
|
+
|
|
29
|
+
and the coordinate variables:
|
|
30
|
+
latitude: (num_lat_bins)
|
|
31
|
+
longitude: (num_lon_bins)
|
|
32
|
+
energy: (determined by build_energy_bins function)
|
|
33
|
+
head: Either '45' or '90'. Default is '45'.
|
|
34
|
+
|
|
35
|
+
as well as the epoch (assumed to be a single time for each product).
|
|
36
|
+
|
|
37
|
+
The counts are generated along a stripe, centered at a given longitude.
|
|
38
|
+
This stripe can be thought of as a 'vertical' line if the lon/az axis is plotted
|
|
39
|
+
as the x-axis and the lat/el axis is plotted as the y-axis. See the figure below.
|
|
40
|
+
|
|
41
|
+
^ Elevation/Latitude
|
|
42
|
+
|
|
|
43
|
+
| 000000000000002468642000000000000000000000000000000
|
|
44
|
+
| 000000000000002468642000000000000000000000000000000
|
|
45
|
+
| 000000000000002468642000000000000000000000000000000
|
|
46
|
+
| 000000000000002468642000000000000000000000000000000
|
|
47
|
+
| 000000000000002468642000000000000000000000000000000
|
|
48
|
+
| 000000000000002468642000000000000000000000000000000
|
|
49
|
+
| 000000000000002468642000000000000000000000000000000
|
|
50
|
+
--------------------------------------------------------->
|
|
51
|
+
Azimuth/Longitude ->
|
|
52
|
+
|
|
53
|
+
Fig. 1: Example of the '90' sensor head stripe
|
|
54
|
+
|
|
55
|
+
To distinguish between the two sensor heads, the counts are halved in the '45' head
|
|
56
|
+
at latitudes above 0 degrees.
|
|
57
|
+
|
|
58
|
+
^ Elevation/Latitude
|
|
59
|
+
|
|
|
60
|
+
| 000000000000000000000000000123432100000000000000000
|
|
61
|
+
| 000000000000000000000000000123432100000000000000000
|
|
62
|
+
| 000000000000000000000000000123432100000000000000000
|
|
63
|
+
| 000000000000000000000000000123432100000000000000000
|
|
64
|
+
| 000000000000000000000000000246864200000000000000000
|
|
65
|
+
| 000000000000000000000000000246864200000000000000000
|
|
66
|
+
| 000000000000000000000000000246864200000000000000000
|
|
67
|
+
--------------------------------------------------------->
|
|
68
|
+
Azimuth/Longitude ->
|
|
69
|
+
|
|
70
|
+
Fig. 2: Example of the '45' sensor head stripe
|
|
71
|
+
|
|
72
|
+
Parameters
|
|
73
|
+
----------
|
|
74
|
+
spacing_deg : float, optional
|
|
75
|
+
The bin spacing in degrees (default is 0.5 degrees).
|
|
76
|
+
stripe_center_lon : int, optional
|
|
77
|
+
The center longitude of the stripe in degrees (default is 0).
|
|
78
|
+
timestr : str, optional
|
|
79
|
+
The time string for the epoch (default is "2025-01-01T00:00:00").
|
|
80
|
+
head : str, optional
|
|
81
|
+
The sensor head (either '45' or '90') (default is '45').
|
|
82
|
+
"""
|
|
83
|
+
num_lat_bins = int(180 / spacing_deg)
|
|
84
|
+
num_lon_bins = int(360 / spacing_deg)
|
|
85
|
+
stripe_center_lon_bin = int(stripe_center_lon / spacing_deg)
|
|
86
|
+
|
|
87
|
+
_, energy_bin_midpoints = build_energy_bins()
|
|
88
|
+
energy_bin_midpoints = energy_bin_midpoints[1:]
|
|
89
|
+
num_energy_bins = len(energy_bin_midpoints)
|
|
90
|
+
|
|
91
|
+
grid_shape = (num_lon_bins, num_lat_bins, num_energy_bins)
|
|
92
|
+
|
|
93
|
+
def get_binomial_counts(distance_scaling, lon_bin, central_lon_bin):
|
|
94
|
+
# Note, this is not quite correct, as it won't wrap around at 720
|
|
95
|
+
distance_lon_bin = np.abs(lon_bin - central_lon_bin)
|
|
96
|
+
|
|
97
|
+
rng = np.random.default_rng(seed=42)
|
|
98
|
+
return rng.binomial(
|
|
99
|
+
n=50,
|
|
100
|
+
p=np.maximum(1 - (distance_lon_bin / distance_scaling), 0.01),
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
counts = np.fromfunction(
|
|
104
|
+
lambda lon_bin, lat_bin, energy_bin: get_binomial_counts(
|
|
105
|
+
distance_scaling=20,
|
|
106
|
+
lon_bin=lon_bin,
|
|
107
|
+
central_lon_bin=stripe_center_lon_bin,
|
|
108
|
+
),
|
|
109
|
+
shape=grid_shape,
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
exposure_time = np.zeros(grid_shape[:2]) + 0.1
|
|
113
|
+
if head == "90":
|
|
114
|
+
exposure_time[
|
|
115
|
+
stripe_center_lon_bin : stripe_center_lon_bin + int(20 / spacing_deg),
|
|
116
|
+
:,
|
|
117
|
+
] = 1
|
|
118
|
+
else:
|
|
119
|
+
counts[
|
|
120
|
+
:,
|
|
121
|
+
: int(90 / spacing_deg),
|
|
122
|
+
:,
|
|
123
|
+
] / 2
|
|
124
|
+
counts = counts.astype(int)
|
|
125
|
+
exposure_time[
|
|
126
|
+
stripe_center_lon_bin : stripe_center_lon_bin + int(70 / spacing_deg),
|
|
127
|
+
: int(90 / spacing_deg),
|
|
128
|
+
] = 1
|
|
129
|
+
|
|
130
|
+
sensitivity = np.ones(grid_shape)
|
|
131
|
+
|
|
132
|
+
pset_product = xr.Dataset(
|
|
133
|
+
{
|
|
134
|
+
"counts": (
|
|
135
|
+
["azimuth_bin_center", "elevation_bin_center", "energy_bin_center"],
|
|
136
|
+
counts,
|
|
137
|
+
),
|
|
138
|
+
"exposure_time": (
|
|
139
|
+
["azimuth_bin_center", "elevation_bin_center"],
|
|
140
|
+
exposure_time,
|
|
141
|
+
),
|
|
142
|
+
"sensitivity": (
|
|
143
|
+
["azimuth_bin_center", "elevation_bin_center", "energy_bin_center"],
|
|
144
|
+
sensitivity,
|
|
145
|
+
),
|
|
146
|
+
"epoch": ensure_spice(spice.str2et, time_kernels_only=True)(timestr),
|
|
147
|
+
},
|
|
148
|
+
coords={
|
|
149
|
+
"azimuth_bin_center": np.arange(0 + spacing_deg / 2, 360, spacing_deg),
|
|
150
|
+
"elevation_bin_center": np.arange(-90 + spacing_deg / 2, 90, spacing_deg),
|
|
151
|
+
"energy_bin_center": energy_bin_midpoints,
|
|
152
|
+
},
|
|
153
|
+
attrs={
|
|
154
|
+
"Logical_file_id": (
|
|
155
|
+
f"imap_ultra_l1c_{head}sensor-pset_{timestr[:4]}"
|
|
156
|
+
f"{timestr[5:7]}{timestr[8:10]}-repointNNNNN_vNNN"
|
|
157
|
+
)
|
|
158
|
+
},
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
return pset_product
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"""Pytest plugin module for test data paths"""
|
|
2
2
|
|
|
3
|
+
from unittest import mock
|
|
4
|
+
|
|
3
5
|
import numpy as np
|
|
4
6
|
import pytest
|
|
5
7
|
|
|
@@ -8,8 +10,10 @@ from imap_processing.ultra.l0.decom_ultra import process_ultra_apids
|
|
|
8
10
|
from imap_processing.ultra.l0.ultra_utils import (
|
|
9
11
|
ULTRA_AUX,
|
|
10
12
|
ULTRA_EVENTS,
|
|
13
|
+
ULTRA_RATES,
|
|
11
14
|
)
|
|
12
15
|
from imap_processing.ultra.l1a import ultra_l1a
|
|
16
|
+
from imap_processing.ultra.l1b.ultra_l1b import ultra_l1b
|
|
13
17
|
from imap_processing.utils import group_by_apid
|
|
14
18
|
|
|
15
19
|
|
|
@@ -165,3 +169,72 @@ def de_dataset(ccsds_path_theta_0, xtce_path):
|
|
|
165
169
|
dataset["START_TYPE"] != np.iinfo(np.int64).min, drop=True
|
|
166
170
|
)
|
|
167
171
|
return l1a_de_dataset
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
@pytest.fixture()
|
|
175
|
+
def rates_dataset(ccsds_path_theta_0, xtce_path):
|
|
176
|
+
"""L1A test data"""
|
|
177
|
+
packets = decom.decom_packets(ccsds_path_theta_0, xtce_path)
|
|
178
|
+
grouped_data = group_by_apid(packets)
|
|
179
|
+
decom_ultra_rates = process_ultra_apids(
|
|
180
|
+
grouped_data[ULTRA_RATES.apid[0]], ULTRA_RATES.apid[0]
|
|
181
|
+
)
|
|
182
|
+
l1a_rates_dataset = ultra_l1a.create_dataset(
|
|
183
|
+
{
|
|
184
|
+
ULTRA_RATES.apid[0]: decom_ultra_rates,
|
|
185
|
+
}
|
|
186
|
+
)
|
|
187
|
+
return l1a_rates_dataset
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
@pytest.fixture()
|
|
191
|
+
def aux_dataset(ccsds_path_theta_0, xtce_path):
|
|
192
|
+
"""L1A test data"""
|
|
193
|
+
packets = decom.decom_packets(ccsds_path_theta_0, xtce_path)
|
|
194
|
+
grouped_data = group_by_apid(packets)
|
|
195
|
+
decom_ultra_aux = process_ultra_apids(
|
|
196
|
+
grouped_data[ULTRA_AUX.apid[0]], ULTRA_AUX.apid[0]
|
|
197
|
+
)
|
|
198
|
+
l1a_aux_dataset = ultra_l1a.create_dataset(
|
|
199
|
+
{
|
|
200
|
+
ULTRA_AUX.apid[0]: decom_ultra_aux,
|
|
201
|
+
}
|
|
202
|
+
)
|
|
203
|
+
return l1a_aux_dataset
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
@pytest.fixture()
|
|
207
|
+
@mock.patch("imap_processing.ultra.l1b.de.get_annotated_particle_velocity")
|
|
208
|
+
def l1b_datasets(
|
|
209
|
+
mock_get_annotated_particle_velocity, de_dataset, use_fake_spin_data_for_time
|
|
210
|
+
):
|
|
211
|
+
"""L1B test data"""
|
|
212
|
+
|
|
213
|
+
data_dict = {}
|
|
214
|
+
data_dict[de_dataset.attrs["Logical_source"]] = de_dataset
|
|
215
|
+
# TODO: this is a placeholder for the hk dataset.
|
|
216
|
+
data_dict["imap_ultra_l1a_45sensor-hk"] = aux_dataset
|
|
217
|
+
data_dict["imap_ultra_l1a_45sensor-rates"] = rates_dataset
|
|
218
|
+
use_fake_spin_data_for_time(
|
|
219
|
+
de_dataset["EVENTTIMES"][0], de_dataset["EVENTTIMES"][-1]
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
# Mock get_annotated_particle_velocity to avoid needing kernels
|
|
223
|
+
def side_effect_func(event_times, position, ultra_frame, dps_frame, sc_frame):
|
|
224
|
+
"""
|
|
225
|
+
Mock behavior of get_annotated_particle_velocity.
|
|
226
|
+
|
|
227
|
+
Returns NaN-filled arrays matching the expected output shape.
|
|
228
|
+
"""
|
|
229
|
+
num_events = event_times.size
|
|
230
|
+
return (
|
|
231
|
+
np.full((num_events, 3), np.nan), # sc_velocity
|
|
232
|
+
np.full((num_events, 3), np.nan), # sc_dps_velocity
|
|
233
|
+
np.full((num_events, 3), np.nan), # helio_velocity
|
|
234
|
+
)
|
|
235
|
+
|
|
236
|
+
mock_get_annotated_particle_velocity.side_effect = side_effect_func
|
|
237
|
+
|
|
238
|
+
output_datasets = ultra_l1b(data_dict, data_version="001")
|
|
239
|
+
|
|
240
|
+
return output_datasets
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import xarray as xr
|
|
3
|
+
|
|
4
|
+
from imap_processing.quality_flags import ImapAttitudeUltraFlags, ImapRatesUltraFlags
|
|
5
|
+
from imap_processing.ultra.l1b.badtimes import calculate_badtimes
|
|
6
|
+
from imap_processing.ultra.l1b.cullingmask import calculate_cullingmask
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def test_calculate_badtimes():
|
|
10
|
+
"""Test calculate_badtimes."""
|
|
11
|
+
|
|
12
|
+
spin_numbers = np.array([0, 1, 2, 3])
|
|
13
|
+
energy_bins = np.array([10, 20, 30, 40])
|
|
14
|
+
|
|
15
|
+
quality_attitude = np.full(
|
|
16
|
+
spin_numbers.shape, ImapAttitudeUltraFlags.NONE.value, dtype=np.uint16
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
quality_ena_rates = np.full(
|
|
20
|
+
(len(energy_bins), len(spin_numbers)),
|
|
21
|
+
ImapRatesUltraFlags.NONE.value,
|
|
22
|
+
dtype=np.uint16,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
quality_ena_rates[:, 0] |= ImapRatesUltraFlags.ZEROCOUNTS.value
|
|
26
|
+
quality_ena_rates[0, 1] |= ImapRatesUltraFlags.ZEROCOUNTS.value
|
|
27
|
+
quality_ena_rates[0, 2] |= ImapRatesUltraFlags.HIGHRATES.value
|
|
28
|
+
quality_ena_rates[0, 3] |= (
|
|
29
|
+
ImapRatesUltraFlags.ZEROCOUNTS.value | ImapRatesUltraFlags.HIGHRATES.value
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
ds = xr.Dataset(
|
|
33
|
+
{
|
|
34
|
+
"quality_attitude": (("spin_number",), quality_attitude),
|
|
35
|
+
"quality_ena_rates": (
|
|
36
|
+
("energy_bin_geometric_mean", "spin_number"),
|
|
37
|
+
quality_ena_rates,
|
|
38
|
+
),
|
|
39
|
+
},
|
|
40
|
+
coords={
|
|
41
|
+
"spin_number": spin_numbers,
|
|
42
|
+
"energy_bin_geometric_mean": energy_bins,
|
|
43
|
+
},
|
|
44
|
+
)
|
|
45
|
+
|
|
46
|
+
culling_ds = calculate_cullingmask(
|
|
47
|
+
ds, name="imap_ultra_l1b_45sensor-badtimes", data_version="v1"
|
|
48
|
+
)
|
|
49
|
+
badtimes_ds = calculate_badtimes(
|
|
50
|
+
ds,
|
|
51
|
+
culling_ds["spin_number"].values,
|
|
52
|
+
name="imap_ultra_l1b_45sensor-badtimes",
|
|
53
|
+
data_version="v1",
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
assert not np.any(
|
|
57
|
+
np.isin(culling_ds["spin_number"].values, badtimes_ds["spin_number"].values)
|
|
58
|
+
)
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import xarray as xr
|
|
3
|
+
|
|
4
|
+
from imap_processing.quality_flags import ImapAttitudeUltraFlags, ImapRatesUltraFlags
|
|
5
|
+
from imap_processing.ultra.l1b.cullingmask import calculate_cullingmask
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def test_calculate_cullingmask_attitude():
|
|
9
|
+
"""Test calculate_cullingmask for attitude culling."""
|
|
10
|
+
|
|
11
|
+
spin_numbers = np.array([0, 1])
|
|
12
|
+
energy_bins = np.array([10, 20, 30, 40])
|
|
13
|
+
|
|
14
|
+
quality_attitude = np.full(
|
|
15
|
+
spin_numbers.shape, ImapAttitudeUltraFlags.NONE.value, dtype=np.uint16
|
|
16
|
+
)
|
|
17
|
+
quality_attitude[1] |= ImapAttitudeUltraFlags.SPINRATE.value
|
|
18
|
+
|
|
19
|
+
quality_ena_rates = np.full(
|
|
20
|
+
(len(energy_bins), len(spin_numbers)),
|
|
21
|
+
ImapRatesUltraFlags.NONE.value,
|
|
22
|
+
dtype=np.uint16,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
ds = xr.Dataset(
|
|
26
|
+
{
|
|
27
|
+
"quality_attitude": (("spin_number",), quality_attitude),
|
|
28
|
+
"quality_ena_rates": (
|
|
29
|
+
("energy_bin_geometric_mean", "spin_number"),
|
|
30
|
+
quality_ena_rates,
|
|
31
|
+
),
|
|
32
|
+
},
|
|
33
|
+
coords={
|
|
34
|
+
"spin_number": spin_numbers,
|
|
35
|
+
"energy_bin_geometric_mean": energy_bins,
|
|
36
|
+
},
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
result_ds = calculate_cullingmask(
|
|
40
|
+
ds, name="imap_ultra_l1b_45sensor-cullingmask", data_version="v1"
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
np.testing.assert_array_equal(result_ds["spin_number"].values, np.array([0]))
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def test_calculate_cullingmask_rates():
|
|
47
|
+
"""Test calculate_cullingmask for rates culling."""
|
|
48
|
+
spin_numbers = np.array([0, 1, 2, 3])
|
|
49
|
+
energy_bins = np.array([10, 20, 30, 40])
|
|
50
|
+
|
|
51
|
+
quality_attitude = np.full(
|
|
52
|
+
spin_numbers.shape, ImapAttitudeUltraFlags.NONE.value, dtype=np.uint16
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
quality_ena_rates = np.full(
|
|
56
|
+
(len(energy_bins), len(spin_numbers)),
|
|
57
|
+
ImapRatesUltraFlags.NONE.value,
|
|
58
|
+
dtype=np.uint16,
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
quality_ena_rates[:, 0] |= ImapRatesUltraFlags.ZEROCOUNTS.value
|
|
62
|
+
quality_ena_rates[0, 1] |= ImapRatesUltraFlags.ZEROCOUNTS.value
|
|
63
|
+
quality_ena_rates[0, 2] |= ImapRatesUltraFlags.HIGHRATES.value
|
|
64
|
+
quality_ena_rates[0, 3] |= (
|
|
65
|
+
ImapRatesUltraFlags.ZEROCOUNTS.value | ImapRatesUltraFlags.HIGHRATES.value
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
ds = xr.Dataset(
|
|
69
|
+
{
|
|
70
|
+
"quality_attitude": (("spin_number",), quality_attitude),
|
|
71
|
+
"quality_ena_rates": (
|
|
72
|
+
("energy_bin_geometric_mean", "spin_number"),
|
|
73
|
+
quality_ena_rates,
|
|
74
|
+
),
|
|
75
|
+
},
|
|
76
|
+
coords={
|
|
77
|
+
"spin_number": spin_numbers,
|
|
78
|
+
"energy_bin_geometric_mean": energy_bins,
|
|
79
|
+
},
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
result_ds = calculate_cullingmask(
|
|
83
|
+
ds, name="imap_ultra_l1b_45sensor-cullingmask", data_version="v1"
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
expected_spins = np.array([0, 1])
|
|
87
|
+
np.testing.assert_array_equal(result_ds["spin_number"].values, expected_spins)
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
"""Tests Extended Raw Events for ULTRA L1b."""
|
|
2
2
|
|
|
3
|
-
from unittest import mock
|
|
4
|
-
|
|
5
3
|
import numpy as np
|
|
6
4
|
import pandas as pd
|
|
7
5
|
import pytest
|
|
8
6
|
|
|
9
7
|
from imap_processing.ultra.constants import UltraConstants
|
|
10
|
-
from imap_processing.ultra.l1b.de import calculate_de
|
|
11
8
|
|
|
12
9
|
|
|
13
10
|
@pytest.fixture()
|
|
@@ -20,94 +17,98 @@ def df_filt(de_dataset, events_fsw_comparison_theta_0):
|
|
|
20
17
|
return df_filt
|
|
21
18
|
|
|
22
19
|
|
|
23
|
-
|
|
24
|
-
def test_calculate_de(mock_get_annotated_particle_velocity, de_dataset, df_filt):
|
|
20
|
+
def test_calculate_de(l1b_datasets, df_filt):
|
|
25
21
|
"""Tests calculate_de function."""
|
|
26
22
|
|
|
27
|
-
|
|
28
|
-
def side_effect_func(event_times, position, ultra_frame, dps_frame, sc_frame):
|
|
29
|
-
"""
|
|
30
|
-
Mock behavior of get_annotated_particle_velocity.
|
|
31
|
-
|
|
32
|
-
Returns NaN-filled arrays matching the expected output shape.
|
|
33
|
-
"""
|
|
34
|
-
num_events = event_times.size
|
|
35
|
-
return (
|
|
36
|
-
np.full((num_events, 3), np.nan), # sc_velocity
|
|
37
|
-
np.full((num_events, 3), np.nan), # sc_dps_velocity
|
|
38
|
-
np.full((num_events, 3), np.nan), # helio_velocity
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
mock_get_annotated_particle_velocity.side_effect = side_effect_func
|
|
42
|
-
|
|
43
|
-
dataset = calculate_de(de_dataset, "imap_ultra_l1b_45sensor-de")
|
|
44
|
-
|
|
23
|
+
l1b_de_dataset = l1b_datasets[0]
|
|
45
24
|
# Front and back positions
|
|
46
|
-
assert np.allclose(
|
|
47
|
-
assert np.allclose(
|
|
48
|
-
assert np.allclose(
|
|
49
|
-
assert np.allclose(
|
|
25
|
+
assert np.allclose(l1b_de_dataset["x_front"].data, df_filt["Xf"].astype("float"))
|
|
26
|
+
assert np.allclose(l1b_de_dataset["y_front"], df_filt["Yf"].astype("float"))
|
|
27
|
+
assert np.allclose(l1b_de_dataset["x_back"], df_filt["Xb"].astype("float"))
|
|
28
|
+
assert np.allclose(l1b_de_dataset["y_back"], df_filt["Yb"].astype("float"))
|
|
50
29
|
|
|
51
30
|
# Coincidence positions
|
|
52
|
-
assert np.allclose(
|
|
31
|
+
assert np.allclose(l1b_de_dataset["x_coin"], df_filt["Xc"].astype("float"))
|
|
53
32
|
|
|
54
33
|
# Time of flight
|
|
55
|
-
assert np.allclose(
|
|
56
|
-
assert np.allclose(
|
|
57
|
-
assert np.allclose(
|
|
34
|
+
assert np.allclose(l1b_de_dataset["tof_start_stop"], df_filt["TOF"].astype("float"))
|
|
35
|
+
assert np.allclose(l1b_de_dataset["tof_stop_coin"], df_filt["eTOF"].astype("float"))
|
|
36
|
+
assert np.allclose(l1b_de_dataset["tof_corrected"], df_filt["cTOF"].astype("float"))
|
|
58
37
|
|
|
59
38
|
# Distances and path lengths
|
|
60
|
-
assert np.allclose(
|
|
61
|
-
|
|
39
|
+
assert np.allclose(
|
|
40
|
+
l1b_de_dataset["front_back_distance"], df_filt["d"].astype("float")
|
|
41
|
+
)
|
|
42
|
+
assert np.allclose(l1b_de_dataset["path_length"], df_filt["r"].astype("float"))
|
|
62
43
|
|
|
63
44
|
# Coincidence, start, and event types
|
|
64
|
-
assert np.allclose(
|
|
65
|
-
|
|
66
|
-
|
|
45
|
+
assert np.allclose(
|
|
46
|
+
l1b_de_dataset["coincidence_type"], df_filt["CoinType"].astype("float")
|
|
47
|
+
)
|
|
48
|
+
assert np.allclose(
|
|
49
|
+
l1b_de_dataset["start_type"], df_filt["StartType"].astype("float")
|
|
50
|
+
)
|
|
51
|
+
assert np.allclose(
|
|
52
|
+
l1b_de_dataset["event_type"], df_filt["StopType"].astype("float")
|
|
53
|
+
)
|
|
67
54
|
|
|
68
55
|
# Energies and species
|
|
69
|
-
assert np.allclose(
|
|
70
|
-
species_array =
|
|
56
|
+
assert np.allclose(l1b_de_dataset["energy"], df_filt["Energy"].astype("float"))
|
|
57
|
+
species_array = l1b_de_dataset["species"][
|
|
71
58
|
np.where(
|
|
72
|
-
(
|
|
73
|
-
& (
|
|
59
|
+
(l1b_de_dataset["tof_corrected"] > UltraConstants.CTOF_SPECIES_MIN)
|
|
60
|
+
& (l1b_de_dataset["tof_corrected"] < UltraConstants.CTOF_SPECIES_MAX)
|
|
74
61
|
)[0]
|
|
75
62
|
]
|
|
76
63
|
assert np.all(species_array == "H")
|
|
77
64
|
|
|
78
65
|
# Velocities in various frames
|
|
79
|
-
test_tof =
|
|
66
|
+
test_tof = l1b_de_dataset["tof_start_stop"]
|
|
67
|
+
test_ph = l1b_de_dataset["event_type"]
|
|
68
|
+
test_species = l1b_de_dataset["species"]
|
|
69
|
+
condition = (test_tof > 0) & (test_ph < 8)
|
|
80
70
|
assert np.allclose(
|
|
81
|
-
|
|
82
|
-
|
|
71
|
+
l1b_de_dataset["direct_event_velocity"][:, 0].values[condition],
|
|
72
|
+
df_filt["vx"].astype("float").values[condition],
|
|
83
73
|
rtol=1e-2,
|
|
84
74
|
)
|
|
85
75
|
assert np.allclose(
|
|
86
|
-
|
|
87
|
-
|
|
76
|
+
l1b_de_dataset["direct_event_velocity"][:, 1].values[condition],
|
|
77
|
+
df_filt["vy"].astype("float").values[condition],
|
|
88
78
|
rtol=1e-2,
|
|
89
79
|
)
|
|
90
80
|
assert np.allclose(
|
|
91
|
-
|
|
92
|
-
|
|
81
|
+
l1b_de_dataset["direct_event_velocity"][:, 2].values[condition],
|
|
82
|
+
df_filt["vz"].astype("float").values[condition],
|
|
83
|
+
rtol=1e-2,
|
|
84
|
+
)
|
|
85
|
+
assert np.allclose(
|
|
86
|
+
l1b_de_dataset["velocity_magnitude"].values[condition],
|
|
87
|
+
df_filt["vmag"].astype("float").values[condition],
|
|
88
|
+
rtol=1e-2,
|
|
89
|
+
)
|
|
90
|
+
condition = (test_tof > 0) & (test_ph < 8) & (test_species == "H")
|
|
91
|
+
assert np.allclose(
|
|
92
|
+
l1b_de_dataset["tof_energy"].values[condition],
|
|
93
|
+
df_filt["energy_revised"].astype("float").values[condition],
|
|
94
|
+
rtol=1e-2,
|
|
95
|
+
)
|
|
96
|
+
assert np.allclose(
|
|
97
|
+
l1b_de_dataset["azimuth"].values[condition],
|
|
98
|
+
df_filt["event_phi"].astype("float").values[condition] % (2 * np.pi),
|
|
93
99
|
rtol=1e-2,
|
|
94
100
|
)
|
|
95
101
|
|
|
96
|
-
assert
|
|
97
|
-
assert
|
|
98
|
-
assert
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
assert dataset["vz_dps_sc"].shape == (len(de_dataset["epoch"]),)
|
|
103
|
-
|
|
104
|
-
assert dataset["vx_dps_helio"].shape == (len(de_dataset["epoch"]),)
|
|
105
|
-
assert dataset["vy_dps_helio"].shape == (len(de_dataset["epoch"]),)
|
|
106
|
-
assert dataset["vz_dps_helio"].shape == (len(de_dataset["epoch"]),)
|
|
102
|
+
assert l1b_de_dataset["velocity_sc"].shape == (len(l1b_de_dataset["epoch"]), 3)
|
|
103
|
+
assert l1b_de_dataset["velocity_dps_sc"].shape == (len(l1b_de_dataset["epoch"]), 3)
|
|
104
|
+
assert l1b_de_dataset["velocity_dps_helio"].shape == (
|
|
105
|
+
len(l1b_de_dataset["epoch"]),
|
|
106
|
+
3,
|
|
107
|
+
)
|
|
107
108
|
|
|
108
109
|
# Event efficiency
|
|
109
110
|
assert np.allclose(
|
|
110
|
-
|
|
111
|
-
np.full(len(
|
|
111
|
+
l1b_de_dataset["event_efficiency"],
|
|
112
|
+
np.full(len(l1b_de_dataset["epoch"]), np.nan),
|
|
112
113
|
equal_nan=True,
|
|
113
114
|
)
|
|
@@ -107,7 +107,7 @@ def test_xarray_rates(decom_test_data):
|
|
|
107
107
|
|
|
108
108
|
# # Spot check metadata data and attributes
|
|
109
109
|
# j2000_time = (
|
|
110
|
-
# np.datetime64("2024-02-07T15:28:37.184000", "ns") -
|
|
110
|
+
# np.datetime64("2024-02-07T15:28:37.184000", "ns") - TTJ2000_EPOCH
|
|
111
111
|
# ).astype(np.int64)
|
|
112
112
|
# specific_epoch_data = dataset.sel(epoch=j2000_time)["START_RF"]
|
|
113
113
|
# startrf_list = specific_epoch_data.values.tolist()
|
|
@@ -147,7 +147,7 @@ def test_xarray_tof(decom_test_data):
|
|
|
147
147
|
|
|
148
148
|
# # Spot check metadata data and attributes
|
|
149
149
|
# j2000_time = (
|
|
150
|
-
# np.datetime64("2024-02-07T15:28:36.184000", "ns") -
|
|
150
|
+
# np.datetime64("2024-02-07T15:28:36.184000", "ns") - TTJ2000_EPOCH
|
|
151
151
|
# ).astype(np.int64)
|
|
152
152
|
# specific_epoch_data = dataset.sel(epoch=j2000_time, sid=0)["PACKETDATA"]
|
|
153
153
|
# packetdata_attr = dataset.variables["PACKETDATA"].attrs
|
|
@@ -196,7 +196,7 @@ def test_xarray_events(decom_test_data, decom_ultra_aux, events_test_path):
|
|
|
196
196
|
|
|
197
197
|
# # Spot check metadata data and attributes
|
|
198
198
|
# j2000_time = (
|
|
199
|
-
# np.datetime64("2024-02-07T15:28:37.184000", "ns") -
|
|
199
|
+
# np.datetime64("2024-02-07T15:28:37.184000", "ns") - TTJ2000_EPOCH
|
|
200
200
|
# ).astype(np.int64)
|
|
201
201
|
# specific_epoch_data = dataset.sel(epoch=j2000_time)["COIN_TYPE"]
|
|
202
202
|
# cointype_list = specific_epoch_data.values.tolist()
|