<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'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'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 = "longitude" ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>lon:long_name = "Longitude" ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>lon:units = "degrees_east" ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>lon:axis = "X" ;</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 = "latitude" ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>lat:long_name = "Latitude" ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>lat:units = "degrees_north" ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>lat:axis = "Y" ;</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 = "air_pressure" ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>level:long_name = "Level" ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>level:units = "millibar" ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span><b>level:positive = "down" ;</b></div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>level:axis = "Z" ;</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 = "longitude" ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>lon:long_name = "longitude" ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>lon:units = "degrees_east" ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>lon:axis = "X" ;</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 = "latitude" ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>lat:long_name = "latitude" ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>lat:units = "degrees_north" ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>lat:axis = "Y" ;</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 = "air_pressure" ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>level:long_name = "Level" ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>level:units = "millibar" ;</div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span><b>level:positive = "up" ;</b></div><div><span class="gmail-Apple-tab-span" style="white-space:pre">                </span>level:axis = "Z" ;</div></div><div><br></div><div><br></div><div>Here's my code:</div><div><br></div><div><div>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"</div><div>load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"</div><div>begin</div><div>dir ="."</div><div>fili ="uwind*"</div><div>files =systemfunc("ls uwind_*.nc")</div><div>numfiles=dimsizes(files)</div><div>do ifil=0,numfiles-1</div><div>f = addfile(files(ifil), "r")</div><div>time := f->time</div><div>date := ut_calendar(time,-2)</div><div>ua := f->uwnd(:,:,:,:)</div><div>level= f->level</div><div>lat= f->lat</div><div>lon= f->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 = "Band Pass: "+cb+"-"+ca+" day"</div><div>ncdf = addfile("filt_"+files(ifil),"c")</div><div>fAtt = True</div><div>fAtt@title = "4th order Butterworth BPass Filter"</div><div>fAtt@source_file = "<a href="http://uwind_anom_1981-2007.nc">uwind_anom_1981-2007.nc</a>"</div><div>fAtt@Conventions = "None"</div><div>fAtt@creation_date = systemfunc("date")</div><div>fileattdef(ncdf,fAtt) ; copy file attributes</div><div>ncdf->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>