__init__.py 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  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. 2014 CODATA recommended values [CODATA2014]_ 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. ============ =================================================================
  92. Binary prefixes
  93. ---------------
  94. ============ =================================================================
  95. ``kibi`` :math:`2^{10}`
  96. ``mebi`` :math:`2^{20}`
  97. ``gibi`` :math:`2^{30}`
  98. ``tebi`` :math:`2^{40}`
  99. ``pebi`` :math:`2^{50}`
  100. ``exbi`` :math:`2^{60}`
  101. ``zebi`` :math:`2^{70}`
  102. ``yobi`` :math:`2^{80}`
  103. ============ =================================================================
  104. Mass
  105. ----
  106. ================= ============================================================
  107. ``gram`` :math:`10^{-3}` kg
  108. ``metric_ton`` :math:`10^{3}` kg
  109. ``grain`` one grain in kg
  110. ``lb`` one pound (avoirdupous) in kg
  111. ``pound`` one pound (avoirdupous) in kg
  112. ``blob`` one inch version of a slug in kg (added in 1.0.0)
  113. ``slinch`` one inch version of a slug in kg (added in 1.0.0)
  114. ``slug`` one slug in kg (added in 1.0.0)
  115. ``oz`` one ounce in kg
  116. ``ounce`` one ounce in kg
  117. ``stone`` one stone in kg
  118. ``grain`` one grain in kg
  119. ``long_ton`` one long ton in kg
  120. ``short_ton`` one short ton in kg
  121. ``troy_ounce`` one Troy ounce in kg
  122. ``troy_pound`` one Troy pound in kg
  123. ``carat`` one carat in kg
  124. ``m_u`` atomic mass constant (in kg)
  125. ``u`` atomic mass constant (in kg)
  126. ``atomic_mass`` atomic mass constant (in kg)
  127. ================= ============================================================
  128. Angle
  129. -----
  130. ================= ============================================================
  131. ``degree`` degree in radians
  132. ``arcmin`` arc minute in radians
  133. ``arcminute`` arc minute in radians
  134. ``arcsec`` arc second in radians
  135. ``arcsecond`` arc second in radians
  136. ================= ============================================================
  137. Time
  138. ----
  139. ================= ============================================================
  140. ``minute`` one minute in seconds
  141. ``hour`` one hour in seconds
  142. ``day`` one day in seconds
  143. ``week`` one week in seconds
  144. ``year`` one year (365 days) in seconds
  145. ``Julian_year`` one Julian year (365.25 days) in seconds
  146. ================= ============================================================
  147. Length
  148. ------
  149. ===================== ============================================================
  150. ``inch`` one inch in meters
  151. ``foot`` one foot in meters
  152. ``yard`` one yard in meters
  153. ``mile`` one mile in meters
  154. ``mil`` one mil in meters
  155. ``pt`` one point in meters
  156. ``point`` one point in meters
  157. ``survey_foot`` one survey foot in meters
  158. ``survey_mile`` one survey mile in meters
  159. ``nautical_mile`` one nautical mile in meters
  160. ``fermi`` one Fermi in meters
  161. ``angstrom`` one Angstrom in meters
  162. ``micron`` one micron in meters
  163. ``au`` one astronomical unit in meters
  164. ``astronomical_unit`` one astronomical unit in meters
  165. ``light_year`` one light year in meters
  166. ``parsec`` one parsec in meters
  167. ===================== ============================================================
  168. Pressure
  169. --------
  170. ================= ============================================================
  171. ``atm`` standard atmosphere in pascals
  172. ``atmosphere`` standard atmosphere in pascals
  173. ``bar`` one bar in pascals
  174. ``torr`` one torr (mmHg) in pascals
  175. ``mmHg`` one torr (mmHg) in pascals
  176. ``psi`` one psi in pascals
  177. ================= ============================================================
  178. Area
  179. ----
  180. ================= ============================================================
  181. ``hectare`` one hectare in square meters
  182. ``acre`` one acre in square meters
  183. ================= ============================================================
  184. Volume
  185. ------
  186. =================== ========================================================
  187. ``liter`` one liter in cubic meters
  188. ``litre`` one liter in cubic meters
  189. ``gallon`` one gallon (US) in cubic meters
  190. ``gallon_US`` one gallon (US) in cubic meters
  191. ``gallon_imp`` one gallon (UK) in cubic meters
  192. ``fluid_ounce`` one fluid ounce (US) in cubic meters
  193. ``fluid_ounce_US`` one fluid ounce (US) in cubic meters
  194. ``fluid_ounce_imp`` one fluid ounce (UK) in cubic meters
  195. ``bbl`` one barrel in cubic meters
  196. ``barrel`` one barrel in cubic meters
  197. =================== ========================================================
  198. Speed
  199. -----
  200. ================== ==========================================================
  201. ``kmh`` kilometers per hour in meters per second
  202. ``mph`` miles per hour in meters per second
  203. ``mach`` one Mach (approx., at 15 C, 1 atm) in meters per second
  204. ``speed_of_sound`` one Mach (approx., at 15 C, 1 atm) in meters per second
  205. ``knot`` one knot in meters per second
  206. ================== ==========================================================
  207. Temperature
  208. -----------
  209. ===================== =======================================================
  210. ``zero_Celsius`` zero of Celsius scale in Kelvin
  211. ``degree_Fahrenheit`` one Fahrenheit (only differences) in Kelvins
  212. ===================== =======================================================
  213. .. autosummary::
  214. :toctree: generated/
  215. convert_temperature
  216. Energy
  217. ------
  218. ==================== =======================================================
  219. ``eV`` one electron volt in Joules
  220. ``electron_volt`` one electron volt in Joules
  221. ``calorie`` one calorie (thermochemical) in Joules
  222. ``calorie_th`` one calorie (thermochemical) in Joules
  223. ``calorie_IT`` one calorie (International Steam Table calorie, 1956) in Joules
  224. ``erg`` one erg in Joules
  225. ``Btu`` one British thermal unit (International Steam Table) in Joules
  226. ``Btu_IT`` one British thermal unit (International Steam Table) in Joules
  227. ``Btu_th`` one British thermal unit (thermochemical) in Joules
  228. ``ton_TNT`` one ton of TNT in Joules
  229. ==================== =======================================================
  230. Power
  231. -----
  232. ==================== =======================================================
  233. ``hp`` one horsepower in watts
  234. ``horsepower`` one horsepower in watts
  235. ==================== =======================================================
  236. Force
  237. -----
  238. ==================== =======================================================
  239. ``dyn`` one dyne in newtons
  240. ``dyne`` one dyne in newtons
  241. ``lbf`` one pound force in newtons
  242. ``pound_force`` one pound force in newtons
  243. ``kgf`` one kilogram force in newtons
  244. ``kilogram_force`` one kilogram force in newtons
  245. ==================== =======================================================
  246. Optics
  247. ------
  248. .. autosummary::
  249. :toctree: generated/
  250. lambda2nu
  251. nu2lambda
  252. References
  253. ==========
  254. .. [CODATA2014] CODATA Recommended Values of the Fundamental
  255. Physical Constants 2014.
  256. https://physics.nist.gov/cuu/Constants/
  257. """
  258. from __future__ import division, print_function, absolute_import
  259. # Modules contributed by BasSw (wegwerp@gmail.com)
  260. from .codata import *
  261. from .constants import *
  262. from .codata import _obsolete_constants
  263. _constant_names = [(_k.lower(), _k, _v)
  264. for _k, _v in physical_constants.items()
  265. if _k not in _obsolete_constants]
  266. _constant_names = "\n".join(["``%s``%s %s %s" % (_x[1], " "*(66-len(_x[1])),
  267. _x[2][0], _x[2][1])
  268. for _x in sorted(_constant_names)])
  269. if __doc__ is not None:
  270. __doc__ = __doc__ % dict(constant_names=_constant_names)
  271. del _constant_names
  272. __all__ = [s for s in dir() if not s.startswith('_')]
  273. from scipy._lib._testutils import PytestTester
  274. test = PytestTester(__name__)
  275. del PytestTester