constants.constants

Collection of physical constants and conversion factors.

Most constants are in SI units, so you can do print ‘10 mile per minute is’, 10*mile/minute, ‘m/s or’, 10*mile/(minute*knot), ‘knots’

The list is not meant to be comprehensive, but just a convenient list for everyday use.

Module Contents

Functions

convert_temperature(val,old_scale,new_scale) Convert from a temperature scale to another one among Celsius, Kelvin,
lambda2nu(lambda_) Convert wavelength to optical frequency
nu2lambda(nu) Convert optical frequency to wavelength.
convert_temperature(val, old_scale, new_scale)

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

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’).
res : float or array of floats
Value(s) of the converted temperature(s) expressed in the new scale.

New in version 0.18.0.

>>> from scipy.constants import convert_temperature
>>> convert_temperature(np.array([-40, 40.0]), 'Celsius', 'Kelvin')
array([ 233.15,  313.15])
lambda2nu(lambda_)

Convert wavelength to optical frequency

lambda_ : array_like
Wavelength(s) to be converted.
nu : float or array of floats
Equivalent optical frequency.

Computes nu = c / lambda where c = 299792458.0, i.e., the (vacuum) speed of light in meters/second.

>>> from scipy.constants import lambda2nu, speed_of_light
>>> lambda2nu(np.array((1, speed_of_light)))
array([  2.99792458e+08,   1.00000000e+00])
nu2lambda(nu)

Convert optical frequency to wavelength.

nu : array_like
Optical frequency to be converted.
lambda : float or array of floats
Equivalent wavelength(s).

Computes lambda = c / nu where c = 299792458.0, i.e., the (vacuum) speed of light in meters/second.

>>> from scipy.constants import nu2lambda, speed_of_light
>>> nu2lambda(np.array((1, speed_of_light)))
array([  2.99792458e+08,   1.00000000e+00])