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

Improve examples #9

Merged
merged 17 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from 13 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
405 changes: 405 additions & 0 deletions all-requirements.txt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ toml==0.10.2
# via wind-up (pyproject.toml)
tomli==2.0.1
# via poethepoet
tqdm==4.66.3
tqdm==4.66.4
# via wind-up (pyproject.toml)
types-pyyaml==6.0.12.20240311
# via wind-up (pyproject.toml)
Expand Down
7 changes: 3 additions & 4 deletions examples/helpers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import math
from collections.abc import Collection
from pathlib import Path

Expand Down Expand Up @@ -26,7 +27,7 @@ def setup_logger(log_fpath: Path, level: int = logging.INFO) -> None:

def download_zenodo_data(
record_id: str, output_dir: Path, filenames: Collection[str] | None = None, *, cache_overwrite: bool = False
) -> list[Path]:
) -> None:
output_dir.mkdir(parents=True, exist_ok=True)
r = requests.get(f"https://zenodo.org/api/records/{record_id}", timeout=10)
r.raise_for_status()
Expand All @@ -52,10 +53,8 @@ def download_zenodo_data(
with Path.open(dst_fpath, "wb") as f:
for chunk in result.iter_content(chunk_size=BYTES_IN_MB):
chunk_number = chunk_number + 1
print(f"{chunk_number} out of {filesize:.2f} MB downloaded", end="\r")
print(f"{chunk_number} out of {math.ceil(filesize)} MB downloaded", end="\r")
f.write(chunk)
else:
logger.info(f"File {dst_fpath} already exists. Skipping download.")
filepaths.append(dst_fpath)

return filepaths
2 changes: 1 addition & 1 deletion examples/kelmarsh_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def _unpack_metadata() -> pd.DataFrame:

reanalysis_dataset = ReanalysisDataset(
id="ERA5T_52.50N_-1.00E_100m_1hr",
data=pd.read_parquet(PARENT_DIR / "ERA5T_52.50N_-1.00E_100m_1hr_2022.parquet"),
data=pd.read_parquet(PARENT_DIR / "kelmarsh_data" / "ERA5T_52.50N_-1.00E_100m_1hr_2022.parquet"),
)
assessment_inputs = AssessmentInputs.from_cfg(
cfg=cfg,
Expand Down
Loading
Loading