Closed monicasantamaria closed 1 year ago
This issue is related to a corrupt cache file. You can simply remove the cache
folder in your current working directory and rerun.
I deleted the cache
folder and rerun, but I get the same error because the folder is actually created while I'm running the code that produces the error:
clm = daymet.get_bygeom(basin.geometry[0], dates, variables="prcp", pet="hargreaves_samani")
I'm using Google colab, and I had to follow some tricks to install python 3.10 for HyRiver packages to work. Do you think this error may be related to it?
That's strange. You're right that as soon as you run the code, that folder gets created. I never tried running it on Google Colab. Since you're using Google Colab you can just disable caching like so:
import os
os.environ["HYRIVER_CACHE_DISABLE"] = "true"
Just one note, you might run out of memory on Colab, since they have limited memory per instance and this example retrieves 10 years of gridded climate with all its variables.
I just tried running this example in Binder and the Daymet cell runs just fine, but during calibration the kernel dies since the memory usage exceeds the 2 GB limit on Binder instances.
Disabling caching actually worked, thank you!
I'm aware of the limited memory in Colab, but luckily I didn't run out of memory. However, I have another question. When retrieving the soil thickness, I'm getting a dependency error using the soil_gnatsgo
function. I have already installed both pystac-client
and planetary-computer
packages, and I'm importing all modules since I didn't find in this or any other example which modules I should import:
from pystac_client import *
from planetary_computer import *
Yet, I get the following error:
ERROR:rasterio._filepath:File-like object not found in virtual filesystem: b'dc26ebe9-188e-4dff-8f3d-ef8d1561ee2f/dc26ebe9-188e-4dff-8f3d-ef8d1561ee2f.aux'
ERROR:rasterio._filepath:File-like object not found in virtual filesystem: b'dc26ebe9-188e-4dff-8f3d-ef8d1561ee2f/dc26ebe9-188e-4dff-8f3d-ef8d1561ee2f.AUX'
ERROR:rasterio._filepath:File-like object not found in virtual filesystem: b'dc26ebe9-188e-4dff-8f3d-ef8d1561ee2f/dc26ebe9-188e-4dff-8f3d-ef8d1561ee2f.aux'
ERROR:rasterio._filepath:File-like object not found in virtual filesystem: b'dc26ebe9-188e-4dff-8f3d-ef8d1561ee2f/dc26ebe9-188e-4dff-8f3d-ef8d1561ee2f.AUX'
---------------------------------------------------------------------------
DependencyError Traceback (most recent call last)
Cell In [38], line 9
6 porosity = porosity.where(porosity > porosity.rio.nodata)
7 porosity = porosity.rio.write_nodata(np.nan)
----> 9 thickness = gh.soil_gnatsgo("tk0_999a", geometry, crs).tk0_999a
10 thickness = thickness.where(thickness < 2e6, drop=False) * 10
11 thickness = thickness.rio.write_nodata(np.nan)
File /usr/local/lib/python3.10/site-packages/pygeohydro/pygeohydro.py:1129, in soil_gnatsgo(layers, geometry, crs)
1105 """Get US soil data from the gNATSGO dataset.
1106
1107 Notes
(...)
1126 Requested soil properties.
1127 """
1128 if NO_STAC:
-> 1129 raise DependencyError("get_soildata", ["pystac-client", "planetary-computer"])
1131 catalog = pystac_client.Client.open(
1132 "https://planetarycomputer.microsoft.com/api/stac/v1",
1133 modifier=planetary_computer.sign_inplace,
1134 )
1135 bounds = geoutils.geo2polygon(geometry, crs, 4326).bounds
DependencyError: The following dependencies are missing for running get_soildata:
pystac-client, planetary-computer
Can you help me identify what I'm doing wrong here? Thanks!
Great! It seems that colab has some issues with caching.
Regarding the dep error, my guess is that you installed them but didn't reload pygeohydro
. Try re-importing pygeohydro
or resetting the kernel, so it can detect installation of these two deps.
I imported them once again before running the soil_gnatsgo
function and it worked. So I finally managed to run the whole notebook in Colab. Thank you!
Before closing this discussion, may I ask if you have plans to include in HyRiver a package to retrieve downscaled CMIP climate and hydrology projections data? https://gdo-dcp.ucllnl.org/downscaled_cmip_projections/
I don't think I can do better than what's already out there. There are several downscaled CMIP6 datasets on Microsoft Planetary like GDDP that can be retrieved easily with stac
and also Pangeo has several example notebooks on getting these types of data from their servers.
Oh, I didn't know about those. I will check them out. Thank you :)
Hi! I'm trying to run the notebook example that uses HYMOD and HyRiver packages for hydrological modelling. I changed the station ID to another station of my interest, and I changed the dates for a longer period than the one in the example. I'm getting the following error when I try to compute the PET using the method hargreaves_samani:
My dates are defined as
("1993-01-01", "2015-12-31")
, but I also tested with a shorter period to check if the database gets locked because of the amount of data I'm retrieving. But I got the same error. Do you have any suggestions on how to solve this error?