/usr/share/doc/grads/html/gradfuncconst.html is in grads 2:2.0.2-8build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | <!--Copyright (C) 1988-2005 by the Institute of Global Environment and Society (IGES). See file COPYRIGHT for more information.-->
<html>
<title>GrADS Function: const</title>
<body bgcolor="e0f0ff" text="#000000">
<h2><b>const()</b></h2> <p>
<p>
<code>const (<i>expr, value,</i> <-u|-a>)</code>
<p>
This is a powerful function that allows the user to change the missing
values of a variable, set all the non-missing values of a variable to
a constant, or set all possible values of a variable (both valid and
missing) to a constant.
<p>
<ul>
<code><i>expr</i> </code>a valid GrADS expression <br>
<code><i>value</i> </code>a constant, either an integer or floating point value <br>
<code>-u </code>all missing data are set to
<code><i>value</i></code>; non-missing data are unchanged<br>
<code>-a </code>all data are set to
<code><i>value</i></code>, both missing and non-missing<br>
</ul>
<p>
Default behaviour is to set all non-missing data equal to
<code><i>value</i></code>; missing data are unchanged <br>
</ul>
<p>
<h3>Usage Notes</h3>
<ol>
<li>The <code>const</code> function operates on both gridded and
station data.
<li>If <code><i>value</i></code> is given as an integer,
it will still be treated as as floating point.
</ol>
<p>
<h3>Examples</h3><p>
<ol>
<li>The <code>const</code> function assigns a new value to missing
data, so that missing data may participate in operations:
<p>
<ul><code>const(z, 0, -u)</code></ul>
<p>
<li>The <code>const</code> function is used with the <a
href="gradcomdsetgxout.html"<code>set gxout linefill</code></a> graphics output
option to define a straight horizontal line:
<p>
<ul>
<code>
set lon -90 <br>
set lat -90 90 <br>
set gxout linefill <br>
set lev 500 <br>
d const(t, -20);t-273 <br>
</code>
</ul>
<p>
<li>In this example, <code>const</code> is used to calculate a daily
timeseries of the fraction of the globe convered by precipitation
greater than <code>10mm/day</code>:
<p>
<ul>
<code>
set lon 0 360 <br>
set lat -90 90 <br>
set t 1 last <br>
define ones = const(const(maskout(p,p-10),1),0,-u) <br>
set x 1 <br>
set y 1 <br>
display tloop(aave(ones,lon=0,lon=360,lat=0,lat=360)) <br>
</code>
</ul>
<p>
Notes: The <a href="gradcomddefine.html">defined</a> variable
<code>"ones"</code> contains <code>1</code> wherever the precip value
is greater than <code>10</code>, and <code>0</code> whever the precip
value is less than <code>10</code>. This is done via nested functions;
first <a href="gradfuncmaskout.html"><code>maskout</code></a> sets all
values less than <code>10</code> to missing, then <code>const</code>
sets all non-missing values to <code>1</code>, then <code>const</code>
is used with the <code>-u</code> flag to set all the missing data
values to <code>0</code>. The <a
href="gradfuncaave.html"><code>aave</code></a> function calculates an
area weighted average. Since we are averaging zeros and ones, the
result is the fraction of the area where there are ones. See the <a
href="gradfunctloop.html"><code>tloop</code></a> function for a
description of how to perform time series of areal averages.
</ol>
</body>
</html>
|