An Exception was encountered at ‘In [14]’.
ROF monthly, annual, seasonal discharge at ocean outlets #
Use the following datasets
reach-D19 gauge link ascii
D19 flow site geopackage
D19 discharge netCDF
monthly and yearly flow netCD (history file)
Read monthly history files from archive.
Reference data: monthly discharge estimates at 922 big river mouths from Dai et al. 2019 data (D19)
3. Read river, catchment, gauge information
catchment polygon (geopackage)
gauge point (geopackage)
gauge-catchment link (csv)
outlet reach information (netCDF) including discharging ocean names
total seasonal flow for oceans.
The Python version: 3.11.4
xarray 2025.4.0
pandas 2.2.3
geopandas 1.0.1
ERROR 1: PROJ: proj_create_from_database: Open of /glade/work/hannay/miniconda3/envs/cupid-analysis/share/proj failed
1. Setup #
# Parameters
case_name = "b.e30_beta06.B1850C_LTso.ne30_t232_wgx3.192"
base_case_name = "b.e30_beta06.B1850C_LTso.ne30_t232_wgx3.188"
CESM_output_dir = "/glade/derecho/scratch/hannay/archive"
base_case_output_dir = "/glade/derecho/scratch/gmarques/archive"
start_date = "0002-01-01"
end_date = "0021-12-01"
base_start_date = "0002-01-01"
base_end_date = "0021-12-01"
obs_data_dir = (
"/glade/campaign/cesm/development/cross-wg/diagnostic_framework/CUPiD_obs_data"
)
ts_dir = None
lc_kwargs = {"threads_per_worker": 1}
serial = True
analysis_name = ""
grid_name = "f09_f09_mosart"
climo_nyears = 10
figureSave = False
subset_kwargs = {}
product = "/glade/work/hannay/CUPiD/examples/key_metrics/computed_notebooks//rof/global_discharge_ocean_compare_obs.ipynb"
dasks (optional)#
2. Loading discharge data #
2.1. Monthly/annual flow netCDFs#
month_data (xr dataset)
year_data (xr dataset)
seas_data (xr dataset)
Finished loading b.e30_beta06.B1850C_LTso.ne30_t232_wgx3.192
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
File <timed exec>:28
File /glade/work/hannay/miniconda3/envs/cupid-analysis/lib/python3.11/site-packages/xarray/backends/api.py:1597, in open_mfdataset(paths, chunks, concat_dim, compat, preprocess, engine, data_vars, coords, combine, parallel, join, attrs_file, combine_attrs, **kwargs)
1594 paths = _find_absolute_paths(paths, engine=engine, **kwargs)
1596 if not paths:
-> 1597 raise OSError("no files to open")
1599 paths1d: list[str | ReadBuffer]
1600 if combine == "nested":
OSError: no files to open
2.2 D19 discharge data#
ds_q_obs_mon (xr datasets)
ds_q_obs_yr (xr datasets)
dr_q_obs_seasonal (xr datasets)
CPU times: user 155 ms, sys: 3.63 ms, total: 158 ms
Wall time: 160 ms
<timed exec>:6: DeprecationWarning: cftime_range() is deprecated, please use xarray.date_range(..., use_cftime=True) instead.
3. Reading river, catchment, gauge infomation #
gauge-catchment (or grid box) link (csv)
gauge point (geopackage)
ocean polygon (geopackage)
catchment polygon (geopackage)
outlet reach information (netCDF)
3.1. reach-D19 gauge link csv#
gauge_reach_lnk (dataframe)
3.2 D19 flow site geopackage#
gauge_shp (dataframe)
CPU times: user 13 ms, sys: 4.53 ms, total: 17.6 ms
Wall time: 41.2 ms
3.3 Ocean polygon geopackage#
ocean_shp (dataframe)
CPU times: user 182 ms, sys: 10.3 s, total: 10.5 s
Wall time: 11 s
3.3 Read river network information#
gdf_cat (dataframe)
%%time
## read catchment geopackage
gdf_cat = {}
for case, meta in case_dic.items():
cat_gpkg = os.path.join(
geospatial_dir, catch_gpkg[meta["grid"]]["file_name"]
) # geopackage name
id_name_cat = catch_gpkg[meta["grid"]]["id_name"] # reach ID in geopackage
var_list = [id_name_cat]
if "lk" in grid_name:
var_list.append("lake")
gdf_cat[case] = read_shps([cat_gpkg], var_list)
Finished reading /glade/campaign/cesm/development/cross-wg/diagnostic_framework/rof_data/geospatial/MOSART_routing_Global_0.5x0.5_c170601_hru.gpkg
Finished reading /glade/campaign/cesm/development/cross-wg/diagnostic_framework/rof_data/geospatial/MOSART_routing_Global_0.5x0.5_c170601_hru.gpkg
CPU times: user 574 ms, sys: 7.76 ms, total: 581 ms
Wall time: 660 ms
3.4 Read river outlet information#
Apppend into gdf_cat (dataframe)
CPU times: user 204 ms, sys: 558 ms, total: 762 ms
Wall time: 833 ms
2.6 Merge gauge, outlet catchment dataframe#
gauge_shp1 (dataframe)
CPU times: user 10.6 ms, sys: 1.87 ms, total: 12.5 ms
Wall time: 11.9 ms
3. Plot annual cycle for global oceans #
Execution using papermill encountered an exception here and stopped:
CPU times: user 2 μs, sys: 2 μs, total: 4 μs
Wall time: 8.11 μs
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
Cell In[14], line 36
31 else:
32 id_list = gauge_shp1[case][gauge_shp1[case]["ocean"] == ocean_name][
33 "route_id"
34 ].values
---> 36 reach_index = get_index_array(reachID[case], id_list)
37 seas_data_vector = seas_data[case][q_name].stack(seg=("lat", "lon"))
38 dr_flow = seas_data_vector.isel(seg=reach_index).sum(dim="seg")
KeyError: 'b.e30_beta06.B1850C_LTso.ne30_t232_wgx3.188'

if client:
client.shutdown()