<div dir="ltr"><div><div><div>x[*] with _FillValue attribute<br><br></div><div> ;nmsg = num(ismissing(x)) ; coun number of missing<br><br></div> igood = ind(.not.ismissing(x))<br></div> xgood = x(igood)<br></div> print(xgood)<br><div><br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 15, 2017 at 3:54 PM, Wang, Jiali <span dir="ltr"><<a href="mailto:jialiwang@anl.gov" target="_blank">jialiwang@anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div link="#0563C1" vlink="#954F72" lang="EN-US">
<div class="m_506594460391687359WordSection1">
<p class="MsoNormal">Dear NCL group,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I am having a similar question as this post <a href="https://www.ncl.ucar.edu/Support/talk_archives/2011/1499.html" target="_blank">
https://www.ncl.ucar.edu/<wbr>Support/talk_archives/2011/<wbr>1499.html</a> but unfortunately i didn’t get it..<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I have a 1D data set (station data) as shown below. I would like to filter out the lower orders (order smaller than 2). I do this using “where”, so I get lots of missing values for those stations with lower orders. But these values take
lots of space, so I want to get rid of them and output a much lighter data only for the stations with non-missing values. Below is what my data and my NCL script look like. Could you please take a look and advice? With my script I am still having all the
missing value in my output.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">ncdump -c 200303091200.CHRTOUT_DOMAIN3<u></u><u></u></p>
<p class="MsoNormal">netcdf \200303091200 {<u></u><u></u></p>
<p class="MsoNormal">dimensions:<u></u><u></u></p>
<p class="MsoNormal"> station = 3678397 ;<u></u><u></u></p>
<p class="MsoNormal"> time = 1 ;<u></u><u></u></p>
<p class="MsoNormal">variables:<u></u><u></u></p>
<p class="MsoNormal"> float latitude(station) ;<u></u><u></u></p>
<p class="MsoNormal"> latitude:long_name = "Station latitude" ;<u></u><u></u></p>
<p class="MsoNormal"> latitude:units = "degrees_north" ;<u></u><u></u></p>
<p class="MsoNormal"> float longitude(station) ;<u></u><u></u></p>
<p class="MsoNormal"> longitude:long_name = "Station longitude" ;<u></u><u></u></p>
<p class="MsoNormal"> longitude:units = "degrees_east" ;<u></u><u></u></p>
<p class="MsoNormal"> float streamflow(station) ;<u></u><u></u></p>
<p class="MsoNormal"> streamflow:units = "meter^3 / sec" ;<u></u><u></u></p>
<p class="MsoNormal"> streamflow:long_name = "River Flow" ;<u></u><u></u></p>
<p class="MsoNormal"> int order(station) ;<u></u><u></u></p>
<p class="MsoNormal"> order:long_name = "Strahler Stream Order" ;<u></u><u></u></p>
<p class="MsoNormal">=============<u></u><u></u></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">a = addfile("200303101200.CHRTOUT_<wbr>DOMAIN3"+".nc","r")<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">st = a->streamflow<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">lat = a->latitude<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">lon = a->longitude<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">ord = a->order ;;do filter based on this number, we only want order>2<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">st1 = new(dimsizes(st),typeof(st))<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">lat1 = new(dimsizes(lat),typeof(lat))<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">lon1 = new(dimsizes(lon),typeof(lon))<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">st@_FillValue = -9999<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">st1 = where(ord .gt. 2, st, st@_FillValue)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">lat1 = where(ord .gt. 2, lat, st@_FillValue)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">lon1 = where(ord .gt. 2, lon, st@_FillValue)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">if (.not.all(ismissing(st1))) then ;;I think this “if” statement has some problem, but I am not sure what’s the right one should be..<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif"> system("/bin/rm -f <a href="http://simple.nc" target="_blank">simple.nc</a>")
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif"> ncdf = addfile("<a href="http://simple.nc" target="_blank">simple.nc</a>" ,"c")
<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif"> ncdf->streamflow = st1<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif"> ncdf->lat = lat1<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif"> ncdf->lon = lon1<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">;;;;;;or output in txt format<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif"> opt = True<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif"> opt@fout = "foo.txt"<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif"> write_matrix(st1, "10f7.2", opt)<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">end if<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">==============<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">Thanks!<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">Jiali Wang, Ph. D<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">Environmental Science Division<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">Argonne National Laboratory<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">Tel: <a href="tel:(630)%20252-2848" value="+16302522848" target="_blank">630-252-2848</a><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif"><a href="http://www.evs.anl.gov/about-evs/staff/detail/index.cfm?/Wang/Jiali" target="_blank">http://www.evs.anl.gov/about-<wbr>evs/staff/detail/index.cfm?/<wbr>Wang/Jiali</a><u></u><u></u></span></p>
<p class="MsoNormal"><u></u> <u></u></p>
</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>