This file is indexed.

/usr/share/doc/pyxplot/html/sec-units.html is in pyxplot-doc 0.9.2-4.

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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta name="generator" content="plasTeX" />
<meta content="text/html; charset=utf-8" http-equiv="content-type" />
<title>PyXPlot Users' Guide: Working with physical units</title>

<link href="sec-angles.html" title="Treatment of angles in Pyxplot" rel="next" />
<link href="sec-complex_numbers.html" title="Working with complex numbers" rel="prev" />
<link href="sect0022.html" title="Performing calculations" rel="up" />
<link rel="stylesheet" href="styles/styles.css" />
</head>
<body>

<div class="navigation">
<table cellspacing="2" cellpadding="0" width="100%">
<tr>
<td><a href="sec-complex_numbers.html" title="Working with complex numbers"><img alt="Previous: Working with complex numbers" border="0" src="icons/previous.gif" width="32" height="32" /></a></td>

<td><a href="sect0022.html" title="Performing calculations"><img alt="Up: Performing calculations" border="0" src="icons/up.gif" width="32" height="32" /></a></td>

<td><a href="sec-angles.html" title="Treatment of angles in Pyxplot"><img alt="Next: Treatment of angles in Pyxplot" border="0" src="icons/next.gif" width="32" height="32" /></a></td>

<td class="navtitle" align="center">PyXPlot Users' Guide</td>
<td><a href="index.html" title="Table of Contents"><img border="0" alt="" src="icons/contents.gif" width="32" height="32" /></a></td>

<td><a href="sect0288.html" title="Index"><img border="0" alt="" src="icons/index.gif" width="32" height="32" /></a></td>

<td><img border="0" alt="" src="icons/blank.gif" width="32" height="32" /></td>
</tr>
</table>
</div>

<div class="breadcrumbs">
<span>
<span>
<a href="index.html">PyXPlot Users' Guide</a> <b>:</b>
</span>

</span><span>
<span>
<a href="sect0001.html">Introduction to PyXPlot</a> <b>:</b>
</span>

</span><span>
<span>
<a href="sect0022.html">Performing calculations</a> <b>:</b>
</span>

</span><span>

<span>
<b class="current">Working with physical units</b>
</span>
</span>
<hr />
</div>

<div><h1 id="sec:units">4.6 Working with physical units</h1>
<p>  <a name="a0000000461" id="a0000000461"></a><a name="a0000000462" id="a0000000462"></a> </p><p>Pyxplot, and all its mathematical functions, have native support for numbers to have physical units. This means, for example, that multiplying two lengths yields an area, and taking passing a selection of lengths to the <tt class="tt">max(...)</tt> function returns the longest of the lengths supplied. </p><p>This makes it a powerful desktop tool for converting measurements between different systems of units – for example, between imperial and metric units – or for doing physical calculations. </p><p>The special function <tt class="tt">unit()</tt><a name="a0000000463" id="a0000000463"></a> is used to specify the physical unit associated with a quantity. For example, the expression </p><pre>
print 2*unit(s)
</pre><p>takes the number 2 and multiplies it by the unit <tt class="tt">s</tt>, which is the SI abbreviation for seconds. Technically, the function <tt class="tt">unit(s)</tt> returns a numeric object equal to one second. </p><p>The resulting quantity above, which has dimensions of time, could then, for example, be divided by the unit <tt class="tt">hr</tt> to find the dimensionless number of hours in two seconds: </p><pre>
print 2*unit(s)/unit(hr)
</pre><p>Compound units such as miles per hour, which is defined in terms of two other units, can be used as in </p><pre>
print 2*unit(miles/hour)
</pre><p>In many cases, commonly-used units such units have their own explicit abbreviations, in this case <tt class="tt">mph</tt>: </p><pre>
print 2*unit(mph)
</pre><p>As these examples demonstrate, the <tt class="tt">unit()</tt> function can be passed a string of units either multiplied together with the <tt class="tt">*</tt> operator, or divided using the <tt class="tt">/</tt> operator. Units may be raised to powers with the <tt class="tt">**</tt> operator<a href="#a0000000464" class="footnote"><sup class="footnotemark">1</sup></a>, as in the example: </p><p> <tt class="ttfamily">pyxplot&gt; <b class="bfseries">a = 2*unit(m**2)</b></tt><br /><tt class="ttfamily">pyxplot&gt; <b class="bfseries">print "An area of %f square feet"%(a/unit(ft**2))</b></tt><br /><tt class="ttfamily">An area of 21.527821 square feet</tt>   </p><p>As the examples above have demonstrated, units may be referred to by either their abbreviated or full names, and each of these may be used in either their singular or plural forms. For example, <tt class="tt">s</tt>, <tt class="tt">second</tt>, and <tt class="tt">seconds</tt> are all valid and equivalent. A complete list of all of the units which Pyxplot recognises by default, together with all of their recognised names, can be found in Appendix <a href="ch-unit_list.html">4</a>. </p><p>SI units may be preceded with SI prefixes<a name="a0000000465" id="a0000000465"></a>, as in the examples<a href="#a0000000466" class="footnote"><sup class="footnotemark">2</sup></a>: </p><pre>
a = 2*unit(um)
a = 2*unit(micrometers)
</pre><p>When quantities with physical units are substituted into algebraic expressions, Pyxplot automatically checks that the expression is dimensionally correct before evaluating it. For example, the following expression is not dimensionally correct and would return an error because the first term in the sum has dimensions of velocity, whereas the second term is a length: <a name="a0000000467" id="a0000000467"></a> </p><p><table cellspacing="0" class="tabular">
<tr>

    
    <td style="text-align:left"><p><img src="images/img-0039.png" alt="\includegraphics{cross}" style="width:20px; height:24px" />
