Re: Problem with saving data without long-lag into NetCDF file

From: <Arnold.Sullivan_at_nyahnyahspammersnyahnyah>
Date: Wed Dec 23 2009 - 15:46:32 MST


Try to make this clear

I have variable SQ_VAR in 2-D (without long and lat, only level and time)
I would like to save this into Netcdf file. However, the result give me level in x axis rather then level axis.


SQ_VAR should be long lat level and time

somehow it becomes

SQ_VAR level long lat and time

The code are shown as bellow.



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"

 diri = "/cs/datastore/csdar/sul086/ipcc_workst/all/enso_iod_sam/enso/var/" ; directory where files reside
 fili = systemfunc ("ls "+diri+"*")
 fin = addfiles (fili, "r") ; note the "s" of addfile

 ListSetType (fin, "cat") ; concatenate or "merge"
 Nmodel = 24
 Nseason = 4
 SQ_VAR = new((/Nmodel,Nseason/),float)
 SQ_VAR(:,0) = fin[:]->SQ_VAR_DJF
 SQ_VAR(:,1) = fin[:]->SQ_VAR_MAM
 SQ_VAR(:,2) = fin[:]->SQ_VAR_JJA
 SQ_VAR(:,3) = fin[:]->SQ_VAR_SON

 diro = "./" ; Output directory
 filo = "" ; Output file
 system("/bin/rm -f " + diro + filo) ; remove if exists
 fout = addfile (diro + filo, "c") ; open output file

 fout@title<mailto:fout@title> = "enso var from model files"

 time = new(Nmodel,"integer") ; create time array
 do i=0,Nmodel-1
       time(i)=i ; combine to strings
 end do

 level = new(Nseason,"integer") ; create time array
 do i=0,Nseason-1
       level(i)=i ; combine to strings
 end do

 delete (time@_FillValue<mailto:time@_FillValue>)
 delete (level@_FillValue<mailto:level@_FillValue>)

; make time and UNLIMITED dimension ; recommended for most applications
 dimNames = (/"time","level"/)
 dimSizes = (/-1,Nseason/)
 dimUnlim = (/True,False/)

 filevardef(fout, "time" ,typeof(time) ,"time")
 filevardef(fout, "level" ,typeof(level) ,"level")
 filevardef(fout, "SQ_VAR" ,typeof(SQ_VAR) ,(/"time","level"/))

 filevarattdef(fout,"time" ,time)
 filevarattdef(fout,"level" ,level)

 fout->time = (/time/) ; write SQ_VAR to a file
 fout->level = (/level/) ; write SQ_VAR to a file
 fout->SQ_VAR = (/SQ_VAR/) ; write SQ_VAR to a file


ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
Received on Wed Dec 23 15:46:55 2009

This archive was generated by hypermail 2.1.8 : Tue Dec 29 2009 - 10:29:16 MST