Re: time dimension problem

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon Mar 01 2010 - 08:48:03 MST

Ioana,

You included your code below, but I don't see where you are writing
the new NetCDF file.

Did you try using addfiles? This will allow you to read in all files
at once. Then, when you read "T"
off this series of files, you can chose to have the number of files
as your new leftmost dimension,
or you can concatenate your new time values.

For example, let's assume "T" on each file is 3-dimensional, nlev x
nlat x nlon.

Let's further assume you have numFILES=50 CAM files.

You can read "T" off all the files in "join" mode, which will cause a
new dimension to be created for T:

   FILES = systemfunc (" ls -1 " + DATADir + "20C3Mb1.cam*.nc ")
   ListSetType(a, "join") ; The defaut is "cat"
   a = addfiles(FILES,"r")
   T = a[:]->T

In this case, "T" will be dimensioned numFiles x nlev x nlat x nlon.

You could then write "T" to a file without having to do any looping.

--Mary

On Feb 28, 2010, at 7:15 PM, Ioana Colfescu wrote:

> Hi ,
>
> Could anybody help me with the following problem ?
>
> I have 10 monthly data .nc files .
> I want to put them all in one single .nc file ( so I should get
> an .nc with 10 moments of time).
> The problem is that though I seem to get a .nc file the time in
> the .nc file I get is still 1 , not 10.
> Can anybody tell me what should I do to get the correct dimension
> for time ?
> I'm attaching the code I'm using below .
> Thanks !
>
> -----------------------------------------------------------
> 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"
>
> begin
>
> ; Make a list of all files we are interested in
> DATADir = "./"
> FILES = systemfunc (" ls -1 " + DATADir + "20C3Mb1.cam*.nc ")
> numFILES = dimsizes(FILES)
>
>
> ; We generate plots, but what kind do we prefer?
> type = "x11"
> ; type = "pdf"
> ; type = "ps"
> ; type = "ncgm"
> wks = gsn_open_wks(type,"plt_metgrid_3")
>
>
> res = True ; Set up some basic plot
> resources
> res@MainTitle = "METGRID FILES"
> res@Footer = False
>
> pltres = True
> mpres = True
>
>
> opts = res
> opts@cnFillOn = True
>
> do ifil = 0,numFILES-1
>
> a = addfile(FILES(ifil)+".nc","r") ; Open the next file
>
> slp1 = a->T ; Get sea level pressure from file
> wks = gsn_open_wks("x11","example")
> gsn_define_colormap(wks,"rainbow")
> r = True
> r@cnFillOn = True
> r@gsnSpreadColors = True
> ; contour = wrf_contour(a,wks,slp,opts)
> plot = gsn_csm_contour_map(wks,slp1(0,1,:,:),r)
> end do
> end
> ---------------------------------------------------
> _______________________________________________
> 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 Mon Mar 1 08:48:20 2010

This archive was generated by hypermail 2.1.8 : Mon Mar 01 2010 - 08:49:37 MST