JuliaGeo / GRIBDatasets.jl

A high level interface to GRIB encoded files.
MIT License
12 stars 5 forks source link

Update conversion from GRIB to NetCDF example #24

Closed Alexander-Barth closed 7 months ago

Alexander-Barth commented 7 months ago

The call NCDatasets.write(netcdf_file,GRIBDataset(grib_file)) does not dispatch on any type defined in NCDatasets and the function write is a generic function from julia Base. Currently, NCDatasets is the only module which defines a function write(dest_filename::AbstractString, src::CommonDataModel.AbstractDataset). I am wondering if it is not better to change this example with the netcdf dataset as the first argument to write.

For your information, I am working on ZarrDatasets.jl (still unregistered) and the GRIB to Zarr conversion also works in a very similar way:

using GRIBDatasets
using Downloads: download
using ZarrDatasets

grib_file = download("https://github.com/JuliaGeo/GRIBDatasets.jl/raw/98356af026ea39a5ec0b5e64e4289105492321f8/test/sample-data/era5-levels-members.grib")

zarr_dir = tempname()
mkdir(zarr_dir)
ZarrDataset(zarr_dir,"c") do ds
    write(ds,GRIBDataset(grib_file))
end
tcarion commented 7 months ago

I agree that write is better defined this way :-) Thank you very much for the PR !