Howtos
How to save results from a retrieval into a file?
You need to use the save()
method on the resulting object. For example, this is how to
save the results of a MARS retrieval into a file:
import earthkit.data
ds = earthkit.data.from_source(
"mars",
param=["2t", "msl"],
levtype="sfc",
area=[50, -10, 40, 10], # N,W,S,E
grid=[2, 2],
date="2023-05-10",
)
ds.save("my_data.grib")
How to call to_xarray() with arguments for NetCDF data?
When calling to_xarray()
for NetCDF data it calls xarray.open_mfdataset
internally. You can pass arguments to this xarray function by using the xarray_open_mfdataset_kwargs
option. For example:
import earthkit.data
req = {
"format": "zip",
"origin": "c3s",
"sensor": "olci",
"version": "1_1",
"year": "2022",
"month": "04",
"nominal_day": "01",
"variable": "pixel_variables",
"region": "europe",
}
ds = earthkit.data.from_source("cds", "satellite-fire-burned-area", req)
r = ds.to_xarray(
xarray_open_mfdataset_kwargs=dict(decode_cf=False, decode_times=False)
)