-
Notifications
You must be signed in to change notification settings - Fork 2
Using ESMF_Regrid
Liam Bindle edited this page May 20, 2021
·
4 revisions
A command line utility to apply ESMF_RegridWeightGen weights to datasets should be added. This will avoid some unnecessay IO that is apparent in these examples. This utility for applying ESMF weights should probably go in xESMF.
# Download sample NetCDF data
wget https://www.unidata.ucar.edu/software/netcdf/examples/sresa1b_ncar_ccsm3-example.nc
# Add "coordinates" attributes to the "tas" variable. ESMF requires this "coordinates" attribute.
ncatted -a coordinates,tas,o,c,"lon lat" sresa1b_ncar_ccsm3-example.nc
# Create C24 gridspec
gridspec-create gcs 24
# Create empty datasets to recieve data to
gridspec-utils touch -m c24_gridspec.nc c24_recv
# Regrid
ESMF_Regrid -s sresa1b_ncar_ccsm3-example.nc -d c24_gridspec.nc --dstdatafile c24_recv --src_var tas --dst_var tas -m conserve
# Join the data tiles
gridspec-utils join c24_recv -m c24_gridspec.nc -d nf -s joinspec.jsonwhere joinspec.json is
{
"rename_dict": {},
"transpose": ["time", "nf", "Ydim", "Xdim"]
}# Create output file (for lat-long grids, ESMF_Regrid's output goes to this file)
gridspec-create latlon 180 360
mv regular_lat_lon_180x360.nc my_output_latlon_file.nc
# Split the input cubed-sphere data into 6 separate files
gridspec-utils split -m c24_gridspec.nc -d nf GCHP.SpeciesConc.20180101_1200z.nc4
# Regrid
VARIABLES=SpeciesConc_O3,SpeciesConc_NO,SpeciesConc_NO2,SpeciesConc_HNO3,SpeciesConc_PAN,SpeciesConc_CO,SpeciesConc_CH2O,SpeciesConc_SO2,SpeciesConc_NH3,SpeciesConc_H2O
ESMF_Regrid -s c24_gridspec.nc --srcdatafile GCHP.SpeciesConc.20180101_1200z -d my_output_latlon_file.nc --src_var ${VARIABLES} --dst_var ${VARIABLES} -m conserve