say '*****************************************' say 'Interactive Grads Script by Gibies George' say ' For spatial distribution of climatology ' say '*****************************************' *var = rf Prompt 'Enter the parameter for analysis: ' pull parameter Prompt 'Enter the variable name representing the parameter: ' pull var Prompt 'Enter the name of new folder to save the output files: ' pull fld '!mkdir ../'fld Prompt 'Enter the starting year: ' pull y1 Prompt 'Enter the ending year: ' pull yn mons='jan feb mar apr may jun jul aug sep oct nov dec' prompt 'Enter the season starting month as number: ' pull m1 mmm1=subwrd(mons,m1) prompt 'Enter the season ending month as number: ' pull mn mmmn=subwrd(mons,mn) prompt 'Enter the season starting day of month 'mmm1': ' pull d1 prompt 'Enter the season ending day of month 'mmmn': ' pull dn Prompt 'Enter the season name: ' pull season prompt 'Enter lat of Southern boundary : ' pull lats prompt 'Enter lat of Northern boundary : ' pull latn prompt 'Enter lon of Western Boundary : ' pull lonw prompt 'Enter lon of Eastern Boundary : ' pull lone 'reinit' 'open ../data/'var'.ctl' 'set lon 'lonw' 'lone'' 'set lat 'lats' 'latn'' ************************************************' say ' Climarology calculation' yyyy=y1 'set t 1' 'define sm=0' while (yyyy<=yn) 'define ssnvar=ave('var',time='d1''mmm1''yyyy',time='dn''mmmn''yyyy' )' 'define sm=sm+ssnvar' 'undefine ssnvar' yyyy=yyyy+1 endwhile num=(1+yn-y1) 'define climr=sm/'num'' 'undefine sm' * say ' Climarology calculation ended' ************************************************ 'clear' 'set grads off' 'set vpage 0 8 0 11' 'set parea 0 8 4 10.5' 'set gxout contour' 'd climr' 'set gxout shaded' 'd climr' 'cbarn' 'draw title Climatology 'parameter' of 'season ********************************************************** say 'Defining the box for area average time series index' * following interactive "box location" code adapted from "cbar_line_box.gs"... * say 'Click where you want the left upper corner of the box' 'query bpos' xb1o = subwrd(result,3) yb2o = subwrd(result,4) say '...left upper corner of the box at X Y: 'xb1o' 'yb2o say 'Click where you want the right lower corner of the box' 'query bpos' xb2o = subwrd(result,3) yb1o = subwrd(result,4) say say'...right lower corner of the box at X Y: 'xb2o' 'yb1o * * draw box to show specified area * 'set line 1 1' 'draw rec 'xb1o' 'yb1o' 'xb2o' 'yb2o * * convert box "xy" coordinates to "grid" coordinates * 'q xy2gr 'xb1o' 'yb2o'define ssnvar=ave(rf,time='d1''mmm1''yyyy',time='dn''mmmn''yyyy' )' x1o = subwrd(result,3) ; x1 =lonw + math_int(x1o+0.5) y2o = subwrd(result,6) ; y2 =lats + math_int(y2o+0.5) 'q xy2gr 'xb2o' 'yb1o x2o = subwrd(result,3) ; x2 =lonw + math_int(x2o+0.5) y1o = subwrd(result,6) ; y1 =lats + math_int(y1o+0.5) say 'The defined box is' say ' (x1o,x2o) = ('x1o','x2o') --> (x1,x2) = ('x1','x2')' say ' (y1o,y2o) = ('y1o','y2o') --> (y1,y2) = ('y1','y2')' *********************************************************** 'undefine climr' 'set t 1 last' 'define ts=aave('var',lon='x1',lon='x2',lat='y1',lat='y2')' say 'Seasonal Mean Calculation ' 'define ssn=ave(ts,time='d1''mmm1',time='dn''mmmn')' 'set vpage 0 8 0 11' 'set parea 0.5 8 .5 3' 'set mproj scaled' 'set lon 'x1 'set lat 'y1 'set gxout bar' 'd ssn' 'draw title Seasonal Mean Time Series Index of 'var 'printim ../'fld'/index.pdf white' say '************************************************' say ' Finished with the script' say '************************************************' say return function clim(var, y1, yn, mmm1, mmmn, d1, dn) yyyy=y1 'set t 1' 'define sm=0' while (yyyy<=yn) 'define ssnvar=ave(var,time='d1''mmm1''yyyy',time='dn''mmmn''yyyy' )' 'define sm=sm+ssnvar' 'undefine ssnvar' yyyy=yyyy+1 endwhile num=(1+yn-y1) 'define climvar=sm/'num'' 'undefine sm' return climvar