# Measurements for OpenOffice / LibreOffice

"Measurements" is a proof-of-concept OpenOffice / LibreOffice Calc add-in I wrote that provides a basic set of spreadsheet functions for manipulating scientific measurements, tracking units of measure and uncertainty (input and displayed as significant figures, but tracked as an arbitrary floating-point number internally).

Measurements has pages on the OpenOffice extension site and the LibreOffice extensions site.

## Design and status[# Top]

Measurements is agnostic to the precise interpretation of the uncertainty value, except that it must be small relative to the measurement value in order for the approximations made in the uncertainty propagation rules to be valid.  One option is to interpret the uncertainty as an upper bound on the standard deviation of the measurement under some Bayesian concept of its distribution; I would imagine that the propagation rules are sound with respect to this interpretation, but I have not formally verified this.  The rules are designed to account for the worst case of complete dependence among the inputs to each mathematical operation in the direction that produces the largest uncertainty in the result.  This can be unreasonably pessimistic in many scenarios, but the easy alternative assumption of independence of the inputs to every mathematical operation is badly unsound.  A better approach seen in some other tools is to assume a particular joint distribution on the set of inputs to a series of operations (e.g., independence may be reasonable in some scenarios), take (say) 1000 independent random samples from that joint distribution, parcel the components of these samples out to the individual inputs (thus representing each input as a list of 1000 samples), map every mathematical operation over these lists, and then compute the uncertainty of any measurement as the standard deviation of its list.  However, manipulating large lists of samples would likely cause severe scalability problems in the current implementation.

Measurements is currently best regarded as a proof of concept, since the sets of units and mathematical operations it supports are limited, it supports only one (pessimistic) uncertainty propagation model, and the representation of measurements as strings like "4.E-1 s^-1 m    [P9mZmZmZmZk/bGYgfrPzcf8BAAAAAA==]" (a value formatted for display and a dump of the internal state) is ugly.  With deeper knowledge of the OpenOffice / LibreOffice API, I might be able to hide the state dump.  I don't plan to make enhancements to the functionality of Measurements unless I become aware of significant demand.  My plans are limited to periodically updating Measurements to maintain compatibility with current versions of OpenOffice and LibreOffice if it doesn't become too much work.  As of 2020-08-30, I tested Measurements in libreoffice-calc-6.4.6.2-1.fc32.x86_64 in Fedora 32 and it worked out of the box (ditto on an upstream build of OpenOffice 4.1.7 on 2020-09-12), but I believe there is a very rare bug if the string "ERROR" coincidentally appears in a base-64 dump.  I am considering making a new release to fix the bug and possibly make packaging improvements in response to changes to OpenOffice / LibreOffice since 2009.

## Installation and usage[# Top]

The following instructions were written for OpenOffice.org in 2009, but I hope a similar procedure works now.

To install: The add-in comes in a UNO package named measurements-V.oxt, where V stands for the version.  Download the newest version.  In OpenOffice, go to Tools -> Extension Manager... -> My Extensions -> Add... -> browse for measurements-V.oxt -> Open.  Then restart OpenOffice.org.  (If you are upgrading, remove the old package and restart OpenOffice.org first.)

FileSizeModification time
measurements-1.3.oxt313792009-09-15 22:41:20 +0000
measurements-1.2.oxt317492009-02-07 04:25:13 +0000
measurements-1.1.oxt304622008-01-08 02:04:41 +0000
measurements-1.uno.pkg305592007-09-09 21:31:16 +0000

Note: For the extension to install properly, you must have the file unoil.jar that contains the OpenOffice.org Java interfaces.  In Fedora, this file is in the main OpenOffice.org package; in Ubuntu, it comes in a separate openoffice.org-java-common package.

To use:

• You might like to look at the demo spreadsheet.
• Input a measurement as a string consisting of a floating-point numerical value (scientific notation preferred), a space, and a unit expression.  The unit expression consists of one or more unit symbols, each optionally raised to an integer power with ^, and separated by *, space (implied multiply), or / (inverts the rest of the expression).  Example: 1.20E3 kg*m^2/s^2.  Only a few units are supported so far; see the list in Unit.java.
• The number of significant figures is inferred from your entry.  You can indicate that a number is exact by following it with a lowercase x.
• A measurement that does not contain a space is interpreted as an exact pure number (because the spreadsheet forgets the number of sig figs entered by the user anyway).  To enter an inexact pure number, enter a formula containing a literal string with a trailing space: ="1.497 ".
• Use the M* functions (MADD, MSUB, MMUL, MDIV, MNEG, MPOWINT, MROOTINT, MPOW, MEXP, MLN) to do arithmetic on measurements.  A computed result shows up as a scientific-notation value to the correct number of significant figures and units (for your benefit) followed by a code containing the add-in's representation of the result (including precision beyond the significant figures).  Example: If mass is in A1 and volume is in A2, put this in A3 to compute the density: =MDIV(A1;A2).
• The difference between MPOWINT and MPOW is that MPOW lets you use a pure-number measurement for the exponent but requires the base to be a pure number, while MPOWINT lets you use a base with units but requires the exponent to be an integer.
• To have a computed result shown in units other than the default, pass it and the desired unit expression to MSTRAS.  Example: =MSTRAS("1 m^3";"L").  This affects only the user-friendly form, not the code.
• If you're picky and want to show the user-friendly form of a result without the code, use MCLEANSTR.  There is also MCLEANSTRAS.
• If you see ERROR, something went wrong, but you have to guess what.  :)  A future version might have better diagnostics.
If you find bugs (which are almost certain to exist), please report them to me!

Measurements consists of:

Measurements comes with absolutely no warranty.

## Version log[# Top]

• Version 1 (2007-09-09): It works!
• Version 1.1 (2008-01-07): Packaging adjusted so it installs properly in OpenOffice.org 2.3.
• Version 1.2 (2009-02-06): Update build process for OpenOffice.org 3.0 and improve documentation.
• Version 1.3 (2009-09-15): Adjust packaging and build against Java 1.5 for greater compatibility.

## Source repository[# Top]

Here is the git repository containing the source code.  You can follow the link to browse the repository in gitweb or clone from it using the git tools.