<div dir="ltr"><div class="gmail_default" style="font-size:small">Stavros and Rick,</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">First, to address the slowness: in addition to what Rick suggested: if the masking locations don't change for the 6000+ time steps, then what you can do is have the shapefile mask function return a mask array of 0s and 1s, and then you can simply apply this mask using the "where" function, instead of calling shapefile_mask_data every time. This is what shapefile_20.ncl is doing:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default"><a href="http://www.ncl.ucar.edu/Applications/shapefiles.shtml#ex20">http://www.ncl.ucar.edu/Applications/shapefiles.shtml#ex20</a><br></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">With regard to the image being wrong, it looks more like a plotting issue than a masking issue. It looks like either the lat/lon arrays are not being passed to the plotting function, OR, you are trying to do a "native" projection by setting tfDoNDCOverlay to True, and then setting the map projection parameters yourself, but the projection is not correct.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">My guess is that "<span style="font-size:12.8px">snow_mask" doesn't have the necessary lat/lon data associated with it, and you may need to copy it over from "snow".</span></div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Can you provide a script so we can see what kind of plotting you're doing?</div><div class="gmail_default" style="font-size:small"><br></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 Wed, Oct 18, 2017 at 7:49 AM, Rick Brownrigg <span dir="ltr"><<a href="mailto:brownrig@ucar.edu" target="_blank">brownrig@ucar.edu</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><div><div><div><div><div>Hi Stavros,<br><br></div>To the best of my knowledge, the masking functions are unaware of any cartographic projections in the data, and so both grid and shapefile need to be in the same coordinate system.  I would guess your shapefile is in lat/lon?  NCL has an unadvertised interface to the well-known projection library Proj4 -- if you know the projection parameters of your stereographic grid, you could use the proj4 interface to convert the grid to lat/lon. The function is:<br><br></div>  transform_coordinate(srcProj:<wbr>string, dstProj:string, x:double, y:double, z:double)<br><br></div>where the src/dstProj are proj4 descriptors of the source/destination projections. The coordinates are passed in and transformed out through the x,y,z arrays (I can get you started if you send me the grid's metadata describing the projection).<br><br></div>As for speeding up the process, one strategy I've used in the past is, for coastal nations that have many small islands (relative to the grid resolution), exclude those. Shapefiles have an "area" variable, and magnitude of that value will be vastly larger than those for islands. So by inspecting the data, you get a feel for which shapefile polygons are the ones "of interest", and you can select those out, and then use the gc_inout() function to perform the masking.  Alternatively, if you have access to GIS software like ArcGIS, you could do the same culling operations (likely much easier!) to create such a paired-down shapefile, and then use shapefile_mask_data() as before.<br><br></div>Hope that helps...<span class="HOEnZb"><font color="#888888"><br></font></span></div><span class="HOEnZb"><font color="#888888">Rick<br></font></span></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 18, 2017 at 4:33 AM, Stavros Dafis <span dir="ltr"><<a href="mailto:sdafis@cc.uoi.gr" target="_blank">sdafis@cc.uoi.gr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Dear NCL users,<br>
<br>
I have a set of netcdf files with snow, land and sea variables and the<br>
projection is Polar Stereographic ellipsoidal (WGS-84 ellipsoid). I have<br>
plotted an example remapped to a Mercator projection:<br>
<a href="https://ibb.co/mFZAd6" rel="noreferrer" target="_blank">https://ibb.co/mFZAd6</a><br>
<br>
I would like to mask the data only inside the shapefile of Greece, but I cannot<br>
figure out why the "shapefile_mask_data" keeps the wrong values. This is what I<br>
get:<br>
<a href="https://ibb.co/iyBZ5m" rel="noreferrer" target="_blank">https://ibb.co/iyBZ5m</a><br>
<br>
How is it possible to cut the values in another projection than the initial?<br>
<br>
This is part of the code for masking:<br>
<br>
shp_filename1 = "/data/dafis/Greek_shape/GRC_a<wbr>dm1.shp"    ; State outlines<br>
<br>
  opt             = True<br>
  ;opt@delta_kilometers  = 2<br>
  ;opt@minlat      = minlat<br>
  ;opt@maxlat      = maxlat<br>
  ;opt@minlon      = minlon<br>
  ;opt@maxlon      = maxlon<br>
  opt@debug       = True<br>
  opt@shape_var   = "NAME_0"<br>
  opt@shape_names = "Greece"<br>
  ;opt@return_mask = True<br>
  opt@keep        = True<br>
<br>
 snow_mask = shapefile_mask_data(snow,shp_f<wbr>ilename1,opt)<br>
<br>
The whole procedure takes 5 minutes for one day and I have 6205 days to compute.<br>
I read in this thread that is normal to take so long to run, due to the complex<br>
coastline:<br>
<a href="https://www.ncl.ucar.edu/Support/talk_archives/2014/0728.html" rel="noreferrer" target="_blank">https://www.ncl.ucar.edu/Suppo<wbr>rt/talk_archives/2014/0728.<wbr>html</a><br>
<br>
Any suggestions? The opt@minlat/lon etc does not help to plot faster.<br>
<br>
Has anyone succeeded in speeding up the procedure or do you know where I can<br>
find coarse shapefiles for countries since I mostly care about excluding the<br>
neighbor countries and not the sea.<br>
<br>
<br>
--<br>
Stavros NTAFIS (DAFIS)<br>
------------------------------<wbr>-----------------<br>
Physicist - Meteorologist, M.Sc.<br>
Ph.D. Candidate, Polytechnic School of Paris, France<br>
Laboratory of Dynamic Meteorology (LMD)<br>
Research Associate, National Observatory of Athens<br>
Tel. : <a href="tel:%28%2B33%299%2081%2094%2022%2012" value="+33981942212" target="_blank">(+33)9 81 94 22 12</a><br>
Mobile: <a href="tel:%28%2B33%29%20066%20030%200147" value="+33660300147" target="_blank">(+33) 066 030 0147</a><br>
<a href="tel:%28%2B30%29%20697%2004%2020%20242" value="+306970420242" target="_blank">(+30) 697 04 20 242</a><br>
---------------<br>
Weather charts:<br>
<a href="http://www.meteo.gr" rel="noreferrer" target="_blank">http://www.meteo.gr</a><br>
<a href="http://www.meteo.gr/meteomaps/" rel="noreferrer" target="_blank">http://www.meteo.gr/meteomaps/</a><br>
<br>
<br>
<br>
______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">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/mailma<wbr>n/listinfo/ncl-talk</a><br>
</blockquote></div><br></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>