Coverage for /usr/lib/python3/dist-packages/scipy/constants/__init__.py: 100%

14 statements  

« prev     ^ index     » next       coverage.py v7.9.1, created at 2025-06-14 15:55 +0200

1r""" 

2================================== 

3Constants (:mod:`scipy.constants`) 

4================================== 

5 

6.. currentmodule:: scipy.constants 

7 

8Physical and mathematical constants and units. 

9 

10 

11Mathematical constants 

12====================== 

13 

14================ ================================================================= 

15``pi`` Pi 

16``golden`` Golden ratio 

17``golden_ratio`` Golden ratio 

18================ ================================================================= 

19 

20 

21Physical constants 

22================== 

23 

24=========================== ================================================================= 

25``c`` speed of light in vacuum 

26``speed_of_light`` speed of light in vacuum 

27``mu_0`` the magnetic constant :math:`\mu_0` 

28``epsilon_0`` the electric constant (vacuum permittivity), :math:`\epsilon_0` 

29``h`` the Planck constant :math:`h` 

30``Planck`` the Planck constant :math:`h` 

31``hbar`` :math:`\hbar = h/(2\pi)` 

32``G`` Newtonian constant of gravitation 

33``gravitational_constant`` Newtonian constant of gravitation 

34``g`` standard acceleration of gravity 

35``e`` elementary charge 

36``elementary_charge`` elementary charge 

37``R`` molar gas constant 

38``gas_constant`` molar gas constant 

39``alpha`` fine-structure constant 

40``fine_structure`` fine-structure constant 

41``N_A`` Avogadro constant 

42``Avogadro`` Avogadro constant 

43``k`` Boltzmann constant 

44``Boltzmann`` Boltzmann constant 

45``sigma`` Stefan-Boltzmann constant :math:`\sigma` 

46``Stefan_Boltzmann`` Stefan-Boltzmann constant :math:`\sigma` 

47``Wien`` Wien displacement law constant 

48``Rydberg`` Rydberg constant 

49``m_e`` electron mass 

50``electron_mass`` electron mass 

51``m_p`` proton mass 

52``proton_mass`` proton mass 

53``m_n`` neutron mass 

54``neutron_mass`` neutron mass 

55=========================== ================================================================= 

56 

57 

58Constants database 

59------------------ 

60 

61In addition to the above variables, :mod:`scipy.constants` also contains the 

622018 CODATA recommended values [CODATA2018]_ database containing more physical 

63constants. 

64 

65.. autosummary:: 

66 :toctree: generated/ 

67 

68 value -- Value in physical_constants indexed by key 

69 unit -- Unit in physical_constants indexed by key 

70 precision -- Relative precision in physical_constants indexed by key 

71 find -- Return list of physical_constant keys with a given string 

72 ConstantWarning -- Constant sought not in newest CODATA data set 

73 

74.. data:: physical_constants 

75 

76 Dictionary of physical constants, of the format 

77 ``physical_constants[name] = (value, unit, uncertainty)``. 

78 

79Available constants: 

80 

81====================================================================== ==== 

82%(constant_names)s 

83====================================================================== ==== 

84 

85 

86Units 

87===== 

88 

89SI prefixes 

90----------- 

91 

92============ ================================================================= 

93``quetta`` :math:`10^{30}` 

94``ronna`` :math:`10^{27}` 

95``yotta`` :math:`10^{24}` 

96``zetta`` :math:`10^{21}` 

97``exa`` :math:`10^{18}` 

98``peta`` :math:`10^{15}` 

99``tera`` :math:`10^{12}` 

100``giga`` :math:`10^{9}` 

101``mega`` :math:`10^{6}` 

102``kilo`` :math:`10^{3}` 

103``hecto`` :math:`10^{2}` 

104``deka`` :math:`10^{1}` 

105``deci`` :math:`10^{-1}` 

106``centi`` :math:`10^{-2}` 

107``milli`` :math:`10^{-3}` 

108``micro`` :math:`10^{-6}` 

109``nano`` :math:`10^{-9}` 

110``pico`` :math:`10^{-12}` 

111``femto`` :math:`10^{-15}` 

112``atto`` :math:`10^{-18}` 

113``zepto`` :math:`10^{-21}` 

114``yocto`` :math:`10^{-24}` 

115``ronto`` :math:`10^{-27}` 

116``quecto`` :math:`10^{-30}` 

117============ ================================================================= 

118 

119Binary prefixes 

120--------------- 

121 

122============ ================================================================= 

123``kibi`` :math:`2^{10}` 

124``mebi`` :math:`2^{20}` 

125``gibi`` :math:`2^{30}` 

126``tebi`` :math:`2^{40}` 

127``pebi`` :math:`2^{50}` 

128``exbi`` :math:`2^{60}` 

129``zebi`` :math:`2^{70}` 

130``yobi`` :math:`2^{80}` 

131============ ================================================================= 

132 

133Mass 

134---- 

135 

136================= ============================================================ 

137``gram`` :math:`10^{-3}` kg 

138``metric_ton`` :math:`10^{3}` kg 

139``grain`` one grain in kg 

140``lb`` one pound (avoirdupous) in kg 

141``pound`` one pound (avoirdupous) in kg 

142``blob`` one inch version of a slug in kg (added in 1.0.0) 

143``slinch`` one inch version of a slug in kg (added in 1.0.0) 

144``slug`` one slug in kg (added in 1.0.0) 

145``oz`` one ounce in kg 

146``ounce`` one ounce in kg 

147``stone`` one stone in kg 

148``grain`` one grain in kg 

149``long_ton`` one long ton in kg 

150``short_ton`` one short ton in kg 

151``troy_ounce`` one Troy ounce in kg 

152``troy_pound`` one Troy pound in kg 

153``carat`` one carat in kg 

154``m_u`` atomic mass constant (in kg) 

155``u`` atomic mass constant (in kg) 

156``atomic_mass`` atomic mass constant (in kg) 

157================= ============================================================ 

158 

159Angle 

160----- 

161 

162================= ============================================================ 

163``degree`` degree in radians 

164``arcmin`` arc minute in radians 

165``arcminute`` arc minute in radians 

166``arcsec`` arc second in radians 

167``arcsecond`` arc second in radians 

168================= ============================================================ 

169 

170 

171Time 

172---- 

173 

174================= ============================================================ 

175``minute`` one minute in seconds 

176``hour`` one hour in seconds 

177``day`` one day in seconds 

178``week`` one week in seconds 

179``year`` one year (365 days) in seconds 

180``Julian_year`` one Julian year (365.25 days) in seconds 

181================= ============================================================ 

182 

183 

184Length 

185------ 

186 

187===================== ============================================================ 

188``inch`` one inch in meters 

189``foot`` one foot in meters 

190``yard`` one yard in meters 

191``mile`` one mile in meters 

192``mil`` one mil in meters 

193``pt`` one point in meters 

194``point`` one point in meters 

195``survey_foot`` one survey foot in meters 

196``survey_mile`` one survey mile in meters 

197``nautical_mile`` one nautical mile in meters 

198``fermi`` one Fermi in meters 

199``angstrom`` one Angstrom in meters 

200``micron`` one micron in meters 

201``au`` one astronomical unit in meters 

202``astronomical_unit`` one astronomical unit in meters 

203``light_year`` one light year in meters 

204``parsec`` one parsec in meters 

205===================== ============================================================ 

206 

207Pressure 

208-------- 

209 

210================= ============================================================ 

211``atm`` standard atmosphere in pascals 

212``atmosphere`` standard atmosphere in pascals 

213``bar`` one bar in pascals 

214``torr`` one torr (mmHg) in pascals 

215``mmHg`` one torr (mmHg) in pascals 

216``psi`` one psi in pascals 

217================= ============================================================ 

218 

219Area 

220---- 

221 

222================= ============================================================ 

223``hectare`` one hectare in square meters 

224``acre`` one acre in square meters 

225================= ============================================================ 

226 

227 

228Volume 

229------ 

230 

231=================== ======================================================== 

232``liter`` one liter in cubic meters 

233``litre`` one liter in cubic meters 

234``gallon`` one gallon (US) in cubic meters 

235``gallon_US`` one gallon (US) in cubic meters 

236``gallon_imp`` one gallon (UK) in cubic meters 

237``fluid_ounce`` one fluid ounce (US) in cubic meters 

238``fluid_ounce_US`` one fluid ounce (US) in cubic meters 

239``fluid_ounce_imp`` one fluid ounce (UK) in cubic meters 

240``bbl`` one barrel in cubic meters 

241``barrel`` one barrel in cubic meters 

242=================== ======================================================== 

243 

244Speed 

245----- 

246 

247================== ========================================================== 

248``kmh`` kilometers per hour in meters per second 

249``mph`` miles per hour in meters per second 

250``mach`` one Mach (approx., at 15 C, 1 atm) in meters per second 

251``speed_of_sound`` one Mach (approx., at 15 C, 1 atm) in meters per second 

252``knot`` one knot in meters per second 

253================== ========================================================== 

254 

255 

256Temperature 

257----------- 

258 

259===================== ======================================================= 

260``zero_Celsius`` zero of Celsius scale in Kelvin 

261``degree_Fahrenheit`` one Fahrenheit (only differences) in Kelvins 

262===================== ======================================================= 

263 

264.. autosummary:: 

265 :toctree: generated/ 

266 

267 convert_temperature 

268 

269Energy 

270------ 

271 

272==================== ======================================================= 

273``eV`` one electron volt in Joules 

274``electron_volt`` one electron volt in Joules 

275``calorie`` one calorie (thermochemical) in Joules 

276``calorie_th`` one calorie (thermochemical) in Joules 

277``calorie_IT`` one calorie (International Steam Table calorie, 1956) in Joules 

278``erg`` one erg in Joules 

279``Btu`` one British thermal unit (International Steam Table) in Joules 

280``Btu_IT`` one British thermal unit (International Steam Table) in Joules 

281``Btu_th`` one British thermal unit (thermochemical) in Joules 

282``ton_TNT`` one ton of TNT in Joules 

283==================== ======================================================= 

284 

285Power 

286----- 

287 

288==================== ======================================================= 

289``hp`` one horsepower in watts 

290``horsepower`` one horsepower in watts 

291==================== ======================================================= 

292 

293Force 

294----- 

295 

296==================== ======================================================= 

297``dyn`` one dyne in newtons 

298``dyne`` one dyne in newtons 

299``lbf`` one pound force in newtons 

300``pound_force`` one pound force in newtons 

301``kgf`` one kilogram force in newtons 

302``kilogram_force`` one kilogram force in newtons 

303==================== ======================================================= 

304 

305Optics 

306------ 

307 

308.. autosummary:: 

309 :toctree: generated/ 

310 

311 lambda2nu 

312 nu2lambda 

313 

314References 

315========== 

316 

317.. [CODATA2018] CODATA Recommended Values of the Fundamental 

318 Physical Constants 2018. 

319 

320 https://physics.nist.gov/cuu/Constants/ 

321 

322""" 

323# Modules contributed by BasSw (wegwerp@gmail.com) 

324from ._codata import * 

325from ._constants import * 

326from ._codata import _obsolete_constants, physical_constants 

327 

328# Deprecated namespaces, to be removed in v2.0.0 

329from . import codata, constants 

330 

331_constant_names_list = [(_k.lower(), _k, _v) 

332 for _k, _v in physical_constants.items() 

333 if _k not in _obsolete_constants] 

334_constant_names = "\n".join(["``{}``{} {} {}".format(_x[1], " "*(66-len(_x[1])), 

335 _x[2][0], _x[2][1]) 

336 for _x in sorted(_constant_names_list)]) 

337if __doc__: 

338 __doc__ = __doc__ % dict(constant_names=_constant_names) 

339 

340del _constant_names 

341del _constant_names_list 

342 

343__all__ = [s for s in dir() if not s.startswith('_')] 

344 

345from scipy._lib._testutils import PytestTester 

346test = PytestTester(__name__) 

347del PytestTester