GRADS - meteogram with spatial vertical section

All other topics about postprocessing model data (GrADS and other software), about other numerical weather prediction software (including WRF-NMM and WRF-ARW discussion unrelated to UEMS/WRF EMS), and general meteorology talk go in this forum.
nebojsa
Posts: 133
Joined: Sun Mar 21, 2010 3:40 pm

GRADS - meteogram with spatial vertical section

Post by nebojsa » Thu Sep 22, 2016 4:29 pm

Hello friends,

I need a grads script for drawing meteograms with spatial vertical section from one point to another, forexample from Zagreb to Bjelovar at some termin.
Anyone has it?

Thanks and best regards!

Nebojsa

meteoadriatic
Posts: 1510
Joined: Wed Aug 19, 2009 10:05 am

Re: GRADS - meteogram with spatial vertical section

Post by meteoadriatic » Thu Sep 22, 2016 6:03 pm

For fixed latitude or longitude crosses it is easy, but with arbitrary points not so much easy.

I hope this will help; of course you will probably want to adjust some things but it should be easy:

Code: Select all

'open 'file

'set t 35'

'set grads off'
'set font 1'
'set rgb 180 180 180 180'
'set grid horizontal 5 180'
'set display color white'
'clear'
'set zlog on'
lon1 = -149.70
lon2 = -149.30
lat1 = -17.77
lat2 = -17.43
lon = lon1

terrain_arr=''

'set parea 0.5 10 0.5 8.0'
'set lat 'lat1
'set lon 'lon1' 'lon2
'set lev 1000 300'
'd rhprs'

'collect 1 free'
'collect 2 free'
'collect 3 free'
'collect 4 free'
'set x 1'
'set y 1'

say 'collecting station data'

'q gxinfo'
xline=sublin(result,3)
yline=sublin(result,4)
xs=subwrd(xline,4)' 'subwrd(xline,6)
ys=subwrd(yline,4)' 'subwrd(yline,6)


while (lon <= lon2)
  'set lev 1000 300'
  lat = lat1 + (lat2-lat1)*(lon-lon1) / (lon2-lon1)
  'collect 1 gr2stn(rhprs,'lon','lat')'
  'collect 2 gr2stn((tmpprs-273),'lon','lat')'
  'collect 3 gr2stn(ugrdprs,'lon','lat')'
  'collect 4 gr2stn(vgrdprs,'lon','lat')'

  'set gxout print'
  'set lat 'lat
  'set lon 'lon
  'set lev 1000'
  'd pressfc/100'

   press=sublin(result,3);press=subwrd(press,1)
   'q w2xy 'lon' 'press
   x=subwrd(result,3)
   y=subwrd(result,6)

   if(x<=subwrd(xs,1));x=subwrd(xs,1);endif
   if(x>=subwrd(xs,2));x=subwrd(xs,2);endif
   if(y<=subwrd(ys,1));y=subwrd(ys,1);endif
   if(y>=subwrd(ys,2));y=subwrd(ys,2);endif

   terrain_arr=terrain_arr''x' 'y' '
   terrain_arry=terrain_arry''x' 'subwrd(ys,1)' 'x' 'y

  lon = lon + 0.0015
endwhile

say 'plotting data'

'clear'
'set grads off'
'set lev 1000 300'
'set lon 'lon1' 'lon2
'set clab on'
'set gxout shaded'
'color 70 100 0.5 -kind white->lightgreen->darkgreen->darkblue'
'd coll2gr(1,-u)'
'set gxout contour'
'set clevs 0' ; 'set ccols 2'
'set clab %.0f`3.`1C'
'd coll2gr(2,-u)'
'set gxout barb'
'set ccolor 1' ; 'set cthick 1' ; 'set digsiz 0.05'
'd skip((1.94*coll2gr(3)),10,1);(1.94*coll2gr(4))'

'xcbar 10.1 10.3 0.7 7.74 -fs 10'

say 'drawing terrain'

x1=subwrd(terrain_arr,1)
y1=subwrd(terrain_arr,2)
terrain_arr=terrain_arr''subwrd(xs,2)' 'subwrd(ys,1)' 'subwrd(xs,1)' 'subwrd(ys,1)' 'x1' 'y1

'set line 15 1 1'
'draw polyf 'terrain_arr

'draw title Cross section: 17.77S/149.70W - 17.43S/149.30W'

'query time'
res = subwrd(result,3) ; res1 = subwrd(result,6) ; fcsthr = substr(res,1,3) ; fcsttime = substr(res,4,13) ; fcstday = substr(res1,1,3)
drawings(domnumber,init,step,fcsthr,fcstday,fcsttime,dateday,datemonth,dateyear)

'printim tmp.png x1200 y900'
This produces something like:
Image

Hope it helps.

nebojsa
Posts: 133
Joined: Sun Mar 21, 2010 3:40 pm

Re: GRADS - meteogram with spatial vertical section

Post by nebojsa » Thu Sep 22, 2016 9:17 pm

