Skip to content

Commit ab64bd7

Browse files
IDEX Initial L2c processing (IMAP-Science-Operations-Center#1682)
* initial idex l2c processing * modify IDEXpointingSet and add tests * SPASE metadata * reorg * refactor remove maps * remove IDEXPointingSet class * rename healpix index name * move import * l2c add rectangular psets * fix tests * recreate 2d counts for rectangular to test 2d histogram works as intended * fix idex l2b test * fix spacing * address PR comments * pr comments from Nat * naming updates * product rename * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add todos * fix l2c attrs * update epoch metadata * address pr comments from Greg. * fix indexing on spatial coords --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 85025b0 commit ab64bd7

12 files changed

Lines changed: 587 additions & 45 deletions

imap_processing/cdf/config/imap_idex_global_cdf_attrs.yaml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,21 @@ imap_idex_l2b_sci:
5555
<<: *instrument_base
5656
Data_level: 2B
5757
Data_type: L2B_SCI>Level-2B Science Data
58-
Logical_source: imap_idex_l2b_sci # TODO how often?
59-
Logical_source_description: IMAP Mission IDEX Instrument Level-2B Data
58+
Logical_source: imap_idex_l2b_sci-1week
59+
Logical_source_description: IMAP Mission IDEX Instrument Level-2B Data
60+
61+
62+
#TODO what should these look like?
63+
imap_idex_l2c_sci-healpix:
64+
<<: *instrument_base
65+
Data_level: 2C
66+
Data_type: L2C_MAP-HEALPIX>Level-2C Science Data
67+
Logical_source: imap_idex_l2c_healpix-map-1week
68+
Logical_source_description: IMAP Mission IDEX Instrument Level-2C Data Healpix
69+
70+
imap_idex_l2c_sci-rectangular:
71+
<<: *instrument_base
72+
Data_level: 2C
73+
Data_type: L2C_MAP-RECTANGULAR>Level-2C Science Data
74+
Logical_source: imap_idex_l2c_rectangular-map-1week
75+
Logical_source_description: IMAP Mission IDEX Instrument Level-2C Data Rectangular

imap_processing/cdf/config/imap_idex_l1b_variable_attrs.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -346,14 +346,14 @@ current_neg2p5v_bus:
346346
ephemeris_position_x:
347347
<<: *spice_base
348348
FIELDNAM: Position X
349-
CATDESC: Cartesian coordinate X positions for the IMAP spacecraft in the ECLIPJ2000 frame.
349+
CATDESC: Cartesian coord X positions for the IMAP spacecraft in the ECLIPJ2000 frame.
350350
LABLAXIS: Position X
351351
UNITS: km
352352

353353
ephemeris_position_y:
354354
<<: *spice_base
355355
FIELDNAM: Position Y
356-
CATDESC: Cartesian coordinate Y positions for the IMAP spacecraft in the ECLIPJ2000 frame.
356+
CATDESC: Cartesian coord Y positions for the IMAP spacecraft in the ECLIPJ2000 frame.
357357
LABLAXIS: Position Y
358358
UNITS: km
359359

@@ -385,18 +385,18 @@ ephemeris_velocity_z:
385385
LABLAXIS: Velocity Z
386386
UNITS: km/s
387387

388-
right_ascension:
388+
longitude:
389389
<<: *spice_base
390390
VALIDMIN: 0
391-
FIELDNAM: Right Ascension
392-
CATDESC: Right ascension of the IMAP spacecraft position as observed from Earth in the ECLIPJ2000 reference frame.
393-
LABLAXIS: Right Ascension
391+
FIELDNAM: Longitude
392+
CATDESC: Longitude of the dust event as observed from Earth in the ECLIPJ2000 frame.
393+
LABLAXIS: Longitude
394394

395-
declination:
395+
latitude:
396396
<<: *spice_base
397-
FIELDNAM: Declination
398-
CATDESC: Declination of the IMAP spacecraft position as observed from Earth in the ECLIPJ2000 reference frame.
399-
LABLAXIS: Declination
397+
FIELDNAM: Latitude
398+
CATDESC: Latitude of the dust event as observed from Earth in the ECLIPJ2000 frame.
399+
LABLAXIS: Latitude
400400

401401
spin_phase:
402402
<<: *spice_base
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
int_fillval: &int_fillval -9223372036854775808
2+
int_maxval: &int_maxval 9223372036854775807
3+
double_fillval: &double_fillval -1.0E31
4+
5+
epoch_collection_set:
6+
CATDESC: Nanoseconds since J2000 with leap seconds. Start (left-edge) of reference time.
7+
FIELDNAM: epoch
8+
LABLAXIS: epoch
9+
FILLVAL: -9223372036854775808
10+
FORMAT: " " # Supposedly not required, fails in xarray_to_cdf
11+
VALIDMIN: -9223372036854775808
12+
VALIDMAX: 9223372036854775807
13+
UNITS: ns
14+
VAR_TYPE: support_data
15+
SCALETYP: linear
16+
MONOTON: INCREASE
17+
TIME_BASE: J2000
18+
TIME_SCALE: Terrestrial Time
19+
REFERENCE_POSITION: Rotating Earth Geoid
20+
RESOLUTION: ' '
21+
DISPLAY_TYPE: time_series
22+
23+
rectangular_lon_pixel_label:
24+
CATDESC: Longitude pixel index label for IDEX SkyMap.
25+
FIELDNAM: Longitude pixel label
26+
FORMAT: A5
27+
VAR_TYPE: metadata
28+
29+
rectangular_lat_pixel_label:
30+
CATDESC: Latitude pixel index label for IDEX SkyMap.
31+
FIELDNAM: Latitude pixel label
32+
FORMAT: A5
33+
VAR_TYPE: metadata
34+
35+
pixel_label:
36+
CATDESC: HEALPix pixel index label for IDEX SkyMap.
37+
FIELDNAM: Pixel label
38+
FORMAT: A5
39+
VAR_TYPE: metadata
40+
41+
pixel_index:
42+
CATDESC: HEALPix pixel index for IDEX SkyMap
43+
FIELDNAM: HEALPix Index
44+
FORMAT: I4
45+
LABLAXIS: HEALPix Index
46+
VAR_TYPE: support_data
47+
UNITS: " "
48+
VALIDMIN: 0
49+
VALIDMAX: 768
50+
FILLVAL: *int_fillval
51+
DICT_KEY: SPASE>Support>SupportQuantity:Positional
52+
53+
rectangular_lon_pixel:
54+
CATDESC: Longitude pixel index for IDEX SkyMap
55+
FIELDNAM: Rectangular Longitude Index
56+
FORMAT: F12.6
57+
LABLAXIS: Longitude Pixel
58+
VAR_TYPE: support_data
59+
UNITS: degrees
60+
VALIDMIN: 0
61+
VALIDMAX: 360
62+
FILLVAL: *double_fillval
63+
DICT_KEY: SPASE>Support>SupportQuantity:Positional
64+
65+
rectangular_lat_pixel:
66+
CATDESC: Latitude pixel index for IDEX SkyMap
67+
FIELDNAM: Rectangular Latitude Index
68+
FORMAT: F12.6
69+
LABLAXIS: Latitude Pixel
70+
VAR_TYPE: support_data
71+
UNITS: degrees
72+
VALIDMIN: -90
73+
VALIDMAX: 90
74+
FILLVAL: *double_fillval
75+
DICT_KEY: SPASE>Support>SupportQuantity:Positional
76+
77+
counts: &counts
78+
CATDESC: Number of raw dust events for each pixel
79+
FIELDNAM: Dust Counts
80+
FORMAT: I12
81+
UNITS: counts
82+
VAR_TYPE: data
83+
DISPLAY_TYPE: time_series
84+
DEPEND_0: epoch
85+
VALIDMIN: 0
86+
VALIDMAX: *int_maxval
87+
FILLVAL: *int_fillval
88+
DICT_KEY: SPASE>Particle>ParticleType:Dust,ParticleQuantity:Counts,Qualifier:Array
89+
90+
healpix_counts:
91+
<<: *counts
92+
DEPEND_1: pixel_index
93+
LABL_PTR_1: pixel_label
94+
95+
rectangular_counts:
96+
<<: *counts
97+
DEPEND_1: rectangular_lon_pixel
98+
DEPEND_2: rectangular_lat_pixel
99+
LABL_PTR_1: rectangular_lon_pixel_label
100+
LABL_PTR_2: rectangular_lat_pixel_label

imap_processing/idex/idex_constants.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
from dataclasses import dataclass
44
from enum import Enum, IntEnum
55

6+
from imap_processing.spice.geometry import SpiceFrame
7+
68

79
class IDEXAPID(IntEnum):
810
"""Create ENUM for apid."""
@@ -67,8 +69,19 @@ class ConversionFactors(float, Enum):
6769
"ephemeris_velocity_x",
6870
"ephemeris_velocity_y",
6971
"ephemeris_velocity_z",
70-
"right_ascension",
71-
"declination",
72+
"longitude",
73+
"latitude",
7274
"solar_longitude",
7375
"spin_phase",
7476
]
77+
78+
# Default IDEX Healpix parameters
79+
# Used in IDEX l2c processing
80+
IDEX_HEALPIX_NSIDE = 8
81+
IDEX_HEALPIX_NESTED = False
82+
# Default IDEX Rectangular parameters
83+
# Used in IDEX l2c processing
84+
IDEX_SPACING_DEG = 4 # TODO
85+
86+
# Define the pointing reference frame for IDEX
87+
IDEX_EVENT_REFERENCE_FRAME = SpiceFrame.ECLIPJ2000

