Installation with pip (if needed)
#!pip install matplotlib
#!pip install climetlab
#!pip install climetlab-eumetnet-postprocessing-benchmark
Loading climetlab
import climetlab as cml
and matplotlib
import matplotlib.pyplot as plt
Download of a deterministic high-resolution forecast (the 2 metre temperature)
ds = cml.load_dataset(
"eumetnet-postprocessing-benchmark-training-data-gridded-forecasts-surface",
date="2017-12-02",
parameter="2t",
kind="highres",
)
The ds
object returned is a climetlab datasource that can be converted to various format.
Note that the data are cached temporarily on your disk so next time you ask for this forecast I might be faster.
For example, conversion to a xarray :
fcs = ds.to_xarray()
fcs
Plotting using climetlab and magics (still in development)
cml.plot_map(ds[5], # plot of the 5th time step
foreground=dict(
map_grid=False,
map_label=False,
map_grid_frame=True,
map_grid_frame_thickness=5,
map_boundaries=True,
),
)
Retrieving the observations corresponding to the forecasts (in xarray format)
obs = ds.get_observations_as_xarray()
obs
Plotting the observations with magics
cml.plot_map(obs.t2m[0,0,5,0], # plot of the 5th time step
foreground=dict(
map_grid=False,
map_label=False,
map_grid_frame=True,
map_grid_frame_thickness=5,
map_boundaries=True,
),
)
Compute the difference between the forecast and the observations
diff = fcs - obs
diff
and plot
cml.plot_map(diff.t2m[0,0,5,0], # plot of the 5th time step
foreground=dict(
map_grid=False,
map_label=False,
map_grid_frame=True,
map_grid_frame_thickness=5,
map_boundaries=True,
),
)
Save the forecast and observations on the hard drive as a netcdf
fcs.to_netcdf('fcs_hr_2017-12-02.nc')
obs.to_netcdf('obs_2017-12-02.nc')
!ls
Plotting the observations and the forecast at 4 different points (forecasts are solid lines, observations are dashed lines)
points = [(20, 20), (20, 70), (70, 20), (70, 70)]
plt.figure(figsize=(10, 8))
for point in points:
line = fcs.t2m.isel(latitude=point[0], longitude=point[1], time=0, surface=0, number=0).plot()
obs.t2m.isel(latitude=point[0], longitude=point[1], time=0, surface=0, number=0).plot(ls='--', color=line[0].get_color())
Download of an ensemble forecast (the precipitation)
ds = cml.load_dataset(
"eumetnet-postprocessing-benchmark-training-data-gridded-forecasts-surface-processed",
date="2017-12-02",
parameter="tp",
kind="ensemble",
)
fcs = ds.to_xarray()
fcs
obs = ds.get_observations_as_xarray()
obs
Plotting the observations and forecast ensemble mean at 4 different points (forecasts are solid lines, observations are dashed lines)
points = [(20, 20), (20, 70), (70, 20), (70, 70)]
plt.figure(figsize=(10, 8))
for point in points:
line = fcs.tp6.isel(latitude=point[0], longitude=point[1], time=0, surface=0).mean('number').plot()
obs.tp6.isel(latitude=point[0], longitude=point[1], time=0, surface=0, number=0).plot(ls='--', color=line[0].get_color())
Download of an ensemble reforecast (the 2 metre temperature)
ds = cml.load_dataset(
"eumetnet-postprocessing-benchmark-training-data-gridded-reforecasts-surface",
date="2017-12-28",
parameter="2t"
)
fcs = ds.to_xarray()
fcs
obs = ds.get_observations_as_xarray()
obs
Plotting the observations and forecast ensemble mean at 4 different points (forecasts are solid lines, observations are dashed lines) in 1997 with the 2017 model version !
points = [(20, 20), (20, 70), (70, 20), (70, 70)]
plt.figure(figsize=(10, 8))
for point in points:
line = fcs.t2m.isel(latitude=point[0], longitude=point[1], time=0, surface=0).mean('number').plot()
obs.t2m.isel(latitude=point[0], longitude=point[1], time=0, surface=0, number=0).plot(ls='--', color=line[0].get_color())
Download of an ensemble reforecast (the precipitation)
ds = cml.load_dataset(
"eumetnet-postprocessing-benchmark-training-data-gridded-reforecasts-surface-processed",
date="2017-12-28",
parameter="tp"
)
fcs = ds.to_xarray()
fcs
obs = ds.get_observations_as_xarray()
obs
Plotting the observations and forecast ensemble mean at 4 different points (forecasts are solid lines, observations are dashed lines) in 1997 with the 2017 model version !!
points = [(20, 20), (20, 70), (70, 20), (70, 70)]
plt.figure(figsize=(10, 8))
for point in points:
line = fcs.tp6.isel(latitude=point[0], longitude=point[1], time=0, surface=0).mean('number').plot()
obs.tp6.isel(latitude=point[0], longitude=point[1], time=0, surface=0, number=0).plot(ls='--', color=line[0].get_color())