Math: Update the units info from ConvertAll

Signed-off-by: James Vega <jamessan@users.sourceforge.net>
This commit is contained in:
James Vega 2009-05-18 00:44:59 -04:00
parent 2e8a2238c1
commit d7237104ae
1 changed files with 138 additions and 93 deletions

View File

@ -3,29 +3,29 @@
# formatted to fit your irc bot. # formatted to fit your irc bot.
# #
# The original version is a nifty PyQt application written by Douglas Bell, # The original version is a nifty PyQt application written by Douglas Bell,
# available at http://www.bellz.org/convertall/. # available at http://convertall.bellz.org/
# #
# Below is the original copyright. Doug Bell rocks. # Below is the original copyright. Doug Bell rocks.
# The hijacker is Keith Jones, and he has no bomb in his shoe. # The hijacker is Keith Jones, and he has no bomb in his shoe.
# #
#**************************************************************************** #****************************************************************************
#****************************************************************************
# convertcore.py, provides non-GUI base classes for data
#
# ConvertAll, a units conversion program
# Copyright (C) 2002, Douglas W. Bell
#
# This is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License, Version 2. This program is
# distributed in the hope that it will be useful, but WITTHOUT ANY WARRANTY.
#*****************************************************************************
import re, copy, sys, os.path, StringIO import re, copy, sys, os.path, StringIO
import supybot.conf as conf import supybot.conf as conf
import supybot.registry as registry import supybot.registry as registry
unitData = \
"""
#*****************************************************************************
# units.dat, the units data file, version 0.3.1
#
# ConvertAll, a units conversion program
# Copyright (C) 2005, Douglas W. Bell
#
# This is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License, Version 2. This program is
# distributed in the hope that it will be useful, but WITTHOUT ANY WARRANTY.
#***************************************************************************** #*****************************************************************************
# #
# Units are defined by an optional quantity and an equivalent unit or unit # Units are defined by an optional quantity and an equivalent unit or unit
@ -44,8 +44,8 @@ import supybot.registry as registry
# followed by either equations or equivalency lists for the definition. # followed by either equations or equivalency lists for the definition.
# For equations, two are given, separated by a ';'. Both are functions of # For equations, two are given, separated by a ';'. Both are functions of
# "x", the first going from the unit to the equivalent unit and the second # "x", the first going from the unit to the equivalent unit and the second
# one in reverse. Any valid Python expression returning a float (including # one in reverse. Any valid Python expression returning a float (including
# the functions in the math module) should work. The equivalency list is a # the functions in the math module) should work. The equivalency list is a
# python list of tuples giving points for linear interpolation. # python list of tuples giving points for linear interpolation.
# #
# All units must reduce to primitive units, which are indicated by an '!' # All units must reduce to primitive units, which are indicated by an '!'
@ -55,8 +55,6 @@ import supybot.registry as registry
# #
############################################################################## ##############################################################################
unitData = \
"""
# #
# mass units # mass units
# #
@ -77,6 +75,8 @@ tonne = 1000 kg # # metric
metric ton = tonne metric ton = tonne
megagram = tonne megagram = tonne
kilotonne = 1000 tonne # # metric kilotonne = 1000 tonne # # metric
gigagram = 1e9 gram
teragram = 1e12 gram
carat = 0.2 gram carat = 0.2 gram
ct = carat # carat ct = carat # carat
amu = 1.66053873e-27 kg # atomic mass amu = 1.66053873e-27 kg # atomic mass
@ -87,6 +87,10 @@ lbm = pound # pound
ounce = 1/16.0 pound ounce = 1/16.0 pound
oz = ounce # ounce oz = ounce # ounce
lid = ounce # # drug slang lid = ounce # # drug slang
pound troy = 5760 grain
lb troy = pound troy # pound troy
ounce troy = 1/12.0 lb troy
oz troy = ounce troy # ounce troy
ton = 2000 lb # # non-metric ton = 2000 lb # # non-metric
kiloton = 1000 ton # # non-metric kiloton = 1000 ton # # non-metric
slug = lbf*s^2/ft slug = lbf*s^2/ft
@ -117,7 +121,6 @@ kilometer = km
megameter = 1000 km megameter = 1000 km
angstrom = 1e-10 m angstrom = 1e-10 m
fermi = 1e-15 m # # nuclear sizes fermi = 1e-15 m # # nuclear sizes
barn = 1e-24 m # # particle physics
inch = 2.54 cm inch = 2.54 cm
in = inch # inch in = inch # inch
inches = inch inches = inch
@ -145,6 +148,7 @@ pica = 12 point
caliber = 0.01 inch # # bullet sizes caliber = 0.01 inch # # bullet sizes
football field = 100 yd football field = 100 yd
marathon = 46145 yd marathon = 46145 yd
mil Swedish = 10 km
au = 1.49597870691e11 m # astronomical unit au = 1.49597870691e11 m # astronomical unit
astronomical unit = au astronomical unit = au
light year = 365.25 light speed * day light year = 365.25 light speed * day
@ -302,10 +306,13 @@ T = tesla # tesla
# molecular units # molecular units
# #
[molecular qty] [molecular qty]
mol = ! # mole mol = ! # mole # gram mole
mole = mol mole = mol # # gram mole
gram mole = mol
kilomole = 1000 mol kilomole = 1000 mol
kmol = kilomole # kilomole kmol = kilomole # kilomole
pound mole = mol*lbm/gram
lbmol = pound mole # pound mole
[size of a mol] [size of a mol]
avogadro = gram/amu*mol avogadro = gram/amu*mol
@ -371,35 +378,47 @@ hemisphere = 1/2.0 sphere
# information units # information units
# #
[data] [data]
bit = ! bit = !
kilobit = 1000 bit # # based on power of 10 kilobit = 1000 bit # # based on power of 10
byte = 8 bit megabit = 1000 kilobit # # based on power of 10
B = byte # byte byte = 8 bit
kilobyte = 1000 byte # # based on power of 2 B = byte # byte
kB = kilobyte # kilobyte # based on power of 2 kilobyte = 1024 byte # # based on power of 2
megabyte = 1000 kB # # based on power of 2 kB = kilobyte # kilobyte # based on power of 2
MB = megabyte # megabyte # based on power of 2 megabyte = 1024 kB # # based on power of 2
gigabyte = 1000 MB # # based on power of 2 MB = megabyte # megabyte # based on power of 2
GB = gigabyte # gigabyte # based on power of 2 gigabyte = 1024 MB # # based on power of 2
terabyte = 1000 GB # # based on power of 2 GB = gigabyte # gigabyte # based on power of 2
TB = terabyte # terabyte # based on power of 2 terabyte = 1024 GB # # based on power of 2
petabyte = 1000 TB # # based on power of 2 TB = terabyte # terabyte # based on power of 2
PB = petabyte # petabyte # based on power of 2 petabyte = 1024 TB # # based on power of 2
PB = petabyte # petabyte # based on power of 2
kibibyte = 1024 byte kilobyte IEC std = 1000 byte # # based on power of 10
KiB = kibibyte # kibibyte kB IEC std = kilobyte IEC std # kilobyte # based on power of 10
mebibyte = 1024 KiB megabyte IEC std = 1000 kB IEC std # # based on power of 10
MiB = mebibyte # mebibyte MB IEC std = megabyte IEC std # megabyte # based on power of 10
gibibyte = 1024 MiB gigabyte IEC std = 1000 MB IEC std # # based on power of 10
GiB = gibibyte # gibibyte GB IEC std = gigabyte IEC std # gigabyte # based on power of 10
tebibyte = 1024 GiB terabyte IEC std = 1000 GB IEC std # # based on power of 10
TiB = tebibyte # tebibyte TB IEC std = terabyte IEC std # terabyte # based on power of 10
pebibyte = 1024 TiB petabyte IEC std = 1000 TB IEC std # # based on power of 10
PiB = pebibyte # pebibyte PB IEC std = petabyte IEC std # petabyte # based on power of 10
kibibyte = 1024 byte
KiB = kibibyte # kibibyte
mebibyte = 1024 KiB
MiB = mebibyte # mebibyte
gibibyte = 1024 MiB
GiB = gibibyte # gibibyte
tebibyte = 1024 GiB
TiB = tebibyte # tebibyte
pebibyte = 1024 TiB
PiB = pebibyte # pebibyte
[data transfer] [data transfer]
bps = bit/sec # bits / second bps = bit/sec # bits / second
kbps = 1000 bps # kilobits / sec. # based on power of 10 kbps = 1000 bps # kilobits / sec. # based on power of 10
# #
@ -463,61 +482,78 @@ ozf = ounce force # ounce force
# area units # area units
# #
[area] [area]
square meter = m^2 barn = 1e-28 m^2 # # particle physics
are = 100 m^2 are = 100 m^2
decare = 10 are
dekare = 10 are
hectare = 100 are hectare = 100 are
acre = 10 chain^2 acre = 10 chain^2
section = mile^2 section = mile^2
township = 36 section township = 36 section
homestead = 160 acre homestead = 160 acre
rai = 1600 m^2 # # Thai
ngaan = 400 m^2 # # Thai
circular inch = 1/4.0 pi*in^2 # # area of 1 inch circle circular inch = 1/4.0 pi*in^2 # # area of 1 inch circle
circular mil = 1/4.0 pi*mil^2 # # area of 1 mil circle circular mil = 1/4.0 pi*mil^2 # # area of 1 mil circle
# #
# volume units # volume units
# #
[volume] [volume]
cc = cm^3 # cubic centimeter cc = cm^3 # cubic centimeter
cubic centimeter = cc cubic centimeter = cc
liter = 1000 cc liter = 1000 cc
L = liter # liter l = liter # liter
litre = liter litre = liter
deciliter = 0.1 liter deciliter = 0.1 liter
centiliter = 0.01 liter centiliter = 0.01 liter
milliliter = cc milliliter = cc
mL = milliliter # milliliter ml = milliliter # milliliter
dekaliter = 10 liter dekaliter = 10 liter
hectoliter = 100 liter hectoliter = 100 liter
kiloliter = 1000 liter kiloliter = 1000 liter
kL = kiloliter # kiloliter kl = kiloliter # kiloliter
cubic meter = kiloliter megaliter = 1000 kiloliter
megaliter = 1000 kiloliter gallon = 231 in^3 # # US liquid
gallon = 231 in^3 gal = gallon # gallon # US liquid
gal = gallon # gallon quart = 1/4.0 gallon # # US liquid
quart = 1/4.0 gallon qt = quart # quart # US liquid
qt = quart # quart pint = 1/2.0 quart # # US liquid
pint = 1/2.0 quart pt = pint # pint # US liquid
pt = pint # pint fluid ounce = 1/16.0 pint # # US
fluid ounce = 1/16.0 pint fl oz = fluid ounce # fluid ounce # US
fl oz = fluid ounce # fluid ounce ounce fluid = fluid ounce # # US
ounce fluid = fluid ounce imperial gallon = 4.54609 liter
cup = 8 fl oz imp gal = imperial gallon # imperial gallon
tablespoon = 1/16.0 cup gallon imperial = imperial gallon
tbsp = tablespoon # tablespoon imperial quart = 1/4.0 imp gal
teaspoon = 1/3.0 tbsp imp qt = imperial quart # imperial quart
tsp = teaspoon # teaspoon quart imperial = imperial quart
barrel = 42 gallon imperial pint = 1/8.0 imp gal
bbl = barrel # barrel imp pt = imperial pint # imperial pint
shot = 1.5 fl oz pint imperial = imperial pint
fifth = 1/5.0 gallon # # alcohol imperial fluid ounce = 1/160.0 imp gal
wine bottle = 750 mL imp fl oz = imperial fluid ounce # imperial fluid ounce
magnum = 1.5 liter # # alcohol cup = 8 fl oz
keg = 15.5 gallon # # beer tablespoon = 1/16.0 cup
bushel = 2150.42 in^3 tbsp = tablespoon # tablespoon
peck = 1/4.0 bushel teaspoon = 1/3.0 tbsp
cord = 128 ft^3 tsp = teaspoon # teaspoon
board foot = ft^2*in barrel = 42 gallon
board feet = board foot bbl = barrel # barrel
shot = 1.5 fl oz
fifth = 1/5.0 gallon # # alcohol
wine bottle = 750 ml
magnum = 1.5 liter # # alcohol
keg = 15.5 gallon # # beer
hogshead wine = 63 gal
hogshead beer = 54 gal
bushel = 2150.42 in^3
peck = 1/4.0 bushel
cord = 128 ft^3
board foot = ft^2*in
board feet = board foot
# #
@ -529,7 +565,7 @@ kt = knot # knot
light speed = 2.99792458e8 m/s light speed = 2.99792458e8 m/s
mph = mi/hr # miles/hour mph = mi/hr # miles/hour
kph = km/hr # kilometers/hour kph = km/hr # kilometers/hour
mach = 331.46 m/s # # speed sound at STP mach = 340.29 m/s # # speed sound at STP
[rot. velocity] [rot. velocity]
rpm = rev/min # rev/min rpm = rev/min # rev/min
rps = rev/sec # rev/sec rps = rev/sec # rev/sec
@ -543,12 +579,12 @@ gph = gal/hr # gallons/hour
gpm = gal/min # gallons/minute gpm = gal/min # gallons/minute
cfs = ft^3/sec # cu ft/second cfs = ft^3/sec # cu ft/second
cfm = ft^3/min # cu ft/minute cfm = ft^3/min # cu ft/minute
lpm = L/min # liter/min lpm = l/min # liter/min
[gas flow] [gas flow]
sccm = atm*cc/min # std cc/min # pressure * flow sccm = atm*cc/min # std cc/min # pressure * flow
sccs = atm*cc/sec # std cc/sec # pressure * flow sccs = atm*cc/sec # std cc/sec # pressure * flow
slpm = atm*L/min # std liter/min # pressure * flow slpm = atm*l/min # std liter/min # pressure * flow
slph = atm*L/hr # std liter/hour # pressure * flow slph = atm*l/hr # std liter/hour # pressure * flow
scfh = atm*ft^3/hour # std cu ft/hour # pressure * flow scfh = atm*ft^3/hour # std cu ft/hour # pressure * flow
scfm = atm*ft^3/min # std cu ft/min # pressure * flow scfm = atm*ft^3/min # std cu ft/min # pressure * flow
@ -559,10 +595,14 @@ scfm = atm*ft^3/min # std cu ft/min # pressure * flow
[pressure] [pressure]
Pa = N/m^2 # pascal Pa = N/m^2 # pascal
pascal = Pa pascal = Pa
hPa = 100 Pa # hectopascal
hectopascal = hPa
kPa = 1000 Pa # kilopascal kPa = 1000 Pa # kilopascal
kilopascal = kPa kilopascal = kPa
MPa = 1000 kPa # megapascal MPa = 1000 kPa # megapascal
megapascal = MPa megapascal = MPa
GPa = 1000 MPa # gigapascal
gigapascal = GPa
atm = 101325 Pa # atmosphere atm = 101325 Pa # atmosphere
atmosphere = atm atmosphere = atm
bar = 1e5 Pa bar = 1e5 Pa
@ -571,6 +611,7 @@ millibar = mbar
microbar = 0.001 mbar microbar = 0.001 mbar
decibar = 0.1 bar decibar = 0.1 bar
kilobar = 1000 bar kilobar = 1000 bar
megabar = 1000 kilobar
mm Hg = mm*density Hg*gravity mm Hg = mm*density Hg*gravity
millimeter of Hg = mm Hg millimeter of Hg = mm Hg
torr = mm Hg torr = mm Hg
@ -693,6 +734,7 @@ Sv = sievert # sievert # equiv. dose
rem = 0.01 Sv # # roentgen equiv mammal rem = 0.01 Sv # # roentgen equiv mammal
millirem = 0.001 rem # # roentgen equiv mammal millirem = 0.001 rem # # roentgen equiv mammal
# #
# viscosity # viscosity
# #
@ -716,9 +758,12 @@ cSt = centistokes # centistokes
gravity = 9.80665 m/s^2 gravity = 9.80665 m/s^2
[constant] [constant]
gravity constant = 6.673e-11 N*m^2/kg^2 gravity constant = 6.673e-11 N*m^2/kg^2
gas constant = 8.314472 J/mol*K # R # based on gram mol gas constant = 8.314472 J/mol*K # R
[fuel consumpt.] [fuel consumpt.]
mpg = mi/gal # miles/gallon mpg = mi/gal # miles/gallon
liter per 100 km = [mpg] 3.785411784 / (x * 0.01609344) ; \
3.785411784 / (x * 0.01609344) # # non-linear
""" """