|
| 1 | +# -*- coding: utf-8 -*- |
1 | 2 | """ |
2 | 3 | """ |
3 | 4 |
|
4 | 5 | from quantities.units.unitquantity import UnitQuantity, UnitMass |
5 | 6 | from quantities.units.length import m |
6 | 7 |
|
7 | | -kg = kilogram = kilograms = \ |
8 | | - UnitMass('kg') |
9 | | -gram = grams = \ |
10 | | - UnitMass('gram', kg/1000) |
11 | | -mg = milligram = milligrams = \ |
12 | | - UnitMass('mg', gram/1000) |
13 | | -ounce = ounces = avoirdupois_ounce = \ |
14 | | - UnitMass('avoirdupois_ounce', 2.834952e-2*kg) |
15 | | -lb = lbs = pound = pounds = avoirdupois_pound = \ |
16 | | - UnitMass('pound', 4.5359237e-1*kg) |
| 8 | +kg = kilogram = UnitMass( |
| 9 | + 'kilograms', |
| 10 | + symbol='kg', |
| 11 | + aliases=['kilograms'] |
| 12 | +) |
| 13 | +g = gram = UnitMass( |
| 14 | + 'gram', |
| 15 | + kg/1000, |
| 16 | + symbol='g', |
| 17 | + aliases=['grams'] |
| 18 | +) |
| 19 | +mg = milligram = UnitMass( |
| 20 | + 'milligram', |
| 21 | + gram/1000, |
| 22 | + symbol='mg', |
| 23 | + aliases=['milligrams'] |
| 24 | +) |
| 25 | +ounce = avoirdupois_ounce = UnitMass( |
| 26 | + 'ounce', |
| 27 | + 28.349523125*g, |
| 28 | + symbol='oz', |
| 29 | + aliases=['ounces','avoirdupois_ounce', 'avoirdupois_ounces'] |
| 30 | +) # exact |
| 31 | +lb = pound = avoirdupois_pound = UnitMass( |
| 32 | + 'pound', |
| 33 | + 0.45359237*kg, |
| 34 | + symbol='lb', |
| 35 | + aliases=['pounds', 'avoirdupois_pound', 'avoirdupois_pounds'] |
| 36 | +) # exact |
17 | 37 |
|
18 | | -assay_ton = \ |
19 | | - UnitMass('assay_ton', 2.916667e-2*kg) |
20 | | -carat = \ |
21 | | - UnitMass('carat', 2e-4*kg) |
22 | | -gr = grain = grains = \ |
23 | | - UnitMass('gr', 6.479891e-5*kg) |
24 | | -long_hundredweight = long_hundredweights = \ |
25 | | - UnitMass('long_hundredweight', 50.80235*kg) |
26 | | -t = metric_ton = tonne = \ |
27 | | - UnitMass('t', 1000*kg) |
28 | | -pennyweight = pennyweights = \ |
29 | | - UnitMass('pennyweight', 1.555174e-3*kg) |
30 | | -short_hundredweight = short_hundredweights = \ |
31 | | - UnitMass('short_hundredweight', 45.35924*kg) |
32 | | -slug = slugs = \ |
33 | | - UnitMass('slug', 14.59390*kg) |
34 | | -apothecary_ounce = troy_ounce = \ |
35 | | - UnitMass('troy_ounce', 3.110348e-2*kg) |
36 | | -apothecary_pound = troy_pound = \ |
37 | | - UnitMass('troy_pound', 0.3732417*kg) |
38 | | -amu = atomic_mass_unit = u = \ |
39 | | - UnitMass('amu', 1.66053886e-27*kg) |
40 | | -u = \ |
41 | | - UnitMass('u', 1.66053886e-27*kg) |
42 | | -scruple = \ |
43 | | - UnitMass('scruple', 20*gr) |
44 | | -apdram = \ |
45 | | - UnitMass('apdram', 60*gr) |
46 | | -apounce = \ |
47 | | - UnitMass('apounce', 480*gr) |
48 | | -appound = \ |
49 | | - UnitMass('appound', 5760*gr) |
50 | | -bag = \ |
51 | | - UnitMass('bag', 94*lb) |
52 | | -ton = short_ton = \ |
53 | | - UnitMass('short_ton', 2000*lb) |
54 | | -long_ton = \ |
55 | | - UnitMass('long_ton', 2240*lb) |
| 38 | +carat = UnitMass( |
| 39 | + 'carat', |
| 40 | + 200*mg, |
| 41 | + aliases=['carats'] |
| 42 | +) |
| 43 | +gr = grain = UnitMass( |
| 44 | + 'grain', |
| 45 | + 64.79891*mg, |
| 46 | + symbol='gr', |
| 47 | + aliases=['grains'] |
| 48 | +) |
| 49 | +long_hundredweight = UnitMass( |
| 50 | + 'long_hundredweight', |
| 51 | + 112*lb, |
| 52 | + aliases=['long_hundredweights'] |
| 53 | +) |
| 54 | +short_hundredweight = UnitMass( |
| 55 | + 'short_hundredweight', |
| 56 | + 100*lb, |
| 57 | + aliases=['short_hundredweights'] |
| 58 | +) # cwt is used for both short and long hundredweight, so we wont use it |
| 59 | +t = metric_ton = tonne = UnitMass( |
| 60 | + 'tonne', |
| 61 | + 1000*kg, |
| 62 | + symbol='t', |
| 63 | + aliases=['tonnes'] |
| 64 | +) |
| 65 | +dwt = pennyweight = UnitMass( |
| 66 | + 'pennyweight', |
| 67 | + 24*gr, |
| 68 | + symbol='dwt', |
| 69 | + aliases=['pennyweights'] |
| 70 | +) |
| 71 | +slug = slugs = UnitMass( |
| 72 | + 'slug', |
| 73 | + 14.59390*kg, |
| 74 | + aliases=['slugs'] |
| 75 | +) |
| 76 | +toz = troy_ounce = apounce = apothecary_ounce = UnitMass( |
| 77 | + 'troy_ounce', |
| 78 | + 480*gr, |
| 79 | + symbol='℥', |
| 80 | + aliases=[ |
| 81 | + 'apounce', 'apounces', 'apothecary_ounce', 'apothecary_ounces', |
| 82 | + 'troy_ounces' |
| 83 | + ] |
| 84 | +) |
| 85 | +troy_pound = appound = apothecary_pound = UnitMass( |
| 86 | + 'troy_pound', |
| 87 | + 12*toz, |
| 88 | + symbol='℔', |
| 89 | + aliases=[ |
| 90 | + 'troy_pounds', 'appound', 'appounds', 'apothecary_pound', |
| 91 | + 'apothecary_pounds' |
| 92 | + ] |
| 93 | +) |
| 94 | +u = amu = atomic_mass_unit = UnitMass( |
| 95 | + 'atomic_mass_unit', |
| 96 | + 1.660538782e-27*kg, |
| 97 | + symbol='u', |
| 98 | + aliases=['amu'] |
| 99 | +) # TODO: needs uncertainty: 0.000000083e-27*kg |
| 100 | +scruple = UnitMass( |
| 101 | + 'scruple', |
| 102 | + 20*gr, |
| 103 | + symbol='℈', |
| 104 | + aliases=['scruples'] |
| 105 | +) |
| 106 | +dram = drachm = apdram = UnitMass( |
| 107 | + 'drachm', |
| 108 | + 60*gr, |
| 109 | + symbol='ʒ', |
| 110 | + aliases=['dram', 'drams', 'drachms', 'apdrams'] |
| 111 | +) |
| 112 | + |
| 113 | +bag = UnitMass( |
| 114 | + 'bag', |
| 115 | + 94*lb, |
| 116 | + aliases=['bags'] |
| 117 | +) |
| 118 | + |
| 119 | +ton = short_ton = UnitMass( |
| 120 | + 'short_ton', |
| 121 | + 2000*lb, |
| 122 | + aliases=['short_tons'] |
| 123 | +) |
| 124 | +long_ton = UnitMass( |
| 125 | + 'long_ton', 2240*lb, |
| 126 | + aliases=['long_tons'] |
| 127 | +) # both long and short tons are referred to as "ton" so we wont use it |
56 | 128 |
|
57 | 129 | ############################################################ |
58 | 130 | ## Mass per unit length ## |
59 | 131 | ############################################################ |
60 | 132 |
|
61 | | -denier = deniers = \ |
62 | | - UnitQuantity('denier', 1.111111e-7*kg/m) |
63 | | -tex = texs = \ |
64 | | - UnitQuantity('tex', 1e-6*kg/m) |
| 133 | +denier = UnitQuantity( |
| 134 | + 'denier', |
| 135 | + g/(9000*m), |
| 136 | + aliases=['deniers'] |
| 137 | +) |
| 138 | +tex = UnitQuantity( |
| 139 | + 'tex', |
| 140 | + g/(1000*m), |
| 141 | + aliases=['texs'] |
| 142 | +) |
| 143 | +dtex = UnitQuantity( |
| 144 | + 'dtex', |
| 145 | + g/(10000*m), |
| 146 | + aliases=['dtexs'] |
| 147 | +) |
65 | 148 |
|
66 | 149 | del UnitQuantity, m |
0 commit comments