<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 'positive' using the 'ncatted' command of NCO.<br></p>
<p dir="ltr">Lyndon Mark Olaguera</p>
<div class="gmail_quote">On 16 Nov 2016 02:54, "Dennis Shea" <<a href="mailto:shea@ucar.edu">shea@ucar.edu</a>> 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 'copy_VarMeta' (contributed.ncl) or other operations that would do this.<br><br><br></div>I suggest that you try to isolate where this occurs. Use 'print' and/or printVarSummary after various operations. <br><br></div><div>You can change this attribute if you think it is inappropriate for, say, variable 'x':<br></div><div> x&level@positive = "up" or "down"<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 'uwind' 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 ="./"<br> fili = systemfunc("cd "+diri+" ; ls uwind_*.nc")<br> path = diri+fili<br> print(path)<br><br> f = addfiles(path, "r") ; one or more files<br> ua = f[:]->uwind ; (time,level,lat,lon)<br><br> printVarSummary(ua)<br> print(ua&level) <wbr> ; print coordinate variable<br><br> ;date = ut_calendar(ua&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 = "Butterworth Band Pass: "+cb+"-"+ca+" day"<br> bf@units = ua@units<br><br> printVarSummary(bf)<br> print(bf&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: 'time' UNLIMITED<br><br> diro = "./"<br> filo = "<a href="http://filter.nc" target="_blank">filter.nc</a>"<br> ptho = diro+filo<br> system("/bin/rm -f "+ptho) ; remove any pre-existing file<br> ncdf = addfile(ptho ,"c") ; open output netCDF file<br><br> fAtt = True<br> fAtt@title = "4th order Butterworth BPass Filter"<br> fAtt@source_file = "<a href="http://uwind_anom_1981-2007.nc" target="_blank">uwind_anom_1981-2007.nc</a>"<br> fAtt@Conventions = "None"<br> fAtt@creation_date = systemfunc("date")<br> fileattdef(ncdf,fAtt) ; copy file attributes<br><br> filedimdef(ncdf,"time",-1,<wbr>True) ; make time an UNLIMITED dimension<br> <wbr> ; recommended for most applications<br> ncdf->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"><<a href="mailto:olagueralyndonmark429@gmail.com" target="_blank">olagueralyndonmark429@gmail.<wbr>com</a>></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'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="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 = "longitude" ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>lon:long_name = "Longitude" ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>lon:units = "degrees_east" ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>lon:axis = "X" ;</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 = "latitude" ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>lat:long_name = "Latitude" ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>lat:units = "degrees_north" ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>lat:axis = "Y" ;</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 = "air_pressure" ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>level:long_name = "Level" ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>level:units = "millibar" ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span><b>level:positive = "down" ;</b></div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </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="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 = "longitude" ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>lon:long_name = "longitude" ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>lon:units = "degrees_east" ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>lon:axis = "X" ;</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 = "latitude" ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>lat:long_name = "latitude" ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>lat:units = "degrees_north" ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>lat:axis = "Y" ;</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 = "air_pressure" ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>level:long_name = "Level" ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span>level:units = "millibar" ;</div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </span><b>level:positive = "up" ;</b></div><div><span class="m_5403780566501260086m_-1019673452007647906gmail-Apple-tab-span" style="white-space:pre-wrap">                </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/nclscri<wbr>pts/csm/gsn_code.ncl"</div><div>load "$NCARG_ROOT/lib/ncarg/nclscri<wbr>pts/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,<wbr>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<wbr>")</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" target="_blank">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>
<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>