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 | |
# get a list of river id numbers you are interested in downloading | |
river_ids = [710431167, ] | |
# Pandas DataFrames and Xarray Datasets each support several output formats | |
# Use the function for the file format you want and provide a file path for the output | |
# example using DataFrames - works for both forecasts and retrospective data |
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') |
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 | |
# get a list of river IDs that you want to get data for. | |
# Some options include using the streams GIS files, using web maps, or writing a list in a csv file | |
river_id_list = [760021611, 160064246, 710431167, 441057380, 430157411, 210406913, 621010293, 130747391, 640255644, ] | |
# get forecast data - returns a dataframe with a multi-index of dates and river numbers | |
forecast_data = geoglows.data.forecast_ensembles(river_id_list) | |
# get retrospective data = returns a dataframe with a datetime index and 1 columns per river ID |
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 pandas as pd | |
path_to_modal_metadata_table = './v2-model-table.parquet' | |
metadata_table = pd.read_parquet(path_to_modal_metadata_table) | |
river_of_interest = 780035587 | |
terminal_link = metadata_table.loc[metadata_table['LINKNO'] == river_of_interest, 'TerminalLink'].values[0] | |
rivers_in_watershed = metadata_table.loc[metadata_table['TerminalLink'] == terminal_link, 'LINKNO'].values.flatten() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
#!/bin/bash | |
set -x | |
HOME=/data/geoglows | |
WORKFLOW_DIR=$HOME/output/forecasts | |
# create date variables | |
TODAY=$(date +"%Y%m%d") | |
DATE_LIMIT=$(date -d "$TODAY - 46 days" +"%Y%m%d") | |
# delete old forecasts |
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 xarray as xr | |
import numpy as np | |
with xr.open_dataset('./2023era5/2023_11_era5_hourly.nc') as ds: | |
# find the time steps where the runoff is not nan when expver=1 | |
a = ds.ro.sel(latitude=0, longitude=0, expver=1) | |
expver1_timesteps = a.time[~np.isnan(a)] | |
# find the time steps where the runoff is not nan when expver=5 | |
b = ds.ro.sel(latitude=0, longitude=0, expver=5) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 matplotlib.pyplot as plt | |
import numpy as np | |
import pandas as pd | |
x = np.arange(0, np.pi * 12, 0.025) | |
q_insitu = 2 * np.sin(0.5 * x) + 4 | |
q_constant = np.ones_like(x) * 4 | |
q_biased_high = 2 * np.sin(0.5 * x) + 4 + 1.5 | |
q_biased_low = 2 * np.sin(0.5 * x) + 4 - 1.5 |
NewerOlder