'\" t .\" Title: UNITS-FILTER .\" Author: Georges Khaznadar .\" Generator: DocBook XSL Stylesheets v1.79.1 .\" Date: 12/02/2016 .\" Manual: units-filter User Manual .\" Source: units-filter .\" Language: English .\" .TH "UNITS\-FILTER" "1" "12/02/2016" "units-filter" "units-filter User Manual" .\" ----------------------------------------------------------------- .\" * Define some portability stuff .\" ----------------------------------------------------------------- .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .\" http://bugs.debian.org/507673 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" ----------------------------------------------------------------- .\" * set default formatting .\" ----------------------------------------------------------------- .\" disable hyphenation .nh .\" disable justification (adjust text to left margin only) .ad l .\" ----------------------------------------------------------------- .\" * MAIN CONTENT STARTS HERE * .\" ----------------------------------------------------------------- .SH "NAME" units-filter \- is a parser for physical and chemical quantities .SH "SYNOPSIS" .HP \w'\fBunits\-filter\fR\ 'u \fBunits\-filter\fR \fB\-s\ \fR \fB\-o\ \fR \fB\-l\ \fR .SH "DESCRIPTION" .PP \fBunits\-filter\fR is a basic standalone parser written in C language, flex and bison\&. It inputs strings like "1\&.5e3 nN\&.m\&.s^\-1" (it could be the time growth ratio of a torque) and outputs the value in standard SI unit, followed by the physical dimension of this value\&. .SH "OPTIONS" .PP \fB\-s \fR .RS 4 Like Significant\&. .sp Takes in account the number of significant digits\&. For example 1\&.0 m contains 2 significant digits, while 0\&.00100 contains 3 significant digits\&. It is possible to enforce the number of significant digits by using a special syntax : if units\-filter parses the input "1\&.0m#6", it interprets it as a value with exactly 6 significant digits, like "1\&.00000 m"\&. The number following the # sign is the forced number of significant digits\&. The number of significant digits appears just before the last zero in the output of the command (this zero is a placeholder for future extensions)\&. .RE .PP \fB\-o \fR .RS 4 Like Output\&. .sp Outputs a correct representation of the physical quantity with its physical unit in the International System notation\&. There may be some simplification with usual units\&. For example, a newton will be represented by the unit N in place of m\&.kg\&.s^\-2\&. The value is expressed as a floating number with one digit before the decimal point, and as many digits in the mantissa as necessary to fit the desired number of significant digits (see an example below)\&. It is possible to enforce the output unit : just add a colon and the desired unit at the end of the input\&. If this unit is homogeneous with the former one, it will be used to format the output\&. .RE .PP \fB\-l \fR .RS 4 Like LaTeX\&. .sp Outputs a correct representation of the physical quantity with its physical unit in the International System notation, in LaTeX language\&. .RE .SH "EXAMPLES" .PP Establish the SI value and unit exponent of a quantity in the mksa system: .PP \fB~$ echo 1\&.5e3 nN\&.m\&.s^\-1 | units\-filter\fR .PP \fB1\&.5e\-6 2 1 \-3 0 0 0 0\fR .PP which means : 1\&.5e\-6 (SI unit) m^2\&.kg\&.s^\-3 .PP .PP Compare different physical quantities: .PP \fB~$ e1=$(echo "1\&.2e\-3 V" | units\-filter)\fR .PP \fB~$ e2=$(echo "1200e3 nWb/s"| units\-filter)\fR .PP \fB~$ if [ "$e1" = "$e2" ]; then echo ok; else echo ko; fi\fR .PP \fBok\fR .PP \&.\&.\&. which emphasizes that webers by unit time are the same as volts\&. .PP .PP Playing with the number of significant digits: .PP \fB~$ echo "0\&.00100m" | src/units\-filter \-s\fR .PP \fB0\&.001 1 0 0 0 0 0 0 3 0\fR .PP \fB~$ echo "0\&.00100m #2" | src/units\-filter \-s\fR .PP \fB0\&.001 1 0 0 0 0 0 0 2 0\fR .PP .PP Giving a value for the relative precision: .PP \fB~$ echo "1kV~2" | units\-filter \-o\fR .PP \fB1e+03 V +\-2%\fR .PP .PP Turning on the LaTeX output: .PP \fB~$ echo "1kohm+\-2%" | units\-filter \-l\fR .PP \fB1\etimes 10^{+03}\e, \eOmega \epm 2\e,\e%\fR .PP .PP Turning on the output of a canonical physical notation: .PP \fB~$ echo "1\&.0 m\&.kg\&.s^\-2 #7" | units\-filter \-o\fR .PP \fB1\&.000000e+00N\fR .PP .PP Choosing a non\-standard unit for the output: .PP \fB~$ echo 1800C:A\&.h| units\-filter \-o\fR .PP \fB5\&.000e\-01 A\&.h\fR .SH "KNOWN BUGS" .PP Few units out of the mksa system are successfully parsed\&. .SH "AUTHOR" .PP \fBGeorges Khaznadar\fR <\&georgesk@ofset\&.org\&> .RS 4 Wrote this manpage\&. .RE .SH "COPYRIGHT" .br Copyright \(co 2009 Georges Khaznadar .br .PP Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 or (at your option) any later version published by the Free Software Foundation\&. .PP On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common\-licenses/GPL\&. .sp