exporting to Excel... (with Excel File attached)

Cottet, Loic (IFPRI) l.cottet at CGIAR.ORG
Wed Jun 7 17:57:26 EDT 2006


Thank you everyone for your help,
 
I am glad I understood better the script, their function and use thanks
to you (Diane particularly).
I have written one script then to export data and make them readable in
Excel.
Hereunder the script:
 
 
'sdfopen data\mrso1.nc'
'set lat 20'
'set lon 55'
'set z 1'
'set t 1 12'
filename='youyou'
'set gxout print'
'd mrso'
rc=write(filename,result)
 
 
The youyou file does not create. It does though when I want the average
(see my attached excel results):
 
 
 
'sdfopen data\mrso1.nc'
'set lat 20 25'
'set lon 52 55'
'set z 1'
'set t 1 12'
'define m1 = ave(mrso.1,t=1,t=601)'
filename='testbis.xls'
'set gxout print'
'd m1'
rc=write(filename,result)
 
 
So, I have 2 questions:
*1st one related to the first script: why can't I have a file created
when I ask to export for each step of time. Indeed, I would like to have
for each grid, a monthly value during my period of time mentionned, do
you know what I mean?
*2nd question: why in Excel the numbers are so big (x*e25, or so small
x*e-17). What are those numbers?
 
 
Thanks a lot for your cooperation,
 
Loic.
 
 
 
 
 

 
 

________________________________

From: Diane Stokes [mailto:Diane.Stokes at noaa.gov] 
Sent: Thursday, June 01, 2006 1:26 PM
To: Cottet, Loic (IFPRI)
Subject: Re: your explanations


Hi, Loic.

"clm" was an example variable name that a I chose to "display".

If you 'set gxout print', then display some field, the values are
printed to the screen.  When you are running a grads script, text output
from each command is stored in the variable "result".  So, if you want
to trap that output to process it further, you have to grab "result".
In the example below, I'm copying the info from "result" into the new
variable "res".  Then I write "res" to text file temp.txt using the
intrinsic function "write".  Every time you call an function, a return
code is generated.  I'm using variable "rc" to store these.

So, here's the example one more time with additional comments in purple:

* tell grads to generate ascii output for display commands.
* For more info see 
http://grads.iges.org/grads/gadoc/gradcomdsetgxout.html
* and http://grads.iges.org/grads/gadoc/gradcomdsetprnopts.html
'set gxout print'

*display field
'd clm'

*save ascii output in variable "res"
res=result

*write ascii output to file temp.txt, saving return code in "rc".
*For more info, see 
http://grads.iges.org/grads/gadoc/script.html#intrinsic
rc=write(temp.txt,res)
say 'return code from write is: 'rc
* depending on what you are doing,
* you may or may not want to close the file

*close output file temp.txt, saving return code in "rc"
*For more info, see 
http://grads.iges.org/grads/gadoc/script.html#intrinsic
rc=close(temp.txt)
say 'return code from close is: 'rc


For more info on the scripting language, see:
   http://grads.iges.org/grads/gadoc/script.html

   Good luck.
      Diane


PS.  I know you've been having trouble getting responses to some of your
posts.  In some cases, your issues were windows related and there just
aren't as many people running grads under windows, so your knowledge
pool is smaller than for folks running under unix or linux.  In the case
of yesterday's msg ("read stream format"), that wasn't so.  Many of us
could have answered.  I guess we were all busy and nobody got to it yet.
Sorry!  Good job looking through the archives.  You are on the right
track with "set gxout print".


Cottet, Loic (IFPRI) wrote: 

        Hi Diane,
         
        After checking the archives I tried to follow your steps to
output data from Grads and make it readable (Clearly) in Excel.
        There is just something that I do not understand in your script:
         
	
        'set gxout print'
        'd clm'
        res=result
        rc=write(temp.txt,res)
        say 'return code from write is: 'rc
        * depending on what you are doing,
        * you may or may not want to close the file
        rc=close(temp.txt)
        say 'return code from close is: 'rc
	

        I am using GradsNC and in the documetation I do not find
anything about d clm and the functions rc and res.

        Thanks a lot for your help,  I would appreciate it.

	
        Loic
	

	
	


-- 
Diane Stokes
Environmental Modeling Center
National Weather Service/NOAA
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20060607/547c63cd/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testbis.xls
Type: application/vnd.ms-excel
Size: 1838 bytes
Desc: testbis.xls
Url : http://gradsusr.org/pipermail/gradsusr/attachments/20060607/547c63cd/attachment.xls 


More information about the gradsusr mailing list