Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge 0.9.6 from main #24

Merged
merged 18 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Tools and utility to access data in the hydrodata hydrology file share.
```bash
You can install the python package with the API to access files using pip with::


pip install git+https://github.com/hydroframe/hf_hydrodata.git
```

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "hf_hydrodata"
version = "0.9.3"
version = "0.9.6"
description = "hydroframe tools and utilities"
authors = ["William M. Hasling", "Laura Condon", "Reed Maxwell", "George Artavanis", "Amy M. Johnson", "Amy C. Defnet"]
license = "MIT"
Expand Down
20 changes: 18 additions & 2 deletions src/hf_hydrodata/gridded.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from dateutil.relativedelta import relativedelta
import numpy as np
import xarray as xr
import pandas as pd
from parflow import read_pfb_sequence
from parflow.tools.io import read_clm
from hf_hydrodata.data_model_access import ModelTableRow
Expand Down Expand Up @@ -393,6 +394,7 @@ def _construct_string_from_qparams(entry, options):
qparam_values["variable"] = entry["variable"]
qparam_values["file_type"] = entry["file_type"]
qparam_values["grid"] = entry["grid"]
qparam_values["structure_type"] = entry["structure_type"]

string_parts = [
f"{name}={value}" for name, value in qparam_values.items() if value is not None
Expand Down Expand Up @@ -817,7 +819,7 @@ def _validate_user():
url_security = f"{HYDRODATA_URL}/api/api_pins?pin={pin}&email={email}"
response = requests.get(url_security, timeout=15)
if not response.status_code == 200:
raise ValueError(f"No registered PIN for email '{email}' and PIN {pin}. See documentation to register with a URL.")
raise ValueError(f"No registered PIN for email '{email}' and PIN '{pin}'. Browse to https://hydrogen.princeton.edu/pin to request an account and create a PIN. Add your email and PIN to the python call 'gridded.register_api_pin()'.")
json_string = response.content.decode("utf-8")
jwt_json = json.loads(json_string)
expires_string = jwt_json.get("expires")
Expand Down Expand Up @@ -1077,7 +1079,21 @@ def _read_and_filter_vegm_files(
"""
paths = get_file_paths(entry, options)
file_path = paths[0]
data = read_clm(file_path, type="vegm")
# data = read_clm(file_path, type="vegm")

df = pd.read_csv(file_path, delim_whitespace=True, skiprows=2, header=None)
df.columns = [f'c{i}' for i in range(df.shape[1])]

# Number of columns and rows determined by last line of file
nx = int(df.iloc[-1]['c0'])
ny = int(df.iloc[-1]['c1'])
# Don't use 'x' and 'y' columns
feature_cols = df.columns[2:]
# Stack everything into (ny, nx, n_features)
data = np.stack(
[df[c].values.reshape((ny, nx)) for c in feature_cols], axis=-1
)

grid_bounds = options.get("grid_bounds")
if grid_bounds is not None:
imin, jmin, imax, jmax = grid_bounds
Expand Down
4 changes: 2 additions & 2 deletions src/hf_hydrodata/model/data_catalog_entry.csv
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ id,dataset,file_type,variable,dataset_var,entry_start_date,entry_end_date,period
218,conus2_domain,pfb,slope_x,slope_x,,,static,-,-,conus2,2,/hydrodata/PFCLM/CONUS2_baseline/inputs/model_inputs/CONUS2.0.Final1km.slopex.pfb,,
219,conus2_domain,pfb,slope_y,slope_y,,,static,-,-,conus2,2,/hydrodata/PFCLM/CONUS2_baseline/inputs/model_inputs/CONUS2.0.Final1km.slopex.pfb,,
220,conus2_domain,drv_clm,clm_run,clm_run,,,static,-,-,conus2,2,/hydrodata/PFCLM/CONUS2_baseline/inputs/model_inputs/drv_clmin.dat,,
221,conus2_domain,vegm,clm_run,clm_run,,,static,-,-,conus2,2,/hydrodata/PFCLM/CONUS2_baseline/inputs/model_inputs/drv_vegm.CONUS2_723.dat,,
222,conus2_domain,vegp,clm_run,clm_run,,,static,-,-,conus2,2,/hydrodata/PFCLM/CONUS2_baseline/inputs/model_inputs/drv_vegm.CONUS2_723.dat,,
221,conus2_domain,vegm,clm_run,clm_run,,,static,-,-,conus2,2,/hydrodata/PFCLM/CONUS2_baseline/inputs/model_inputs/drv_vegm.CONUS2_fixed.2.dat,,
222,conus2_domain,vegp,clm_run,clm_run,,,static,-,-,conus2,2,/hydrodata/PFCLM/CONUS2_baseline/inputs/model_inputs/drv_vegp.dat,,
223,conus2_domain,pfb,pme,pme,,,static,m/h,-,conus2,2,/hydrodata/PFCLM/CONUS2_baseline/inputs/model_inputs/1km_CONUS2_PME.pfb,pme that was used for steady state CONUS2 spinup,
224,conus2_domain,pfsol,pf_solid,pf_solid,,,static,-,-,conus2,2,/hydrodata/PFCLM/CONUS2_baseline/inputs/model_inputs/CONUS2.0_fix115.pfsol,,
225,conus2_domain,pfb,mannings,mannings,,,static,-,-,conus2,2,/hydrodata/PFCLM/CONUS2_baseline/inputs/model_inputs/CONUS2.0.Final1km_mannings_rv50_original_values_Lake_Sink.pfb,,
Expand Down