Re: 3D variable from multiple addfile reads of 2D data?

From: Chris Herbster <herbstec_at_nyahnyahspammersnyahnyah>
Date: Tue Jan 10 2012 - 19:58:34 MST

I've been playing around a bit trying to see if I can figure this out.

I was able to create an array with the correct dimensions with:

Newx = new ((/225,301,nlist1/),float)

printVarSummary (Newx)

which yields:
Variable: Newx
Type: float
Total Size: 1625400 bytes
             406350 values
Number of Dimensions: 3
Dimensions and sizes: [225] x [301] x [6]
Coordinates:
Number Of Attributes: 1
   _FillValue : 9.96921e+36

An initial victory! For this test there are just 6 input files (6 hours).

Next I try to process a list of files, filling the variable "x" (in
the code below)

; Open each file and read the data

do i = 0, nlist1 - 1

     grib_in1= addfile(list1(i),"r")

     x = grib_in1->AIA_P0_L10_GLC0

     Newx = (/x(:,:),i/)

end do

I know this isn't the correct syntax to do what I want, as I get the
following error that the arrays are not the same dimensions. (I've
tried a variety of permutations of "(" and "/" arrangements but have
just gotten other errors.)

fatal:_NclBuildArray: each element of a literal array must have the same
number of dimensions
fatal:Execute: Error occurred at or near line 50 in file make3d-correl.ncl

Can someone out there help with the syntax (or proper method) to do
this? Thanks!

Chris H.

-- 
  Dr. Christopher G. Herbster
  Associate Professor
  Director of Science and Technology
  for the ERAU Weather Center
  Applied Aviation Sciences
  Embry-Riddle Aeronautical Univ.
  600 S. Clyde Morris Blvd.
  Daytona Beach, FL 32114-3900
  386.226.6444 Office
  386.226.6446 Weather Center
  http://wx.erau.edu/
Schedule at:  http://wx.erau.edu/faculty/herbster/Schedules/
On 01/10/2012 04:41 PM, Chris Herbster wrote:
> Hi folks,
>
> I know that I could use "addfiles" to get what I want, but my next step
> will be to do some correlation calculations and I think it might be more
> efficient to build the 3D array with time as the rightmost index rather
> than use the internal reordering technique (there are going to be many
> time steps eventually).
>
> Here is the code that fills my array "x"
>
> ---------
>
> ; Create list of input files from a file
> list1 = systemfunc ("cat list1")
> nlist1 = dimsizes(list1)
>
> print ("list1 has " +nlist1)
>
> ; Open each file and read the data
>
> do i = 0, nlist1 - 1
>
>      grib_in1= addfile(list1(i),"r")
>      names1  = getfilevarnames(grib_in1)   ; extract ALL variable names
>
>      x = grib_in1->AIA_P0_L10_GLC0
>
> end do
>
>      printVarSummary(x)
>      xsize = dimsizes(x)
>      print ("dimsizes = " + xsize)
>
>
> ---------
> The print statements yield:
>
> Variable: x
> Type: float
> Total Size: 270900 bytes
>               67725 values
> Number of Dimensions: 2
> Dimensions and sizes:   [ygrid_0 | 225] x [xgrid_0 | 301]
> Coordinates:
> Number Of Attributes: 13
>     initial_time :        12/01/2009 (05:00)
>     forecast_time_units : hours
>     forecast_time :       0
>     level_type :  Entire Atmosphere
>     parameter_template_discipline_category_number :       ( 0, 0, 20, 50 )
>     parameter_discipline_and_category :   Meteorological products,
> Atmospheric chemical constituents
>     grid_type :   Lambert Conformal can be secant or tangent, conical or
> bipolar
>     coordinates : gridlat_0 gridlon_0
>     units :       mol
>     long_name :   Amount in atmosphere
>     production_status :   Operational products
>     center :      US National Weather Service - NCEP (WMC)
>     _FillValue :  1e+20
> (0)     dimsizes = 225
> (1)     dimsizes = 301
>
>
> Each reading of the data from the next file will yield a new hour, so
> that 24 files would result in reading a whole day of data.
>
> What I would like is a new variable, say "Rx" with 3 dimensions like:
>
> Rx [ygrid_0|225 x xgrid_0|301 x time|nlist1] where "nlist1" is know from
> above.
>
> Do I need to create this array with "new" or can I just use the do loop
> on "i" to build the array as I go?  Sorry for being dense here, I'm a
> relative newbie with NCL.
>
> Thanks, in advance, for the help!
>
> Chris Herbster
>
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Jan 10 19:58:44 2012

This archive was generated by hypermail 2.1.8 : Wed Jan 18 2012 - 09:21:55 MST