How to concatenate variable ??

From: Marjolaine Rouault <marjolaine_at_nyahnyahspammersnyahnyah>
Date: Sun, 25 Dec 2005 17:57:27 +0200

Dear All,

I think I found a way to do it. What I did was to open the archive file of
previously grabbed DODS data. I then create a new empty array with a time
dimension greater by one and then populate the new array with both the
archived data and the new data. The new array is then saved to the archive
file. For those interested in the details, i have enclosed my code below for
the Jason1 altimetry data.

begin
;-----------------------------------------------------------
; Define region of interest
;-----------------------------------------------------------
minLon=30
maxLon=115
minLat=-30
maxLat=10
;-----------------------------------------------------------
; Open archive file of ssha Jason1_ssha.nc
;-----------------------------------------------------------
farch = addfile ("Jason1_ssha.nc", "w") ; open output file
; Get archive data
ssha_arch = farch->ssha
time_arch = farch->time
; Get dimensions of archived variable
dims=dimsizes(ssha_arch)
;-----------------------------------------------------------
; Get last ssha record from dods url
;-----------------------------------------------------------
url =
"http://las.pfeg.noaa.gov/cgi-bin/nph-dods/data/oceanwatch/nrt/jason/"
fname = "J110day.nc"
exists = isfilepresent(url+fname)

; Check if file can be found on server
if(.not.exists) then
  print("...Either file doesn't exist, or this server is not DODS enabled...")
else
  f = addfile(url + fname,"r")
  time_series = (/f->time_series/)
  ; find out dimension of time index time_series
  timedim=dimsizes(time_series)
  last_time=(/time_series(timedim(0)-1)/)
    ;-----------------------------------------------------------
    ; Check for new record
    ;-----------------------------------------------------------
    if (last_time.eq.(/time_arch(dims(0)-1)/))
      print("...The DODS file does not contain any new data...")
    else
      print("...New record found, updating archive file...")
      ;-----------------------------------------------------------
      ; Initialise new variables to contain updated ssha and time
      ;-----------------------------------------------------------
      ssha = new((/ dims(0)+1, dims(1), dims(2) /), float)
      time = new((/ dims(0)+1 /), double)
      ssha(0:dims(0)-1,0:dims(1)-1,0:dims(2)-1) = ssha_arch
      time(0:dims(0)-1)=time_arch
      ;-----------------------------------------------------------
      ; import most recent SSH Anomaly for selected domain
      ;-----------------------------------------------------------
      last_ssha = (/f->sshd(timedim(0)-1,{minLat:maxLat},{minLon:maxLon})/)
      ; convert from meters to cm
      last_ssha = last_ssha*100
      ;-----------------------------------------------------------
      ; Add last record to time and ssha variables
      ;-----------------------------------------------------------
      time(dims(0))=(/last_time/)
      ssha(dims(0),:,:) = (/last_ssha/)
      ssha&time = time ; update time coord variables
      ;-----------------------------------------------------------
      ; Add updated variables to archive file
      ;-----------------------------------------------------------
      farch->time = time
      farch->ssha = ssha
    end if
end if

end

On Wednesday, 14 December 2005 15:40, you wrote:
> On Tue, 13 Dec 2005, Marjolaine Rouault wrote:
> > Hello,
> >
> > I am not sure how to add a record to a file variable. I am reading data
> > with dods and want to append the most recent data read to a pre-existing
> > file.
> >
> > How do I append for example my most recently read variable T of dimension
> > (lat, lon) to an already existing variable T of dimension (time, lat,
> > lon).
> >
> > With my best regards, Marjolaine.
> >
> > _______________________________________________
> > ncl-talk mailing list
> > ncl-talk_at_ucar.edu
> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk

-- 
Marjolaine Rouault
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Sun Dec 25 2005 - 08:57:27 MST

This archive was generated by hypermail 2.2.0 : Tue Dec 27 2005 - 09:01:14 MST