NVIDIA / earth2studio

Open-source deep-learning framework for exploring, building and deploying AI weather/climate workflows.
https://nvidia.github.io/earth2studio/
Apache License 2.0
95 stars 31 forks source link

🚀[FEA]: Overwriting NetCDF4 output files #105

Closed jleinonen closed 3 months ago

jleinonen commented 3 months ago

Is this a new feature, an improvement, or a change to existing functionality?

Improvement

How would you describe the priority of this feature request

Low (would be nice)

Please provide a clear description of problem you would like to solve.

Trying to write to a NetCDF4 file that already exists currently produces the following error:

AssertionError: Warning! <variable> is already in the NetCDF Store.

This is not particularly clear as to the nature of what went wrong. I also think most people would expect that the default behavior is to overwrite the file if it already exists, as most utilities do. I'd suggest two improvements:

  1. Make the error message clearer as to why it occurred (i.e. the file already existed)
  2. Add an option to overwrite any existing file (maybe even make it the default behavior)

Item 2 should be achievable by using write mode w instead of r+ in: https://github.com/NVIDIA/earth2studio/blob/c90c04d0d54de465a4891936f3c9f46918f80312/earth2studio/io/netcdf4.py#L52-L58

NickGeneva commented 3 months ago

Re-opening to add more informative error when write fails. (suggest a backend)