<div dir="ltr"><div class="gmail_default" style="font-size:small">Dear Igor,</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">We need a little more information.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">First, it is helpful if you copy-and-paste the actual error message in your email. </div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Second, please include the output from "printVarSummary(SLP)".</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Really, though, it helps if you can provide the data files so we can run the script and see what the issue is.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Thanks,</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">--Mary</div><div class="gmail_default" style="font-size:small"><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 5, 2015 at 2:52 AM, igor akkerman <span dir="ltr"><<a href="mailto:igorakkerman89@gmail.com" target="_blank">igorakkerman89@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><font size="4">Hi,</font></div><div><font size="4"><br></font></div><div><font size="4">I need to regrid NCEP-NCAR reanalysis to a rotated regional model grid that is set up as follows:</font></div><div><br></div><div><span style="font-size:12.8000001907349px">Sketch of the rotated grid (rot.lat, rot.lon)</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">(24.5,-27.5) ------ (24.5,27.0)</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px"> | |</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px"> | |</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">(-25.0,-27.5) ------ (-25.0,27.0)</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">This is a regular grid with uniform resol. of 0.5.</span><br style="font-size:12.8000001907349px"><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">and in geograf. grid (geograf. lat, lon):</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">(53.8,-134.6) ------ (54.2,135.1)</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px"> | |</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px"> | |</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px">(53.5,-44.7) ------ (53.85,44.2)</span><br style="font-size:12.8000001907349px"></div><div><br></div><div><font size="4">I also have an ascii file with rotated grid cell coordinates and equivalent geographical coordinates called 'hirham_rot_geo_koor.dat". </font></div><div><font size="4"><br></font></div><div><font size="4">I tried making a script but can't correctly assign the conversion between rotated and geographical grid coordinates. Could you please take a look at the script and suggest how to fix it?</font></div><div><font size="4"><br></font></div><div><font size="4">The error message is that SLP_regrid variable has only one coordinate instead of three.</font></div><div><br></div><div><br></div><div> WRITE_NETCDF = False </div><div> </div><div>; TEXT FILE CONVERTING ROTATED AND SPHERICAL LATS AND LONS</div><div>filename = "hirham_rot_geo_koor.dat"</div><div>coords = asciiread(filename,(/100,110,4/),"float")</div><div>lat2d = coords(:,:,0) ; reading rotated latitude from ascii file</div><div>lon2d = coords(:,:,1) ; reading rotated longitude from ascii file</div><div>printMinMax(lon2d, True)</div><div><br></div><div>;---NCEP-NCAR reanalysis</div><div> srcFileName = "<a href="http://slp.1948.nc" target="_blank">slp.1948.nc</a>"</div><div> sfile = addfile(srcFileName,"r")</div><div><br></div><div> Opt = True</div><div> Opt@SrcTitle = "NCEP-NCAR reanalysis" ; optional</div><div><br></div><div> Opt@WgtFileName = "NCEP_to_Rect.nc"</div><div><br></div><div> Opt@ForceOverwrite = True</div><div><br></div><div> SLP = sfile->slp</div><div> SLP@lat2d = lat2d </div><div> SLP@lon2d = lon2d</div><div><br></div><div>printVarSummary(SLP)</div><div> </div><div> dims = dimsizes(lat2d)</div><div> nlat = dims(0)</div><div> nlon = dims(1)</div><div><br></div><div> Opt@SrcFileName = "Rectilinear.nc" ; Name of source and</div><div> Opt@DstFileName = "WRF_SCRIP.nc" ; destination files</div><div><br></div><div>;---Create the destination lat/lon grid</div><div> printVarSummary(lat2d)</div><div> printVarSummary(lon2d)</div><div> printMinMax(lat2d, True)</div><div> printMinMax(lon2d, True)</div><div> lat = fspan( -25, 24.5,nlat)</div><div> lon = fspan( -27.5,27,nlon)</div><div> lat@units = "degrees_north"</div><div> lon@units = "degrees_east"</div><div> lat!0 = "lat"</div><div> lon!0 = "lon"</div><div> lat&lat = lat</div><div> lon&lon = lon</div><div><br></div><div> Opt@DstGridType = "rectilinear"</div><div> Opt@DstGridLat = lat</div><div> Opt@DstGridLon = lon</div><div><br></div><div> Opt@InterpMethod = "bilinear"</div><div> Opt@SrcRegional = True</div><div> Opt@DstRegional = True</div><div> Opt@Debug = True</div><div> SLP_regrid = ESMF_regrid(SLP,Opt) ; Do the regridding for TMP</div><div>;</div><div>; The source and destination grid description files and</div><div>; weight file will be the same for the next call to </div><div>; ESMF_grid, so no need to regenerate them.</div><div>;</div><div> Opt@SkipSrcGrid = True</div><div> Opt@SkipDstGrid = True</div><div> Opt@SkipWgtGen = True</div><div> </div><div>;---Reset 0 values to missing values.</div><div> SLP_regrid@_FillValue = default_fillvalue(typeof(SLP_regrid))</div><div><br></div><div> SLP_regrid = where(SLP_regrid.eq.0.0,SLP_regrid@_FillValue,\</div><div> SLP_regrid)</div><div><br></div><div> printVarSummary(SLP_regrid)</div><div><br></div><div>;----------------------------------------------------------------------</div><div>; Plotting section</div><div>;</div><div>; This section creates filled contour plots of both the original</div><div>; data and the regridded data, and panels them.</div><div>;----------------------------------------------------------------------</div><div> wks_slp = gsn_open_wks("png","interpolate_slp")</div><div><br></div><div> res = True</div><div><br></div><div> res@gsnDraw = False</div><div> res@gsnFrame = False</div><div><br></div><div> res@cnFillOn = True</div><div> res@cnLinesOn = False</div><div> res@cnLineLabelsOn = False</div><div> res@lbLabelBarOn = False</div><div> res@cnLevelSelectionMode = "ManualLevels"</div><div><br></div><div> res@gsnPolar = "NH"</div><div> res@mpMinLatF = min(lat)</div><div> res@gsnAddCyclic = False</div><div><br></div><div> nrec = 0</div><div> dims_orig = tostring(dimsizes(SLP(nrec,:,:)))</div><div><br></div><div> mnmxint_slp = nice_mnmxintvl( min(SLP), max(SLP), 18, False)</div><div><br></div><div>;---SLP</div><div> res@cnMinLevelValF = mnmxint_slp(0)</div><div> res@cnMaxLevelValF = mnmxint_slp(1)</div><div> res@cnLevelSpacingF = mnmxint_slp(2)/2. ; Create more levels</div><div> res@tiMainFontHeightF = 0.015</div><div><br></div><div>;---SLP regridded</div><div> res@tiMainString = "rectilinear grid (" + Opt@InterpMethod + " interpolation)"</div><div> slp_regrid = gsn_csm_contour_map(wks_slp,SLP_regrid(nrec,:,:),res)</div><div><br></div><div>;---SLP original</div><div> res@tiMainString = "SLP on original curvilinear grid (" + \</div><div> str_join(dims_orig," x ") + ")"</div><div><br></div><div> slp_orig = gsn_csm_contour_map(wks_slp,SLP(nrec,:,:),res) </div><div><br></div><div>;---Compare the plots in a panel</div><div> pres = True</div><div> pres@gsnMaximize = True</div><div> pres@gsnPanelLabelBar = True</div><div><br></div><div> gsn_panel(wks_slp,(/slp_orig,slp_regrid/),(/1,2/),pres)</div><div><br></div><div>;---Trim</div><div> system("convert -trim interpolate_slp.png interpolate.png")</div></div>
<br>_______________________________________________<br>
ncl-talk mailing list<br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>