Created
April 14, 2024 18:25
-
-
Save rileyhales/11ac6df64593dabb641ad9f044b23e37 to your computer and use it in GitHub Desktop.
Archive GEOGLOWS forecast records efficiently
This file contains 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
import geoglows | |
# example river segments from the Dominican Republic | |
river_ids = [780019062, 780019446, 780020214, 780021751, 780014456, ] | |
# as dataframes | |
df = geoglows.data.forecast_stats(river_id=river_ids) | |
df = df[['flow_avg', ]].dropna() | |
df = df.loc[df.index.get_level_values('time') < df.index.get_level_values('time')[0] + pd.Timedelta(days=1)] | |
df.to_parquet('./forecast_records_subset.parquet') | |
# as xarray | |
ds = geoglows.data.forecast_stats(river_id=river_ids, format='xarray') | |
ds = ds.sel(time=slice(ds.time[0], ds.time[0] + pd.Timedelta(days=1))) | |
ds['flow_avg'].to_netcdf('./forecast_records_subset.nc') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment