Skip to content
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
4 changes: 2 additions & 2 deletions spicy_snow/processing/generate_dataarrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,8 @@ def generate_forest_fraction_dataarray(aoi, ref = None) -> xr.Dataset:
# first check if in us
if not within_conus(aoi):
log.info(f'AOI outside of CONUS. Using Proba-V datasets')
tmp_dir = tempfile.gettempdir()
fcf = xr.open_dataarray(download_proba_v(), tmp_dir.joinpath('fcf.tif'))[0]
tmp_dir = Path(tempfile.gettempdir())
fcf = xr.open_dataarray(download_proba_v(tmp_dir.joinpath('fcf.tif')))[0]
else:
log.info(f'AOI inside of CONUS. NLCD 2021 Forest Cover')
fcf = get_nlcd(aoi)
Expand Down
5 changes: 1 addition & 4 deletions spicy_snow/processing/wet_snow.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,6 @@ def flag_wet_snow(dataset: xr.Dataset) -> Union[None, xr.Dataset]:

melt_season = (dataset['time.month'] > 1) & (dataset['time.month'] < 8)

# get images of this relative orbit and in the melt season
melt_season = (dataset['time.month'] > 1) & (dataset['time.month'] < 8)

# get images of this relative orbit and in the melt season
melt_orbit = (melt_season & (dataset.track == orbit))

Expand Down Expand Up @@ -224,6 +221,6 @@ def flag_wet_snow(dataset: xr.Dataset) -> Union[None, xr.Dataset]:
# if less than 50% are wet then keep the save value for wet_snow otherwise set to 1
dataset['wet_snow'] = dataset['wet_snow'].where(dataset['perma_wet'] < 0.5, 1)

dataset['wet_snow'].loc[dict(time = ts)] = dataset.sel(time = ts)['wet_snow'].where(dataset.sel(time = ts)['snowcover'] == True, 0)
dataset['wet_snow'] = dataset['wet_snow'].where(dataset['snowcover'] == True, 0)

return dataset
9 changes: 6 additions & 3 deletions spicy_snow/utils/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,10 @@ def decompress(infile, tofile):
def download_proba_v(out_fp):
# this is the url from Lievens et al. 2021 paper
fcf_url = 'https://zenodo.org/record/3939050/files/PROBAV_LC100_global_v3.0.1_2019-nrt_Tree-CoverFraction-layer_EPSG-4326.tif'
# download just forest cover fraction to out file
fcf_fp = download_url(url = fcf_url, filename = out_fp)
# asf_search.download_url takes (url, path, filename) and writes to path/filename;
# split out_fp into its parent directory and filename. download_url returns None,
# so we return out_fp ourselves.
out_fp = Path(out_fp)
download_url(url = fcf_url, path = str(out_fp.parent), filename = out_fp.name)

return fcf_fp
return out_fp
Loading