[gradsusr] how to extract start date and end date using GrADS script from netcdf file?

Marsh, Kieren [FGUAE] k.marsh at fugro-uae.com
Wed Jun 11 03:37:36 EDT 2014


* Open your netCDF file
* ---------------------------
'sdfopen xxxxxxx.nc'



* Get the start time
* ---------------------
'set t 1'
'q time'
startTime = subwrd(result, 3)



* Get end time requires you to find the number
* of time steps in the data set first
* ---------------------------------------------------------
'q ctlinfo'
ctlRes = result



* Loop through the result of 'q ctlinfo'
* to find the line that starts with 'tdef'
* ---------------------------------------------
line = 1
found = 0
while (!found)
  info = sublin(ctlRes, line)
  if (subwrd(info, 1) = 'tdef')
    handle = info
    found = 1
  endif
  line = line + 1
endwhile



* Variable 'handle' now contains the line that starts
* with 'tdef'
*
* Second word on the line is the number of time steps
* -----------------------------------------------------------------
numOfSteps = subwrd(handle, 2)



* Set time environment to last step of data set
* ---------------------------------------------------------
'set t 'numOfSteps
'q time'



* Grab time of last time step
* ----------------------------
endTime = subwrd(result, 3)



* Write out to text file
* [Here you enter the path and name of the text file
* you want to output]
* -----------------------------------------------------
rc=write(NAME_AND_PATH_OF_TEXTFILE, 'Start time = 'startTime', End time = 'endTime)
rc=close(NAME_AND_PATH_OF_TEXTFILE)


________________________________

From: gradsusr-bounces at gradsusr.org [gradsusr-bounces at gradsusr.org] on behalf of Malleswararao Maguluri [mallesh4science at gmail.com]
Sent: Wednesday, June 11, 2014 10:58 AM
To: GrADS Users Forum
Subject: [gradsusr] how to extract start date and end date using GrADS script from netcdf file?

Hi,

  how to extract start date and end date using GrADS script from netcdf file?. I need start date and end date output in text file.

Waiting for your reply,

Thanks & regards,

--
M. MALLESWARA RAO
M.Tech (Atmospheric Science) & M.Sc (Physics)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20140611/0de405ea/attachment.html 


More information about the gradsusr mailing list