NCAR / geocat-examples

GeoCAT-examples provides a gallery of visualization examples demonstrating how to reproduce plots from NCL Applications scripts with packages in Python. It also includes some longer form examples demonstrating how to use functionality from various GeoCAT packages.
https://geocat-examples.readthedocs.io
Apache License 2.0
66 stars 42 forks source link

Not finding file in GeoCAT-examples NCL_color_1.py #625

Closed eroesler closed 1 week ago

eroesler commented 1 week ago

I am following along with the example NCL_color_1.py to have the example produce a contour plot for an ERA5 netcdf file. It is unable to do so. I get an error when trying to change the filename in the xarray open dataset line. I copied the error below.

Traceback (most recent call last): File "/home/user/geocat/GeoCAT-examples/Gallery/Contours/NCL_color_1.py", line 36, in ds = xr.open_dataset(gdf.get("/path/to/file/reanalysis-era5-pressure-levels-specific_cloud_ice_water_content-011940.nc")).isel(valid_time=-946771200, pressure_level=1000) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/.../python3.11/site-packages/geocat/datafiles/init.py", line 31, in get return POOCH.fetch(fname) ^^^^^^^^^^^^^^^^^^ File "/..../anaconda3/envs/geocat-examples/lib/python3.11/site-packages/pooch/core.py", line 561, in fetch self._assert_file_in_registry(fname) File "/.../anaconda3/envs/geocat-examples/lib/python3.11/site-packages/pooch/core.py", line 609, in _assert_file_in_registry raise ValueError(f"File '{fname}' is not in the registry.")

kafitzgerald commented 1 week ago

It looks like you're attempting to use your own file, but still have some code intended to help grab the sample file.

Removing the gdf.get() portion of the code should allow you to read in your file. Something like this: xr.open_dataset("/path/to/file/reanalysis-era5-pressure-levels-specific_cloud_ice_water_content-011940.nc").isel(valid_time=-946771200, pressure_level=1000)

eroesler commented 1 week ago

Thank you very much for the quick response. That fixed it.