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

Malleswararao Maguluri mallesh4science at gmail.com
Wed Jun 11 04:27:41 EDT 2014


Thanks Marsh,




On Wed, Jun 11, 2014 at 1:07 PM, Marsh, Kieren [FGUAE] <
k.marsh at fugro-uae.com> wrote:

>  * 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)
>
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
>


-- 
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/770d5880/attachment-0001.html 


More information about the gradsusr mailing list