Output data from grib for given coordinates
Goodson,Ron [Edm]
Ron.Goodson at EC.GC.CA
Thu Dec 10 11:12:51 EST 2009
There are a number of options ..
the simplest is to set gxout print ... display the data which will go into the "result" variable .. and then use subwrd /sublin to grab and print (say) the variable.
Attached is a script I use with my data which reads a file of lat/lon points.. and prints out a bit of data for each point. This was just for testing so you will have to modify. If you can't understand the program flow -- you can contact me directly if you wish.
ron
________________________________
From: GRADSUSR at LIST.CINECA.IT [mailto:GRADSUSR at LIST.CINECA.IT] On Behalf Of Nathan Cool
Sent: December 9, 2009 3:55 PM
To: GRADSUSR at LIST.CINECA.IT
Subject: Re: Output data from grib for given coordinates
Thanks everyone.
I was able to do this by manually entering in each command, but I need to run this in batch mode, if possible.
A simple script I have now is:
'open nww3.ctl'
'set lon 206'
'set lat 33'
'set t 3'
'd HTSGWsfc'
Grads is then executed using the following arguments:
gradsc -lbxc point.gs
...where point.gs is the script above.
In batch mode, I don't see the result output. Is there a way to run this in batch mode, or perhaps a GRADS command to output the result into a file?
-Nathan
On Wed, Dec 9, 2009 at 8:49 AM, Goodson,Ron [Edm] <Ron.Goodson at ec.gc.ca> wrote:
I'm lazier than that...
I just set lat lon to be the coordinates I want, then print out the result of displaying the data.
This is only useful if you don't mind getting the nearest grid point to your lat/lon. Otherwise - simply use the GrADS "bilinear".
Hmmm .. thought that was in the script library but don't see it .. so here is a copy I have buried in one of my scripts. Haven't used this script in many years, so no warrantly expressed or implied. You will probably have to modify it as it looks like it was hardwired for a specific-sized grid. And it looks like it would run pretty slow.
-------------------------------------------------------------------------------------------
*****bilinear interpolation from 4 nearest gridpoints:
function bilinear(llat, llon, myvar)
**_llat = subwrd(myposition, 1)
**_llon = subwrd(myposition, 2)
************say 'q w2gr 'llon' 'llat
'q w2gr 'llon' 'llat
*************say result
xdim=subwrd(result,3)
xdim=0.+xdim
if ( xdim <= 1.) ; xdim=96.+xdim ; endif
ydim=subwrd(result,6)
* nearest x dimensions :
x1= math_int(xdim)
x2 = x1 + 1
* the weights are
xw1= xdim-x1
xw2= 1.-xw1
* nearest y dimensions :
y1= math_int(ydim)
y2 = y1 + 1
* the weights are
yw1= ydim-y1
yw2= 1.-yw1
'set x ' x1
'set y ' y1
'd ' myvar
line2 = sublin(result,2)
pointa = subwrd(line2,4)
'set x ' x2
'set y ' y1
'd ' myvar
line2 = sublin(result,2)
pointb = subwrd(line2,4)
'set x ' x1
'set y ' y2
'd ' myvar
line2 = sublin(result,2)
pointc = subwrd(line2,4)
'set x ' x2
'set y ' y2
'd ' myvar
line2 = sublin(result,2)
pointd = subwrd(line2,4)
newtemp = pointa*xw2*yw2 + pointb*xw1*yw2 + pointc*xw2*yw1 + pointd*xw1*yw1
return newtemp
* station = f(x1,y1)*xw2*yw2+
* f(x2,y1)*xw1*yw2+
* f(x1,y2)*xw2*yw1+
* f(x2,y2)*xw1*yw1
________________________________
From: GRADSUSR at LIST.CINECA.IT [mailto:GRADSUSR at LIST.CINECA.IT] On Behalf Of Guilherme Martins
Sent: December 9, 2009 8:49 AM
To: GRADSUSR at LIST.CINECA.IT
Subject: Re: Output data from grib for given coordinates
Hi Nathan!
You can use the lats4d.gs. You can extract levels, variables, specific times and coordinates. The output format can be, .nc, .bin, .grb.
Guilherme.
2009/12/9 Nathan Cool <nathan at nathancool.com>
Good morning everyone,
I'm working on a project where I need to extract data from a grib file for specific coordinates only. Is there a way, using GRADS, where I can specify a given coordinate (lon, lat), and retrieve data just for that coordinate for each time series in a grib file? Or is GRADS not the tool to do this; I was thinking of just dumping the grib using wgrib and text parsing it, but thought GRADS might have an easier way.
Thanks in advance,
-Nathan
--
-----------------------------------------------------------
José Guilherme Martins dos Santos
Grupo de Modelagem da Atmosfera e Interfaces - GMAI
Divisão de Modelagem e Desenvolvimento - DMD
Centro de Previsão de Tempo e Estudos Climáticos - INPE
Rodovia Presidente Dutra, km 39 - CEP 12630-000
Cachoeira Paulista, SP, Brasil
Telefone(CP): +55 12 3186 8502
Celular(SJC): +55 12 91678770 / +55 12 81528580
E-mail: guilherme.martins at cptec.inpe.br
E-mail alternativo: jgmsantos at gmail.com
Homepage: http://guilhermemartins.hd1.com.br/
-----------------------------------------------------------
Sent from Sao Jose Dos Campos, SP, Brazil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20091210/46cd5221/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: WriteData.gs
Type: application/octet-stream
Size: 2953 bytes
Desc: WriteData.gs
Url : http://gradsusr.org/pipermail/gradsusr/attachments/20091210/46cd5221/attachment.obj
More information about the gradsusr
mailing list