feat: update the dscovr api and restrict the end time#78
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates SWVO’s DSCOVR solar-wind ingestion to use the NOAA NCEI Space Weather Portal “values” API, updates the processing pipeline accordingly (including pdyn derivation), and adjusts the test suite to validate the new request/response format and output schema.
Changes:
- Switched DSCOVR downloads from SWPC product JSON files to the NCEI portal
valuesendpoint with parameterized queries. - Reworked parsing to consume a single combined payload, normalize to a minute cadence, and compute
pdyn. - Updated/expanded DSCOVR tests to mock the portal response and validate column mapping, invalid-value handling, and request parameters.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
swvo/io/solar_wind/dscovr.py |
Migrates DSCOVR download + processing logic to the NCEI portal API and adds new parsing/cleaning logic. |
tests/io/solar_wind/test_dscovr.py |
Updates tests to mock the new portal payload and verify the updated output and request construction. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
136
to
140
| except Exception as e: | ||
| logger.error(f"Failed to process file for {date}: {e}") | ||
| if tmp_path.exists(): | ||
| tmp_path.unlink() | ||
| # if tmp_path.exists(): | ||
| # tmp_path.unlink() | ||
| continue |
Comment on lines
+352
to
+355
| data = pd.DataFrame(payload.get("data", {})) | ||
|
|
||
| if len(data["time"]) == 0: | ||
| raise FileNotFoundError("No data found in the downloaded DSCOVR file.") |
Comment on lines
+385
to
+389
| def _replace_invalid_values(self, data: pd.DataFrame) -> None: | ||
| """Replace known DSCOVR missing-value sentinels with NaN.""" | ||
| for k in [*self.MAG_FIELDS, *self.SWEPAM_FIELDS]: | ||
| mask = (data[k] < -99999.0) | (data[k] == 0.0) | ||
| data.loc[mask, k] = np.nan |
| LABEL = "dscovr" | ||
|
|
||
| def download_and_process(self, request_time: datetime) -> None: | ||
| def download_and_process(self, start_time: datetime, end_time: datetime) -> None: |
Comment on lines
+94
to
+95
| start_time = enforce_utc_timezone(start_time) | ||
| end_time = enforce_utc_timezone(end_time) |
Comment on lines
+84
to
+88
| If the request_time is in the future or if start_time is after end_time. | ||
| FileNotFoundError | ||
| If the downloaded files are empty. | ||
| ValueError | ||
| If the end_time is after 2026-06-30, since DSCOVR data is only available until that date. |
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.