本文整理汇总了Python中numpy.log10函数的典型用法代码示例。如果您正苦于以下问题:Python log10函数的具体用法?Python log10怎么用?Python log10使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了log10函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_mean_and_stddevs
def get_mean_and_stddevs(self, sites, rup, dists, imt, stddev_types):
"""
See :meth:`superclass method
<.base.GroundShakingIntensityModel.get_mean_and_stddevs>`
for spec of input and result values.
"""
# Distance term
R = np.sqrt(dists.rjb ** 2 + 11.29 ** 2)
# Magnitude term
M = rup.mag - 6
# Site term only distinguishes between lava and ash;
# since ash sites have Vs30 in the range 60-200m/s,
# we use this upper value as class separator
S = np.zeros(R.shape)
S[sites.vs30 <= 200] = 1
# Mean ground motion (log10)
mean = (0.518 + 0.387*M - np.log10(R) - 0.00256*R + 0.335*S)
# Converting to natural log
mean /= np.log10(np.e)
# Check for standard deviation type
assert all(stddev_type in self.DEFINED_FOR_STANDARD_DEVIATION_TYPES
for stddev_type in stddev_types)
# Constant (total) standard deviation
stddevs = [0.237/np.log10(np.e) + np.zeros(R.shape)]
return mean, stddevs
开发者ID:digitalsatori,项目名称:oq-engine,代码行数:33,代码来源:munson_thurber_1997.py
示例2: cd_sphere_vector
def cd_sphere_vector(Re):
"Computes the drag coefficient of a sphere as a function of the Reynolds number Re."
# Curve fitted after fig . A -56 in Evett & Liu :% " Fluid Mechanics & Hydraulics ",
# Schaum ' s Solved Problems McGraw - Hill 1989.
from numpy import log10,array,polyval
CD = zeros_like(Re)
CD = where(Re<0,0.0,0.0) # condition 1
CD = where((Re > 0.0) & (Re <=0.5),24/Re,CD) # condition 2
p = array([4.22,-14.05,34.87,0.658])
CD = where((Re > 0.5) & (Re <=100.0),polyval(p,1.0/Re),CD) #condition 3
p = array([-30.41,43.72,-17.08,2.41])
CD = where((Re >100.0) & (Re <=1.0e4) ,polyval(p,1.0/log10(Re)),CD) #condition 4
p = array([-0.1584,2.031,-8.472,11.932])
CD = where((Re > 1.0e4) & (Re <=3.35e5),polyval(p,log10(Re)),CD) #condition 5
CD = where((Re > 3.35e5) & (Re <=5.0e5),91.08*(log10(Re/4.5e5))**4 + 0.0764,CD) #condition 6
p = array([-0.06338,1.1905,-7.332,14.93])
CD = where((Re > 5.05e5) & (Re <=8.0e6),polyval(p,log10(Re)),CD) #condition 7
CD = where(Re>8.0e6,0.2,CD) # condition 8
return CD
开发者ID:lrhgit,项目名称:tkt4140,代码行数:29,代码来源:DragCoefficient.py
示例3: compute_angular_momentum_transfer
def compute_angular_momentum_transfer(snapshot, Rmin, Rmax, NR = None, Nphi = None, alpha=0.1, h0=0.1):
"""
Compute the angular momentum transfer as a function of
radius from a simulation snapshot and a prescribed grid
data structure containing the coordinates of grid points
where the torque balance should be evaluated.
"""
if (NR is None):
NR = 512
if (Nphi is None):
Nphi = int(2 * np.pi / (10**((np.log10(Rmax) - np.log10(Rmin))/NR) - 1))
# Create a polar grid
grid = grid_polar(NR = NR, Nphi = Nphi, Rmin= Rmin,Rmax = Rmax,scale='log')
mdot = mass_advection(snapshot,grid)
torque_adv = angular_momentum_advection(snapshot,grid)
torque_visc = angular_momentum_viscosity(snapshot,grid, alpha = alpha, h0 = h0)
torque_grav = angular_momentum_gravity(snapshot,grid)
return grid.R.mean(axis=0),mdot, torque_adv,torque_visc,torque_grav
开发者ID:djmunoz,项目名称:disk_data_analysis,代码行数:27,代码来源:disk_angular_momentum.py
示例4: __init__
def __init__(self,fname=None,mindx=None,mlist=[],logopt = 0, Lbox=2750., massfxnfname=None):
"""
Read in a list of masses. If logopt==1, then input masses are understood to be logarithmic.
"""
self.Lbox = Lbox
if mlist != []:
if logopt == 0:
self.m = np.array(mlist)
self.lg10m = np.log10(self.m)
else:
self.lg10m = np.array(mlist)
self.m = 10**(self.log10m)
self.lg10mcen, self.Nofm = None, None ## set these later with massfxn.
elif massfxnfname is not None:
self.lg10mcen, self.Nofm = np.loadtxt(massfxnfname,unpack=True,usecols=[0,1])
else:
if 0==0:
# try:
if logopt == 0:
self.m = np.loadtxt(fname,usecols=[mindx],unpack=True)
self.lg10m = np.log10(self.m)
else:
self.lg10m = np.loadtxt(fname,usecols=[mindx],unpack=True)
self.m = 10**(self.lg10m)
self.lg10mcen, self.Nofm = None, None ## set these later with massfxn.
else:
# except:
print 'file read did not work.'
self.m = None
self.lg10m = None
开发者ID:bareid,项目名称:LSSanalysis,代码行数:32,代码来源:sim.py
示例5: get_cs
def get_cs(e_0=100, z=74):
"""
Returns a function representing the scaled bremsstrahlung cross_section.
Args:
e_0 (float): The electron kinetic energy, used to scale u=e_e/e_0.
z (int): Atomic number of the material.
Returns:
A function representing cross_section(e_g,u) in mb/keV, with e_g in keV.
"""
# NOTE: Data is given for E0>1keV. CS values below this level should be used with caution.
# The default behaviour is to keep it constant
with open(os.path.join(data_path, "cs/grid.csv"), 'r') as csvfile:
r = csv.reader(csvfile, delimiter=' ', quotechar='|',
quoting=csv.QUOTE_MINIMAL)
t = next(r)
e_e = np.array([float(a) for a in t[0].split(",")])
log_e_e = np.log10(e_e)
t = next(r)
k = np.array([float(a) for a in t[0].split(",")])
t = []
with open(os.path.join(data_path, "cs/%d.csv" % z), 'r') as csvfile:
r = csv.reader(csvfile, delimiter=' ', quotechar='|',
quoting=csv.QUOTE_MINIMAL)
for row in r:
t.append([float(a) for a in row[0].split(",")])
t = np.array(t)
scaled = interpolate.RectBivariateSpline(log_e_e, k, t, kx=3, ky=1)
m_electron = 511
z2 = z * z
return lambda e_g, u: (u * e_0 + m_electron) ** 2 * z2 / (u * e_0 * e_g * (u * e_0 + 2 * m_electron)) * (
scaled(np.log10(u * e_0), e_g / (u * e_0)))
开发者ID:Dih5,项目名称:xpecgen,代码行数:34,代码来源:xpecgen.py
示例6: plot_hist
def plot_hist(axis, data_list, label_list, logx, logy, overlaid):
"""
"""
if logx:
# Setup the logarithmic scale on the X axis
data_array = np.array(data_list)
vmin = np.log10(data_array.min())
vmax = np.log10(data_array.max())
bins = np.logspace(vmin, vmax, 50) # Make a range from 10**vmin to 10**vmax
else:
bins = 50
if overlaid:
for data_array, label in zip(data_list, label_list):
res_tuple = axis.hist(data_array,
bins=bins,
log=logy, # Set log scale on the Y axis
histtype=HIST_TYPE,
alpha=ALPHA,
label=label)
else:
res_tuple = axis.hist(data_list,
bins=bins,
log=logy, # Set log scale on the Y axis
histtype=HIST_TYPE,
alpha=ALPHA,
label=label_list)
开发者ID:jdhp-sap,项目名称:data-pipeline-standalone-scripts,代码行数:28,代码来源:plot_execution_time_histogram.py
示例7: plotPSD
def plotPSD(self, chan, time_interval):
Npackets = np.int(time_interval * self.accum_freq)
plot_range = (Npackets / 2) + 1
figure = plt.figure(num= None, figsize=(12,12), dpi=80, facecolor='w', edgecolor='w')
# I
plt.suptitle('Channel ' + str(chan) + ' , Freq = ' + str((self.freqs[chan] + self.LO_freq)/1.0e6) + ' MHz')
plot1 = figure.add_subplot(311)
plot1.set_xscale('log')
plot1.set_autoscale_on(True)
plt.ylim((-160,-80))
plt.title('I')
line1, = plot1.plot(np.linspace(0, self.accum_freq/2., (Npackets/2) + 1), np.zeros(plot_range), label = 'I', color = 'green', linewidth = 1)
plt.grid()
# Q
plot2 = figure.add_subplot(312)
plot2.set_xscale('log')
plot2.set_autoscale_on(True)
plt.ylim((-160,-80))
plt.title('Q')
line2, = plot2.plot(np.linspace(0, self.accum_freq/2., (Npackets/2) + 1), np.zeros(plot_range), label = 'Q', color = 'red', linewidth = 1)
plt.grid()
# Phase
plot3 = figure.add_subplot(313)
plot3.set_xscale('log')
plot3.set_autoscale_on(True)
plt.ylim((-120,-70))
#plt.xlim((0.0001, self.accum_freq/2.))
plt.title('Phase')
plt.ylabel('dBc rad^2/Hz')
plt.xlabel('log Hz')
line3, = plot3.plot(np.linspace(0, self.accum_freq/2., (Npackets/2) + 1), np.zeros(plot_range), label = 'Phase', color = 'black', linewidth = 1)
plt.grid()
plt.show(block = False)
count = 0
stop = 1.0e10
while count < stop:
Is, Qs, phases = self.get_stream(chan, time_interval)
I_mags = np.fft.rfft(Is, Npackets)
Q_mags = np.fft.rfft(Is, Npackets)
phase_mags = np.fft.rfft(phases, Npackets)
I_vals = (np.abs(I_mags)**2 * ((1./self.accum_freq)**2 / (1.0*time_interval)))
Q_vals = (np.abs(Q_mags)**2 * ((1./self.accum_freq)**2 / (1.0*time_interval)))
phase_vals = (np.abs(phase_mags)**2 * ((1./self.accum_freq)**2 / (1.0*time_interval)))
phase_vals = 10*np.log10(phase_vals)
phase_vals -= phase_vals[0]
#line1.set_ydata(Is)
#line2.set_ydata(Qs)
#line3.set_ydata(phases)
line1.set_ydata(10*np.log10(I_vals))
line2.set_ydata(10*np.log10(Q_vals))
line3.set_ydata(phase_vals)
plot1.relim()
plot1.autoscale_view(True,True,False)
plot2.relim()
plot2.autoscale_view(True,True,False)
#plot3.relim()
plot3.autoscale_view(True,True,False)
plt.draw()
count +=1
return
开发者ID:braddober,项目名称:blastfirmware,代码行数:60,代码来源:blastfirmware_dirfile.py
示例8: __repr__
def __repr__(self):
pars = ""
if not isinstance(self.parameters, OrderedDict):
keys = sorted(self.parameters.keys()) # to ensure the order is always the same
else:
keys = self.parameters.keys()
for k in keys:
v = self.parameters[k].value
par_fmt = "{}"
post = ""
if hasattr(v, 'unit'):
post = " {}".format(v.unit)
v = v.value
if isinstance(v, float):
if v == 0:
par_fmt = "{:.0f}"
elif np.log10(v) < -2 or np.log10(v) > 5:
par_fmt = "{:.2e}"
else:
par_fmt = "{:.2f}"
elif isinstance(v, int) and np.log10(v) > 5:
par_fmt = "{:.2e}"
pars += ("{}=" + par_fmt + post).format(k, v) + ", "
if isinstance(self.units, DimensionlessUnitSystem):
return "<{}: {} (dimensionless)>".format(self.__class__.__name__, pars.rstrip(", "))
else:
return "<{}: {} ({})>".format(self.__class__.__name__, pars.rstrip(", "), ",".join(map(str, self.units._core_units)))
开发者ID:adrn,项目名称:gala,代码行数:33,代码来源:core.py
示例9: compatibility
def compatibility(par_low, par_high):
"""Quantify spectral compatibility of power-law
measurements in two energy bands.
Reference: 2008ApJ...679.1299F Equation (2)
Compute spectral compatibility parameters for the
situation where two power laws were measured in a low
and a high spectral energy band.
par_low and par_high are the measured parameters,
which must be lists in the following order:
e, f, f_err, g, g_err
where e is the pivot energy, f is the flux density
and g the spectral index
"""
# Unpack power-law paramters
e_high, f_high, f_err_high, g_high, g_err_high = par_high
e_low, f_low, f_err_low, g_low, g_err_low = par_low
log_delta_e = np.log10(e_high) - np.log10(e_low)
log_delta_f = np.log10(f_high) - np.log10(f_low)
# g_match is the index obtained by connecting the two points
# with a power law, i.e. a straight line in the log_e, log_f plot
g_match = -log_delta_f / log_delta_e
# sigma is the number of standar deviations the match index
# is different from the measured index in one band.
# (see Funk et al. (2008ApJ...679.1299F) eqn. 2)
sigma_low = (g_match - g_low) / g_err_low
sigma_high = (g_match - g_high) / g_err_high
sigma_comb = np.sqrt(sigma_low ** 2 + sigma_high ** 2)
return g_match, sigma_low, sigma_high, sigma_comb
开发者ID:keflavich,项目名称:gammapy,代码行数:33,代码来源:powerlaw.py
示例10: _default_response_frequencies
def _default_response_frequencies(A, n):
"""Compute a reasonable set of frequency points for bode plot.
This function is used by `bode` to compute the frequency points (in rad/s)
when the `w` argument to the function is None.
Parameters
----------
A : ndarray
The system matrix, which is square.
n : int
The number of time samples to generate.
Returns
-------
w : ndarray
The 1-D array of length `n` of frequency samples (in rad/s) at which
the response is to be computed.
"""
vals = linalg.eigvals(A)
# Remove poles at 0 because they don't help us determine an interesting
# frequency range. (And if we pass a 0 to log10() below we will crash.)
poles = [pole for pole in vals if pole != 0]
# If there are no non-zero poles, just hardcode something.
if len(poles) == 0:
minpole = 1
maxpole = 1
else:
minpole = min(abs(real(poles)))
maxpole = max(abs(real(poles)))
# A reasonable frequency range is two orders of magnitude before the
# minimum pole (slowest) and two orders of magnitude after the maximum pole
# (fastest).
w = numpy.logspace(numpy.log10(minpole) - 2, numpy.log10(maxpole) + 2, n)
return w
开发者ID:JT5D,项目名称:scipy,代码行数:35,代码来源:ltisys.py
示例11: error_vs_updates
def error_vs_updates(self, output_dir=None):
fig = plt.figure()
ax = fig.add_subplot(111)
ax.scatter(log10(centered(self.w_truth)) - log10(centered(self.medians)), self.updates, c=self.stds, cmap=plt.jet(), s=25, clip_on=False, lw=0.5)
ax.set_xlabel('log10(w_truth)-log10(median w)')
ax.set_ylabel('num updates')
show(fig, output_dir, 'error_vs_updates.png')
开发者ID:gjx,项目名称:phip-stat,代码行数:7,代码来源:gibbs.py
示例12: create_center_frequencies
def create_center_frequencies(stt=180, stp=7000, n_bands=32, kind='log'):
'''
Define center frequencies for spectrograms.
Generally this is for auditory spectrogram extraction. Most auditory
analysis uses 180 - 7000 Hz, so for now those
are the defaults.
Parameters
----------
stt : float | int
The starting frequency
stp : float | int
The end frequency
n_bands : int
The number of bands to calculate
kind : 'log' | 'erb'
Whether to use log or erb spacing
Returns
-------
freqs : array, shape (n_frequencies,)
An array of center frequencies.
'''
if kind == 'log':
freqs = np.logspace(np.log10(stt), np.log10(stp), n_bands).astype(int)
elif kind == 'erb':
freqs = hears.erbspace(stt * Hz, stp * Hz, n_bands)
else:
print("I don't know what kind of spacing that is")
return freqs
开发者ID:kingjr,项目名称:ecogtools,代码行数:31,代码来源:audio.py
示例13: fluence_dist
def fluence_dist(self):
""" Plots the fluence distribution and gives the mean and median fluence
values of the sample """
fluences = []
for i in range(0,len(self.fluences),1):
try:
fluences.append(float(self.fluences[i]))
except ValueError:
continue
fluences = np.array(fluences)
mean_fluence = np.mean(fluences)
median_fluence = np.median(fluences)
print('Mean Fluence =',mean_fluence,'(15-150 keV) [10^-7 erg cm^-2]')
print('Median Fluence =',median_fluence,'(15-150 keV) [10^-7 erg cm^-2]')
plt.figure()
plt.xlabel('Fluence (15-150 keV) [$10^{-7}$ erg cm$^{-2}$]')
plt.ylabel('Number of GRBs')
plt.xscale('log')
minimum, maximum = min(fluences), max(fluences)
plt.axvline(mean_fluence,color='red',linestyle='-')
plt.axvline(median_fluence,color='blue',linestyle='-')
plt.hist(fluences,bins= 10**np.linspace(np.log10(minimum),np.log10(maximum),20),color='grey',alpha=0.5)
plt.show()
开发者ID:jtwm1,项目名称:adampy,代码行数:26,代码来源:swift_functions.py
示例14: t90_dist
def t90_dist(self):
""" Plots T90 distribution, gives the mean and median T90 values of the
sample and calculates the number of short, long bursts in the sample """
t90s = []
for i in range(0,len(self.t90s),1):
try:
t90s.append(float(self.t90s[i]))
except ValueError:
continue
t90s = np.array(t90s)
mean_t90 = np.mean(t90s)
median_t90 = np.median(t90s)
print('Mean T90 time =',mean_t90,'s')
print('Median T90 time=',median_t90,'s')
mask = np.ma.masked_where(t90s < 2, t90s)
short_t90s = t90s[mask == False]
long_t90s = t90s[mask != False]
print('Number of Short/Long GRBs =',len(short_t90s),'/',len(long_t90s))
plt.figure()
plt.xlabel('T$_{90}$ (s)')
plt.ylabel('Number of GRBs')
plt.xscale('log')
minimum, maximum, = min(short_t90s), max(long_t90s)
plt.axvline(mean_t90,color='red',linestyle='-')
plt.axvline(median_t90,color='blue',linestyle='-')
plt.hist(t90s,bins= 10**np.linspace(np.log10(minimum),np.log10(maximum),20),color='grey',alpha=0.5)
plt.show()
开发者ID:jtwm1,项目名称:adampy,代码行数:30,代码来源:swift_functions.py
示例15: pltytfield
def pltytfield():
fig=plt.figure()
ppy=yt.ProjectionPlot(ds, "x", "Bxy", weight_field="density") #Project X-component of B-field from z-direction
By=ppy._frb["Bxy"]
ax=fig.add_subplot(111)
plt.xticks(tick_locs,tick_lbls)
plt.yticks(tick_locs,tick_lbls)
Bymag=ax.pcolormesh(np.log10(By))
cbar_m=plt.colorbar(Bymag)
cbar_m.set_label("Bxy")
plt.title("Bxy in yz plane")
fig=plt.figure()
ppy=yt.ProjectionPlot(ds, "y", "Bxy", weight_field="density") #Project X-component of B-field from z-direction
By=ppy._frb["Bxy"]
ax=fig.add_subplot(111)
plt.xticks(tick_locs,tick_lbls)
plt.yticks(tick_locs,tick_lbls)
Bymag=ax.pcolormesh(np.log10(By))
cbar_m=plt.colorbar(Bymag)
cbar_m.set_label("Bxy")
plt.title("Bxy in xz plane")
fig=plt.figure()
ppy=yt.ProjectionPlot(ds, "z", "Bxy", weight_field="density") #Project X-component of B-field from z-direction
By=ppy._frb["Bxy"]
ax=fig.add_subplot(111)
plt.xticks(tick_locs,tick_lbls)
plt.yticks(tick_locs,tick_lbls)
Bymag=ax.pcolormesh(np.log10(By))
cbar_m=plt.colorbar(Bymag)
cbar_m.set_label("Bxy")
plt.title("Bxy in xy plane")
开发者ID:jwyl,项目名称:joycesoft,代码行数:33,代码来源:testfunctions.py
示例16: update_all_baseline_plots
def update_all_baseline_plots(i, fig, crawler, lines, norm_cross=False, forward=True):
if forward:
try:
crawler.forward()
except EOFError as err:
print err
raw_input("End of File. Press enter to quit.")
sys.exit()
burst = crawler
for k in range(len(BASELINES)):
if k < 4:
#autos
lines[k].set_data(FREQS, 10*np.log10(burst.autos[BASELINES[k]]))
#overlays
lines[-(k+1)].set_data(FREQS,10*np.log10(burst.autos[BASELINES[k]]))
elif norm_cross:
norm_val = np.array(burst.cross[BASELINES[k]])/np.sqrt(np.array(burst.autos[BASELINES[k][0]*2])*np.array(burst.autos[BASELINES[k][1]*2]))
lines[k]['real'].set_data(FREQS, np.real(norm_val))
lines[k]['imag'].set_data(FREQS, np.imag(norm_val))
else:
lines[k].set_data(FREQS, 10*np.log10(np.abs(np.real(burst.cross[BASELINES[k]]))))
return lines
开发者ID:aldof19,项目名称:lofasm,代码行数:30,代码来源:animate_lofasm.py
示例17: test_behroozi10_smhm_z1
def test_behroozi10_smhm_z1():
""" The arrays ``logmh_z01`` and ``logmratio_z01`` were provided by Peter Behroozi
via private communication. These quantities are in the h=0.7 units adopted in
Behroozi+10. This test function treats these arrays as truth,
and enforces that the result computed by Halotools agrees with them.
"""
model = Behroozi10SmHm()
logmh_z1 = np.array(
[11.368958, 11.493958, 11.618958, 11.743958,
11.868958, 11.993958, 12.118958, 12.243958,
12.368958, 12.493958, 12.618958, 12.743958,
12.868958, 12.993958, 13.118958, 13.243958,
13.368958, 13.493958, 13.618958, 13.743958,
13.868958, 13.993958, 14.118958, 14.243958]
)
logmratio_z1 = np.array(
[-2.145909, -2.020974, -1.924020, -1.852937,
-1.804730, -1.776231, -1.764455, -1.766820,
-1.781140, -1.805604, -1.838727, -1.879292,
-1.926290, -1.978890, -2.036405, -2.098245,
-2.163930, -2.233045, -2.305230, -2.380185,
-2.457643, -2.537377, -2.619191, -2.702901]
)
halo_mass_z1 = (10.**logmh_z1)*model.littleh
logmratio_z1 = np.log10((10.**logmratio_z1)*model.littleh)
z1_sm = model.mean_stellar_mass(prim_haloprop=halo_mass_z1, redshift=1.0)
z1_ratio = z1_sm / halo_mass_z1
z1_result = np.log10(z1_ratio)
assert np.allclose(z1_result, logmratio_z1, rtol=0.02)
开发者ID:johannesulf,项目名称:halotools,代码行数:33,代码来源:test_behroozi10.py
示例18: get_log_fluxes
def get_log_fluxes(self):
# Initialize arrays
log_flux = np.zeros(self.flux.shape, dtype=np.float64)
log_error = np.zeros(self.error.shape, dtype=np.float64)
weight = np.zeros(self.valid.shape, dtype=np.float64)
# Fluxes
r = self.valid == 1
log_flux[r] = np.log10(self.flux[r]) - 0.5 * (self.error[r] / self.flux[r]) ** 2. / np.log(10.)
log_error[r] = np.abs(self.error[r] / self.flux[r]) / np.log(10.)
weight[r] = 1. / log_error[r] ** 2.
# Lower and upper limits
r = (self.valid == 2) | (self.valid == 3)
log_flux[r] = np.log10(self.flux[r])
log_error[r] = self.error[r]
# Log10[Fluxes]
r = self.valid == 4
log_flux[r] = self.flux[r]
log_error[r] = self.error[r]
weight[r] = 1. / log_error[r] ** 2.
# Ignored points
r = self.valid == 9
log_flux[r] = np.log10(self.flux[r]) - 0.5 * (self.error[r] / self.flux[r]) ** 2. / np.log(10.)
log_error[r] = np.abs(self.error[r] / self.flux[r]) / np.log(10.)
return weight, log_flux, log_error
开发者ID:bsipocz,项目名称:sedfitter,代码行数:30,代码来源:source.py
示例19: sutherland_gaunt_factor
def sutherland_gaunt_factor(self, wavelength):
"""
Calculates the free-free gaunt factor calculations of [1]_.
The Gaunt factors of [1]_ are read in using `ChiantiPy.tools.io.gffRead`
as a function of :math:`u` and :math:`\gamma^2`. The data are interpolated
to the appropriate wavelength and temperature values using
`~scipy.ndimage.map_coordinates`.
References
----------
.. [1] Sutherland, R. S., 1998, MNRAS, `300, 321 <http://adsabs.harvard.edu/abs/1998MNRAS.300..321S>`_
"""
# calculate scaled quantities
lower_u = ch_const.planck*(1.e8*ch_const.light)/ch_const.boltzmann/np.outer(self.Temperature,wavelength)
gamma_squared = (self.Z**2)*ch_const.ryd2erg/ch_const.boltzmann/self.Temperature[:,np.newaxis]*np.ones(lower_u.shape)
# convert to index coordinates
i_lower_u = (np.log10(lower_u) + 4.)*10.
i_gamma_squared = (np.log10(gamma_squared) + 4.)*5.
# read in sutherland data
gf_sutherland_data = ch_io.gffRead()
# interpolate data to scaled quantities
gf_sutherland = map_coordinates(gf_sutherland_data['gff'],
[i_gamma_squared.flatten(), i_lower_u.flatten()]).reshape(lower_u.shape)
return np.where(gf_sutherland < 0., 0., gf_sutherland)
开发者ID:wtbarnes,项目名称:ChiantiPy,代码行数:26,代码来源:Continuum.py
示例20: test_Moster13SmHm_behavior
def test_Moster13SmHm_behavior():
"""
"""
default_model = Moster13SmHm()
mstar1 = default_model.mean_stellar_mass(prim_haloprop = 1.e12)
ratio1 = mstar1/3.4275e10
np.testing.assert_array_almost_equal(ratio1, 1.0, decimal=3)
default_model.param_dict['n10'] *= 1.1
mstar2 = default_model.mean_stellar_mass(prim_haloprop = 1.e12)
assert mstar2 > mstar1
default_model.param_dict['n11'] *= 1.1
mstar3 = default_model.mean_stellar_mass(prim_haloprop = 1.e12)
assert mstar3 == mstar2
mstar4_z1 = default_model.mean_stellar_mass(prim_haloprop = 1.e12, redshift=1)
default_model.param_dict['n11'] *= 1.1
mstar5_z1 = default_model.mean_stellar_mass(prim_haloprop = 1.e12, redshift=1)
assert mstar5_z1 != mstar4_z1
mstar_realization1 = default_model.mc_stellar_mass(prim_haloprop = np.ones(1e4)*1e12, seed=43)
mstar_realization2 = default_model.mc_stellar_mass(prim_haloprop = np.ones(1e4)*1e12, seed=43)
mstar_realization3 = default_model.mc_stellar_mass(prim_haloprop = np.ones(1e4)*1e12, seed=44)
assert np.array_equal(mstar_realization1, mstar_realization2)
assert not np.array_equal(mstar_realization1, mstar_realization3)
measured_scatter1 = np.std(np.log10(mstar_realization1))
model_scatter = default_model.param_dict['scatter_model_param1']
np.testing.assert_allclose(measured_scatter1, model_scatter, rtol=1e-3)
default_model.param_dict['scatter_model_param1'] = 0.3
mstar_realization4 = default_model.mc_stellar_mass(prim_haloprop = np.ones(1e4)*1e12, seed=43)
measured_scatter4 = np.std(np.log10(mstar_realization4))
np.testing.assert_allclose(measured_scatter4, 0.3, rtol=1e-3)
开发者ID:bsipocz,项目名称:halotools,代码行数:35,代码来源:test_smhm_components.py
注:本文中的numpy.log10函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论