Units: A Unit Conversion Program and Scientific Calculator: Logging Calculations

Next: Invoking Units, Previous: Unit Lists, Up: Top [Contents][Index]

## 8 Logging Calculations

The `--log` option allows you to save the results of calculations in a file; this can be useful if you need a permanent record of your work. For example, the fluid-flow conversion in Complicated Unit Expressions, is lengthy, and if you were to use it in designing a piping system, you might want a record of it for the project file. If the interactive session

    # Conversion factor A1 for pressure drop
    # dP = A1 rho f L Q^2/d^5
    You have: (8/pi^2) (lbm/ft^3)ft(ft^3/s)^2(1/in^5) # Input units
    You want: psi
            * 43.533969
            / 0.022970568

were logged, the log file would contain

    ### Log started Fri Oct 02 15:55:35 2015

    # Conversion factor A1 for pressure drop
    # dP = A1 rho f L Q^2/d^5
    From: (8/pi^2) (lbm/ft^3)ft(ft^3/s)^2(1/in^5)   # Input units
    To:   psi
            * 43.533969
            / 0.022970568

The time is written to the log file when the file is opened.

The use of comments can help clarify the meaning of calculations for the log. The log includes conformability errors between the units at the ‘`You have:`’ and ‘`You want:`’ prompts, but not other errors, including lack of conformability of items in sums or differences or among items in a unit list. For example, a conversion between zenith angle and elevation angle could involve

    You have: 90 deg - (5 deg + 22 min + 9 sec)
                                       ^
    Illegal sum or difference of non-conformable units
    You have: 90 deg - (5 deg + 22 arcmin + 9 arcsec)
    You want: dms
            84 deg + 37 arcmin + 51 arcsec
    You have: _
    You want: deg
            * 84.630833
            / 0.011816024
    You have:

The log file would contain

    From: 90 deg - (5 deg + 22 arcmin + 9 arcsec)
    To:   deg;arcmin;arcsec
            84 deg + 37 arcmin + 51 arcsec
    From: _
    To:   deg
            * 84.630833
            / 0.011816024

The initial entry error (forgetting that minutes have dimension of time, and that arcminutes must be used for dimensions of angle) does not appear in the output. When converting to a unit list alias, `units` expands the alias in the log file.

The ‘`From:`’ and ‘`To:`’ tags are written to the log file even if the `--quiet` option is given. If the log file exists when `units` is invoked, the new results are appended to the log file. The time is written to the log file each time the file is opened. The `--log` option is ignored when `units` is used non-interactively.

Next: Invoking Units, Previous: Unit Lists, Up: Top [Contents][Index]