This repository was archived by the owner on Jun 2, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 12
new gfs loader #338
Merged
Merged
new gfs loader #338
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
35a032b
new gfs loader
AUdaltsova e3a002b
add warning to filter_channels.py
AUdaltsova e20c917
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 5735f9f
pass provider label to filter_channels
AUdaltsova ce4d82a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 4d9a132
Update warning in filter_channels.py
AUdaltsova da13cfd
add gfs test data
AUdaltsova fcd6fe7
Added gfs load test to test_load_nwp.py
AUdaltsova 5cfcf9c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] a61b8d4
Update gfs.py
AUdaltsova 8beef57
Update filter_channels.py
AUdaltsova 6d93665
Update test_load_nwp.py
AUdaltsova c19f4af
linting filter_channels.py
AUdaltsova 6f3393b
linting gfs.py
AUdaltsova 5795881
Delete tests/data/gfs.zarr.zip
AUdaltsova 50ac208
add gfs test data
AUdaltsova ab097f0
Create .zmetadata
AUdaltsova 7432995
Create .zgroup
AUdaltsova 26d18c4
Create .zattrs
AUdaltsova 32bfe1e
Update gfs test data path test_load_nwp.py
AUdaltsova d6f7a9f
Update provider label for gfs, cleaner type checks in test_load_nwp.py
AUdaltsova eed00a5
Update comment in filter_channels.py
AUdaltsova a8e8cab
remove unnecessary bool in test_load_nwp.py
AUdaltsova 4f28218
remove extrapolation option gfs.py
AUdaltsova 5fb9eee
change warning text filter_channels.py
AUdaltsova 6066ec8
Update gfs consts in consts.py
AUdaltsova 93df966
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] ff7a302
typo consts.py
AUdaltsova 2264e61
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,33 @@ | ||
"""Open GFS Forecast data""" | ||
|
||
import logging | ||
from pathlib import Path | ||
from typing import Union | ||
|
||
import pandas as pd | ||
import xarray as xr | ||
|
||
from ocf_datapipes.load.nwp.providers.utils import open_zarr_paths | ||
|
||
_log = logging.getLogger(__name__) | ||
|
||
|
||
def open_gfs(zarr_path: Union[Path, str]) -> xr.Dataset: | ||
def open_gfs(zarr_path) -> xr.DataArray: | ||
""" | ||
Opens GFS dataset | ||
Opens the GFS data | ||
|
||
Args: | ||
zarr_path: Path to Zarr(s) to open | ||
zarr_path: Path to the zarr to open | ||
|
||
Returns: | ||
Xarray dataset of GFS Forecasts | ||
Xarray DataArray of the NWP data | ||
""" | ||
|
||
_log.info("Loading NWP GFS data") | ||
|
||
if "*" in zarr_path: | ||
nwp = xr.open_mfdataset(zarr_path, engine="zarr", combine="time", chunks="auto") | ||
else: | ||
nwp = xr.load_dataset(zarr_path, engine="zarr", mode="r", chunks="auto") | ||
|
||
variables = list(nwp.keys()) | ||
# Open data | ||
gfs: xr.Dataset = open_zarr_paths(zarr_path, time_dim="init_time_utc") | ||
nwp: xr.DataArray = gfs.to_array() | ||
|
||
nwp = xr.concat([nwp[v] for v in variables], "channel") | ||
nwp = nwp.assign_coords(channel=variables) | ||
del gfs | ||
|
||
nwp = nwp.transpose("time", "step", "channel", "latitude", "longitude") | ||
nwp = nwp.rename({"time": "init_time_utc"}) | ||
nwp = nwp.rename({"variable": "channel"}) | ||
nwp = nwp.transpose("init_time_utc", "step", "channel", "latitude", "longitude") | ||
if "valid_time" in nwp.coords.keys(): | ||
nwp = nwp.drop("valid_time") | ||
|
||
_log.debug("Interpolating hour 0 to NWP data") | ||
nwp_step0 = nwp.interp(step=[pd.Timedelta(hours=0)]) | ||
nwp = xr.concat([nwp_step0, nwp], dim="step") | ||
nwp = nwp.resample(init_time_utc="60min").pad() | ||
nwp = nwp.resample(step="60min").pad() | ||
|
||
_log.debug(nwp) | ||
|
||
return nwp |
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"Conventions": "CF-1.7", | ||
"GRIB_centre": "kwbc", | ||
"GRIB_centreDescription": "US National Weather Service - NCEP", | ||
"GRIB_edition": 2, | ||
"GRIB_subCentre": 0, | ||
"description": "Global Forecast System", | ||
"institution": "US National Weather Service - NCEP", | ||
"local_grib": "/root/data/gfs/20230624/subset_56ef2a91__gfs.t00z.pgrb2.1p00.f000", | ||
"model": "gfs", | ||
"product": "pgrb2.1p00", | ||
"remote_grib": "https://noaa-gfs-bdp-pds.s3.amazonaws.com/gfs.20230624/00/atmos/gfs.t00z.pgrb2.1p00.f000", | ||
"search": ":[TLMH]CDC:|:[UV]GRD:(?:10|100) m|:RH:sigma|:(?:TMP|VIS|PRATE|SNOD|D[SL]WRF):surface|:RH:100 mb" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"zarr_format": 2 | ||
} |
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.