Skip to content

Update data tools and fixes #65

Merged
klaundal merged 12 commits into
klaundal:mainfrom
FasilGibdaw:update-data-folders
May 18, 2026
Merged

Update data tools and fixes #65
klaundal merged 12 commits into
klaundal:mainfrom
FasilGibdaw:update-data-folders

Conversation

@FasilGibdaw

Copy link
Copy Markdown
Contributor

Scripts to download data in the data_tools folder are fixed and example (data_tools_example.ipynb) on how to use it added in the examples folder.

Copilot AI review requested due to automatic review settings May 18, 2026 12:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the lompe.data_tools download/read helpers (SuperMAG, AMPERE/Iridium, SuperDARN, CHAMP, DMSP) and adds a vendored SuperMAG API client module intended to support more robust SuperMAG downloads.

Changes:

  • Refactors SuperMAG downloading to use a SuperMAG API client with retries/parallel station fetch and Lompe-style output formatting.
  • Adjusts several data tools for small robustness/behavior tweaks (Iridium variable handling, SuperDARN “file exists” behavior, formatting fixes, clearer CHAMP message).
  • Adds a new supermag_api.py module (vendored API client).

Reviewed changes

Copilot reviewed 7 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
lompe/data_tools/supermag.py Refactor SuperMAG download flow to use an API client + retries and output conversion.
lompe/data_tools/supermag_api.py Adds a vendored SuperMAG API client implementation.
lompe/data_tools/superdarn.py Minor behavior change when cached SuperDARN file exists.
lompe/data_tools/get_lompe_data.py Updates Swarm import and default paths; minor formatting change.
lompe/data_tools/dmsp_ssies.py Indentation/formatting adjustments in spline prep calls.
lompe/data_tools/dataloader.py Updates Iridium raw-file globbing and supports b_eci vs db_eci.
lompe/data_tools/champ.py Updates the “no data” message to include CHAMP availability range.
lompe/data_tools/ampere.py Adds “file exists” log and minor formatting change.
Comments suppressed due to low confidence (3)

lompe/data_tools/supermag.py:156

  • _get_supermag_inventory ignores the status return value from SuperMAGGetInventory. On HTTP/API errors the underlying client returns status=0 and an error payload, which can be mistaken for a non-empty station list and later cause bogus station downloads. Check status and raise/retry when it is false, and consider validating that station entries look like station codes before returning.
        try:
            status, stations = SuperMAGGetInventory(userid, start, extent)

            if stations is None or len(stations) == 0:
                raise ValueError("No stations returned")

            return stations

lompe/data_tools/supermag.py:281

  • _get_supermag_all_stations reads station metadata from an absolute, user-specific path (/Users/.../supermag_stations_info.csv). This will fail for everyone else (including CI) and breaks the downloader out of the box. Either ship this CSV as package data and load it via importlib.resources, query station latitudes from SuperMAG, or make the high-latitude filter optional with a configurable path/threshold.
        smag_stations = pd.read_csv(
            "/Users/fasilkebede/Documents/LOMPE/substorm/supermag_stations_info.csv"
        )
        high_lat = smag_stations[smag_stations["GEOLAT"] >= 50]
        stations = np.intersect1d(stations, high_lat["IAGA"].values)

lompe/data_tools/supermag.py:33

  • Typo in docstring: "geogrpahic" → "geographic".
    """Download SuperMAG geogrpahic magnetic field data for one event day.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +12 to +18
try:
from supermag_api.supermag_api import *
except ImportError:
raise ImportError(
"supermag-api is not installed. Install it with:\n\n"
"pip install supermag-api"
)
Comment on lines 10 to +16
from .champ import download_champ
from .superdarn import download_sdarn
from .swarm import download_swarm
from .swarm import download_swarm_mag
from .dmsp_ssies import download_dmsp_ssies


def prepare_event_data(event, data_path="./lompe_data/", sources=None, basepath="./", **kwargs):
def prepare_event_data(event, data_path="./sample_dataset/", sources=None, basepath="./sample_dataset/", **kwargs):
Comment on lines +18 to +24
;supermag_api.py
; ================
; Author S. Antunes, based on supermag-api.pro by R.J.Barnes


; (c) 2021 The Johns Hopkins University Applied Physics Laboratory
;LLC. All Rights Reserved.
Comment thread lompe/data_tools/champ.py
except Exception as e:
print(f"No champ data in this period: {e}")
print(
f"No champ data: Champ data available (2000-07-19 to 2010-09-17), returning: {e}")
@klaundal
klaundal merged commit c164b8a into klaundal:main May 18, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants