earthkit-data icon indicating copy to clipboard operation
earthkit-data copied to clipboard

Implement writing GRIB data to FDB

Open sandorkertesz opened this issue 11 months ago • 2 comments

Is your feature request related to a problem? Please describe.

We can already write earthkit-data GRIB data into an FDB as the https://earthkit-data.readthedocs.io/en/latest/examples/grib_fdb_write.html example demonstrates. The task is now to simplify this process and allow users to do it by simply calling a method on a FieldList.

Currently, a FieldList can only write into a file and the API consists of the save() and write() methods:

def save(self, filename, append=False, **kwargs):
      r"""Write all the fields into a file."""

def write(self, f, **kwargs):
     r"""Write all the fields to a file object."""

write() can also be called on a Field.

Now, the primary task is to extend this public API to allow for using a target in save(). It is not clear how to do it. Some possible solutions:

  • use different method names for each target:
     ds.to_file(filename, append=False, **kwargs)
     ds.to_fdb(fdb_object, **kwargs)
    
  • add all options to save():
     ds.save(target="file", fileName="data.grib", append=False, **kwargs)
     ds.save(target="fdb", fdb=fdb_object, **kwargs)
    
  • use a to_target() method:
     ds.to_target("file", fileName, append=True, **kwargs)
     ds.to_target("fdb", fdb_oject, **kwargs)
    

### Organisation

ECMWF

sandorkertesz avatar Feb 26 '24 17:02 sandorkertesz