Update data folders#64
Closed
FasilGibdaw wants to merge 12 commits into
Closed
Conversation
There was a problem hiding this comment.
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_pathis built with string concatenation; ifbasepathdoesn’t end with a slash, the filename will be incorrect. Preferos.path.join(basepath, filename)here (and likewise indownload_sdarn()when buildingsavefile/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_ftpat runtime, but that package is not declared inpyproject.tomldependencies/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 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 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 | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.