Last active
February 26, 2024 10:45
-
-
Save BaptisteVandecrux/d670344de9c9c71092eac6cd27147aeb to your computer and use it in GitHub Desktop.
Projection information for the CARRA reanalysis west domain grid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# CARRA homepage: https://cds.climate.copernicus.eu/cdsapp#!/dataset/reanalysis-carra-single-levels?tab=overview | |
# The West domain's grid is described as "Lambert conformal conic grid with 1069 x 1269 grid points for the CARRA-West domain" | |
# but no proj4 description is given on the website nor on the GRIB/NetCDF files that are distributed. | |
# The CRS was found in a static file distributed by ECMWF: fraction.west.nc | |
# It had the same grid size as the CARRA west domain and following projection information: | |
# proj4 = " +units=m +a=6371229.0 +b=6371229.0 +y_0=-9872984.57134 +lon_0=-36.0 +proj=lcc +x_0=-0.0 +lat_2=72.0 +lat_1=72.0" | |
# To read a grib file and add the CRS information the following script can be used: | |
import xarray as xr | |
import rioxarray | |
from rasterio.crs import CRS | |
import cfgrib # check dependencies at https://pypi.org/project/cfgrib/ | |
crs = CRS.from_string("+units=m +a=6371229.0 +b=6371229.0 +y_0=-9872984.57134 +lon_0=-36.0 +proj=lcc +x_0=-0.0 +lat_2=72.0 +lat_1=72.0") | |
ds = xr.open_dataset(path_to_grib_file, engine='cfgrib') | |
ds = ds.rio.write_crs(crs) | |
# now you can reproject/select/crop/extract |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment