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

updating docs, fix random.choice(str) #61

Merged
merged 2 commits into from
Jul 1, 2024
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
Binary file modified docs/_images/model_layout.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 13 additions & 4 deletions src/ewatercycle_HBV/forcing.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from datetime import datetime
from pathlib import Path
from typing import Optional
import random
import secrets
import string

import pandas as pd
Expand All @@ -24,7 +24,7 @@

REQUIRED_PARAMS = ["pr", "evspsblpot", "tas"]
class HBVForcing(DefaultForcing):
"""Container for HBV forcing data.
"""Class for HBV forcing data, mainly focused on using CAMELS dataset.

Args:
camels_file: .txt file that contains CAMELS forcing from https://hess.copernicus.org/articles/21/5293/2017/
Expand Down Expand Up @@ -136,7 +136,16 @@ def from_test_txt(self) -> xr.Dataset:
return ds

def from_camels_txt(self) -> xr.Dataset:
"""Load forcing data from a txt file into an xarray dataset.
"""Load forcing data from a txt file into a xarray dataset.

Note:
This is only tested with the daymet files.
The other two sources (NLDAS/maurer) can pose some issues, for more details
see this repo `<https://github.com/Daafip/CAMELS-to-netcdf/blob/218a5c6c17472d1b59630ee4a1000c3cb8fafcd0/read_camels.py#L56>`_ .
Instead, use the
`eWaterCycle CAMELS functionality <https://github.com/eWaterCycle/ewatercycle/pull/407>`_
which utilises
`OpenDAP <https://doi.org/10.4121/ca13056c-c347-4a27-b320-930c2a4dd207>`_ .

Requirements:
Must be in the same format as the CAMELS dataset:
Expand Down Expand Up @@ -269,7 +278,7 @@ def crop_ds(self, ds: xr.Dataset, name: str):

time = str(datetime.now())[:-10].replace(":", "_")
letters = string.ascii_lowercase + string.ascii_uppercase
unique_identifier = ''.join((random.choice(letters)) for _ in range(5))
unique_identifier = ''.join((secrets.choice(letters)) for _ in range(5))
ds_name = f"HBV_forcing_{name}_{time}_{unique_identifier}.nc"
out_dir = self.directory / ds_name
if not out_dir.exists():
Expand Down
Loading