</p></td>

    
    <td style="text-align:left"><p><div style="width:0.0pt" class="minipage"><tt class="tt"> a = 2*unit(m)<br />b = 4*unit(s)<br />print a/b + a </tt></div></p></td>

</tr>
</table> </p><p>Pyxplot continues to throw an error in this case, even when explicit numerical errors are turned off with the <tt class="tt">set numeric errors quiet</tt> command<a name="a0000000468" id="a0000000468"></a>, since it is deemed a serious error: the above expression would never be correct for any values of <tt class="tt">a</tt> and <tt class="tt">b</tt> given their dimensions. </p><p>A large number of units are pre-defined in Pyxplot by default, a complete list of which can be found in Appendix <a href="ch-unit_list.html">4</a>. However, the need may occasionally arise to define new units. It is not possible to do this from an interactive Pyxplot terminal, but it is possible to do so from a configuration script which Pyxplot runs upon start-up. Such configuration scripts will be discussed in Chapter <a href="ch-configuration.html">7</a>. New units may either be derived from existing SI units, alternative measures of existing quantities, or entirely new base units such as numbers of CPU cycles or man-hours of labour. </p></div>

<div class="contents section-contents"><!--<strong>Subsections</strong>-->
<ul>
<li><a href="sec-angles.html">4.6.1 Treatment of angles in Pyxplot</a>
   
</li><li><a href="sect0024.html">4.6.2 Converting between different temperature scales</a>
   
</li>



</ul>
</div>

<div id="footnotes">
<p><b>Footnotes</b></p>
<ol>
<li id="a0000000464">The <tt class="tt"><img src="images/img-0037.png" alt="\^{}" style="vertical-align:9px; width:5px; height:4px" class="accent gen" /></tt> character may be used as an alias for the <tt class="tt">**</tt> operator, though this notation is arguably confusing, since the same character is used for the binary exclusive or operator in Pyxplot’s normal arithmetic.</li><li id="a0000000466">As the first of these examples demonstrates, the letter <tt class="tt">u</tt> is used as a Roman-alphabet substitute for the Greek letter <img src="images/img-0130.png" alt="$\upmu $" style="vertical-align:-4px; 
                                     width:11px; 
                                     height:13px" class="math gen" />.</li>
</ol>
</div>

<div class="navigation">
<table cellspacing="2" cellpadding="0" width="100%">
<tr>
<td><a href="sec-complex_numbers.html" title="Working with complex numbers"><img alt="Previous: Working with complex numbers" border="0" src="icons/previous.gif" width="32" height="32" /></a></td>

<td><a href="sect0022.html" title="Performing calculations"><img alt="Up: Performing calculations" border="0" src="icons/up.gif" width="32" height="32" /></a></td>

<td><a href="sec-angles.html" title="Treatment of angles in Pyxplot"><img alt="Next: Treatment of angles in Pyxplot" border="0" src="icons/next.gif" width="32" height="32" /></a></td>

<td class="navtitle" align="center">PyXPlot Users' Guide</td>
<td><a href="index.html" title="Table of Contents"><img border="0" alt="" src="icons/contents.gif" width="32" height="32" /></a></td>

<td><a href="sect0288.html" title="Index"><img border="0" alt="" src="icons/index.gif" width="32" height="32" /></a></td>

<td><img border="0" alt="" src="icons/blank.gif" width="32" height="32" /></td>
</tr>
</table>
</div>

<script language="javascript" src="icons/imgadjust.js" type="text/javascript"></script>

</body>
</html>