****************************************************************************** * File name: test_data_values.gs * A grads script to check whether data in a file is having values within a * desirable range. This script can be used to identify portions of a gridded * data where data values are suspicious. This script uses following two grads * functions (1) amax() http://www.iges.org/grads/gadoc/gradfuncamax.html * (2) amin() http://www.iges.org/grads/gadoc/gadocindex.html * Both of the above functions works only in GrADS versions 2.0.2 or later *TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT * Author : Martin V. Mathew, vmartinmathew@gmail.com * Date : 20 April 2013 *LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL 'reinit' 'set display color white' 'c' ****************************************************************************** * 1) Open the ddf & specify no. of figures. ****************************************************************************** infile1='open /users/martin/work/research/levitus/levitus_quarter/prgs/my_prgms/grads/ddf/monthly/DDF.WOA0.25GLB_MONALL_T_LEVALL' *============================================================================== * 2) Defining lat, lon, lev cordinates of the required domain. Values of space * coordinates will remain the same (given by following variables) throughout * the execution of program *============================================================================== latMin=-5.0 latMax= 5.0 lonMin=42.0 lonMax=100.0 levMin=0.0 *levMax=0.0 Only one level is read at a time *============================================================================== * 3) Defining time cordinates of the required domain. Time dimention will loop * through tMin and tMax. *============================================================================== tMin=1 tMax=12 *============================================================================== * 4) specifing the variable in the given to be tested. Curently only one variable * is tested at a time. In future this program can be modified to test more * than one variable at a time, if required. *============================================================================== TstVar.1='temp' *============================================================================== * 5) Defining expected minimum & maximum values of the above variable. This * program will check whether the value of above variable exceed a specified * limit in the area specified by lat, lon and level cordinates specified * earlier. In event any descripencies are found, ther relevent detils are * displayed in terminal as well as a figure is plotted highlighting the * area where data exceeds the required limit. The varibles ExpMin.1 and * ExpMax.1 specifies the expected minimum & maximum values. *============================================================================== ExpMin.1= 27.0 ExpMax.1= 30.0 *============================================================================== * 6) Testing the data *============================================================================== * opening input file infile1 'set lev 'levMin currTime=tMin while(currTime<=tMax) 'set t 'currTime 'define minVal= amin('TstVar.1', lon='lonMin', lon='lonMax', lat='latMin', lat='latMax')' 'define maxVal= amax('TstVar.1', lon='lonMin', lon='lonMax', lat='latMin', lat='latMax')' 'd minVal'; MinVal1=subwrd(result,4); 'd maxVal'; MaxVal1=subwrd(result,4); flg=0 if MinVal1ExpMax.1 say 'Time = 'currTime' || Data value is higher than desirable limit :'ExpMax.1 ' Highest value is :'MaxVal1 flg=1 endif ;* if MaxVal1>ExpMin.1 * Plotting the data if it exceeds the desirable limit if flg=1 'c' 'set lon 'lonMin' 'lonMax 'set lat 'latMin' 'latMax 'set lev 'levMin' 'levMin 'set gxout shaded' 'set clevs 'ExpMin.1' 'ExpMax.1 'set ccols 4 0 2' 'd 'TstVar.1 'run /users/martin/work/supporting_files/grads/cbarn.gs' TitleTxt='Time= 'currTime': Variable 'TstVar.1' exceding limits 'ExpMin.1' & 'ExpMax.1 'draw title 'TitleTxt say 'Should the limits 'ExpMin.1' & 'ExpMax.1' are to be modified. If so run this' say 'program after modifying the limits ' prompt 'Enter 0 for stop executing or 1 to continue executing the script : ' pull swich say '------------------------------------------------------------------------------' endif ;* if flg=1 * Incrementing time if swich=0 currTime=tMax+1 say '&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&' say 'Stoping program execution based on user input. ' say '&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&' else ;*if swich=0 currTime=currTime+1 endif ;*if swich=0 endwhile;*while(currTime<=tMax) if swich=1 say '&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&' say 'The data is tested for specified range of time. Stoping program execution.' say '&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&' endif ;*if swich=1