<div dir="ltr"><div class="gmail_default" style="font-size:small">Hi Juris,</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default">When you use conservative regridding, an additional array is needed that provides the "bounds" of each data point. If you don't provide one, NCL tries to calculate one for you by generating a rectangle that encloses each data point. This is what becomes "grid_corner_lat" and "grid_corner_lon" on the NetCDF file.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">This "guess" is likely not going to be accurate for your own data, because NCL has no way of knowing what the true bounds are. The error you are seeing is likely because over the poles, this guesswork can be especially bad.</div><br>The best way to handle this is to provide your own "bounds" via the special SrcGridCornerLat and Opt@SrcGridCornerLon options<div class="gmail_default" style="font-size:small;display:inline">.</div><div><br>
<div class="gmail_default" style="font-size:small">I'm interested in seeing if we can improve the "guessing" algorithm, however, or maybe finding another solution for you.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Can you provide me with the data to run this script? If it's not too large, you can use our ftp:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default"><a href="http://www.ncl.ucar.edu/report_bug.shtml#HowToFTP">http://www.ncl.ucar.edu/report_bug.shtml#HowToFTP</a><br></div><div class="gmail_default"><br></div><div class="gmail_default">Feel free to email me offline about this if you can provide the file but don't want to make it public.</div><div class="gmail_default"><br></div><div class="gmail_default">--Mary</div><div class="gmail_default"><br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jun 21, 2017 at 5:05 PM, Juris Almonte <span dir="ltr"><<a href="mailto:Juris.Almonte@umanitoba.ca" target="_blank">Juris.Almonte@umanitoba.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word">
Dear NCL help,
<div><br>
</div>
<div>I am having trouble regridding my WRF precipitation data (4 km) to a coarser grid (10 km grid with a polar stereographic projection) using the “conserve” method. I should note that it works for the “bilinear method”. I get the following error
when using the “conserve” method. I am using NCL V6.3.</div>
<div><br>
</div>
<div>
<div style="margin:0px;font-size:13px;font-family:Menlo">20170621 172919.788 INFO PET0 Running with ESMF Version 6.3.0rp1</div>
<div style="margin:0px;font-size:13px;font-family:Menlo">20170621 172940.034 ERROR PET0 ~~~~~~~~~~~~~~~~~~~~ Concave Element Detected ~~~~~~~~~~~~~~~~~~~~</div>
<div style="margin:0px;font-size:13px;font-family:Menlo">20170621 172940.034 ERROR PET0 concave elem. id=683007</div>
<div style="margin:0px;font-size:13px;font-family:Menlo">20170621 172940.034 ERROR PET0 </div>
<div style="margin:0px;font-size:13px;font-family:Menlo">20170621 172940.034 ERROR PET0 concave elem. coords (lon [-180 to 180], lat [-90 to 90]) (x,y,z)</div>
<div style="margin:0px;font-size:13px;font-family:Menlo">20170621 172940.034 ERROR PET0 ------------------------------<wbr>------------------------------<wbr>-----</div>
<div style="margin:0px;font-size:13px;font-family:Menlo">20170621 172940.034 ERROR PET0 0 (-100.720581, 89.804306) (-0.000635, -0.003356, 0.999994)</div>
<div style="margin:0px;font-size:13px;font-family:Menlo">20170621 172940.034 ERROR PET0 1 (-76.010437, 89.767494) (0.000981, -0.003938, 0.999992)</div>
<div style="margin:0px;font-size:13px;font-family:Menlo">20170621 172940.034 ERROR PET0 2 (-133.219574, 89.857407) (-0.001704, -0.001814, 0.999997)</div>
<div style="margin:0px;font-size:13px;font-family:Menlo">20170621 172940.034 ERROR PET0 3 (130.780121, 89.925125) (-0.000854, 0.000990, 0.999999)</div>
<div style="margin:0px;font-size:13px;font-family:Menlo">20170621 172940.034 ERROR PET0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<wbr>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<wbr>~~~~~~</div>
<div style="margin:0px;font-size:13px;font-family:Menlo">20170621 172940.035 ERROR PET0 ESMCI_Regrid_F.C:178 c_esmc_regrid_create() Invalid argument - Dst contains a concave cell</div>
<div style="margin:0px;font-size:13px;font-family:Menlo">20170621 172940.035 ERROR PET0 ESMCI_Regrid_F.C:434 c_esmc_regrid_create() Invalid argument Internal subroutine call returned Error</div>
<div style="margin:0px;font-size:13px;font-family:Menlo">20170621 172940.035 ERROR PET0 ESMF_Regrid.F90:321 ESMF_RegridStore Invalid argument - Internal subroutine call returned Error</div>
<div style="margin:0px;font-size:13px;font-family:Menlo">20170621 172940.035 ERROR PET0 ESMF_FieldRegrid.F90:1008 ESMF_FieldRegridStoreNX Invalid argument - Internal subroutine call returned Error</div>
<div style="margin:0px;font-size:13px;font-family:Menlo">20170621 172940.035 ERROR PET0 ESMF_RegridWeightGen.F90:1152 ESMF_RegridWeightGenFile Invalid argument - Internal subroutine call returned Error</div>
<div style="margin:0px;font-size:13px;font-family:Menlo"><br>
</div>
</div>
<div><br>
</div>
<div> I have searched the archives regarding this error and have changed the longitudes of both the source and destination grids so that it goes from 0-360 instead of -180 to 180 as suggested, but I still get the same error. I have FTP’d the files
in the following script.</div>
<div><br>
</div>
<div>
<div>load "$NCARG_ROOT/lib/ncarg/<wbr>nclscripts/csm/gsn_code.ncl"</div>
<div>load "$NCARG_ROOT/lib/ncarg/<wbr>nclscripts/csm/gsn_csm.ncl"</div>
<div>load "$NCARG_ROOT/lib/ncarg/<wbr>nclscripts/csm/contributed.<wbr>ncl"</div>
<div>load "$NCARG_ROOT/lib/ncarg/<wbr>nclscripts/esmf/ESMF_<wbr>regridding.ncl"</div>
<div><br>
</div>
<div>begin</div>
<div>;---Data file containing source grid</div>
<div> src_file = "/home/umalmonj/Jan_Apr_<wbr><a href="http://monthly_total_2d.nc">monthly_total_2d.nc</a>" ;;---Change (likely)</div>
<div> src_constants = "/global/scratch/umalmonj/WRF/<wbr>juris/CTRL/2D/<a href="http://wrfout_conus_constants.nc" target="_blank">wrfout_conus_<wbr>constants.nc</a>"</div>
<div> sfile = addfile(src_file,"r")</div>
<div> constants = addfile(src_constants,"r")</div>
<div><br>
</div>
<div>;---Get variable to regrid</div>
<div>prec_acc_nc = sfile->PREC_ACC_NC</div>
<div>var = dim_sum_n_Wrap(prec_acc_nc,0) ; this sums the variable for the 4 months</div>
<div> src_lat = constants->XLAT(0,:,:) ;;---Change (maybe)</div>
<div> src_lon = constants->XLONG(0,:,:) ;;---Change (maybe)</div>
<div> var@lat2d = src_lat ;;---Change (likely)</div>
<div> src_lon = where(src_lon.lt.0,src_lon+<wbr>360,src_lon)</div>
<div> var@lon2d=src_lon</div>
<div><br>
</div>
<div>;---Data file containing destination grid</div>
<div> dst_file = "/global/scratch/umalmonj/WRF/<wbr>juris/CaPA/<wbr>AccumulatedtotalPrecipitation.<wbr>nc" ;;---Change (likely)</div>
<div> dfile = addfile(dst_file,"r")</div>
<div> dst_lat = dfile->gridlat_0 ;;---Change (likely)</div>
<div> dst_long = dfile->gridlon_0 ;;---Change (likely)</div>
<div> dst_lon = where(dst_long.lt.0,dst_long+<wbr>360,dst_long)</div>
<div><br>
</div>
<div>;---Set up regridding options</div>
<div> Opt = True</div>
<div><br>
</div>
<div>;---"bilinear" is the default. "patch" and "conserve" are other options.</div>
<div> Opt@InterpMethod = "conserve" ; might want to use conservative for precip</div>
<div><br>
</div>
<div> Opt@WgtFileName = "<a href="http://curv_to_curv.nc" target="_blank">curv_to_curv.nc</a>" ; optional</div>
<div><br>
</div>
<div> Opt@SrcGridLat = src_lat ; source grid</div>
<div> Opt@SrcGridLon = src_lon</div>
<div> Opt@SrcRegional = True ;;--Change (maybe)</div>
<div> Opt@SrcFileName = src_file ; optional, but good idea</div>
<div> Opt@SrcGridMask = where(.not.ismissing(var),1,0) ; Necessary if has</div>
<div> ; missing values.</div>
<div><br>
</div>
<div><br>
</div>
<div> Opt@DstGridLat = dst_lat ; destination grid</div>
<div> Opt@DstGridLon = dst_lon</div>
<div> Opt@DstRegional = True ;;--Change (maybe)</div>
<div> Opt@DstGridMask = where(.not.ismissing(dst_lat).<wbr>and.\</div>
<div> .not.ismissing(dst_lon),1,0) ; Necessary if lat/lon</div>
<div> ; has missing values.</div>
<div>; there is an attribute in the dest. file called "corners", but there are four</div>
<div>; diff. numbers for both the lon and lat variables</div>
<div>; just let NCL figure out the corners...</div>
<div>; Opt@DstLLCorner = (/12.21208,217.1075/)</div>
<div>; Opt@DstURCorner = (/79.82558,147.6248/)</div>
<div> Opt@ForceOverwrite = True</div>
<div> Opt@PrintTimings = True</div>
<div> Opt@Debug = True</div>
<div><br>
</div>
<div> var_regrid = ESMF_regrid(var,Opt) ; Do the regridding</div>
<div><br>
</div>
<div> printVarSummary(var_regrid)</div>
<div><br>
</div>
</div>
<div><br>
</div>
<div>Any help would be greatly appreciated,</div>
<div><br>
</div>
<div>Juris</div>
<div><br>
</div>
<div><br>
</div>
</div>
<br>______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/<wbr>mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>