<div dir="ltr"><div><div>Hi,<br><br></div>Its rather hard to say with certainty what&#39;s going on here, but my best guess is:<br><br></div>i) 
 The original error message likely came about because the variable &quot;var&quot;
 did not have coordinate arrays associated with it.  This is from the 
comments for shapefile_mask_data():<br><br><pre>;  - If a rectilinear grid, then &quot;data&quot; must have coordinate arrays
;    attached. 
;  - If a curvilinear grid, then &quot;data&quot; must have the special lat2d 
;    and lon2d attributes attached.
;  - If a unstructured grid, then &quot;data&quot;must have the special lat1d 
;    and lon1d attributes attached.<br><span style="font-family:arial,helvetica,sans-serif"><br></span></pre><pre><span style="font-family:arial,helvetica,sans-serif">If you are not familiar with the notion of coordinate arrays in NetCDF, please see:<br><br><a href="http://ncl.ucar.edu/Document/Manuals/Ref_Manual/NclVariables.shtml#Coordinates" target="_blank">http://ncl.ucar.edu/Document/<wbr>Manuals/Ref_Manual/<wbr>NclVariables.shtml#Coordinates</a><br><br>If there have been no other changes to your script, in the original, you had already extracted<br>the variable var as a 2D variable via:<br><br>var                                 = doubletofloat(a-&gt;HEM_DLY(0,:,:))<br><br>Thus when you attempt to slice it again in the call to shapefile_mask_data(), you get the error regarding &quot;using 3, 2 expected&quot;<br><br><br></span></pre><pre><span style="font-family:arial,helvetica,sans-serif">Hope that helps...<br></span></pre><pre><span style="font-family:arial,helvetica,sans-serif">Rick<br></span></pre></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Aug 3, 2016 at 10:14 PM, Amit Kumar <span dir="ltr">&lt;<a href="mailto:amitkumar.777@hotmail.com" target="_blank">amitkumar.777@hotmail.com</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">

<div style="font-size:10pt;color:#2672ec;background-color:#ffffff;font-family:Arial,Helvetica,sans-serif">
<p>Hi,</p>
<p><br>
</p>
<p>Earlier I was using <br>
</p>
<p><br>
</p>
<p><font color="#2672EC" face="Arial,Helvetica,sans-serif" size="2"><span style="font-size:10pt;background-color:white"><font color="red"><b><font color="#4BA524">shp_mask = shapefile_mask_data(var,<wbr>filename,opt) , so here I got the
 error:</font></b></font></span></font></p><span class="">
<p><font color="#2672EC" face="Arial,Helvetica,sans-serif" size="2"><span style="font-size:10pt;background-color:white"><font color="red"><b><font color="#4BA524"><br>
</font></b></font></span></font></p>
<p><font color="#2672EC" face="Arial,Helvetica,sans-serif" size="2"><span style="font-size:10pt;background-color:white"><font color="red"><b><font color="#4BA524"></font></b></font></span></font><font color="#2672EC" face="Arial,Helvetica,sans-serif" size="2"><span style="font-size:10pt;background-color:white"><font color="red"><b>(0)  
  shapefile_mask_data: Error: not a valid rectilinear, curvilinear, or unstructured grid</b></font><font color="red"><b><br>
</b></font></span></font></p>
<p><br>
</p>
</span><p>so then I used <br>
</p>
<p><br>
</p>
<p><font color="#2672EC" face="Arial,Helvetica,sans-serif" size="2"><span style="font-size:10pt;background-color:white"><font color="red"><b><font color="#4BA524">shp_mask = shapefile_mask_data(var(0,:,:)<wbr>,filename,opt) , but I got
 this error,</font></b></font></span></font></p><span class="">
