Skip to content

Commit

Permalink
updated scripts for read_ts_xrdataset and read_attr_xrdataset for cam…
Browse files Browse the repository at this point in the history
…elsus
  • Loading branch information
OuyangWenyu committed Sep 14, 2024
1 parent dfa87de commit 853fffb
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion examples/scripts.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
Author: Wenyu Ouyang
Date: 2022-09-06 23:42:46
LastEditTime: 2024-09-12 14:53:47
LastEditTime: 2024-09-14 13:27:17
LastEditors: Wenyu Ouyang
Description: examples for using hydrodataset
FilePath: \hydrodataset\examples\scripts.py
Expand All @@ -26,6 +26,7 @@
us_region = "US"

# ------------------------------ US --------------------------------
# if files is not zipped, set download=True to unzip the files
camels_us = Camels(camels_us_path, download=False, region=us_region)
gage_ids = camels_us.read_object_ids()
flows = camels_us.read_target_cols(
Expand Down Expand Up @@ -69,6 +70,24 @@
attr_types[:3], np.array(["gauge_lat", "gauge_lon", "elev_mean"])
)

# we highly recommend to cache the xrdataset for faster access
camels_us.cache_xrdataset()
forcings = camels_us.read_ts_xrdataset(
gage_id_lst=gage_ids[:5],
t_range=["2013-01-01", "2014-01-01"],
var_lst=["prcp", "srad", "tmax"],
)
flows = camels_us.read_ts_xrdataset(
gage_id_lst=gage_ids[:5],
t_range=["2013-01-01", "2014-01-01"],
# NOTE: the variable name is "streamflow" instead of "usgsFlow" after caching
var_lst=["streamflow"],
)
attrs = camels_us.read_attr_xrdataset(
gage_id_lst=gage_ids[:5],
var_lst=["soil_conductivity", "elev_mean", "geol_1st_class"],
)

# ------------------------------ AUS --------------------------------
camels_aus = Camels(camels_aus_path, download=False, region=aus_region)
gage_ids = camels_aus.read_object_ids()
Expand Down

0 comments on commit 853fffb

Please sign in to comment.