imap_processing/idex/idex_l1b.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323

2424
from imap_processing import imap_module_directory
2525
from imap_processing.cdf.imap_cdf_manager import ImapCdfAttributes
26-
from imap_processing.idex.idex_constants import ConversionFactors
26+
from imap_processing.idex.idex_constants import (
27+
IDEX_EVENT_REFERENCE_FRAME,
28+
ConversionFactors,
29+
)
2730
from imap_processing.idex.idex_utils import get_idex_attrs, setup_dataset
2831
from imap_processing.spice.geometry import (
2932
SpiceBody,
@@ -350,15 +353,15 @@ def get_spice_data(
350353
# Get spacecraft spin phase in degrees
351354
spin_phase = get_spacecraft_spin_phase(query_met_times=met)
352355
imap_spin_phase = get_spin_angle(spin_phase, degrees=True)
353-
# Get position and velocity of IMAP in ecliptic frame
356+
# Get the position and velocity of IMAP in ecliptic frame
354357
ephemeris = imap_state(et, observer=SpiceBody.SUN)
355-
# Get Idex pointing in the j2000 equatorial frame
358+
# Get Idex pointing in the defined frame
356359
idex_pointing = instrument_pointing(
357-
et, SpiceFrame.IMAP_IDEX, SpiceFrame.J2000, cartesian=True
360+
et, SpiceFrame.IMAP_IDEX, IDEX_EVENT_REFERENCE_FRAME, cartesian=True
358361
)
359362
solar_lon = solar_longitude(et, degrees=True)
360-
361-
range_ra_and_dec = cartesian_to_spherical(idex_pointing)
363+
# longitude and latitude
364+
lon_and_lat = cartesian_to_spherical(idex_pointing)[:, 1:]
362365

363366
spice_data = {
364367
"ephemeris_position_x": ephemeris[:, 0],
@@ -367,8 +370,8 @@ def get_spice_data(
367370
"ephemeris_velocity_x": ephemeris[:, 3],
368371
"ephemeris_velocity_y": ephemeris[:, 4],
369372
"ephemeris_velocity_z": ephemeris[:, 5],
370-
"right_ascension": range_ra_and_dec[:, 1],
371-
"declination": range_ra_and_dec[:, 2],
373+
"longitude": lon_and_lat[:, 0],
374+
"latitude": lon_and_lat[:, 1],
372375
"spin_phase": imap_spin_phase,
373376
"solar_longitude": solar_lon,
374377
}

0 commit comments

Comments
 (0)