<div dir="ltr"><div class="gmail_default" style="font-size:small"><div class="gmail_default">Hi Alan,</div><div class="gmail_default"><br></div><div class="gmail_default">If the lat/lon values of your data are the same for every iteration of the loop and/or subset of your data, then what I recommend is to use shapefile_mask_data *once* to create a mask array of 0s and 1s, save this mask file to a NetCDF file, and then use this to do the masking for subsequent masking. This will go *much* faster than calling shapefile_mask_data every time.</div><div class="gmail_default"><br></div><div class="gmail_default">The &quot;shapefiles_11.ncl&quot; script shows how to do this:</div><div class="gmail_default"><br></div><div class="gmail_default"><div class="gmail_default"><a href="http://www.ncl.ucar.edu/Applications/shapefiles.shtml#ex11" target="_blank">http://www.ncl.ucar.edu/Applications/shapefiles.shtml#ex11</a></div></div><div class="gmail_default"><ul><li style="margin-left:15px">shapefile_mask_data is called with &quot;return_mask set to True. This causes an array of 0s and 1s to be returned. </li><li style="margin-left:15px">The 0s and 1s array is written to a NetCDF file</li><li style="margin-left:15px">For subsequent masking, the mask array is read off the file once, and used in conjunction with the &quot;where&quot; function to do the masking.<br></li></ul></div><div class="gmail_default">If your lat/lon data is different for every iteration, then the above won&#39;t be of much help to you.  </div><div class="gmail_default"><br></div><div class="gmail_default">However, just recently one of our former NCL developers sent us some potentially faster masking code to use with shapefile data, which I haven&#39;t had a chance to try out.  If you want to give this a try, then it would help if I could have access to the data used with your script, so I can test it.</div><div class="gmail_default"><br></div><div class="gmail_default">--Mary</div><div class="gmail_default"><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Aug 7, 2015 at 1:31 PM, Alan Rhoades <span dir="ltr">&lt;<a href="mailto:alan.m.rhoades@gmail.com" target="_blank">alan.m.rhoades@gmail.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 dir="ltr">Hello,<div><br></div><div>I use shapefiles and the NCL masking command for a lot of climate dataset analysis.  I&#39;ve recently gotten to the point where I need to start masking 4D data for a rather large shapefile region (over several seasons of data) and it can take upwards of two days to complete on my local server (which can be an issue for troubleshooting if something goes wrong in my script).  I was curious if you could take a look at my masking script (see attached) and give any pointers on how to better optimize and speed-up the masking process.</div><div><br></div><div>All the best,</div><div><br></div><div>AR</div><span class="HOEnZb"><font color="#888888"><div><div><br></div>-- <br><div><div dir="ltr"><div><div dir="ltr"><font color="#006600"><div style="font-weight:bold"><br></div><div><font color="#006600" size="4"><b>Alan Rhoades</b></font></div></font><div><div><b><font size="2" color="#000000">PhD Student, Atmospheric Science Graduate Group</font></b></div><div><b><font size="2" color="#000000">Climate Change Water and Society (CCWAS) NSF IGERT Trainee</font></b></div><div><b><font size="2" color="#000000">University of California, Davis</font></b></div><div><span style="font-family:arial,sans-serif;background-color:rgb(255,255,255)"><u><b><a href="https://www.linkedin.com/pub/alan-rhoades/22/5bb/52a" target="_blank"><font color="#0000ff">LinkedIn</font></a></b></u></span></div><div><span style="font-family:arial,sans-serif;background-color:rgb(255,255,255)"><u><b><font size="2"><a href="mailto:alan.m.rhoades@gmail.com" target="_blank">alan.m.rhoades@gmail.com</a> </font></b></u></span></div><div><span style="font-family:arial,sans-serif;background-color:rgb(255,255,255)"><u><b><font size="2"><a href="mailto:amrhoades@ucdavis.edu" target="_blank">amrhoades@ucdavis.edu</a></font></b></u></span></div></div><div><font color="#003300" size="2"><b><br></b></font></div><div><b><i><font color="#006600" size="2">&quot;It’s all really there. That’s what really gets you. But you gotta stop and think about it to really get the pleasure about the complexity, the inconceivable nature of nature.&quot;</font></i></b></div><div><b><i><font color="#006600" size="2">Richard Feynman</font></i></b></div></div></div></div></div>
</div></font></span></div>
<br>_______________________________________________<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/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>