Skip to content

ISTP Validation Errors on Logical Source #3145

@vineetbansal

Description

@vineetbansal

I'm opening an issue that may serve as the discussion-point for the ISTP validation errors that @davidt0x observed. I'll let him chip in, but at a high-level the problem seems to be that around 1/3 of the cdfs are failing with errors of the form:

Logical_file_id should be 'imap_swe_l2_sci_20260427_v001'.  It is 'imap_swe_l2_sci_20260428_v001'.

The issue seems to be that the first epoch has to fall in the date pattern specified by the logical source.

To reproduce one such (arbitrarily chosen) error:

To install the required tools on a *nix machine:

wget https://spdf.gsfc.nasa.gov/skteditor/skteditor_1.3.12-1_amd64.deb
dpkg-deb -x skteditor_1.3.12-1_amd64.deb skteditor

To run and observe the error:

imap-data-access download imap_swe_l2_sci_20260428_v001.cdf

java -Djava.library.path="./skteditor/opt/skteditor/lib/app" -cp "./skteditor/opt/skteditor/lib/app/spdfjavaClasses.jar:./skteditor/opt/skteditor/lib/app/cdfjava.jar" gsfc.spdf.istp.tools.CDFCheck $IMAP_DATA_DIR/imap/swe/l2/2026/04/imap_swe_l2_sci_20260428_v001.cdf

If we run a script (below) to determine the first timestamp in the epoch for this l2 file, we get:

l2

uv run --with cdflib --with spacepy python check_epoch_dates.py $IMAP_DATA_DIR/imap/swe/l2/2026/04/imap_swe_l2_sci_20260428_v001.cdf 

...
  First: 2026-04-27T23:59:46.761652352
  Last:  2026-04-28T23:59:59.976963456

Tracing back from l2 -> l1b -> l1a, the progression of starting epoch seems to be:

l1b

uv run --with cdflib --with spacepy python check_epoch_dates.py $IMAP_DATA_DIR/imap/swe/l2/2026/04/imap_swe_l1b_sci_20260428_v001.cdf
  First: 2026-04-27T23:59:46.761652352
  Last:  2026-04-28T23:59:59.976963456

l1a (I couldn't find a v001 but I think it shouldn't matter?)

uv run --with cdflib --with spacepy python check_epoch_dates.py $IMAP_DATA_DIR/imap/swe/l2/2026/04/imap_swe_l1a_sci_20260428_v002.cdf
  First: 2026-04-27T23:59:00.128774784
  Last:  2026-04-29T00:00:46.053757440

l0

python check_packet_time.py $IMAP_DATA_DIR/imap/swe/l0/2026/04/imap_swe_l0_raw_20260428_v001.pkts
...
First packet UTC: 2026-04-27T23:59:20.375214+00:00

The scripts themselves (that AI wrote), are:

# check_epoch_dates.py
import sys
import cdflib
import spacepy.pycdf

CDF_FILE = sys.argv[1] 
with cdflib.CDF(CDF_FILE) as cdf:
    info = cdf.cdf_info()
    print(f"Logical_file_id: {cdf.globalattsget().get('Logical_file_id', ['<not set>'])[0]}")

    epoch_vars = [v for v in info.zVariables if "epoch" in v.lower()]
    print(f"Epoch variables: {epoch_vars}\n")

    for var in epoch_vars:
        raw = cdf.varget(var)
        if raw is None or len(raw) == 0:
            print(f"{var}: no data")
            continue

        times = cdflib.cdfepoch.to_datetime(raw)
        print(f"  First: {times[0]}")
        print(f"  Last:  {times[-1]}")
# check_packet_time.py
import sys
import struct
import datetime

IMAP_EPOCH = datetime.datetime(2010, 1, 1, tzinfo=datetime.timezone.utc)

PKT_FILE = sys.argv[1]

with open(PKT_FILE, "rb") as f:
    data = f.read(12)

apid = ((data[0] & 0x07) << 8) | data[1]
coarse = struct.unpack(">I", data[6:10])[0]
fine = struct.unpack(">H", data[10:12])[0]

t = IMAP_EPOCH + datetime.timedelta(seconds=coarse, microseconds=fine / 65536 * 1e6)

print(f"APID:        {apid} (0x{apid:03x})")
print(f"Coarse MET:  {coarse} s")
print(f"Fine:        {fine} ({fine/65536:.6f} s)")
print(f"First packet UTC: {t.isoformat()}")
print(f"UTC date:    {t.date()}")

Metadata

Metadata

Assignees

No one assigned

    Labels

    Data Release 1See - https://lasp.colorado.edu/galaxy/spaces/IMAP/pages/324168272/Public+ReleasesRelease BlockerNeeds to be addressed before (next) public release

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions