<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" style="font-size:small">I ran your script on my Mac and it seemed to work fine. This is likely due to the fact I just upgraded my ESMF_RegridWeightGen to version 7.0.1 (NCL comes with 6.3.0rp1).</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">If you tell me what kind of system you have, I can try to build a new ESMF_RegridWeightGen for you.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Meanwhile, here&#39;s a modified version of your script that creates a panel plot, and also draws the grid lines of the destination grid so you can see where the two grids intersect. This script will only work once ESMF_RegridWeightGen is upgraded.  I included the PNG images so you can see what it looks like.</div><div class="gmail_default" style="font-size:small"><br></div>Note: Once you have the WRF_to_CMC_RDPA_APCP_conserve.nc weights file and you feel that the regridding is working<div class="gmail_default" style="font-size:small;display:inline">​ correctly​</div>, then you can regrid subsequent variables by calling the following:<div class="gmail_default" style="font-size:small">







<p class="gmail-p1"><font face="monospace, monospace"><span class="gmail-s1">  Opt = True<br></span><span class="gmail-s1">  var_regrid = </span><span class="gmail-s2">ESMF_regrid_with_weights</span><span class="gmail-s1">(var,</span><span class="gmail-s3">&quot;WRF_to_CMC_RDPA_APCP_conserve</span><span class="gmail-s3">.nc&quot;,Opt)</span></font></p></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 Wed, Jun 21, 2017 at 5:05 PM, Juris Almonte <span dir="ltr">&lt;<a href="mailto:Juris.Almonte@umanitoba.ca" target="_blank">Juris.Almonte@umanitoba.ca</a>&gt;</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 &quot;$NCARG_ROOT/lib/ncarg/<wbr>nclscripts/csm/gsn_code.ncl&quot;</div>
<div>load &quot;$NCARG_ROOT/lib/ncarg/<wbr>nclscripts/csm/gsn_csm.ncl&quot;</div>
<div>load &quot;$NCARG_ROOT/lib/ncarg/<wbr>nclscripts/csm/contributed.<wbr>ncl&quot;</div>
<div>load &quot;$NCARG_ROOT/lib/ncarg/<wbr>nclscripts/esmf/ESMF_<wbr>regridding.ncl&quot;</div>
<div><br>
</div>
<div>begin</div>
<div>;---Data file containing source grid</div>
<div>    src_file = &quot;/home/umalmonj/Jan_Apr_<wbr><a href="http://monthly_total_2d.nc">monthly_total_2d.nc</a>&quot;                    ;;---Change (likely)</div>
<div>    src_constants = &quot;/global/scratch/umalmonj/WRF/<wbr>juris/CTRL/2D/<a href="http://wrfout_conus_constants.nc" target="_blank">wrfout_conus_<wbr>constants.nc</a>&quot;</div>
<div>    sfile    = addfile(src_file,&quot;r&quot;)</div>
<div>    constants = addfile(src_constants,&quot;r&quot;)</div>
<div><br>
</div>
<div>;---Get variable to regrid</div>
<div>prec_acc_nc = sfile-&gt;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-&gt;XLAT(0,:,:)                   ;;---Change (maybe)</div>
<div>    src_lon  = constants-&gt;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 = &quot;/global/scratch/umalmonj/WRF/<wbr>juris/CaPA/<wbr>AccumulatedtotalPrecipitation.<wbr>nc&quot;                    ;;---Change (likely)</div>
<div>    dfile    = addfile(dst_file,&quot;r&quot;)</div>
<div>    dst_lat  = dfile-&gt;gridlat_0                   ;;---Change (likely)</div>
<div>    dst_long  = dfile-&gt;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>;---&quot;bilinear&quot; is the default. &quot;patch&quot; and &quot;conserve&quot; are other options.</div>
<div>    Opt@InterpMethod      = &quot;conserve&quot;       ; might want to use conservative for precip</div>
<div><br>
</div>
<div>    Opt@WgtFileName       = &quot;<a href="http://curv_to_curv.nc" target="_blank">curv_to_curv.nc</a>&quot;  ; 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 &quot;corners&quot;, 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>