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

GFSForecast radiation variables broken. #253

Closed
Mutaz-Datatactics opened this issue Oct 10, 2024 · 3 comments · Fixed by #254
Closed

GFSForecast radiation variables broken. #253

Mutaz-Datatactics opened this issue Oct 10, 2024 · 3 comments · Fixed by #254
Labels
bug Something isn't working

Comments

@Mutaz-Datatactics
Copy link

Description
When running CoCiP with GFS (see https://py.contrails.org/notebooks/GFS.html#Run-CoCiP-with-GFS), opening a rad dataset results in the following error:

KeyError: "No variable named 'ulwrf'. Variables on the dataset include []"

This worked until the last update on the 8th of October (v0.54.1). It seems that the loaded dataset is empty.

Details

  • Version: 0.54.1
  • Module: pycontrails.datalib.gfs
  • OS: manjaro
  • Reporter: Mutaz-Datatactics

Steps to Reproduce

  1. Import GFSForecast (from pycontrails.datalib.gfs import GFSForecast)
  2. Initialize a GFSForecast object with time range and rad variables: gfs_rad = GFSForecast(("2022-03-01 00:00:00", "2022-03-01 23:00:00"), variables=Cocip.rad_variables, show_progress=True)
  3. Download and open the respective metdataset: rad = gfs_rad.open_metdataset()

Additional Notes

  • Running the steps above with the parameter pressure_levels returns ValueError, because it expects a met_variable.

  • Met data can be downloaded and opened correctly. Only rad data is broken.

@Mutaz-Datatactics Mutaz-Datatactics added the bug Something isn't working label Oct 10, 2024
@Mutaz-Datatactics
Copy link
Author

it looks to me like the error is in gfs.py in the definition of _download_file.
After downloading the file to tmp, the function tries to declare the dataset using

            ds = self._open_gfs_dataset(temp_grib_filename, t)

In _open_gfs_dataset, it checks if ds is None, and if so, sets it to tmpds, which is constructed using the temp_grib_name above. However, the file usually no longer exists by then, and ds is still None.
The line

                ds[v.short_name] = tmpds[v.short_name]

Then throws an error, since no variables exist.

@zebengberg
Copy link
Contributor

Thanks for finding this! I've been able to reproduce what you're seeing. I've found that this also fails on earlier versions of pycontrails as well.

@zebengberg
Copy link
Contributor

I think some of the GFS variable names have changed. For a quick fix, see 0ea1596

I'll get this integrated into pycontrails.

@zebengberg zebengberg mentioned this issue Oct 11, 2024
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants