本文整理匯總了Python中scipy.constants.h方法的典型用法代碼示例。如果您正苦於以下問題:Python constants.h方法的具體用法?Python constants.h怎麽用?Python constants.h使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類scipy.constants
的用法示例。
在下文中一共展示了constants.h方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: population
# 需要導入模塊: from scipy import constants [as 別名]
# 或者: from scipy.constants import h [as 別名]
def population(self, Mole, Temp):
"""Calculate population for each level at given temperature"""
RoTemp = np.reshape(Temp*1., (Temp.size, 1))
Qr = self.weighti*np.exp(-(self.e_cm1*100*c*h)/(k*RoTemp))
# RoPr = Qr/Ntotal # This is for all transitions
RoPr = Qr/(Qr.sum(axis=1).reshape(RoTemp.size, 1)) # only given trans.
linet = []
for xx in range(self.nt):
gdu, gdl = self.weighti[self.tran_tag[xx][1:].astype(int)]
_up = int(self.tran_tag[xx][1])
_low = int(self.tran_tag[xx][2])
Aei = self.ai[_up, _low]
line_const = (c*10**2)**2*Aei*(gdu/gdl)*1.e-6*1.e14 /\
(8.*np.pi*(self.freq_array[xx]*1.e9)**2)
# Hz->MHz,cm^2 ->nm^2
# W = C.h*C.c*E_cm1[_low]*100. # energy level above ground state
"This is the function of calculating H2O intensity"
line = (1.-np.exp(-h*(self.freq_array[xx]*1.e9) /
k/RoTemp))*line_const
linet.append(line[:, 0]*RoPr[:, _low]) # line intensity non-LTE
Ni_LTE = Mole.reshape((Mole.size, 1))*RoPr # *0.75 # orth para ratio
Ite_pop = [[Ni_LTE[i].reshape((self.ni, 1))] for i in range(Mole.size)]
return Ite_pop
#import numba
示例2: test_tlcorrection
# 需要導入模塊: from scipy import constants [as 別名]
# 或者: from scipy.constants import h [as 別名]
def test_tlcorrection(self):
# testing long correction function
x_for_long = np.array([20.,21.,22.,23.,24.,25.])
y_for_long = np.array([1.0,1.0,1.0,1.0,1.0,1.0])
nu0 = 1.0/(514.532)*1e9 #laser wavenumber at 514.532
nu = 100.0*x_for_long # cm-1 to m-1
T = 23.0+273.15 # the temperature in K
x_long,long_res,eselong = rp.tlcorrection(x_for_long, y_for_long,23.0,514.532,correction = 'long',normalisation='area') # using the function
t0 = nu0**3.0*nu/((nu0-nu)**4)
t1= 1.0 - np.exp(-h*c*nu/(k*T)) # c in m/s : t1 dimensionless
long_calc= y_for_long*t0*t1 # pour les y
long_calc = long_calc/np.trapz(long_calc,x_for_long) # area normalisation
np.testing.assert_equal(long_res,long_calc)
np.testing.assert_equal(x_for_long,x_long)
x_long,long_res,eselong = rp.tlcorrection(x_for_long, y_for_long,23.0,514.532,correction = 'long',normalisation='no') # using the function
t0 = nu0**3.0*nu/((nu0-nu)**4)
t1= 1.0 - np.exp(-h*c*nu/(k*T)) # c in m/s : t1 dimensionless
long_calc= y_for_long*t0*t1 # pour les y
np.testing.assert_equal(long_res,long_calc)
np.testing.assert_equal(x_for_long,x_long)
示例3: Responsivity
# 需要導入模塊: from scipy import constants [as 別名]
# 或者: from scipy.constants import h [as 別名]
def Responsivity(wavelength, quantumEffic):
"""
Responsivity quantifies the amount of output seen per watt of radiant
optical power input [1]. But, for this application it is interesting to
define spectral responsivity that is the output per watt of monochromatic
radiation.
The model used here is based on Equations 7.114 in Dereniak's book.
Args:
| wavelength: spectral variable [m]
| quantumEffic: spectral quantum efficiency
Returns:
| responsivity in [A/W]
"""
return (const.e * wavelength * quantumEffic) / (const.h * const.c)
################################################################################
#
示例4: plotSpectre
# 需要導入模塊: from scipy import constants [as 別名]
# 或者: from scipy.constants import h [as 別名]
def plotSpectre(transitions, eneval, spectre):
""" plot the UV-visible spectrum using matplotlib. Absissa are converted in nm. """
# lambda in nm
lambdaval = [cst.h * cst.c / (val * cst.e) * 1.e9 for val in eneval]
# plot gaussian spectra
plt.plot(lambdaval, spectre, "r-", label = "spectre")
# plot transitions
plt.vlines([val[1] for val in transitions], \
0., \
[val[2] for val in transitions], \
color = "blue", \
label = "transitions" )
plt.xlabel("lambda / nm")
plt.ylabel("Arbitrary unit")
plt.title("UV-visible spectra")
plt.grid()
plt.legend(fancybox = True, shadow = True)
plt.show()
示例5: get_electron_wavelength
# 需要導入模塊: from scipy import constants [as 別名]
# 或者: from scipy.constants import h [as 別名]
def get_electron_wavelength(accelerating_voltage):
"""Calculates the (relativistic) electron wavelength in Angstroms for a
given accelerating voltage in kV.
Parameters
----------
accelerating_voltage : float or 'inf'
The accelerating voltage in kV. Values `numpy.inf` and 'inf' are
also accepted.
Returns
-------
wavelength : float
The relativistic electron wavelength in Angstroms.
"""
if accelerating_voltage in (np.inf, "inf"):
return 0
E = accelerating_voltage * 1e3
wavelength = (
h / math.sqrt(2 * m_e * e * E * (1 + (e / (2 * m_e * c * c)) * E)) * 1e10
)
return wavelength
示例6: PopuSource
# 需要導入模塊: from scipy import constants [as 別名]
# 或者: from scipy.constants import h [as 別名]
def PopuSource(LowerPop, UpperPop, LowerDeg, UpperDeg, Freq_c):
sij = (2.*h*Freq_c**3)/(c**2*(LowerPop*UpperDeg/UpperPop/LowerDeg-1.))
return sij
示例7: Bv_T
# 需要導入模塊: from scipy import constants [as 別名]
# 或者: from scipy.constants import h [as 別名]
def Bv_T(Freq, T):
# brbr = 1 # .e7*1.e-4
Bv_out = 2.*h*Freq**3/c**2/(np.exp(h*Freq/k/T)-1.)
return Bv_out
示例8: basic
# 需要導入模塊: from scipy import constants [as 別名]
# 或者: from scipy.constants import h [as 別名]
def basic(LowerPop, UpperPop, Blu, Bul, Freq):
u"""
calculate absorption coefficient.\n
Freq should be Hz
"""
_const = h*Freq/4./np.pi
return (LowerPop*Blu - UpperPop*Bul)*_const
示例9: calc_abscoeff
# 需要導入模塊: from scipy import constants [as 別名]
# 或者: from scipy.constants import h [as 別名]
def calc_abscoeff(tran, itera, alt=None):
_up, _low = Tran_tag[tran][1:].astype(int)
_v0 = Freqi[_up, _low]*1.e9
_const = C.h*_v0/4./N.pi
if alt is None:
lowerPop = N.array(Ite_pop)[alt][itera][_low][0]
upperPop = N.array(Ite_pop)[alt][itera][_up][0]
else:
lowerPop = N.array(Ite_pop)[:, itera, _low, 0]
upperPop = N.array(Ite_pop)[:, itera, _up, 0]
BLU = Blu[_up, _low]
BUL = Bul[_up, _low]
# AUL = Ai[_up, _low]
return (lowerPop*BLU - upperPop*BUL)*_const
示例10: test_twomode
# 需要導入模塊: from scipy import constants [as 別名]
# 或者: from scipy.constants import h [as 別名]
def test_twomode(self):
"""Test if function returns two-mode squeezing parameters that correctly reconstruct the
input normal mode frequencies."""
w = -k * self.T / (0.5 * h * c * 100) * np.log(np.tanh(self.t))
assert np.allclose(w, self.w)
示例11: planck
# 需要導入模塊: from scipy import constants [as 別名]
# 或者: from scipy.constants import h [as 別名]
def planck(lam, T):
""" Returns the spectral radiance of a black body at temperature T.
Returns the spectral radiance, B(lam, T), in W.sr-1.m-2 of a black body
at temperature T (in K) at a wavelength lam (in nm), using Planck's law.
"""
lam_m = lam / 1.e9
fac = h*c/lam_m/k/T
B = 2*h*c**2/lam_m**5 / (np.exp(fac) - 1)
return B
示例12: Absorption
# 需要導入模塊: from scipy import constants [as 別名]
# 或者: from scipy.constants import h [as 別名]
def Absorption(wavelength, Eg, tempDet, a0, a0p):
"""
Calculate the spectral absorption coefficient
for a semiconductor material with given material values.
The model used here is based on Equations 3.5, 3.6 in Dereniaks book.
Args:
| wavelength: spectral variable [m]
| Eg: bandgap energy [Ev]
| tempDet: detector's temperature in [K]
| a0: absorption coefficient [m-1] (Dereniak Eq 3.5 & 3.6)
| a0p: absorption coefficient in [m-1] (Dereniak Eq 3.5 & 3.6)
Returns:
| absorption: spectral absorption coefficient in [m-1]
"""
#frequency/wavelength expressed as energy in Ev
E = const.h * const.c / (wavelength * const.e )
# the np.abs() in the following code is to prevent nan and inf values
# the effect of the abs() is corrected further down when we select
# only the appropriate values based on E >= Eg and E < Eg
# Absorption coef - eq. 3.5- Dereniak
a35 = (a0 * np.sqrt(np.abs(E - Eg))) + a0p
# Absorption coef - eq. 3.6- Dereniak
a36 = a0p * np.exp((- np.abs(E - Eg)) / (const.k * tempDet))
absorption = a35 * (E >= Eg) + a36 * (E < Eg)
return absorption
################################################################################
#
示例13: deeStarPeak
# 需要導入模塊: from scipy import constants [as 別名]
# 或者: from scipy.constants import h [as 別名]
def deeStarPeak(wavelength,temperature,eta,halfApexAngle):
i = 0
for wlc in wavelength:
wl = np.linspace(wlc/100, wlc, 1000).reshape(-1, 1)
LbackLambda = ryplanck.planck(wl,temperature, type='ql')/np.pi
Lback = np.trapz(LbackLambda.reshape(-1, 1),wl, axis=0)[0]
Eback = Lback * np.pi * (np.sin(halfApexAngle)) ** 2
# funny construct is to prevent divide by zero
tempvar = np.sqrt(eta/(Eback+(Eback==0))) * (Eback!=0) + 0 * (Eback==0)
dstarwlc[i] = 1e-6 * wlc * tempvar/(const.h * const.c * np.sqrt(2))
#print(Eback)
i = i + 1
return dstarwlc * 100. # to get cm units
示例14: __init__
# 需要導入模塊: from scipy import constants [as 別名]
# 或者: from scipy.constants import h [as 別名]
def __init__(self):
""" Precalculate the Planck function constants.
Reference: http://www.spectralcalc.com/blackbody/appendixC.html
"""
import scipy.optimize
self.c1em = 2 * np.pi * const.h * const.c * const.c
self.c1el = self.c1em * (1.0e6)**(5-1) # 5 for lambda power and -1 for density
self.c1en = self.c1em * (100)**3 * 100 # 3 for wavenumber, 1 for density
self.c1ef = 2 * np.pi * const.h / (const.c * const.c)
self.c1qm = 2 * np.pi * const.c
self.c1ql = self.c1qm * (1.0e6)**(4-1) # 5 for lambda power and -1 for density
self.c1qn = self.c1qm * (100)**2 * 100 # 2 for wavenumber, 1 for density
self.c1nf = 2 * np.pi / (const.c * const.c)
self.c2m = const.h * const.c / const.k
self.c2l = self.c2m * 1.0e6 # 1 for wavelength density
self.c2n = self.c2m * 1.0e2 # 1 for cm-1 density
self.c2f = const.h / const.k
self.sigmae = const.sigma
self.zeta3 = 1.2020569031595942853
self.sigmaq = 4 * np.pi * self.zeta3 * const.k ** 3 \
/ (const.h ** 3 * const.c ** 2)
self.a2 = scipy.optimize.brentq(self.an, 1, 2, (2) )
self.a3 = scipy.optimize.brentq(self.an, 2, 3, (3) )
self.a4 = scipy.optimize.brentq(self.an, 3.5, 4, (4) )
self.a5 = scipy.optimize.brentq(self.an, 4.5, 5, (5) )
self.wel = 1e6 * const.h * const.c /(const.k * self.a5)
self.wql = 1e6 * const.h * const.c /(const.k * self.a4)
self.wen = self.a3 * const.k /(100 * const.h * const.c )
self.wqn = self.a2 * const.k /(100 * const.h * const.c )
self.wef = self.a3 * const.k /(const.h )
self.wqf = self.a2 * const.k /(const.h )
示例15: calcLuxEquivalent
# 需要導入模塊: from scipy import constants [as 別名]
# 或者: from scipy.constants import h [as 別名]
def calcLuxEquivalent(wavelength,rad_min,rad_dynrange,units):
"""Calc the interpolation function between lux and photon rate radiance
Assuming single wavelength colour, the specified wavelength value is used to
calculate the lux equivalent lux image for the radiance input range.
Args:
| wavelength (np.array): wavelength vector
| sysresp (np.array): system response spectral vector
| rad_min (float): minimum photon rate radiance lookup table
| rad_dynrange (float): maximum photon rate radiance in lookup table
| units (string): input radiance units q/s or W
Returns:
| interpolation function
Raises:
| No exception is raised.
Author: CJ Willers
"""
if 'q' in units:
conversion = wavelength / (const.h * const.c)
else:
conversion = 1.
Wm2tolux = 683 * 1.019 * np.exp(-285.51 * (wavelength*1e6 - 0.5591)**2)
# convert from q/s to W
rad_minW = rad_min / conversion
rad_dynrangeW = rad_dynrange / conversion
radW = np.linspace(0.99*rad_minW, 1.01*(rad_minW+rad_dynrangeW), 1000)
lux = Wm2tolux * radW
# convert from W back to q/s when setting up the function
fintp = interpolate.interp1d((radW*wavelength / (const.h * const.c)).reshape(-1), lux.reshape(-1))
return fintp
################################################################
################################################################
##