Benutzerspezifische Werkzeuge

##### Sektionen
Sie sind hier: NCL / DKRZ PyNGL example regridding with xesmf
Info
Alle Inhalte des Nutzerportal sind nur auf Englisch verfügbar.

# DKRZ PyNGL example regridding with xesmf

This example demonstrate how to use xesmf and xarray to regrid to a higher resolution grid.

Example script:

`##  File:#    TRANS_regrid_xesmf_rectilinear_to_rectilinear.py##  Synopsis:#    Illustrates how to create a contour fill plot on a map##  Categories:#    contour plot#    map plot##  Author:#    Karin Meier-Fleischer, based on NCL example#  #  Date of initial publication:#    October 2018##  Description:#    This example shows how to create a contour fill plot on a map.##  Effects illustrated:#    o  Drawing a contour fill plot#    o  Drawing a map# #  Output:#    Two visualizations are produced, original data and regridded data.##  Notes: The data for this example can be downloaded from #    http://www.ncl.ucar.edu/Document/Manuals/NCL_User_Guide/Data/#   '''  Transition Guide Python Example:     TRANS_regrid_xesmf_rectilinear_to_rectilinear.py  - read netCDF file  - regrid to higher resolution grid   - drawing contour fill plots  - drawing a map    18-10-15  kmf'''from __future__ import print_functionimport numpy as npimport xarray as xrimport xesmf as xeimport Ngl#--  open file and read variablesdata = xr.open_dataset("rectilinear_grid_3D.nc")t   = data['t'][0,0,:,:]lat = np.array(data['lat'][:])lon = np.array(data['lon'][:])#-- destination lat/londst_lat = np.arange(-89.5,90.5,1.0)dst_lon = np.arange(-179.5,180.5,1.0)#-- init destination griddstgrid = xr.Dataset({'lat': (['lat'], dst_lat),                      'lon': (['lon'], dst_lon),})#-- regridregridder = xe.Regridder(data, dstgrid, 'bilinear')t_regrid   = regridder(t)lat_regrid = regridder(t).latlon_regrid = regridder(t).lon#-- plottingwks = Ngl.open_wks("png","plot_TRANS_regrid_xesmf_py")res                 =  Ngl.Resources()res.nglFrame        =  Falseres.cnFillOn        =  Trueres.cnFillPalette   = "NCL_default"res.cnLineLabelsOn  =  Falseres.cnLevelSelectionMode = "ManualLevels"   #-- use manual contour line levelsres.cnMinLevelValF  =  235.0                #-- contour min. valueres.cnMaxLevelValF  =  310.0                #-- contour max. valueres.cnLevelSpacingF =    5.0                #-- contour intervalres.lbOrientation   = "horizontal"res.sfXArray        =  dst_lonres.sfYArray        =  dst_latplot = Ngl.contour_map(wks,t_regrid,res)Ngl.frame(wks)res.sfXArray        =  lonres.sfYArray        =  latplot = Ngl.contour_map(wks,t,res)Ngl.frame(wks)#-- clean-upregridder.clean_weight_file()`

Artikelaktionen