[gradsusr] Create boolean map applying threshold
Clark, Douglas B.
dbcl at ceh.ac.uk
Fri Jun 24 08:00:22 EDT 2011
Chris,
You need to define a variable along the lines of
define newvar=const(const(maskout(var,var-2),1),0,-u)
where var is the existing variable that you want to apply the threshold to.
This is a rather complex expression, so you might want to build it up in parts (e.g. 3 lines), starting with the inner maskout so you can work out what's going on. See the GrADS documentation for the maskout and const functions.
In fact I think this will set newvar to 1 where var>=2 (i.e. >= rather than > ), so if you really want to exclude values that are "exactly" (meaning "close to"!) 2 you could use something like "var-2.00001".
In any case, check that you get the answer you want/expect!
(Your example didn't work because you were manipulating scalar variables in the GrADS scripting language, not gridded variables.)
Doug
From: gradsusr-bounces at gradsusr.org [mailto:gradsusr-bounces at gradsusr.org] On Behalf Of a.arvensis at gmail.com
Sent: 24 June 2011 11:28
To: gradsusr at gradsusr.org
Subject: [gradsusr] Create boolean map applying threshold
Dear Grads users,
I have a grid with varying values (t). From this grid I want to create a boolean grid where a value of (1) is assigned to all grid cells above a certain threshold (2) and the value of (0) is assigned to all other values. This would be something like:
if (t > 2); t = 1; else t = 0; endif
The line above does not work and my feeling is that such conditional statements cannot be applied to grid cells, but are rather meant to control the flow of your script. What approach is appropriate? Thank you very much in advance!
With kind regards,
Chris
--
This message (and any attachments) is for the recipient only. NERC
is subject to the Freedom of Information Act 2000 and the contents
of this email and any reply you make may be disclosed by NERC unless
it is exempt from release under the Act. Any material supplied to
NERC may be stored in an electronic records management system.
More information about the gradsusr
mailing list