Replacing values by GrADS expression

Becker, Bernd bernd.becker at METOFFICE.GOV.UK
Mon Feb 7 12:12:26 EST 2005


You may try to work with maskout and const
define the global field and multiply with a mask
of 0 and 1 where the condition holds tru and leave the rest untouched.


* define new variable ?pdf, same dimensions as var, set all values to
0/1.
'define apdf=const('var',0,-a)'
'define bpdf=const('var',0,-a)'
while ( quint < 5 )

         quint=quint+1

*        the observed quint.  (maskout the observed quint, set values to
0,1 respectively)
*        say 'the observed quint:
obs=const(const(maskout(maskout('var'(x=19),'quint'-'var'(x=19)),'var'(x=19)-'quint'),1),0,-u)'

*       'maskout('var'(x=19),'quint'-'var'(x=19)'       blend out quint
< obs quint
*       'maskout(.......,'var'(x=19)-'quint'),1),0,-u)' blend out quint
> obs quint
*       'const(.................,1)'  set to constant "1" where
condition holds true
*       'const(..............,0,-u)'  set to constant "0" where
condition holds not true (undefined)

        'define obs'quint'
=const(const(maskout(maskout('var'(x=19),'quint'-'var'(x=19)),'var'(x=19)-'quint'),1),0,-u)'

*        the forecast quint.  (maskout the forecast quint, set values to
0,1 respectively)
*        say 'the forecast quint:
obs=const(const(maskout(maskout('var'(x=19),'quint'-'var'(x=19)),'var'(x=19)-'quint'),1),0,-u)'

*       'maskout('var'(x=19),'quint'-'var'(x=19)'       blend out quint
< obs quint
*       'maskout(.......,'var'(x=19)-'quint'),1),0,-u)' blend out quint
> obs quint
*       'const(.................,1)'  set to constant "1" where
condition holds true
*       'const(..............,0,-u)'  set to constant "0" where
condition holds not true (undefined)

        'define fx'quint'
=const(const(maskout(maskout('var'(x=17),'quint'-'var'(x=17)),'var'(x=17)-'quint'),1),0,-u)'

*        accumulated observation probability
        'define bpdf=bpdf + obs'quint
        'define bpdf'quint'=bpdf'

*        end loop  over quints
endwhile


On Mon, 2005-02-07 at 17:01, Rainer Behrendt wrote:
> Dear GrADS Users,
>
> what I want to do is to replace one GrADS
> expression by an other if a defined condition is valid.
>
> A stupid example:
> If one tried to displace in a lat/lon dimension evironment temperature
> by relative humidity wherever temperature is lower than
> 10 degree Celsius.
>
> By the maskout function the relevant temperature values
> could be set to missing data. Then the missing values could be fitted
> by the const function. Unfortunately no GrADS expression can be used as
> substitude.
>
> I already thought about using set defval within a
> loop over all grid points. But I think, there must be a
> smarter and faster solution.
>
> Has anyone an idea?
>
> Regards,
>
> Rainer Behrendt
>
> Institut fuer
> Meteorologie und Klimaforschung (IMK)
> Universitaet Karlsruhe (TH)/
> Forschungszentrum Karlsruhe (FZK)
--
Bernd Becker   The Monthly Outlook
Met Office  FitzRoy Road  Exeter   Devon EX1 3PB  United Kingdom
Tel.: +44 (0) 1392 884511 Fax: +44 (0)870 900 5050
E-mail:bernd.becker at metoffice.gov.uk -  http://www.metoffice.gov.uk



More information about the gradsusr mailing list