Module cosmicBallet.Conversion

Functions

def distance_conversion(distance_list: list, unit: str) ‑> list

Function that converts the distance to SI Units

Converts the distance values in the distance_list to SI Units. All elements within the distance_list need to be of a 
single unit. The units are provided to the function via shorthand notation.
    Accepted Units are: AU (astronomical unit), ly (light year), mi (mile), km (kilometer)

Args

distance_list : list
Distance values needed for conversion. Single values need to be input as a list
unit : str
The current unit of the distance value

Raises

TypeError
Raised if the distance_list or unit are not of specified data type.
ValueError
Raised if the unit is unrecognized

Returns

list
Distance list in SI Units.

Example

>>> test_distance = [1,2]
>>> test_distance_si = distance_conversion(distance_list=test_distance, unit="ly")
>>> print(test_distance_si)
[9.4607e15, 1.89214e16]
def mass_conversion(mass_list: list, unit: str) ‑> list

Function that converts the mass to SI Units

Converts the mass values in the mass_list to SI Units. All elements within the mass_list need to be of a single unit. The
units are provided to the function via shorthand notation.
    Accepted Units are: lbs (pounds), Me (Earth Mass) and Ms (Solar Mass)

Args

mass_list : list
Mass values needed for conversion. Single values need to be input as a list
unit : str
The current unit of the mass value

Raises

TypeError
Raised if the mass_list or unit are not of specified data type.
ValueError
Raised if the unit is unrecognized

Returns

list
Mass list in SI Units.

Example

>>> test_mass = [1,2]
>>> test_mass_si = mass_conversion(mass_list=test_mass, unit="Ms")
>>> print(test_mass_si)
[1.9884e30, 3.9768e30]
def temperature_conversion(temperature: Union[float, int], unit: str) ‑> float

Function that converts the temperature to SI Units

Converts the temperature to SI Units (kelvin). The accepted units for conversion and method of conversion are:
    C (celcius) -> temp_kelvin = temp_celcius + 273.15
    F (Fahrenheit) -> temp_kelvin = ((temp_fahrenheit - 32)/1.8) + 273.15
    R (Rankine) -> temp_kelvin = temp_rankine * 5 / 9

Args

temperature (float/int): Temperature value for conversion to SI Units
unit : str
Unit of the temperature value

Raises

TypeError
Raised if the temperature or unit are of unspecified datatypes
ValueError
Raised if the unit is unspecified

Returns

float
Temperature value in SI Units

Example

>>> test_temp = 212
>>> test_temp_si = temperature_conversion(temperature=test_temp, unit="F")
>>> print(test_temp_si)
373.15
def velocity_conversion(velocity_list: list, unit: str) ‑> list

Function that converts the velocity to SI Units

Converts the velocity values in the velocity_list to SI Units. All elements within the velocity_list need to be of a single 
unit. The units are provided to the function via shorthand notation.
    Accepted Units are: ftps (feet/second), mph (miles/hour), kmph (kilometer/hour) and AUpD (Astronomical Units/Day)

Args

velocity_list : list
Velocity values needed for conversion. Single values need to be input as a list
unit : str
The current unit of the velocity value

Raises

TypeError
Raised if the velocity_list or unit are not of specified data type.
ValueError
Raised if the unit is unrecognized

Returns

list
Velocity list in SI Units.

Example

>>> test_velocity = [100,200]
>>> test_velocity_si = velocity_conversion(velocity_list=test_velocity, unit="Ms")
>>> print(test_velocity_si)
[44.704, 89.408]