<div>Thank you very much Doug! Works perfectly. You made my day!</div><div> </div><div>Cheers,</div><div>Chris<br></div><div class="gmail_quote">On Fri, Jun 24, 2011 at 2:00 PM, Clark, Douglas B. <span dir="ltr">&lt;<a href="mailto:dbcl@ceh.ac.uk">dbcl@ceh.ac.uk</a>&gt;</span> wrote:<br>
<blockquote style="margin: 0px 0px 0px 0.8ex; padding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1px; border-left-style: solid;" class="gmail_quote">Chris,<br>
<br>
You need to define a variable along the lines of<br>
<br>
define newvar=const(const(maskout(var,var-2),1),0,-u)<br>
<br>
where var is the existing variable that you want to apply the threshold to.<br>
<br>
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&#39;s going on. See the GrADS documentation for the maskout and const functions.<br>

<br>
In fact I think this will set newvar to 1 where var&gt;=2 (i.e. &gt;= rather than &gt; ), so if you really want to exclude values that are &quot;exactly&quot; (meaning &quot;close to&quot;!) 2 you could use something like &quot;var-2.00001&quot;.<br>

<br>
In any case, check that you get the answer you want/expect!<br>
<br>
(Your example didn&#39;t work because you were manipulating scalar variables in the GrADS scripting language, not gridded variables.)<br>
<br>
Doug<br>
<br>
<br>
<br>
From: <a href="mailto:gradsusr-bounces@gradsusr.org">gradsusr-bounces@gradsusr.org</a> [mailto:<a href="mailto:gradsusr-bounces@gradsusr.org">gradsusr-bounces@gradsusr.org</a>] On Behalf Of <a href="mailto:a.arvensis@gmail.com">a.arvensis@gmail.com</a><br>

Sent: 24 June 2011 11:28<br>
To: <a href="mailto:gradsusr@gradsusr.org">gradsusr@gradsusr.org</a><br>
Subject: [gradsusr] Create boolean map applying threshold<br>
<div><div></div><div class="h5"><br>
Dear Grads users,<br>
<br>
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:<br>

<br>
if (t &gt; 2); t = 1; else t = 0; endif<br>
<br>
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!<br>

<br>
With kind regards,<br>
Chris<br>
</div></div>--<br>
This message (and any attachments) is for the recipient only. NERC<br>
is subject to the Freedom of Information Act 2000 and the contents<br>
of this email and any reply you make may be disclosed by NERC unless<br>
it is exempt from release under the Act. Any material supplied to<br>
NERC may be stored in an electronic records management system.<br>
_______________________________________________<br>
gradsusr mailing list<br>
<a href="mailto:gradsusr@gradsusr.org">gradsusr@gradsusr.org</a><br>
<a href="http://gradsusr.org/mailman/listinfo/gradsusr" target="_blank">http://gradsusr.org/mailman/listinfo/gradsusr</a><br>
</blockquote></div><br>