How to use the quantities.unitquantity.UnitMass function in quantities

To help you get started, we’ve selected a few quantities examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github python-quantities / python-quantities / quantities / unitquantity.py View on Github external
If both system and individual defaults are given, the system
    defaults will be applied first, followed by the individual ones.
    """
    if system is not None:
        system = system.lower()
        try:
            assert system in ('si', 'cgs')
        except AssertionError:
            raise ValueError('system must be "SI" or "cgs", got "%s"' % system)
        if system == 'si':
            UnitCurrent.set_default_unit('A')
            UnitLength.set_default_unit('m')
            UnitMass.set_default_unit('kg')
        elif system == 'cgs':
            UnitLength.set_default_unit('cm')
            UnitMass.set_default_unit('g')
        UnitLuminousIntensity.set_default_unit('cd')
        UnitSubstance.set_default_unit('mol')
        UnitTemperature.set_default_unit('degK')
        UnitTime.set_default_unit('s')

    UnitCurrency.set_default_unit(currency)
    UnitCurrent.set_default_unit(current)
    UnitInformation.set_default_unit(information)
    UnitLength.set_default_unit(length)
    UnitLuminousIntensity.set_default_unit(luminous_intensity)
    UnitMass.set_default_unit(mass)
    UnitSubstance.set_default_unit(substance)
    UnitTemperature.set_default_unit(temperature)
    UnitTime.set_default_unit(time)
github python-quantities / python-quantities / quantities / units / mass.py View on Github external
dr = dram = UnitMass(
    'dram',
    oz/16,
    symbol='dr',
    aliases=['drams'],
    doc='avoirdupois dram'
)
drachm = apdram = UnitMass(
    'drachm',
    60*gr,
    u_symbol='  ',
    aliases=['drachms', 'apdram', 'apdrams'],
    doc='also known as the apothecary dram'
)

bag = UnitMass(
    'bag',
    94*lb,
    aliases=['bags']
)

ton = short_ton = UnitMass(
    'short_ton',
    2000*lb,
    aliases=['short_tons']
)
long_ton = UnitMass(
    'long_ton', 2240*lb,
    aliases=['long_tons']
) # both long and short tons are referred to as "ton" so we wont use it

############################################################
github python-quantities / python-quantities / quantities / units / mass.py View on Github external
]
)
u = amu = atomic_mass_unit = dalton = Da = UnitMass(
    'atomic_mass_unit',
    1.660538782e-27*kg,
    symbol='u',
    aliases=['amu', 'Da', 'dalton'],
    doc='relative uncertainty = 5e-8'
)
scruple = UnitMass(
    'scruple',
    20*gr,
    u_symbol='℈',
    aliases=['scruples']
)
dr = dram = UnitMass(
    'dram',
    oz/16,
    symbol='dr',
    aliases=['drams'],
    doc='avoirdupois dram'
)
drachm = apdram = UnitMass(
    'drachm',
    60*gr,
    u_symbol='  ',
    aliases=['drachms', 'apdram', 'apdrams'],
    doc='also known as the apothecary dram'
)

bag = UnitMass(
    'bag',
github python-quantities / python-quantities / quantities / units / mass.py View on Github external
symbol='kg',
    aliases=['kilograms']
)
g = gram = UnitMass(
    'gram',
    kg/1000,
    symbol='g',
    aliases=['grams']
)
mg = milligram = UnitMass(
    'milligram',
    gram/1000,
    symbol='mg',
    aliases=['milligrams']
)
oz = ounce = avoirdupois_ounce = UnitMass(
    'ounce',
    28.349523125*g,
    symbol='oz',
    aliases=['ounces','avoirdupois_ounce', 'avoirdupois_ounces'],
    doc='exact'
)
lb = pound = avoirdupois_pound = UnitMass(
    'pound',
    0.45359237*kg,
    symbol='lb',
    aliases=['pounds', 'avoirdupois_pound', 'avoirdupois_pounds'],
    doc='exact'
)
st = stone = UnitMass(
    'stone',
    14*lb,
github python-quantities / python-quantities / quantities / units / mass.py View on Github external
)
drachm = apdram = UnitMass(
    'drachm',
    60*gr,
    u_symbol='  ',
    aliases=['drachms', 'apdram', 'apdrams'],
    doc='also known as the apothecary dram'
)

bag = UnitMass(
    'bag',
    94*lb,
    aliases=['bags']
)

ton = short_ton = UnitMass(
    'short_ton',
    2000*lb,
    aliases=['short_tons']
)
long_ton = UnitMass(
    'long_ton', 2240*lb,
    aliases=['long_tons']
) # both long and short tons are referred to as "ton" so we wont use it

############################################################
##                 Mass per unit length                   ##
############################################################

denier = UnitQuantity(
    'denier',
    g/(9000*m),
github python-quantities / python-quantities / quantities / units / mass.py View on Github external
aliases=['grams']
)
mg = milligram = UnitMass(
    'milligram',
    gram/1000,
    symbol='mg',
    aliases=['milligrams']
)
oz = ounce = avoirdupois_ounce = UnitMass(
    'ounce',
    28.349523125*g,
    symbol='oz',
    aliases=['ounces','avoirdupois_ounce', 'avoirdupois_ounces'],
    doc='exact'
)
lb = pound = avoirdupois_pound = UnitMass(
    'pound',
    0.45359237*kg,
    symbol='lb',
    aliases=['pounds', 'avoirdupois_pound', 'avoirdupois_pounds'],
    doc='exact'
)
st = stone = UnitMass(
    'stone',
    14*lb,
    symbol='st',
    doc='As defined in the UK, 1 stone = 14 avoirdupois pounds'
)

carat = UnitMass(
    'carat',
    200*mg,
github python-quantities / python-quantities / quantities / units / mass.py View on Github external
symbol='st',
    doc='As defined in the UK, 1 stone = 14 avoirdupois pounds'
)

carat = UnitMass(
    'carat',
    200*mg,
    aliases=['carats']
)
gr = grain = UnitMass(
    'grain',
    64.79891*mg,
    symbol='gr',
    aliases=['grains']
)
long_hundredweight = UnitMass(
    'long_hundredweight',
    112*lb,
    aliases=['long_hundredweights']
)
short_hundredweight = UnitMass(
    'short_hundredweight',
    100*lb,
    aliases=['short_hundredweights']
) # cwt is used for both short and long hundredweight, so we wont use it
t = metric_ton = tonne = UnitMass(
    'tonne',
    1000*kg,
    symbol='t',
    aliases=['tonnes']
)
dwt = pennyweight = UnitMass(
github python-quantities / python-quantities / quantities / units / mass.py View on Github external
aliases=[
        'apounce', 'apounces', 'apothecary_ounce', 'apothecary_ounces',
        'troy_ounces'
    ]
)
troy_pound = appound = apothecary_pound = UnitMass(
    'troy_pound',
    12*toz,
    symbol='tlb',
    u_symbol='℔',
    aliases=[
        'troy_pounds', 'appound', 'appounds', 'apothecary_pound',
        'apothecary_pounds'
    ]
)
u = amu = atomic_mass_unit = dalton = Da = UnitMass(
    'atomic_mass_unit',
    1.660538782e-27*kg,
    symbol='u',
    aliases=['amu', 'Da', 'dalton'],
    doc='relative uncertainty = 5e-8'
)
scruple = UnitMass(
    'scruple',
    20*gr,
    u_symbol='℈',
    aliases=['scruples']
)
dr = dram = UnitMass(
    'dram',
    oz/16,
    symbol='dr',
github python-quantities / python-quantities / quantities / units / mass.py View on Github external
doc='relative uncertainty = 5e-8'
)
scruple = UnitMass(
    'scruple',
    20*gr,
    u_symbol='℈',
    aliases=['scruples']
)
dr = dram = UnitMass(
    'dram',
    oz/16,
    symbol='dr',
    aliases=['drams'],
    doc='avoirdupois dram'
)
drachm = apdram = UnitMass(
    'drachm',
    60*gr,
    u_symbol='  ',
    aliases=['drachms', 'apdram', 'apdrams'],
    doc='also known as the apothecary dram'
)

bag = UnitMass(
    'bag',
    94*lb,
    aliases=['bags']
)

ton = short_ton = UnitMass(
    'short_ton',
    2000*lb,
github python-quantities / python-quantities / quantities / units / mass.py View on Github external
aliases=['pounds', 'avoirdupois_pound', 'avoirdupois_pounds'],
    doc='exact'
)
st = stone = UnitMass(
    'stone',
    14*lb,
    symbol='st',
    doc='As defined in the UK, 1 stone = 14 avoirdupois pounds'
)

carat = UnitMass(
    'carat',
    200*mg,
    aliases=['carats']
)
gr = grain = UnitMass(
    'grain',
    64.79891*mg,
    symbol='gr',
    aliases=['grains']
)
long_hundredweight = UnitMass(
    'long_hundredweight',
    112*lb,
    aliases=['long_hundredweights']
)
short_hundredweight = UnitMass(
    'short_hundredweight',
    100*lb,
    aliases=['short_hundredweights']
) # cwt is used for both short and long hundredweight, so we wont use it
t = metric_ton = tonne = UnitMass(