Hi Francesc,
It wouldn't be that difficult at all to modify the make big functions to
add a timestep at the beginning instead of to the end.
for make1_big you could change this:
xnew(0:dimx(0)-1) = (/ x /)
xnew(3) = (/x(dimx(0)-1)+3/) ; will add 3 to the last time value in
the original file
to this:
xnew(1:dimx(0)) = (/ x /)
xnew(0) = (/x(0)-3/) ; will subtract 3 from the first time value in
the original file
for make_big change this:
xnew(0:dimx(0)-1,:,:) = (/ x /)
xnew(3,:,:) = xnew(1,:,:)
to this:
xnew(1:dimx(0),:,:) = (/ x /)
xnew(0,:,:) = xnew(1,:,:) ; copy the temperatures from the first time
in original file to the file time in new file
The above is untested. Make sure to check the data after passing it
through these functions to verify that the functions are doing what you
expect them to be doing. I would also suggest you read over the NCL
mini-language manual if you have not done so already, especially section
2.9 where it discusses subscripting:
http://www.ncl.ucar.edu/Document/Manuals/language_man.pdf
If the above does not help please respond to ncl-talk only.
Adam
On 03/22/2013 10:10 AM, Montane Caminal, Francesc wrote:
>
> Hi,
>
> Attached is a netcdf file that contains 3-h temperature data for 3
> times. The file dimensions are (time, lat, lon): (3, 360, 720).
>
> I used 'make_big' function to add a new time at the end of the file
> (see script below and attached netcdf file). The new time added was
> 3-h after the last time in the original file and then the temperature
> value from time 2 was copied to the new time (new file dimensions
> (time, lat, lon): (4, 360, 720) with temperature values for all the
> times; thank you, Adam!).
>
> Now I am trying to create the first time in the file (new time created
> 3-hour before the first time in the initial file), and then copy the
> temperature values from time 2 to the new time created. But I have
> problems because the last time has no temperature values. What is
> necessary to modify in the script below to add the first time instead
> of the last time with 'make_big' function? I guess that when creating
> a new time with the 'make_big' function the new time by default is
> created last instead of first in the new file. But I wonder how to
> deal with this if I am interested in creating the first time instead
> of the last time.
>
> I really appreciate any help with this.
> Thanks in advance.
>
> Francesc
>
> *_SCRIPT_*
>
> **
>
> 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"
>
> function make1_big(x,d1big)
> begin
>
> dimx = dimsizes(x)
> rankx= dimsizes(dimx)
> if (rankx.ne.1) then
> print("make_big: rankx="+rankx+": expecting rank=1")
> exit
> end if
> xnew = new ( (/d1big/),typeof(x), getFillValue(x))
> xnew(0:dimx(0)-1) = (/ x /)
> xnew(3) = (/x(dimx(0)-1)+3/) ; will add 3 to the last time value
> in the original file
> return(xnew)
> end
>
> function make_big(x, d1big)
> begin
> dimx = dimsizes(x)
> rankx= dimsizes(dimx)
> if (rankx.ne.3) then
> print("make_big: rankx="+rankx+": expecting rank=3")
> exit
> end if
> xnew = new ( (/d1big, dimx(1),dimx(2)/), typeof(x), getFillValue(x))
> xnew(0:dimx(0)-1,:,:) = (/ x /)
> xnew(3,:,:) = xnew(1,:,:)
> return(xnew)
> end
>
> begin
> print("reading the variables")
> a = addfile("cruncep_tairnew_2010_1x1_3h_2time.nc","r")
> y1=a->y
> TIME1=a->TIME
> print("variables read")
>
> time=make1_big(TIME1,4)
> time!0 = "time"
> time&time = time
> copy_VarAtts(TIME1,time)
>
> y2=make_big(y1,4)
> copy_VarAtts(y1,y2)
> ;printVarSummary(y2)
> exit
>
> y2!0 = "time"
> y2!1 = "lat"
> y2!2 = "lon"
>
> y2&time = time
> y2&lat = y1&lat
> y2&lon = y1&lon
>
> fout=addfile("tair_2010_3h_4times_new.nc", "c")
> copy_VarAtts(a,fout)
> fout->y=y2
> end
>
>
> **
>
> **
>
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
-- ______________________________________________________________ Adam Phillips asphilli@ucar.edu NCAR/Climate and Global Dynamics Division (303) 497-1726 P.O. Box 3000 Boulder, CO 80307-3000 http://www.cgd.ucar.edu/cas/asphilli
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Apr 3 16:36:59 2013
This archive was generated by hypermail 2.1.8 : Sun Apr 07 2013 - 21:13:30 MDT