__init__.py 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. r"""
  2. ==================================
  3. Constants (:mod:`scipy.constants`)
  4. ==================================
  5. .. currentmodule:: scipy.constants
  6. Physical and mathematical constants and units.
  7. Mathematical constants
  8. ======================
  9. ================ =================================================================
  10. ``pi`` Pi
  11. ``golden`` Golden ratio
  12. ``golden_ratio`` Golden ratio
  13. ================ =================================================================
  14. Physical constants
  15. ==================
  16. =========================== =================================================================
  17. ``c`` speed of light in vacuum
  18. ``speed_of_light`` speed of light in vacuum
  19. ``mu_0`` the magnetic constant :math:`\mu_0`
  20. ``epsilon_0`` the electric constant (vacuum permittivity), :math:`\epsilon_0`
  21. ``h`` the Planck constant :math:`h`
  22. ``Planck`` the Planck constant :math:`h`
  23. ``hbar`` :math:`\hbar = h/(2\pi)`
  24. ``G`` Newtonian constant of gravitation
  25. ``gravitational_constant`` Newtonian constant of gravitation
  26. ``g`` standard acceleration of gravity
  27. ``e`` elementary charge
  28. ``elementary_charge`` elementary charge
  29. ``R`` molar gas constant
  30. ``gas_constant`` molar gas constant
  31. ``alpha`` fine-structure constant
  32. ``fine_structure`` fine-structure constant
  33. ``N_A`` Avogadro constant
  34. ``Avogadro`` Avogadro constant
  35. ``k`` Boltzmann constant
  36. ``Boltzmann`` Boltzmann constant
  37. ``sigma`` Stefan-Boltzmann constant :math:`\sigma`
  38. ``Stefan_Boltzmann`` Stefan-Boltzmann constant :math:`\sigma`
  39. ``Wien`` Wien displacement law constant
  40. ``Rydberg`` Rydberg constant
  41. ``m_e`` electron mass
  42. ``electron_mass`` electron mass
  43. ``m_p`` proton mass
  44. ``proton_mass`` proton mass
  45. ``m_n`` neutron mass
  46. ``neutron_mass`` neutron mass
  47. =========================== =================================================================
  48. Constants database
  49. ------------------
  50. In addition to the above variables, :mod:`scipy.constants` also contains the
  51. 2018 CODATA recommended values [CODATA2018]_ database containing more physical
  52. constants.
  53. .. autosummary::
  54. :toctree: generated/
  55. value -- Value in physical_constants indexed by key
  56. unit -- Unit in physical_constants indexed by key
  57. precision -- Relative precision in physical_constants indexed by key
  58. find -- Return list of physical_constant keys with a given string
  59. ConstantWarning -- Constant sought not in newest CODATA data set
  60. .. data:: physical_constants
  61. Dictionary of physical constants, of the format
  62. ``physical_constants[name] = (value, unit, uncertainty)``.
  63. Available constants:
  64. ====================================================================== ====
  65. %(constant_names)s
  66. ====================================================================== ====
  67. Units
  68. =====
  69. SI prefixes
  70. -----------
  71. ============ =================================================================
  72. ``yotta`` :math:`10^{24}`
  73. ``zetta`` :math:`10^{21}`
  74. ``exa`` :math:`10^{18}`
  75. ``peta`` :math:`10^{15}`
  76. ``tera`` :math:`10^{12}`
  77. ``giga`` :math:`10^{9}`
  78. ``mega`` :math:`10^{6}`
  79. ``kilo`` :math:`10^{3}`
  80. ``hecto`` :math:`10^{2}`
  81. ``deka`` :math:`10^{1}`
  82. ``deci`` :math:`10^{-1}`
  83. ``centi`` :math:`10^{-2}`
  84. ``milli`` :math:`10^{-3}`
  85. ``micro`` :math:`10^{-6}`
  86. ``nano`` :math:`10^{-9}`
  87. ``pico`` :math:`10^{-12}`
  88. ``femto`` :math:`10^{-15}`
  89. ``atto`` :math:`10^{-18}`
  90. ``zepto`` :math:`10^{-21}`
  91. ``yocto`` :math:`10^{-24}`
  92. ============ =================================================================
  93. Binary prefixes
  94. ---------------
  95. ============ =================================================================
  96. ``kibi`` :math:`2^{10}`
  97. ``mebi`` :math:`2^{20}`
  98. ``gibi`` :math:`2^{30}`
  99. ``tebi`` :math:`2^{40}`
  100. ``pebi`` :math:`2^{50}`
  101. ``exbi`` :math:`2^{60}`
  102. ``zebi`` :math:`2^{70}`
  103. ``yobi`` :math:`2^{80}`
  104. ============ =================================================================
  105. Mass
  106. ----
  107. ================= ============================================================
  108. ``gram`` :math:`10^{-3}` kg
  109. ``metric_ton`` :math:`10^{3}` kg
  110. ``grain`` one grain in kg
  111. ``lb`` one pound (avoirdupous) in kg
  112. ``pound`` one pound (avoirdupous) in kg
  113. ``blob`` one inch version of a slug in kg (added in 1.0.0)
  114. ``slinch`` one inch version of a slug in kg (added in 1.0.0)
  115. ``slug`` one slug in kg (added in 1.0.0)
  116. ``oz`` one ounce in kg
  117. ``ounce`` one ounce in kg
  118. ``stone`` one stone in kg
  119. ``grain`` one grain in kg
  120. ``long_ton`` one long ton in kg
  121. ``short_ton`` one short ton in kg
  122. ``troy_ounce`` one Troy ounce in kg
  123. ``troy_pound`` one Troy pound in kg
  124. ``carat`` one carat in kg
  125. ``m_u`` atomic mass constant (in kg)
  126. ``u`` atomic mass constant (in kg)
  127. ``atomic_mass`` atomic mass constant (in kg)
  128. ================= ============================================================
  129. Angle
  130. -----
  131. ================= ============================================================
  132. ``degree`` degree in radians
  133. ``arcmin`` arc minute in radians
  134. ``arcminute`` arc minute in radians
  135. ``arcsec`` arc second in radians
  136. ``arcsecond`` arc second in radians
  137. ================= ============================================================
  138. Time
  139. ----
  140. ================= ============================================================
  141. ``minute`` one minute in seconds
  142. ``hour`` one hour in seconds
  143. ``day`` one day in seconds
  144. ``week`` one week in seconds
  145. ``year`` one year (365 days) in seconds
  146. ``Julian_year`` one Julian year (365.25 days) in seconds
  147. ================= ============================================================
  148. Length
  149. ------
  150. ===================== ============================================================
  151. ``inch`` one inch in meters
  152. ``foot`` one foot in meters
  153. ``yard`` one yard in meters
  154. ``mile`` one mile in meters
  155. ``mil`` one mil in meters
  156. ``pt`` one point in meters
  157. ``point`` one point in meters
  158. ``survey_foot`` one survey foot in meters
  159. ``survey_mile`` one survey mile in meters
  160. ``nautical_mile`` one nautical mile in meters
  161. ``fermi`` one Fermi in meters
  162. ``angstrom`` one Angstrom in meters
  163. ``micron`` one micron in meters
  164. ``au`` one astronomical unit in meters
  165. ``astronomical_unit`` one astronomical unit in meters
  166. ``light_year`` one light year in meters
  167. ``parsec`` one parsec in meters
  168. ===================== ============================================================
  169. Pressure
  170. --------
  171. ================= ============================================================
  172. ``atm`` standard atmosphere in pascals
  173. ``atmosphere`` standard atmosphere in pascals
  174. ``bar`` one bar in pascals
  175. ``torr`` one torr (mmHg) in pascals
  176. ``mmHg`` one torr (mmHg) in pascals
  177. ``psi`` one psi in pascals
  178. ================= ============================================================
  179. Area
  180. ----
  181. ================= ============================================================
  182. ``hectare`` one hectare in square meters
  183. ``acre`` one acre in square meters
  184. ================= ============================================================
  185. Volume
  186. ------
  187. =================== ========================================================
  188. ``liter`` one liter in cubic meters
  189. ``litre`` one liter in cubic meters
  190. ``gallon`` one gallon (US) in cubic meters
  191. ``gallon_US`` one gallon (US) in cubic meters
  192. ``gallon_imp`` one gallon (UK) in cubic meters
  193. ``fluid_ounce`` one fluid ounce (US) in cubic meters
  194. ``fluid_ounce_US`` one fluid ounce (US) in cubic meters
  195. ``fluid_ounce_imp`` one fluid ounce (UK) in cubic meters
  196. ``bbl`` one barrel in cubic meters
  197. ``barrel`` one barrel in cubic meters
  198. =================== ========================================================
  199. Speed
  200. -----
  201. ================== ==========================================================
  202. ``kmh`` kilometers per hour in meters per second
  203. ``mph`` miles per hour in meters per second
  204. ``mach`` one Mach (approx., at 15 C, 1 atm) in meters per second
  205. ``speed_of_sound`` one Mach (approx., at 15 C, 1 atm) in meters per second
  206. ``knot`` one knot in meters per second
  207. ================== ==========================================================
  208. Temperature
  209. -----------
  210. ===================== =======================================================
  211. ``zero_Celsius`` zero of Celsius scale in Kelvin
  212. ``degree_Fahrenheit`` one Fahrenheit (only differences) in Kelvins
  213. ===================== =======================================================
  214. .. autosummary::
  215. :toctree: generated/
  216. convert_temperature
  217. Energy
  218. ------
  219. ==================== =======================================================
  220. ``eV`` one electron volt in Joules
  221. ``electron_volt`` one electron volt in Joules
  222. ``calorie`` one calorie (thermochemical) in Joules
  223. ``calorie_th`` one calorie (thermochemical) in Joules
  224. ``calorie_IT`` one calorie (International Steam Table calorie, 1956) in Joules
  225. ``erg`` one erg in Joules
  226. ``Btu`` one British thermal unit (International Steam Table) in Joules
  227. ``Btu_IT`` one British thermal unit (International Steam Table) in Joules
  228. ``Btu_th`` one British thermal unit (thermochemical) in Joules
  229. ``ton_TNT`` one ton of TNT in Joules
  230. ==================== =======================================================
  231. Power
  232. -----
  233. ==================== =======================================================
  234. ``hp`` one horsepower in watts
  235. ``horsepower`` one horsepower in watts
  236. ==================== =======================================================
  237. Force
  238. -----
  239. ==================== =======================================================
  240. ``dyn`` one dyne in newtons
  241. ``dyne`` one dyne in newtons
  242. ``lbf`` one pound force in newtons
  243. ``pound_force`` one pound force in newtons
  244. ``kgf`` one kilogram force in newtons
  245. ``kilogram_force`` one kilogram force in newtons
  246. ==================== =======================================================
  247. Optics
  248. ------
  249. .. autosummary::
  250. :toctree: generated/
  251. lambda2nu
  252. nu2lambda
  253. References
  254. ==========
  255. .. [CODATA2018] CODATA Recommended Values of the Fundamental
  256. Physical Constants 2018.
  257. https://physics.nist.gov/cuu/Constants/
  258. """
  259. # Modules contributed by BasSw (wegwerp@gmail.com)
  260. from ._codata import *
  261. from ._constants import *
  262. from ._codata import _obsolete_constants, physical_constants
  263. # Deprecated namespaces, to be removed in v2.0.0
  264. from . import codata, constants
  265. _constant_names_list = [(_k.lower(), _k, _v)
  266. for _k, _v in physical_constants.items()
  267. if _k not in _obsolete_constants]
  268. _constant_names = "\n".join(["``%s``%s %s %s" % (_x[1], " "*(66-len(_x[1])),
  269. _x[2][0], _x[2][1])
  270. for _x in sorted(_constant_names_list)])
  271. if __doc__:
  272. __doc__ = __doc__ % dict(constant_names=_constant_names)
  273. del _constant_names
  274. del _constant_names_list
  275. __all__ = [s for s in dir() if not s.startswith('_')]
  276. from scipy._lib._testutils import PytestTester
  277. test = PytestTester(__name__)
  278. del PytestTester