convert grib file to ascii file

Rafael Mundaray remm69 at GMAIL.COM
Tue Jun 5 08:28:01 EDT 2007


Hi, Giannakos if your files are .ctl for GrADS, it can help you...
*****************************************************************
****Este SCRIPT genera Archivos .txt de cualquier variables, simplemente hay
que cambiar el nombre del .ctl a abrir, ***cambiar la variable por la que se
desea en 'd variable' y cambiar la ruta del archivo donde se va a guardar
los datos
***by: Ing. Rafael Mundaray
*****************************************************************
'reinit'
'open /home/Rafael/DOMAINS/Venezuela/postprd/wrfnmm_d01_24.ctl'
'q dims'
rec=sublin(result,2)
lonmin=subwrd(rec,6)
lonmax=subwrd(rec,8)
     say 'lonmin 'lonmin 'lonmax 'lonmax
rec=sublin(result,3)
latmin=subwrd(rec,6)
latmax=subwrd(rec,8)
     say 'latmin 'latmin 'latmax 'latmax
rec=sublin(result,2)
Imax=subwrd(rec,13)
     say 'Imax 'Imax
rec=sublin(result,3)
Jmax=subwrd(rec,13)
     say 'Jmax 'Jmax
'set gxout shaded'
'd rhprs'
dLon = (math_abs(lonmin)-math_abs(lonmax))/Imax
dLat = math_abs(math_abs(latmin)-math_abs(latmax))/Jmax
     say 'dLon 'dLon 'dLat 'dLat
rc = write('/home/Rafael/Desktop/test_xy2w_2.txt','lat lon  var')
lon=lonmin
     while (lon <= lonmax+dLon)
          lat=latmin
               while (lat <= latmax)
               'set lat 'lat
               'set lon 'lon
               'd rhprs'
               var = subwrd(result,4)
               lonval = math_format('%6.3f',lon)
               latval = math_format('%6.3f',lat)
               say 'latval 'latval 'lonval 'lonval 'var 'var
               rc = write('/home/Rafael/Desktop/test_xy2w_2.txt',''latval'
'lonval' 'var'')
               'clear'
               lat=lat+dLat
               endwhile
           lon=lon+dLon
     endwhile
rc = close('/home/Rafael/Desktop/test_xy2w_2.txt')

It is mine i made for change the grads information in ASCII format... For
example: if you make a graphic of PRECIPITATION you can obtain a ASCII with
the information of the image...


2007/6/5, Giannakos Apostolos <geom06005 at geo.aegean.gr>:
>
> Hi list
>
> I have a grib file and i want to write it to an ascii does anyone know
> what
> should i do? Also i want to be able  to extract several grib files to
> ascii
> format.
>
> I would appreciate any assistance
>
> Thanks in advance
>



--
Ing. Rafael E. Mundaray M.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20070605/20428bb1/attachment.html 


More information about the gradsusr mailing list