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

Add checks for existing directory on out filepath #65

Merged
merged 1 commit into from
Sep 11, 2023
Merged
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
6 changes: 5 additions & 1 deletion spicy_snow/retrieval.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def retrieve_snow_depth(area: shapely.geometry.Polygon,
wet_snow_thresh: float = -2,
freezing_snow_thresh: float = 1,
wet_SI_thresh: float = 0,
outfp: Union[str, bool] = False,
outfp: Union[str, Path, bool] = False,
params: List[float] = [2.5, 0.2, 0.55]) -> xr.Dataset:
"""
Finds, downloads Sentinel-1, forest cover, water mask (not implemented), and
Expand Down Expand Up @@ -87,6 +87,10 @@ def retrieve_snow_depth(area: shapely.geometry.Polygon,
assert len(params) == 3, f"List of params must be 3 in order A, B, C. Got {params}"
A, B, C = params

if type(outfp) != bool:
outfp = Path(outfp).expanduser().resolve()
assert outfp.parent.exists(), f"Out filepath {outfp}'s directory does not exist"

## set up directories and logging

os.makedirs(work_dir, exist_ok = True)
Expand Down