<div dir="ltr"><div><div class="gmail_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="gmail-Apple-tab-span" style="white-space:pre">        </span>lon = 144 ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>lat = 73 ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>level = 17 ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>time = UNLIMITED ; // (9861 currently)</div><div>variables:</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>float lon(lon) ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>lon:standard_name = &quot;longitude&quot; ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>lon:long_name = &quot;Longitude&quot; ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>lon:units = &quot;degrees_east&quot; ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>lon:axis = &quot;X&quot; ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>float lat(lat) ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>lat:standard_name = &quot;latitude&quot; ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>lat:long_name = &quot;Latitude&quot; ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>lat:units = &quot;degrees_north&quot; ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>lat:axis = &quot;Y&quot; ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>float level(level) ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>level:standard_name = &quot;air_pressure&quot; ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>level:long_name = &quot;Level&quot; ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>level:units = &quot;millibar&quot; ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span><b>level:positive = &quot;down&quot; ;</b></div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </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="gmail-Apple-tab-span" style="white-space:pre">        </span>lon = 144 ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>lat = 73 ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>level = 17 ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>time = UNLIMITED ; // (1 currently)</div><div>variables:</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>float lon(lon) ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>lon:standard_name = &quot;longitude&quot; ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>lon:long_name = &quot;longitude&quot; ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>lon:units = &quot;degrees_east&quot; ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>lon:axis = &quot;X&quot; ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>float lat(lat) ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>lat:standard_name = &quot;latitude&quot; ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>lat:long_name = &quot;latitude&quot; ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>lat:units = &quot;degrees_north&quot; ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>lat:axis = &quot;Y&quot; ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>float level(level) ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>level:standard_name = &quot;air_pressure&quot; ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>level:long_name = &quot;Level&quot; ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>level:units = &quot;millibar&quot; ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span><b>level:positive = &quot;up&quot; ;</b></div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </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/nclscripts/csm/gsn_code.ncl&quot;</div><div>load &quot;$NCARG_ROOT/lib/ncarg/nclscripts/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,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&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">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>