{ } Raw JSON

bundles / scipy 1.17.1 / scipy / constants / _constants / convert_temperature

function

scipy.constants._constants:convert_temperature

source: /scipy/constants/_constants.py :228

Signature

def   convert_temperature ( val : npt.ArrayLike old_scale : str new_scale : str )  →  Any

Summary

Convert from a temperature scale to another one among Celsius, Kelvin, Fahrenheit, and Rankine scales.

Parameters

val : array_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

res : float or array of floats

Value(s) of the converted temperature(s) expressed in the new scale.

Notes

Array API Standard Support

convert_temperature has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variable SCIPY_ARRAY_API=1 and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported.

====================  ====================  ====================
Library               CPU                   GPU
====================  ====================  ====================
NumPy                 ✅                     n/a                 
CuPy                  n/a                   ✅                   
PyTorch               ✅                     ✅                   
JAX                   ✅                     ✅                   
Dask                  ✅                     n/a                 
====================  ====================  ====================

See dev-arrayapi for more information.

Examples

from scipy.constants import convert_temperature
import numpy as np
convert_temperature(np.array([-40, 40]), 'Celsius', 'Kelvin')

Aliases

  • scipy.constants.convert_temperature

Referenced by

This package