ecmwf / cfgrib

A Python interface to map GRIB files to the NetCDF Common Data Model following the CF Convention using ecCodes
Apache License 2.0
407 stars 77 forks source link

Make sure temp files are removed #306

Closed emfdavid closed 2 years ago

emfdavid commented 2 years ago

Change temp file behavior to ensure files are unlinked (removed). Related to https://github.com/ecmwf/cfgrib/issues/283

FussyDuck commented 2 years ago

CLA assistant check
All committers have signed the CLA.

iainrussell commented 2 years ago

Hi @emfdavid,

Many thanks for taking an interest in cfgrib and for contributing a change!

But in fact these files are not temporary, they are index files that persist on the filesystem in order to avoid potentially expensive re-scanning of a GRIB file each time it is opened.

However, you can suppress their creation completely by passing the indexpath argument to cfgrib like this:

xr.open_dataset('era5-levels-members.grib', engine='cfgrib', backend_kwargs={'indexpath':''})

Best regards, Iain

emfdavid commented 2 years ago

Closing per discussion in https://github.com/ecmwf/cfgrib/issues/283