User Tools

Site Tools


howtos:toolcoding:unit_of_measure_conversions

This is an old revision of the document!


There are two unit of measure parameters included with every TOOL object: the SI unit of measure (SIuom) and the alternate unit of measure (altUom).

The SIUom is the base units for the data and is the units that are used for storing the data and doing any math with that data, including interacting with other objects.

The altUom is the display and input units of measure that will be used anytime you interact with the data. Interacting would include: the display tools like table, and graph, entering data manually through these tools, and direct assignment in code in views. Each altUom should be setup in the measures table (see measures tab in Documenter) to specify how the conversion to the related SIUom should be done.

TOOL can handle unit of measure conversions across multiple objects seamlessly provided that the user defines the new measure in Documenter and properly specifies the unit of measure when defining the shape of a variable. The general steps to implement unit of measure conversions are:

  1. Define relevant altUom measures in Documenter
  2. Specify a unit of measure (altUom) for the source variable shape that matches the unit of measure of the source data
  3. Create a target variable with the same shape as the source variable but with the desired unit of measure (altUom)
  4. Set the target variable equal to the source variable

The target variable will be displayed in the desired unit of measure.

Example

For this example we are going be importing fuel consumption data in mpg and converting the output to km/L

First we need to define the required altUom measures in Documenter.

To do this:

  • Go to the measures tab and click the Add button

This will open the Measure Information window

  • Define the new altUom measures as follows:

Mile
Measure Type - Scientific Measure
Name - mile
SI Signature - m^1
Conversion to SI units - 0.000621371

US Gallon Measure Type - Scientific Measure
Name - USgallon
SI Signature - m^3
Conversion to SI units - 264.172

Kilometer Measure Type - Scientific Measure
Name - km
SI Signature - m^1
Conversion to SI units - 0.001

Litre Measure Type - Scientific Measure
Name - litre
SI Signature - m^3
Conversion to SI units - 1000

Once the altUom's have been created we need to apply them to the shapes of our variables fuelConIn and fuelConOut.

We will need to set the altUom for the varialbe fuelConIn to mpg and the altUom for the variable fuelConOut to km/L.

To do this:

  • Double click on the variable fuelConIn in the diagram. This will open the Variable Information window.
  • Navigate to the More Shape tab

varible info 2 image

  • Click on the button to access the Units window

units image

  • Specify mile as the numerator and USgallon as the denominator
  • Click OK to exit the Units window
  • Click Ok to exit the Variable Information window

Repeat this process for the variable fuelConOut with km as the numerator and litre as the denominator

  • Now we can set fuelConOut equal to fuelConIn in procedure 1 using the following code
fuelConOut[vt,t]=fuelConIn[vt,t]

After loading the model from Documenter into SAMM and importing the source data into SAMM we can see how the source data which is in mpg gets converted to km/l in the target variable in the tables below

fuelConIn

fuelConOut

howtos/toolcoding/unit_of_measure_conversions.1308263771.txt.gz · Last modified: 2011/06/16 22:36 by chris.strashok