Skip to content

Commit

Permalink
Merge pull request #65 from SnowEx/out-file-path-checks
Browse files Browse the repository at this point in the history
Add checks for existing directory on out filepath
  • Loading branch information
gbrencher authored Sep 11, 2023
2 parents 8b4bda3 + 701d23d commit f58feb0
Showing 1 changed file with 5 additions and 1 deletion.
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

0 comments on commit f58feb0

Please sign in to comment.