Using NetCDF data

[1]:
import earthkit.data as ekd

ekd.download_example_file("test.nc")
[2]:
d = ekd.from_source("file", "test.nc")
d
[2]:
NetCDF file

pathtest.nc
size28.1 KiB
typesxarray, pandas, fieldlist, numpy, array
[3]:
d.to_xarray()
[3]:
<xarray.Dataset> Size: 1kB
Dimensions:     (latitude: 8, longitude: 13)
Coordinates:
  * latitude    (latitude) float64 64B 70.0 65.0 60.0 55.0 50.0 45.0 40.0 35.0
  * longitude   (longitude) float64 104B -20.0 -15.0 -10.0 ... 30.0 35.0 40.0
    number      int64 8B ...
    time        datetime64[ns] 8B ...
    step        timedelta64[ns] 8B ...
    surface     float64 8B ...
    valid_time  datetime64[ns] 8B ...
Data variables:
    t2m         (latitude, longitude) float32 416B dask.array<chunksize=(8, 13), meta=np.ndarray>
    msl         (latitude, longitude) float32 416B dask.array<chunksize=(8, 13), meta=np.ndarray>
Attributes:
    GRIB_edition:            1
    GRIB_centre:             ecmf
    GRIB_centreDescription:  European Centre for Medium-Range Weather Forecasts
    GRIB_subCentre:          0
    Conventions:             CF-1.7
    institution:             European Centre for Medium-Range Weather Forecasts
    history:                 2026-03-23T18:21 GRIB to CDM+CF via cfgrib-0.9.1...
[4]:
fl = d.to_fieldlist()
fl.ls()
[4]:
parameter.variable time.valid_datetime time.base_datetime time.step vertical.level vertical.level_type ensemble.member geography.grid_type
0 t2m 2020-05-13 12:00:00 2020-05-13 12:00:00 0 days 0.0 surface 0 None
1 msl 2020-05-13 12:00:00 2020-05-13 12:00:00 0 days 0.0 surface 0 None
[5]:
for f in fl:
    print(f)
Field(t2m, 2020-05-13 12:00:00, 2020-05-13 12:00:00, 0:00:00, 0.0, surface, 0, None)
Field(msl, 2020-05-13 12:00:00, 2020-05-13 12:00:00, 0:00:00, 0.0, surface, 0, None)