<p dir="ltr">Hi Sir Dennis,<br>
 <br>
Many thanks for your reply.</p>
<p dir="ltr">I found that this error is not created by ncl. It is CDO which I used to merged the outputs.I have to process the file per year because the original filesize is around 14GB. When I run the script it gives me an error about memory allocation. I am using the pre compiled version of ncl.<br></p>
<p dir="ltr">After getting the output per year, I merge them using CDO( cdo -f nc2 mergetime ifile ofile). </p>
<p dir="ltr">To solve this, I just changed the attributes of the &#39;positive&#39; using the &#39;ncatted&#39; command of NCO.<br></p>
<p dir="ltr">Lyndon Mark Olaguera</p>
<div class="gmail_quote">On 16 Nov 2016 02:54, &quot;Dennis Shea&quot; &lt;<a href="mailto:shea@ucar.edu">shea@ucar.edu</a>&gt; wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>I have no idea why the level@positive attribute would change. <br>The is nothing in &#39;copy_VarMeta&#39; (contributed.ncl) or other operations that would do this.<br><br><br></div>I suggest that you try to isolate where this occurs. Use &#39;print&#39; and/or printVarSummary after various operations. <br><br></div><div>You can change this attribute if you think it is inappropriate for, say, variable &#39;x&#39;:<br></div><div>      x&amp;level@positive = &quot;up&quot;  or &quot;down&quot;<br><br>---<br></div><div>Certainly, it not the Butterworth filter that does anything with the meta data.<br>--<br></div><div>Also, Why are you doing each year separately? Use addfiles.<br><br></div><div>I have no idea what your &#39;uwind&#39; files look like. <br>However I suggest the following *untested* approach.<br></div><div>Output one file. If you want arbitrary temporal subset, extract from the sinfle file<br></div><div><br>    ca    = 100.0<br>    cb    = 20.0<br>    fca   = 1.0/ca<br>    fcb   = 1.0/cb<br><br>    diri  =&quot;./&quot;<br>    fili  = systemfunc(&quot;cd &quot;+diri+&quot; ; ls uwind_*.nc&quot;)<br>    path  = diri+fili<br>    print(path)<br><br>    f     = addfiles(path, &quot;r&quot;)     ; one or more files<br>    ua    = f[:]-&gt;uwind             ; (time,level,lat,lon)<br><br>    printVarSummary(ua)<br>    print(ua&amp;level)               <wbr>  ; print coordinate variable<br><br>   ;date  = ut_calendar(ua&amp;time,-2) ; yyyymmdd (not used)<br>   ;print(date)<br><br>; bandpass<br><br>    opt   = True<br>    opt@m = 4<br>    dims  = 0                       ; time<br><br>    bf    = bw_bandpass_filter(ua,fca,fcb,<wbr>opt,dims)<br>    copy_VarCoords(ua,bf)<br>    bf@long_name = &quot;Butterworth Band Pass: &quot;+cb+&quot;-&quot;+ca+&quot; day&quot;<br>    bf@units     = ua@units<br><br>    printVarSummary(bf)<br>    print(bf&amp;level)<br><br>; output netCDF<br>; <a href="http://www.ncl.ucar.edu/Applications/o-netcdf.shtml" target="_blank">http://www.ncl.ucar.edu/<wbr>Applications/o-netcdf.shtml</a><br>; Method 1: &#39;time&#39; UNLIMITED<br><br>    diro  = &quot;./&quot;<br>    filo  = &quot;<a href="http://filter.nc" target="_blank">filter.nc</a>&quot;<br>    ptho  =  diro+filo<br>    system(&quot;/bin/rm -f &quot;+ptho)       ; remove any pre-existing file<br>    ncdf = addfile(ptho ,&quot;c&quot;)           ; open output netCDF file<br><br>    fAtt = True<br>    fAtt@title                 = &quot;4th order Butterworth BPass Filter&quot;<br>    fAtt@source_file     = &quot;<a href="http://uwind_anom_1981-2007.nc" target="_blank">uwind_anom_1981-2007.nc</a>&quot;<br>    fAtt@Conventions   = &quot;None&quot;<br>    fAtt@creation_date = systemfunc(&quot;date&quot;)<br>    fileattdef(ncdf,fAtt)                  ; copy file attributes<br><br>    filedimdef(ncdf,&quot;time&quot;,-1,<wbr>True)  ; make time an UNLIMITED dimension<br>                              <wbr>                       ; recommended  for most applications<br>    ncdf-&gt;bf = bf<br><br></div><div><br></div><br><div><div><br><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 14, 2016 at 6:44 PM, Lyndon Mark Olaguera <span dir="ltr">&lt;<a href="mailto:olagueralyndonmark429@gmail.com" target="_blank">olagueralyndonmark429@gmail.<wbr>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"><div><div class="m_5403780566501260086m_-1019673452007647906gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Dear All,</div><div>I&#39;m trying to do a bandpass filter in ncl. When I compare the input and output netcdf file the vertical levels seems to be reversed. Did I missed something in writing the output netcdf file that caused this?</div><div><br></div><div>I&#39;ll appreciate any help:</div><div><br></div><div><b>ncdump -h of input file:</b></div><div><br></div><div><div>netcdf uwind_1981-2007 {</div><div>dimensions:</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">        </span>lon = 144 ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">        </span>lat = 73 ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">        </span>level = 17 ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">        </span>time = UNLIMITED ; // (9861 currently)</div><div>variables:</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">        </span>float lon(lon) ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>lon:standard_name = &quot;longitude&quot; ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>lon:long_name = &quot;Longitude&quot; ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>lon:units = &quot;degrees_east&quot; ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>lon:axis = &quot;X&quot; ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">        </span>float lat(lat) ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>lat:standard_name = &quot;latitude&quot; ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>lat:long_name = &quot;Latitude&quot; ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>lat:units = &quot;degrees_north&quot; ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>lat:axis = &quot;Y&quot; ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">        </span>float level(level) ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>level:standard_name = &quot;air_pressure&quot; ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>level:long_name = &quot;Level&quot; ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>level:units = &quot;millibar&quot; ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span><b>level:positive = &quot;down&quot; ;</b></div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>level:axis = &quot;Z&quot; ;</div></div><div><br></div><div><b>ncdump -h of processed file:</b> </div><div><div><br></div><div>netcdf uwind_anom_DJF_ph8 {</div><div>dimensions:</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">        </span>lon = 144 ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">        </span>lat = 73 ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">        </span>level = 17 ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">        </span>time = UNLIMITED ; // (1 currently)</div><div>variables:</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">        </span>float lon(lon) ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>lon:standard_name = &quot;longitude&quot; ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>lon:long_name = &quot;longitude&quot; ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>lon:units = &quot;degrees_east&quot; ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>lon:axis = &quot;X&quot; ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">        </span>float lat(lat) ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>lat:standard_name = &quot;latitude&quot; ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>lat:long_name = &quot;latitude&quot; ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>lat:units = &quot;degrees_north&quot; ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>lat:axis = &quot;Y&quot; ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">        </span>float level(level) ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>level:standard_name = &quot;air_pressure&quot; ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>level:long_name = &quot;Level&quot; ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>level:units = &quot;millibar&quot; ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span><b>level:positive = &quot;up&quot; ;</b></div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>level:axis = &quot;Z&quot; ;</div></div><div><br></div><div><br></div><div>Here&#39;s my code:</div><div><br></div><div><div>load &quot;$NCARG_ROOT/lib/ncarg/nclscri<wbr>pts/csm/gsn_code.ncl&quot;</div><div>load &quot;$NCARG_ROOT/lib/ncarg/nclscri<wbr>pts/csm/gsn_csm.ncl&quot;</div><div>begin</div><div>dir  =&quot;.&quot;</div><div>fili =&quot;uwind*&quot;</div><div>files =systemfunc(&quot;ls uwind_*.nc&quot;)</div><div>numfiles=dimsizes(files)</div><div>do ifil=0,numfiles-1</div><div>f = addfile(files(ifil), &quot;r&quot;)</div><div>time := f-&gt;time</div><div>date := ut_calendar(time,-2)</div><div>ua := f-&gt;uwnd(:,:,:,:)</div><div>level= f-&gt;level</div><div>lat= f-&gt;lat</div><div>lon= f-&gt;lon</div><div>ca = 100.0</div><div>cb = 20.0</div><div>fca = 1.0/ca</div><div>fcb = 1.0/cb</div><div>opt = True</div><div>opt@m = 4</div><div>dims = 0</div><div>bf := bw_bandpass_filter(ua,fca,fcb,<wbr>opt,dims)</div><div>copy_VarMeta(ua,bf)</div><div>bf@long_name = &quot;Band Pass: &quot;+cb+&quot;-&quot;+ca+&quot; day&quot;</div><div>ncdf = addfile(&quot;filt_&quot;+files(ifil),&quot;c<wbr>&quot;)</div><div>fAtt = True</div><div>fAtt@title         = &quot;4th order Butterworth BPass Filter&quot;</div><div>fAtt@source_file   = &quot;<a href="http://uwind_anom_1981-2007.nc" target="_blank">uwind_anom_1981-2007.nc</a>&quot;</div><div>fAtt@Conventions   = &quot;None&quot;</div><div>fAtt@creation_date = systemfunc(&quot;date&quot;)</div><div>fileattdef(ncdf,fAtt)            ; copy file attributes</div><div>ncdf-&gt;bf = bf</div><div>end do</div><div>end</div></div><div><br></div><div><br></div><div><br></div></div></div></div></div></div></div></div></div></div>
</div>
<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>
<br></blockquote></div><br></div>
</blockquote></div>