<div dir="ltr"><div class="gmail_default" style="font-size:small">Hi Ming,</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Sorry for the delay in response. I think you might need to use something larger than -130, like -127.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">I'm in a conference this week. If you continue to have problems, you might try the masking using shapefile names, rather than lat/lon boundaries.</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 Sun, Jul 5, 2015 at 12:34 PM, Ming Chen <span dir="ltr"><<a href="mailto:chen1718@umn.edu" target="_blank">chen1718@umn.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>Thanks a lot Mary! <br><br>The lonFlip function worked and I was able to mask the data.<br></div></div>However, I found that Alaska is also masked in, while I just need the contiguous US.<br></div>I have specified the max/min of longitude and latitude, is it not working?<br><br></div><div>Here is the debug message:<br>(0) ==================================================<br>(0) Shapefile: cb_2014_us_nation_20m.shp <b>###NOTE that I changed a shape file because the previous one did not work well and only masked in the Alaska area. ###</b> This one could be download at <a href="https://www.census.gov/geo/maps-data/data/cbf/cbf_nation.html" target="_blank">https://www.census.gov/geo/maps-data/data/cbf/cbf_nation.html</a><span class=""><br>(0) Areas of interest: the whole shapefile<br>(0) min_lat_chk: 20<br>(0) max_lat_chk: 50<br></span>(0) min_lon_chk: -130<br>(0) max_lon_chk: -65<span class=""><br>(0) min_lat_data: -90<br>(0) max_lat_data: 90<br></span>(0) min_lon_data: -180<br>(0) max_lon_data: 177.5<span class=""><br>(0) 13824 data values originally<br>(0) Will keep data values inside given shapefile areas<br>(0) ==================================================<br></span>(0) 229 data values kept<br>(0) shapefile_mask_data: elapsed time: 0.377945 CPU seconds.<br>(0) ==================================================<br><br></div><div>Thanks,<br></div>Ming<br></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jul 4, 2015 at 11:45 PM, Mary Haley <span dir="ltr"><<a href="mailto:haley@ucar.edu" target="_blank">haley@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 class="gmail_default" style="font-size:small">If you have lat/lon coordinate arrays attached to your data, then can try the "lonFlip" function to convert your data to be -180 to 180 longitude:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default"><a href="http://www.ncl.ucar.edu/Document/Functions/Contributed/lonFlip.shtml" target="_blank">http://www.ncl.ucar.edu/Document/Functions/Contributed/lonFlip.shtml</a><br></div><div class="gmail_default"><br></div><div class="gmail_default">If you don't have coordinate arrays, but instead are using the special lat2d/lon2d or lat1d/lon1d attributes, then you can try the "where" function:</div><div class="gmail_default"> </div><div class="gmail_default"><span style="font-size:12.8000001907349px">NEE_AVG@lon2d = </span>where(<span style="font-size:12.8000001907349px">lon2d</span>.gt.180, <span style="font-size:12.8000001907349px">lon2d - </span>360, <span style="font-size:12.8000001907349px">lon2d</span>)<br></div><div class="gmail_default">
<p>Note: I don't know what your longitude array is called. I'm just using "lon2d" as an example here. You can operate on the attribute directly:</p><p></p><div class="gmail_default" style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"></div><p></p><div class="gmail_default" style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-size:12.8000001907349px">NEE_AVG@lon2d = </span>where(<span style="font-size:12.8000001907349px">NEE_AVG @</span><span style="font-size:12.8000001907349px">lon2d</span>.gt.180, <span style="font-size:12.8000001907349px">NEE_AVG @</span><span style="font-size:12.8000001907349px">lon2d - </span>360,<span style="font-size:12.8000001907349px"> NEE_AVG@</span><span style="font-size:12.8000001907349px">lon2d</span>)</div><div class="gmail_default" style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div class="gmail_default" style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">You will also need to update your minlon/maxlon attributes to be in -180 to 180</div><div class="gmail_default" style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><div class="gmail_default" style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-size:12.8000001907349px"> opt@minlon = -130 ; 230 - 360</span><br style="font-size:12.8000001907349px"><span style="font-size:12.8000001907349px"> opt@maxlon = -65 ; 295 - 360</span><span><font color="#888888"><br></font></span></div><span><font color="#888888"><div class="gmail_default" style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-size:12.8000001907349px"><br></span></div><div class="gmail_default" style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><span style="font-size:12.8000001907349px"><br></span></div><div class="gmail_default" style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">--Mary</div><div class="gmail_default" style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><br></div><p><br></p></font></span></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Sat, Jul 4, 2015 at 9:34 PM, Ming Chen <span dir="ltr"><<a href="mailto:chen1718@umn.edu" target="_blank">chen1718@umn.edu</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr"><div><div>I think I know why it is happening... The data I'm trying to mask has the longitude from 0 to 357.5, while the shapefile has the longitude from -179.1 to 179.8...<br><br></div>Does anyone has suggestion how I can fix that? Thanks!<span><font color="#888888"><br><br></font></span></div><span><font color="#888888">Ming<br><div><div><br><br></div></div></font></span></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jul 4, 2015 at 10:19 PM, Ming Chen <span dir="ltr"><<a href="mailto:chen1718@umn.edu" target="_blank">chen1718@umn.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>Hi all,<br><br></div>I was trying to mask the contiguous United States using a shape file and the script "shapefile_mask_data.ncl", but got all missing values.<br><br></div>I used ncl 6.2.1. The script I used is here:<br><br>;Begins to calculate US averaged NEE<br> shp_filename = "coastl_usa.shp"<br> opt = True<br> opt@minlat = 20<br> opt@maxlat = 50<br> opt@minlon = 230<br> opt@maxlon = 295<br> opt@debug = True<br> opt@keep = True<br> opt@loop_check = True<br> data_mask = shapefile_mask_data(NEE_AVG,shp_filename,opt)<br> NEE_scalar = wgt_areaave(data_mask,1.,1.,0) ;averaged NEE over the United States<br><br><br></div>And here is the message I got:<br>(0) ==================================================<br>(0) Shapefile: coastl_usa.shp<br>(0) Areas of interest: the whole shapefile<br>(0) min_lat_chk: 20<br>(0) max_lat_chk: 50<br>(0) min_lon_chk: 230<br>(0) max_lon_chk: 295<br>(0) min_lat_data: -90<br>(0) max_lat_data: 90<br>(0) min_lon_data: 0<br>(0) max_lon_data: 357.5<br>(0) 13824 data values originally<br>(0) Will keep data values inside given shapefile areas<br>(0) ==================================================<br>(0) 0 data values kept<br>(0) shapefile_mask_data: elapsed time: 0.930859 CPU seconds.<br>(0) ==================================================<br><div><br></div><div>I can see there are 13824 data points in my NEE_AVG data. And I have plot that without problem. Why there was no data masked?<br><br></div><div>Thanks,<br></div><div>Ming<span><font color="#888888"><br></font></span></div><span><font color="#888888"><div><br clear="all"><div><div><div><div><br>-- <br><div>Department of Soil, Water and Climate<br>439 Borlaug Hall 1991 Upper Buford Cir.<br>St. Paul 55108<br>MN USA<div>Office: <a href="tel:612-624-1645" value="+16126241645" target="_blank">612-624-1645</a><br><div><a href="http://www.biometeorology.umn.edu/people_ming.php" target="_blank">http://www.biometeorology.umn.edu/people_ming.php</a>
</div></div></div>
</div></div></div></div></div></font></span></div>
</blockquote></div><br><br clear="all"><br>-- <br><div>Department of Soil, Water and Climate<br>439 Borlaug Hall 1991 Upper Buford Cir.<br>St. Paul 55108<br>MN USA<div>Office: <a href="tel:612-624-1645" value="+16126241645" target="_blank">612-624-1645</a><br><div><a href="http://www.biometeorology.umn.edu/people_ming.php" target="_blank">http://www.biometeorology.umn.edu/people_ming.php</a>
</div></div></div>
</div>
</div></div><br></div></div><span>_______________________________________________<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/mailman/listinfo/ncl-talk</a><br>
<br></span></blockquote></div><br></div>
</blockquote></div><br><br clear="all"><br>-- <br><div>Department of Soil, Water and Climate<br>439 Borlaug Hall 1991 Upper Buford Cir.<br>St. Paul 55108<br>MN USA<div>Office: <a href="tel:612-624-1645" value="+16126241645" target="_blank">612-624-1645</a><br><div><a href="http://www.biometeorology.umn.edu/people_ming.php" target="_blank">http://www.biometeorology.umn.edu/people_ming.php</a>
</div></div></div>
</div>
</div></div></blockquote></div><br></div>