Re: Unable to write out filtered data

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Wed Nov 16 2011 - 08:59:21 MST

I took your script and cleaned it up.
It ran correctly. NCL version 6.0.0

  load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
  load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
  load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
  load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/diagnostics_cam.ncl"
  begin

  f = addfile("uwnd.mon.mean.nc", "r")
  x = short2flt(f->uwnd(:,{850},:,:))
  print( getfilevarnames(f))
  printVarSummary(x)

  srate = 1 ; monthly means
  bpf = (/20,36,49/) ;
  opt = False

  xBPF = band_pass_latlon_time (x, srate, bpf, opt)
  printVarSummary( xBPF )

  ;open file to write
  fileName = "uwnd.nc"
  system("/bin/rm -f "+fileName) ; remove any pre-existing file

  ;setfileoption("nc","Format","LargeFile") ; why?
  outFile = addfile(fileName,"c")

  ;write data to file
  outFile->uwn = xBPF
  ;print("Thank you,come again." + systemfunc("date"))
  end

On 11/15/11 9:33 PM, Zablone Owiti wrote:

> Thanks for the ideas. The printVarSummary(x) gives the following:
> /Variable: x
> Type: float
> Total Size: 32166720 bytes
> 8041680 values
> Number of Dimensions: 3
> Dimensions and sizes: [time | 765] x [lat | 73] x [lon | 144]/
> /Coordinates:
> time: [17067072..17625168]
> lat: [90..-90]
> lon: [ 0..357.5]
> Number Of Attributes: 15
> _FillValue : -9.96921e+36
> parent_stat : Other
> statistic : Mean
> level_desc : Surface
> dataset : CDC Derived NCEP Reanalysis Products
> var_desc : u-wind
> least_significant_digit : 1
> precision : 2
> missing_value : -9.96921e+36
> scale_factor : 1
> add_offset : 0
> units : m/s
> actual_range : ( -17.73966, 18.80581 )
> valid_range : ( -102.2, 102.2 )
> long_name : Monthly surface zonal wind/
> *And the short2flt command indicates the variable isalready in type float*
> /(0)short2flt: input variable is already type float: Monthly surface
> zonal wind
> (0) short2flt: no conversion performed/
> */I suspect there could be an error in the code (attached) but I can't
> figure it out/*
> *//*
> *//*
> */ZABLONE OWITI
> /*
> *//*
>
> *From:* Dennis Shea <shea@ucar.edu>
> *To:* Zablone Owiti <zablonowiti@yahoo.com>
> *Cc:* "ncl-talk@ucar.edu" <ncl-talk@ucar.edu>
> *Sent:* Wednesday, 16 November 2011 12:19 AM
> *Subject:* Re: [ncl-talk] Unable to write out filtered data
>
> The 1st rule of data processing s to 'look at your data.'
> I am sure if you used
>
> f = addfile("uwnd.mon.mean.nc", "r")
> x = f->uwnd
> printVarSummary(x)
>
> you would see something like
>
> Variable: x
> Type: short <============ 16 bit integer
> add_offset : ....
> scale_factor : ...
>
> Further, I speculate it is 4-dimensional
>
> Dimensions and sizes: [time | ???] x [level | 17] x [lat | 73] x
> [lon | 144]
>
>
> You must unpack this before using the data
> http://www.ncl.ucar.edu/Document/Functions/Contributed/short2flt.shtml
>
> x = short2flt( f->uwnd )
>
> It is 4-dimensional. It has 'named' dimensions (time,lev,lat,lon)
>
> Hence, you must has gotten an eror message when you did
>
> x(time|:,lat|:,lon|:)
>
> On 11/15/11 3:49 AM, Zablone Owiti wrote:
> > Dear all,
> > I'm new to NCL and am trying to filter and write the filtered
> data to a
> > file using the following code:
> > load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> > load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> > load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
> > load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/diagnostics_cam.ncl"
> > begin
> >
> > f = addfile("uwnd.mon.mean.nc", "r")
> > x = f->uwnd
> > print( getfilevarnames(f))
> >
> > srate = 1 ; monthly means
> > bpf = (/20,36,49/) ;
> > wgty =latRegWgt(x&lon,"double",0)
> > opt = False
> >
> > xBPF = band_pass_latlon_time (x(time|:,lat|:,lon|:), srate, bpf, opt)
> > xBPF !0 = "time"
> > xBPF !1 = "lat"
> > xBPF !2 = "lon"
> > printVarSummary( xBPF )
> >
> > ;Return variable to original dimension
> >
> > uwn = xBPF(time|:,lat|:,lon|:)
> >
> > uwn&time = x&time
> > uwn&lon = x&lon
> > uwn&lat = x&lat
> > copy_VarAtts(x,uwn)
> > ;open file to write
> > fileName = "uwnd.nc"
> > setfileoption("nc","Format","LargeFile")
> > outFile = addfile(fileName,"c")
> >
> > ;write data to file
> > outFile->uwn = uwn
> > printVarSummary( uwn )
> > ;print("Thank you,come again." + systemfunc("date"))
> > end
> > When I try to plot the written data (uwnd.nc), I get the error:
> > *Warning: Countour plot; no valid values in scalar field; contourPlot
> > possible: [errno=1101]*
> > Any help please
> > */===================================================/*
> > */ZABLONE OWITI
> > /*
> >
> >
> > _______________________________________________
> > ncl-talk mailing list
> > List instructions, subscriber options, unsubscribe:
> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Nov 16 08:59:27 2011

This archive was generated by hypermail 2.1.8 : Thu Nov 17 2011 - 11:50:12 MST