<p><font color="#2672EC" face="Arial,Helvetica,sans-serif" size="2"><span style="font-size:10pt;background-color:white"><font color="red"><b><font color="#4BA524"><br>
</font></b></font></span></font></p>
<p><font color="#2672EC" face="Arial,Helvetica,sans-serif" size="2"><span style="font-size:10pt;background-color:white"><font color="red"><b><font color="#4BA524"></font></b></font></span></font><font color="#2672EC" face="Arial,Helvetica,sans-serif" size="2"><span style="font-size:10pt;background-color:white"><font color="red" face="Arial,Helvetica,sans-serif"><b>fatal:Number
 of subscripts do not match number of dimensions of variable,(3) Subscripts used, (2) Subscripts expected</b></font></span></font></p>
<p><br>
</p>
</span><p>so please suggest how to mention my variable in which has three dimensions <font color="#2672EC" face="Arial,Helvetica,sans-serif" size="2">
<span style="font-size:10pt;background-color:white"><font color="red"><b><font color="#4BA524">var(0,:,:) i.e. time, lon, lat so that shapefile_mask_data works.</font></b></font></span></font></p>
<p><font color="#2672EC" face="Arial,Helvetica,sans-serif" size="2"><span style="font-size:10pt;background-color:white"><font color="red"><b><font color="#4BA524"><br>
</font></b></font></span></font></p>
<p><font color="#2672EC" face="Arial,Helvetica,sans-serif" size="2"><span style="font-size:10pt;background-color:white"><font color="red"><b><font color="#4BA524">Regards</font></b></font></span></font></p>
<p><font color="#2672EC" face="Arial,Helvetica,sans-serif" size="2"><span style="font-size:10pt;background-color:white"><font color="red"><b><font color="#4BA524">Amit</font></b></font></span></font><br>
</p>
</div>
<hr style="display:inline-block;width:98%">
<div dir="ltr"><font style="font-size:11pt" color="#000000" face="Calibri, sans-serif"><b>From:</b> Guido Cioni &lt;<a href="mailto:guidocioni@gmail.com" target="_blank">guidocioni@gmail.com</a>&gt;<br>
<b>Sent:</b> Wednesday, August 3, 2016 5:01:47 PM<br>
<b>To:</b> Amit Kumar<br>
<b>Cc:</b> <a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
<b>Subject:</b> Re: [ncl-talk] Issue with Masking with shapefile</font>
<div> </div>
</div><div><div class="h5">
<div>Just judging from what you are saying (I didn’t read the script), you had some error regarding the shape file which was blocking the execution of the script at line xxx, but then you fixed that error and now you have another error at line yyy (with yyy
 &gt; xxx likely to be) that wasn’t detected before since you didn’t actually reach that line while executing the script.
