error reading WRF netCDF data

From: Kyoko Ikeda <kyoko_at_nyahnyahspammersnyahnyah>
Date: Thu, 1 Dec 2005 17:00:06 -0700 (MST)

Hello,

I am trying to read in WRF dataset (in netCDF) on bluesky (set to 32-bit,
double precision) and write a selection of variables to a new netCDF file.
 But I have been having problems.
The following is my script:

     load "WRFOptions.ncl"
     load "$NCARG_LIB/ncarg/nclscripts/csm/gsn_code.ncl"
     load "WRFPlot.ncl"
     load "WRFUserARW.ncl"
     load "$NCARG_LIB/ncarg/nclscripts/csm/contributed.ncl"

     begin
     ;-------------------------------------------------------------- ;
     The WRF ARW input file. ;--------------------------------------------------------------
       OUTDIR = "/ptmp/kyoko/"
       INDIR = "/mmm/mmmtmp/chliu/wrf/WRFV2/run/"
       FILENM = "wrfout_d01_2003-07-03_00:00:00.nc"

       a = addfile(INDIR+FILENM,"r")

     ;-------------------------------------------------------------- ;
     Debug information. ;--------------------------------------------------------------

     ; debug = False
       debug = True

     ;--------------------------------------------------------------
     ;--------------------------------------------------------------
       Times = a->Times;
       times = chartostring(Times) ;

       RAINC = a->RAINC;
       RAINNC = a->RAINNC;
       LH = a->LH;
       tmpvar = a->RAINC;

       printVarSummary(tmpvar)
       ndim_tmpvar = dimsizes(tmpvar);
       ntime = ndim_tmpvar(0);
       ny = ndim_tmpvar(1);
       nx = ndim_tmpvar(2);
       delete(tmpvar)
       delete(ndim_tmpvar)

       system("/bin/rm $TMPDIR/example.nc") ; remove if exists fout
       = addfile("/ptmp/kyoko/example.nc","c") ; open output file ;--------------------------------------------------------------
     ;--------------------------------------------------------------
       fAtt = True ; assign file attributes
       fAtt_at_title = "NCL write_wrf_nc"
       fAtt_at_source_file = FILENM
       fAtt_at_Conventions = "None"
       fAtt_at_creation_date = systemfunc("date")
       fileattdef(fout,fAtt)

     ;--------------------------------------------------------------
     ;-------------------------------------------------------------- dimNames = (/"Time","south_north","west_east"/)
       dimSizes = (/ntime,ny,nx/)
       dimUnlim = (/False,False,False/)
       filedimdef(fout,dimNames,dimSizes,dimUnlim)

     ;--------------------------------------------------------------
     ;-------------------------------------------------------------- filevardef(fout, "Times", typeof(Times), "Time")
       filevardef(fout, "RAINC",
       typeof(RAINC),(/"Time","south_north","west_east"/))
       filevardef(fout, "RAINNC", typeof(RAINNC),
       (/"Time","south_north","west_east"/)) filevardef(fout, "LH",
       typeof(LH), (/"Time","south_north","west_east"/)) ;--------------------------------------------------------------
     ;--------------------------------------------------------------
       filevarattdef(fout,"RAINC",RAINC)
       filevarattdef(fout,"RAINNC",RAINNC)
       filevarattdef(fout,"LH",LH)

     ;--------------------------------------------------------------
     ;--------------------------------------------------------------
       fout->Times = (/Times/)
       fout->RAINC=(/RAINC/)
       fout->RAINNC=(/RAINNC/)
       fout->LH=(/LH/)

     end
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Troubles are,
(1) I get following error messages
    ncvarget: Error in getting the data: Invalid argument
    ncvarget: Error in getting the data: Invalid argument
    ncvarget: Error in getting the data: Invalid argument
    ncvarget: Error in getting the data: Invalid argument
    ncvarget: Error in getting the data: Invalid argument

   corresponding to these commands
    Times = a->Times;
    RAINC = a->RAINC;
    RAINNC = a->RAINNC;
    LH = a->LH;
    tmpvar = a->RAINC;
(2) values do not exist after the 20th time index. However,results from
ncdump on these variables tells me that values do exist at all time and
grid points.(3) When I check times that has been converted via chartostring, I get
correct times from index 0 to 19, but the rest is blank or have funny
characters: Variable: times (subsection)
     Type: string
     Total Size: 176 bytes
                 22 values
     Number of Dimensions: 1
     Dimensions and sizes: [22]
     Coordinates:
     (0) 2003-07-03_00:30:00
     (1) 2003-07-03_01:00:00
     (2) 2003-07-03_01:30:00
     (3) 2003-07-03_02:00:00
     (4) 2003-07-03_02:30:00
     (5) 2003-07-03_03:00:00
     (6) 2003-07-03_03:30:00
     (7) 2003-07-03_04:00:00
     (8) 2003-07-03_04:30:00
     (9) 2003-07-03_05:00:00
     (10) 2003-07-03_05:30:00
     (11) 2003-07-03_06:00:00
     (12) 2003-07-03_06:30:00
     (13) 2003-07-03_07:00:00
     (14) 2003-07-03_07:30:00
     (15) 2003-07-03_08:00:00
     (16) 2003-07-03_08:30:00
     (17) 2003-07-03_09:00:00
     (18) 2003-07-03_09:30:00
     (19) 2003-07-03_10:00:00
     (20)
     (21)
      .
      .
      .
     (228) òÍp
     (229)
     (230)
     (231) òÒÐ
      .
      .
      .
     (336)

(4) If I try to plot out a variable following examples from
http://www.ncl.ucar.edu/Applications/wrf.shtml and WRF_NCL scripts, I also
have trouble reading times and variables after 19th time index.
Could someone help me?

Thank you.

-kyoko

_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Dec 01 2005 - 17:00:06 MST

This archive was generated by hypermail 2.2.0 : Fri Dec 02 2005 - 16:53:55 MST