BioSimSpace.Types.Mass¶
- class BioSimSpace.Types.Mass(*args)[source]¶
A mass type.
- __init__(*args)[source]¶
Constructor.
*args
can be a value and unit, or a string representation of the mass, e.g. “12 grams”.- Parameters:
value (float) – The value.
unit (str) – The unit.
string (str) – A string representation of the mass.
Examples
Create an object representing a mass of 12 grams then print the mass in kilograms.
>>> import BioSimSpace as BSS >>> mass = BSS.Types.Mass(12, "G") >>> print(mass.kilograms())
The same as above, except passing a string representation of the mass to the constructor.
>>> import BioSimSpace as BSS >>> mass = BSS.Types.Mass("12 G") >>> print(mass.kilograms())
The string matching is extremeley flexible, so all of the following would be valid arguments: “12 G”, “12 grams”, “1.2e1 grams”.
Methods
__init__
(*args)Constructor.
angle
()Return the power in the 'angle' dimension.
charge
()Return the power in the 'charge' dimension.
Return the dimensions of this type.
Return the mass in femtograms.
grams
()Return the mass in grams.
Return the mass in kilograms.
length
()Return the power in the 'length' dimension.
mass
()Return the power in the 'mass' dimension.
Return the mass in micrograms.
Return the mass in milligrams.
Return the mass in nanograms.
Return the mass in picograms.
quantity
()Return the power in the 'quantity' dimension.
Return the power in the 'temperature' dimension.
time
()Return the power in the 'time' dimension.
to
(unit)Return the value of this general unit in the specified unit.
unit
()Return the unit.
value
()Return the value.
- classmethod angle()¶
Return the power in the ‘angle’ dimension.
- Returns:
angle – The power in the ‘angle’ dimension.
- Return type:
int
- classmethod charge()¶
Return the power in the ‘charge’ dimension.
- Returns:
charge – The power in the ‘charge’ dimension.
- Return type:
int
- classmethod dimensions()¶
Return the dimensions of this type. This is a tuple containing the power in each dimension.
- Returns(int, int, int, int, int, int)
The power in each dimension: ‘mass’, ‘length’, ‘temperature’, ‘charge’, ‘time’, ‘quantity’, and ‘angle’.
- femtograms()[source]¶
Return the mass in femtograms.
- Returns:
mass – The mass in femtograms.
- Return type:
- kilograms()[source]¶
Return the mass in kilograms.
- Returns:
mass – The mass in kilograms.
- Return type:
- classmethod length()¶
Return the power in the ‘length’ dimension.
- Returns:
length – The power in the ‘length’ dimension.
- Return type:
int
- classmethod mass()¶
Return the power in the ‘mass’ dimension.
- Returns:
mass – The power in the ‘mass’ dimension.
- Return type:
int
- micrograms()[source]¶
Return the mass in micrograms.
- Returns:
mass – The mass in micrograms.
- Return type:
- milligrams()[source]¶
Return the mass in milligrams.
- Returns:
mass – The mass in milligrams.
- Return type:
- nanograms()[source]¶
Return the mass in nanograms.
- Returns:
mass – The mass in nanograms.
- Return type:
- picograms()[source]¶
Return the mass in picograms.
- Returns:
mass – The mass in picograms.
- Return type:
- classmethod quantity()¶
Return the power in the ‘quantity’ dimension.
- Returns:
quantity – The power in the ‘quantity’ dimension.
- Return type:
int
- classmethod temperature()¶
Return the power in the ‘temperature’ dimension.
- Returns:
temperature – The power in the ‘temperature’ dimension.
- Return type:
int
- classmethod time()¶
Return the power in the ‘time’ dimension.
- Returns:
time – The power the ‘time’ dimension.
- Return type:
int
- to(unit)¶
Return the value of this general unit in the specified unit.
- Parameters:
unit (str) – The unit to convert to.
- Returns:
value – The value in the specified unit.
- Return type:
float
- unit()¶
Return the unit.
- Returns:
unit – The unit of the type.
- Return type:
str
- value()¶
Return the value.
- Returns:
value – The value of the type.
- Return type:
float