Skip to content

Update data folders#64

Closed
FasilGibdaw wants to merge 12 commits into
klaundal:mainfrom
FasilGibdaw:update-data-folders
Closed

Update data folders#64
FasilGibdaw wants to merge 12 commits into
klaundal:mainfrom
FasilGibdaw:update-data-folders

Conversation

@FasilGibdaw

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI review requested due to automatic review settings May 18, 2026 11:39

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

Adds/updates data-download tooling and supporting reference data to expand Lompe’s ability to fetch event-day datasets (SuperMAG, SuperDARN, CHAMP, Swarm), plus small utilities to support date handling and loader robustness.

Changes:

  • Added new download utilities in lompe/data_tools/ (SuperMAG, SuperDARN, CHAMP, Swarm) and an orchestration helper (get_lompe_data.py).
  • Added new reference CSVs under lompe/data/ for SuperMAG station metadata and SuperDARN Zenodo records.
  • Updated existing utilities/loaders (lompe/utils/time.py, lompe/data_tools/dataloader.py, lompe/data_tools/dmsp_ssusi.py, lompe/data_tools/README) to support the new workflows and data sources.

Reviewed changes

Copilot reviewed 14 out of 17 changed files in this pull request and generated 15 comments.

Show a summary per file
File Description
lompe/utils/time.py Formatting cleanups and new date2doy() helper.
lompe/data/supermag_stations.csv Adds SuperMAG station metadata inventory CSV.
lompe/data/sdarn_2010_to_2021.csv Adds Zenodo record index for SuperDARN grid files.
lompe/data_tools/swarm.py Adds Swarm download script using viresclient.
lompe/data_tools/supermag.py Adds SuperMAG downloader with retries and parallel station fetching.
lompe/data_tools/supermag_api.py Vendors a SuperMAG API client implementation.
lompe/data_tools/superdarn.py Adds SuperDARN download + processing to HDF workflow.
lompe/data_tools/get_lompe_data.py Adds “download once, subset many” helper that returns lompe.Data objects.
lompe/data_tools/dmsp_ssusi.py Integrates date2doy and CDAWeb-based SSUSI download workflow.
lompe/data_tools/dmsp_ssies.py No functional diff shown here; included in PR contents as context.
lompe/data_tools/dataloader.py Extends SSUSI reading for multiple sources; improves Iridium variable handling; SSIES download filtering tweaks.
lompe/data_tools/champ.py Adds CHAMP download + processing workflow.
lompe/data_tools/ampere.py Adds AMPERE/Iridium raw download + conversion workflow.
lompe/data_tools/README Updates documented supported datasets list.
Comments suppressed due to low confidence (2)

lompe/data_tools/superdarn.py:76

  • save_path is built with string concatenation; if basepath doesn’t end with a slash, the filename will be incorrect. Prefer os.path.join(basepath, filename) here (and likewise in download_sdarn() when building savefile/temp_sdarn_path).
                url_to_download = 'https://zenodo.org' + href
                # print(url_to_download)
                save_path = basepath + \
                    url_to_download.split('/')[-1].split('?')[0]
                download_sdarn_file(url_to_download, save_path)

lompe/data_tools/champ.py:34

  • This code imports requests_ftp at runtime, but that package is not declared in pyproject.toml dependencies/optionals. Consider adding it to an appropriate optional extra (or avoiding the dependency) so fresh installs don’t fail when CHAMP download is used.
    if not os.path.isfile(savefile):
        from requests_ftp import ftp
        session = requests.Session()
        session.mount('ftp://', ftp.FTPAdapter())
        ftp_url = f"ftp://isdcftp.gfz-potsdam.de/champ/ME/Level3/MAG/V0102/{year}/CH_ME_MAG_LR_3_{event_date}_0102.cdf"

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

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 on lines +277 to +279
smag_stations = pd.read_csv(
"/Users/fasilkebede/Documents/LOMPE/substorm/supermag_stations_info.csv"
)
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"
)
backoff_factor=0.5,
max_retry_rounds=4,
):
"""Download SuperMAG geogrpahic magnetic field data for one event day.
Comment thread lompe/data_tools/swarm.py Outdated
Comment on lines +36 to +40
for line in lines:
if line.startswith("token ="):
token_value = line.split('=', 1)[1].strip()
if token_value:
print("Swarm token is present:", token_value)
Comment on lines +238 to +243
def download_ssusi_files(event, source='cedaweb', basepath='./ssusi_tempfiles/'):
"""Downloading data from the SSUSI instrument onboard the DMSP satellites for a given event date.

Args:
event strin: format 'YYYY-MM-DD'
source (str, optional): data source. Defaults to 'cedaweb'.
Comment on lines +329 to 343
# ssies = str([s for s in filenames if '_' + str(sat) + 's1' in s][0])
ssies = [s for s in filenames if '_' + str(sat) + 's1.' in s]
# temp_dens = str(
# [s for s in filenames if '_' + str(sat) + 's4.' in s][0])
temp_dens = [s for s in filenames if '_' + str(sat) + 's4.' in s]

datafile = basepath + 'ssies_temp_' + event + '.hdf5'
result = testData.downloadFile(
ssies, datafile, **madrigal_kwargs, format="hdf5")
ssies[0], datafile, **madrigal_kwargs, format="hdf5")
f = pd.read_hdf(datafile, mode='r', key='Data/Table Layout')

tempdensfile = basepath + 'ssies_tempdens_data_' + event + '.hdf5'
result = testData.downloadFile(
temp_dens, tempdensfile, **madrigal_kwargs, format="hdf5")
temp_dens[0], tempdensfile, **madrigal_kwargs, format="hdf5")
f2 = pd.read_hdf(tempdensfile, mode='r', key='Data/Table Layout')
Comment thread lompe/utils/time.py
Comment on lines +121 to +122
date = dt.datetime.strptime(date_str, "%Y-%m-%d")
return date.timetuple().tm_yday
Comment on lines +7 to +9
from joblib import Parallel, delayed
from tqdm import tqdm

Comment on lines +5 to +10
import shutil
import requests
import pandas as pd
import xarray as xr
from bs4 import BeautifulSoup

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.

2 participants