Skip to content

Add auto unit type selection? #9

@ChrisBarker-NOAA

Description

@ChrisBarker-NOAA

In pyNUCOS, we allow the user to convert some units without specifying a unit type:

us.convert("ft", "m", 1.0)

But if you want to convert to, say "fraction", and you may not know that unit)type is (e.g. Concentration, not length, or mass or ..) than there are issues, as "fraction" may belong to more than one unit type (by the NUCOS definition). note that this can be an issue with lots of units, like "oz" which could be a weight or a fluid oz.

In PyNUCOS, we do support this use case -- the "UnitType" is optional in the convert function. It's done by building a mapping with the FindUnitTypes() function in:

https://github.com/NOAA-ORR-ERD/PyNUCOS/blob/master/unit_conversion/unit_conversion.py

Note that it excludes certain unit types and specific units, to avoid clashes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions