<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal">Dear NCL group,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></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">
https://www.ncl.ucar.edu/Support/talk_archives/2011/1499.html</a> but unfortunately i didn’t get it..<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></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.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">ncdump -c 200303091200.CHRTOUT_DOMAIN3<o:p></o:p></p>
<p class="MsoNormal">netcdf \200303091200 {<o:p></o:p></p>
<p class="MsoNormal">dimensions:<o:p></o:p></p>
<p class="MsoNormal">        station = 3678397 ;<o:p></o:p></p>
<p class="MsoNormal">        time = 1 ;<o:p></o:p></p>
<p class="MsoNormal">variables:<o:p></o:p></p>
<p class="MsoNormal">        float latitude(station) ;<o:p></o:p></p>
<p class="MsoNormal">                latitude:long_name = "Station latitude" ;<o:p></o:p></p>
<p class="MsoNormal">                latitude:units = "degrees_north" ;<o:p></o:p></p>
<p class="MsoNormal">        float longitude(station) ;<o:p></o:p></p>
<p class="MsoNormal">                longitude:long_name = "Station longitude" ;<o:p></o:p></p>
<p class="MsoNormal">                longitude:units = "degrees_east" ;<o:p></o:p></p>
<p class="MsoNormal">        float streamflow(station) ;<o:p></o:p></p>
<p class="MsoNormal">                streamflow:units = "meter^3 / sec" ;<o:p></o:p></p>
<p class="MsoNormal">                streamflow:long_name = "River Flow" ;<o:p></o:p></p>
<p class="MsoNormal">        int order(station) ;<o:p></o:p></p>
<p class="MsoNormal">                order:long_name = "Strahler Stream Order" ;<o:p></o:p></p>
<p class="MsoNormal">=============<o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">a = addfile("200303101200.CHRTOUT_DOMAIN3"+".nc","r")<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">st = a->streamflow<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">lat = a->latitude<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">lon = a->longitude<o:p></o:p></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<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">st1 = new(dimsizes(st),typeof(st))<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">lat1 = new(dimsizes(lat),typeof(lat))<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">lon1 = new(dimsizes(lon),typeof(lon))<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">st@_FillValue = -9999<o:p></o:p></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)<o:p></o:p></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)<o:p></o:p></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)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif"><o:p> </o:p></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..<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">    system("/bin/rm -f simple.nc")  
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">    ncdf = addfile("simple.nc" ,"c")
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">    ncdf->streamflow = st1<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">    ncdf->lat        = lat1<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">    ncdf->lon        = lon1<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">;;;;;;or output in txt format<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">      opt = True<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">      opt@fout = "foo.txt"<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">      write_matrix(st1, "10f7.2", opt)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">end if<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">==============<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">Thanks!<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">Jiali Wang, Ph. D<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">Environmental Science Division<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">Argonne National Laboratory<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:"Times New Roman",serif">Tel: 630-252-2848<o:p></o:p></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">http://www.evs.anl.gov/about-evs/staff/detail/index.cfm?/Wang/Jiali</a><o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>