__init__.py 14 KB

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