scipy.constants.convert_temperature¶
- scipy.constants.convert_temperature(val, old_scale, new_scale)[source]¶
Convert from a temperature scale to another one among Celsius, Kelvin, Fahrenheit, and Rankine scales.
- Parameters
- valarray_like
Value(s) of the temperature(s) to be converted expressed in the original scale.
- old_scale: str
Specifies as a string the original scale from which the temperature value(s) will be converted. Supported scales are Celsius (‘Celsius’, ‘celsius’, ‘C’ or ‘c’), Kelvin (‘Kelvin’, ‘kelvin’, ‘K’, ‘k’), Fahrenheit (‘Fahrenheit’, ‘fahrenheit’, ‘F’ or ‘f’), and Rankine (‘Rankine’, ‘rankine’, ‘R’, ‘r’).
- new_scale: str
Specifies as a string the new scale to which the temperature value(s) will be converted. Supported scales are Celsius (‘Celsius’, ‘celsius’, ‘C’ or ‘c’), Kelvin (‘Kelvin’, ‘kelvin’, ‘K’, ‘k’), Fahrenheit (‘Fahrenheit’, ‘fahrenheit’, ‘F’ or ‘f’), and Rankine (‘Rankine’, ‘rankine’, ‘R’, ‘r’).
- Returns
- resfloat or array of floats
Value(s) of the converted temperature(s) expressed in the new scale.
Notes
New in version 0.18.0.
Examples
>>> from scipy.constants import convert_temperature >>> convert_temperature(np.array([-40, 40]), 'Celsius', 'Kelvin') array([ 233.15, 313.15])