Skip to content

feat: update the dscovr api and restrict the end time#78

Merged
sahiljhawar merged 1 commit into
mainfrom
update-dscovr
Jul 9, 2026
Merged

feat: update the dscovr api and restrict the end time#78
sahiljhawar merged 1 commit into
mainfrom
update-dscovr

Conversation

@sahiljhawar

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings July 9, 2026 09:45
@sahiljhawar sahiljhawar merged commit c6043da into main Jul 9, 2026
3 of 12 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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 values endpoint 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.
@sahiljhawar sahiljhawar deleted the update-dscovr branch July 10, 2026 16:40
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