<div><br>
<div>Please mark the line where the error (subscripts) is happening and go into the code to see all the assignments that you made at that point. Usually a few print statements (printVarSummary) before that line can lead you the way..</div>
<div>Without the line where the error is happening you are forcing people to read your code entirely, which many be time consuming :) <br>
<div>
<div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
<br>
Guido Cioni</div>
<div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
<a href="http://guidocioni.altervista.org" target="_blank">http://guidocioni.altervista.<wbr>org</a> </div>
</div>
<br>
<div>
<blockquote type="cite">
<div>On 03 Aug 2016, at 13:26, Amit Kumar &lt;<a href="mailto:amitkumar.777@hotmail.com" target="_blank">amitkumar.777@hotmail.com</a>&gt; wrote:</div>
<br>
<div>
<div style="font-size:10pt;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;color:rgb(38,114,236);background-color:rgb(255,255,255);font-family:Arial,Helvetica,sans-serif">
<p style="margin-top:0px;margin-bottom:0px"></p>
<div><br>
Hi,<span> </span><br>
<br>
I&#39;m truing to do masking using shapefile, script is attached.<br>
<br>
I&#39;m getting following error:<br>
<br>
<span><b><span style="color:rgb(255,0,0)">(0)    shapefile_mask_data: Error: not a valid rectilinear, curvilinear, or unstructured grid<br>
<br>
</span></b><span style="color:rgb(255,0,0)"><span style="color:rgb(0,111,201)"></span><span style="color:rgb(0,111,201)">so I made following changes:</span></span><b><span style="color:rgb(255,0,0)"><br>
<br>
<div><span style="color:rgb(75,165,36)">opt             = True</span><br>
<span style="color:rgb(75,165,36)">  opt@return_mask = True</span><br>
<span style="color:rgb(75,165,36)">  shp_mask = shapefile_mask_data(var(0,:,:)<wbr>,filename,opt)</span><br>
<span style="color:rgb(75,165,36)">shp_mask_3d = conform_dims(dimsizes(var),<wbr>shp_mask,(/1,2/))<span> </span></span><br>
<br>
<span style="color:rgb(75,165,36)">var_shp_mask = where(shp_mask_3d.eq.1,var,<wbr>var@_FillValue)</span><br>
<span style="color:rgb(75,165,36)">copy_VarMeta(var,var_shp_mask)</span><br>
<br>
<span style="color:rgb(75,165,36)">;---For shapefile plot, use the shapefile outlines.</span><br>
<span style="color:rgb(75,165,36)">  res@mpOutlineOn  = False</span><br>
<br>
<span style="color:rgb(75,165,36)">;---Create plot of original data masked by shapefile outlines</span><br>
<span style="color:rgb(75,165,36)">  res@tiMainString = &quot;Original data masked by shapefile outlines&quot;</span><br>
<span style="color:rgb(75,165,36)">  var_shp_plot = gsn_csm_contour_map(wks,var_<wbr>shp_mask,res)</span><br>
<span style="color:rgb(75,165,36)">  dum = gsn_add_shapefile_polylines(<wbr>wks,var_shp_plot,filename,<wbr>False)</span><br>
<span style="color:rgb(75,165,36)"> draw(plot)</span><br>
<span style="color:rgb(75,165,36)"> frame(wks)</span><br>
<span style="color:rgb(75,165,36)"> end</span><br>
</div>
<br>
</span></b><span style="color:rgb(255,0,0)"><span style="color:rgb(0,111,201)"></span><span style="color:rgb(0,111,201)">after these changes earlier error is rectified but now I&#39;m getting following error:</span></span><b><span style="color:rgb(255,0,0)"><br>
</span></b></span><br>
<font color="#2672EC" face="Arial,Helvetica,sans-serif" size="2"><span style="font-size:10pt;background-color:white"><font><font color="#2672EC" face="Arial,Helvetica,sans-serif"><font color="red"><b>fatal:Number
 of subscripts do not match number of dimensions of variable,(3) Subscripts used, (2) Subscripts expected</b></font></font></font></span></font><br>
<br>
<font color="#2672EC" face="Arial,Helvetica,sans-serif" size="2"><span style="font-size:10pt;background-color:white"><font><font color="#2672EC" face="Arial,Helvetica,sans-serif">Please suggest how to proceed further.</font></font></span></font></div>
<br>
<p style="margin-top:0px;margin-bottom:0px"></p>
</div>
<span>&lt;hem_shp_mask_1.ncl&gt;</span><span style="font-family:Helvetica;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">__________<wbr>______________________________<wbr>_______</span><br style="font-family:Helvetica;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
<span style="font-family:Helvetica;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">ncl-talk
 mailing list</span><br style="font-family:Helvetica;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
<a href="mailto:ncl-talk@ucar.edu" style="font-family:Helvetica;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">ncl-talk@ucar.edu</a><br style="font-family:Helvetica;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
<span style="font-family:Helvetica;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline!important">List
 instructions, subscriber options, unsubscribe:</span><br style="font-family:Helvetica;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" style="font-family:Helvetica;font-size:13px;font-style:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" target="_blank">http://mailman.ucar.edu/<wbr>mailman/listinfo/ncl-talk</a></div>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</div></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>