Thanks a lot!
That should bi it! Mostly. I will try to add other temperatures.

I'll post some results when I make them.

BR!

Nebojsa

nebojsa
Posts: 133
Joined: Sun Mar 21, 2010 3:40 pm

Re: GRADS - meteogram with spatial vertical section

Post by nebojsa » Mon Sep 26, 2016 4:47 pm

Hi meteoadriatic!

I've tried to make some spatial meteograms but several problems occured:
a) there must be some rule for the latitude and longitude cause just some combinations I've tried gave some results. What should be "fixed" latitude or longitude?
b) can't get terrain
c) colors are not as specified in the script (white -> green -> blue) but "rainbow" spectrum.

Any suggestions?

Best regards!

meteoadriatic
Posts: 1510
Joined: Wed Aug 19, 2009 10:05 am

Re: GRADS - meteogram with spatial vertical section

Post by meteoadriatic » Mon Sep 26, 2016 7:57 pm

You need to get this script for colors:

http://kodama.fubuki.info/wiki/wiki.cgi ... gs?lang=en

But, also you need to copy/paste output from GrADS.. any errors or something, beucase without that I don't know what went wrong (except colors, that was easy to guess).

nebojsa
Posts: 133
Joined: Sun Mar 21, 2010 3:40 pm

Re: GRADS - meteogram with spatial vertical section

Post by nebojsa » Tue Sep 27, 2016 6:00 am

Thanks!
I'll check this script for colors and post errors next time.

Best regrds!!

nebojsa
Posts: 133
Joined: Sun Mar 21, 2010 3:40 pm

Re: GRADS - meteogram with spatial vertical section

Post by nebojsa » Fri Sep 30, 2016 10:48 am

Hi meteoadriatic,

Here's the "output" of the script:

Code: Select all

ga-> run spatial_meteogram.gs
collecting station data
plotting data
Unknown command: color
Unknown command: xcbar
drawing terrain
Function not found: drawings        
  Error occurred on line 114
  In file spatial_meteogram.gs
ga->
I've noticed that sometime the same script with the same gribs doesn't wanna to work at all and sometimes it works and breaks on this line.
Crazy.

meteoadriatic
Posts: 1510
Joined: Wed Aug 19, 2009 10:05 am

Re: GRADS - meteogram with spatial vertical section

Post by meteoadriatic » Fri Sep 30, 2016 1:34 pm

First things first. Download these two:
https://github.com/kodamail/gscript/blo ... r/color.gs
https://github.com/kodamail/gscript/blo ... r/xcbar.gs

Put both files inside grads scripts folder. That will fix first two errors. I forgot to add drawings function that does informational printing on maps, that is function called by that line:
drawings(domnumber,init,step,fcsthr,fcstday,fcsttime,dateday,datemonth,dateyear)

And here it is for this example:

Code: Select all

function drawings(domnumber,init,step,fcsthr,fcstday,fcsttime,dateday,datemonth,dateyear)
'set string 1 bl 3 0' ; 'set strsiz 0.11'
'draw string 0.5 0.12 meteoforce.fr WRF'
'set string 1 bl 3 0' ; 'set strsiz 0.12'
'draw string 10.3 0.45 RH(%)'
'set string 1 tl 1' ; 'set strsiz 0.10'
'draw string 0.55 7.8 init: 'init'z, 'dateday'.'datemonth'.'dateyear
'set string 1 tl 1' ; 'set strsiz 0.13'
'draw string 0.55 7.6 valid: 'fcsthr', 'fcstday', 'fcsttime
'set font 2'
'set string 1 bl 3 0' ; 'set strsiz 0.11'
'draw string 4.7 0.68 Tahiti'
return
But for it to work you must pass to it all of it's variables, that I read from outside shell.. so basically, to get it working without that informational text, that you can do in your own way I guess, the best will be to remove that line for now (this line: drawings(domnumber,init,step,fcsthr,fcstday,fcsttime,dateday,datemonth,dateyear) )

When you do those three things:
1) download two scripts
2) put them into grads scripts directory
3) remove drawings line

Try again and if you have new errors again then post them, and also post your current script.

nebojsa
Posts: 133
Joined: Sun Mar 21, 2010 3:40 pm

Re: GRADS - meteogram with spatial vertical section

Post by nebojsa » Fri Sep 30, 2016 5:30 pm

Thanks!

I'll try and inform you about results.

nebojsa
Posts: 133
Joined: Sun Mar 21, 2010 3:40 pm

Re: GRADS - meteogram with spatial vertical section

Post by nebojsa » Sat Oct 01, 2016 6:07 am

Hi meteoadriatic,

I did as you said: download those two scripts colors.gs and xbar.gs and create file with your script/function drawings, put them in one folder but I still got this:

Code: Select all

ga-> run spatial_meteogram.gs
collecting station data
plotting data
Unknown command: color
drawing terrain
Function not found: drawings        
  Error occurred on line 114
  In file spatial_meteogram.gs
ga->
Should there be some extra line in the main script where it calls those external scripts?

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest