ecmwf / cfgrib

A Python interface to map GRIB files to the NetCDF Common Data Model following the CF Convention using ecCodes
Apache License 2.0
407 stars 77 forks source link

Conversion of COSMO-REA6 gribfiles to netcdf using cfgrib causes a westward shift of the data of about 10-15 km #386

Open LidewijvdB opened 5 months ago

LidewijvdB commented 5 months ago

What happened?

I downloaded COSMO-REA6 grib files for both wind gust and u and v component of wind speed. The wind gust data I did not convert to netcdf but only to zarr using xarray, while the u and v component of wind speed was converted to netcdf first using the xarray code shown below. Several processing and repojection steps follow, but they are identical for both files. ot I end up with a wind gust file with a perfect projection, whereas the wind speed file shows a westward shift in its projection for Southern Europe only (northern UErope is not affected or less affected. It seems to get worse going south.

This is the code we have used (see below)

we always upgrade the eccodes library before running the script to esnrue it is using the latest version. Sicne the res tof the steps are the same, but the outcome is different, we suspect this conversion is causing the issue. Could you come up with a solution fo r us? We have found no other way to convert grib to netcdf

What are the steps to reproduce the bug?

ds = xr.open_mfdataset(file, combine='nested', coords='minimal', compat='override', parallel=False, engine='cfgrib', backend_kwargs={'indexpath': ''})

print("save netcdf file") ds.to_netcdf(new_file_path+'.nc', engine = 'netcdf4')

you could use this on raw data files of consmo-rea6 found overhere:

wind gust: https://opendata.dwd.de/climate_environment/REA/COSMO_REA6/hourly/2D/VMAX_10M/

u and v component of wind speed:

https://opendata.dwd.de/climate_environment/REA/COSMO_REA6/hourly/2D/U_10M/

https://opendata.dwd.de/climate_environment/REA/COSMO_REA6/hourly/2D/V_10M/

for reprojection raster we have used the following CDO commands:

/root/miniconda/bin/cdo remapdis,COSMO-REA6_grid_in_CDO.txt,2 COSMO_REA6_VMAX_max_10M_1991_2021.nc COSMO_REA6_VMAX_max_10M_1991_2021_remapdis_2.nc

with the file COSMO-REA6_grid_in_CDO containing:

gridtype = lonlat

xsize = 10000

ysize = 5500

xfirst = -30

yfirst = 20

xinc = 0.01

yinc = 0.01

Version

10.4

Platform (OS and architecture)

databricks

Relevant log output

no error messages were produced

Accompanying data

No response

Organisation

Royal HaskoningDHV