nasa / trick

Trick Simulation Environment. Trick provides a common set of simulation capabilities and utilities to build simulations automatically.
Other
44 stars 22 forks source link

Trick needs a way to display a list of available units #455

Closed jmpenn closed 7 years ago

jmpenn commented 7 years ago

Since we moved to udunits, we don't have a way to display a list of available units that a user can use in their simulation, short of digging into the udunits xml units database.

The way to find the database is to invoke "udunits2 -h", and then find the default [[ath to the database at the bottom of the printout.

% udunits2 -h Usage: udunits2 -h udunits2 [-A|-L|-U] [-r] [-H have] [-W want] [XML_file]

where: -A Use ASCII encoding (default). -L Use ISO-8859-1 (ISO Latin-1) encoding. -U Use UTF-8 encoding. -h Help. Print this message. -r Reveal any problems in the database. -H have Use "have" unit for conversion. Default is reply to prompt. -W want Use "want" unit for conversion. Empty string requests definition of "have" unit. Default is reply to prompt. XML_file XML database file. Default is "/usr/local/Cellar/udunits/2.2.24/share/udunits/udunits2.xml".

V-A-Kaiser commented 7 years ago

What do you propose? Should there be a "trick-units" perl script in 'bin' that users can run to receive a print-out of all the units they can use? Should Trick throw warnings and direct the user to the appropriate documentation when it receives values for units that it doesn't recognize?

Will the list of available units change significantly over time? If not, simply adding the list of available units to the documentation would be a simple and immediate benefit to the user. If so, creating a program to display the available unit types might be a better solution.

alexlin0 commented 7 years ago

A stand alone script or program would be fine. Perl would be an excellent choice. This was the previous output when we ran "ICG -u". Just reproducing something similar is what we are currently looking for. And to answer your question, the list of units won't change much.

Trick Measurement Units Summary
-------------------------------
                Time:   s min  hr day
Angular Displacement:   r   d  as  am rev
             Voltage:   v
            Amperage: amp
          Resistance: ohm
               Sound:  dB
            Unitless:  -- cnt one mol

English System Units
--------------------
 Linear Displacement:  ft  in  yd  mi  n.m.
                Mass:  sl lbm
               Force:  oz lbf
         Temperature:   R   F
              Energy:   BTU
               Power:   hp
            Pressure:   psi

Metric System Units
-------------------
 Linear Displacement:   m
                Mass:   g  mt
               Force:   N
         Temperature:   C   K
              Energy:   J   TNT
               Power:   W 
            Pressure:   Pa  atm

Prefixes for Multiples and Submultiples 
(Not valid for English system units)
---------------------------------------
10**-1    d           10      da
10**-2    c           10**2    h
10**-3    m           10**3    k
10**-6    u           10**6    M
10**-9    n           10**9    G
10**-12   p           10**12   T
10**-15   f           10**15   P
10**-18   a           10**18   E
10**-21   z           10**21   Z
10**-24   y           10**24   Y
V-A-Kaiser commented 7 years ago

Cool. This will give me a chance to play with Perl too. I'll start working on the script now.

V-A-Kaiser commented 7 years ago

Updated the script to better reflect the units Trick currently uses.