[gradsusr] rainfall rate script
Ben Stephens
benstephens at utexas.edu
Tue Jan 19 19:34:03 EST 2016
Thanks Chuck! I will give this a try.
Ben
> On Jan 19, 2016, at 6:02 PM, Charles Seman - NOAA Federal <charles.seman at noaa.gov> wrote:
>
> Ben,
>
> Think for the fwrite loop below, set i=1 to start... I should have
> looked at it more carefully...
>
> Chuck
>
>> On 01/19/2016 06:58 PM, Charles Seman - NOAA Federal wrote:
>> Ben,
>>
>> We have calculated WRF precip rates from variable RAINNC.
>>
>> You can try using code like (caution, has not been tested):
>>
>> * Calculate the WRF precipitation rates from accumulated precip...
>> * convert WRF model accumulated precipitation from [mm] to [mm/day]
>> *
>> * note, we can only go to "nt-1" because we do forward-in-time finite
>> * differences for the WRF model precipitation rate...
>>
>> nt = 6578 ;* or the # of time levels in your time series
>> dt = 0.5 ;* 12 hours or 0.5 day
>> 'set x 1'
>> 'set y 1'
>> 'set z 1'
>> 'set t 1 'nt-1
>> 'define pratec = (RAINC(t+1)-RAINC(t+0))/'dt
>> 'define pratenc = (RAINNC(t+1)-RAINNC(t+0))/'dt
>>
>> then you can use pratec and pratenc (or whatever you call them)...
>>
>> you can plot the variables directly; try something like:
>>
>> legends = 'RAINC RAINNC'
>> colors = ' 2 3'
>> marks = ' 0 0'
>>
>> while ( nv <= 2 )
>> c.nv = subwrd(colors,nv)
>> m.nv = subwrd(marks,nv)
>> l.nv = subwrd(legends,nv)
>> nv = nv + 1
>> endwhile
>>
>> pmin = 1e6 ; pmax = -1e6
>>
>> 'set t 1 'nt-1
>> 'set gxout stat'
>> 'd pratec'
>> min_max = sublin(result,8)
>> minv = subwrd(min_max,4)
>> maxv = subwrd(min_max,5)
>> if( minv < pmin )
>> pmin = minv
>> endif
>> if( maxv > pmax )
>> pmax = maxv
>> endif
>> 'd pratenc'
>> min_max = sublin(result,8)
>> minv = subwrd(min_max,4)
>> maxv = subwrd(min_max,5)
>> if( minv < pmin )
>> pmin = minv
>> endif
>> if( maxv > pmax )
>> pmax = maxv
>> endif
>>
>> 'set gxout line'
>> 'set grads off'
>>
>> 'set vrange 'pmin' 'pmax
>>
>> 'set ccolor 'c.1
>> 'set cmark 'm.1
>> 'd pratec'
>>
>> 'set ccolor 'c.2
>> 'set cmark 'm.2
>> 'd pratenc'
>>
>> 'cbar_line -x 3 -y 6 -c 'c.1' 'c.2' -l 1 1 -m "'m.1'" "'m.2'" -t "'l.1'"
>> "'l.2'" -p'
>>
>> note, the above code hasn't been tested, but it should give you some
>> ideas of how to plot the variables... cbar_line can be found at
>> http://cola.gmu.edu/grads/gadoc/library.html
>>
>> if you still want to write out a binary file, try adapting your code:
>>
>> 'set fwrite scm9yr12hr.daily.grads'
>> 'set gxout fwrite'
>> i=2
>> while(i<nt)
>> 'set t 'i
>> 'd pratec'
>> 'd pratenc'
>> i=i+1
>> endwhile
>> 'disable fwrite’
>>
>> see also http://cola.gmu.edu/grads/gadoc/aboutgriddeddata.html
>>
>> Hope this helps,
>> Chuck
>>
>>
>>> On 01/16/2016 12:15 AM, Ben Stephens wrote:
>>> Hi, I am writing a script that will take existing total accumulated
>>> rainfall data (units of mm) and output daily rainfall rates (mm/day) for
>>> both rainc and rainnc. This is the single-column WRF model output so
>>> there is only one grid point with 20 levels and 12-hour time increment.
>>> Here is the script I have so far:
>>>
>>> 'open scm9yr12hr.ctl'
>>> 'set fwrite scm9yr12hr.daily.grads'
>>> 'set gxout fwrite'
>>> i=2
>>> while(i<6578)
>>> 'set t 'i
>>> 'd rainc(t+2)-rainc'
>>> 'd rainnc(t+2)-rainc'
>>> i=i+2
>>> endwhile
>>> 'disable fwrite’
>>>
>>> I am basically wondering what to do after running the script. I open
>>> GrADS and execute the script with a run command, and it generates the
>>> given output file, but I have not been able to display the data,
>>> assuming it is working correctly. I tried to create a new control file
>>> for the output, and it opens, and the data seem to be there but they are
>>> clearly wrong. I am getting numbers with huge exponents and so on. Any
>>> input on whether my script is written correctly or how to display my
>>> output?
>>>
>>> Thanks!
>>> Ben
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> gradsusr mailing list
>>> gradsusr at gradsusr.org
>>> http://gradsusr.org/mailman/listinfo/gradsusr
>
> --
>
> Please note that Charles.Seman at noaa.gov should be considered my NOAA
> email address, not cjs at gfdl.noaa.gov.
>
> ********************************************************************
> Charles Seman Charles.Seman at noaa.gov
> U.S. Department of Commerce / NOAA / OAR
> Geophysical Fluid Dynamics Laboratory voice: (609) 452-6547
> 201 Forrestal Road fax: (609) 987-5063
> Princeton, NJ 08540-6649 http://www.gfdl.noaa.gov/~cjs/
> ********************************************************************
>
> "The contents of this message are mine personally and do not reflect any
> official or unofficial position of the United States Federal Government,
> the United States Department of Commerce, or NOAA."
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
More information about the gradsusr
mailing list