Here are the examples of the python api numpy.log10 taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1308 Examples
5
Source : basic.py
with MIT License
from dmitriy-serdyuk
with MIT License
from dmitriy-serdyuk
def impl(self, x):
# If x is an int8 or uint8, numpy.log10 will compute the result in
# half-precision (float16), where we want float32.
x_dtype = str(getattr(x, 'dtype', ''))
if x_dtype in ('int8', 'uint8'):
return numpy.log10(x, sig='f')
return numpy.log10(x)
def grad(self, inputs, gout):
5
Source : QuickCSF.py
with GNU General Public License v3.0
from vpclab
with GNU General Public License v3.0
from vpclab
def makeContrastSpace(min=.01, max=1, count=24):
'''Creates contrast values at log-linear equal1ly spaced intervals'''
logger.debug('Making contrast space: ' + str(locals()))
sensitivityRange = [1/min, 1/max]
expRange = numpy.log10(sensitivityRange[0])-numpy.log10(sensitivityRange[1])
expMin = numpy.log10(sensitivityRange[1])
contrastSpace = numpy.array([0.] * count)
for i in range(count):
contrastSpace[count-i-1] = 1.0 / (
10**((i/(count-1.))*expRange + expMin)
)
return contrastSpace
def makeFrequencySpace(min=.2, max=36, count=20):
5
Source : QuickCSF.py
with GNU General Public License v3.0
from vpclab
with GNU General Public License v3.0
from vpclab
def makeFrequencySpace(min=.2, max=36, count=20):
'''Creates frequency values at log-linear equally spaced intervals'''
logger.debug('Making frequency space: ' + str(locals()))
expRange = numpy.log10(max)-numpy.log10(min)
expMin = numpy.log10(min)
frequencySpace = numpy.array([0.] * count)
for i in range(count):
frequencySpace[i] = (
10** ( (i/(count-1)) * expRange + expMin )
)
return frequencySpace
def csf_unmapped(parameters, frequency):
3
Source : functions.py
with MIT License
from 3fon3fonov
with MIT License
from 3fon3fonov
def run_gls(obj,fend =1.0,fbeg=10000):
#fbeg = abs(max(obj.fit_results.rv_model.jd)-min(obj.fit_results.rv_model.jd)) * 2.0
omega = 1/ np.logspace(np.log10(fend), np.log10(fbeg), num=int(1000))
if len(obj.fit_results.rv_model.jd) > 5:
RV_per = gls.Gls((obj.fit_results.rv_model.jd, obj.fit_results.rv_model.rvs, obj.fit_results.rv_model.rv_err),
fast=True, verbose=False, norm='ZK',ofac=10, fbeg=omega[-1], fend=omega[0],)
obj.gls = RV_per
else:
return obj
return obj
def run_gls_o_c(obj,fend =1.0,fbeg=10000, as_main = False):
3
Source : bubbly.py
with MIT License
from AashitaK
with MIT License
from AashitaK
def set_range(values, logscale=False):
''' Finds the axis range for the figure.'''
if logscale:
rmin = min(np.log10(values))*0.97
rmax = max(np.log10(values))*1.04
else:
rmin = min(values)*0.7
rmax = max(values)*1.4
return [rmin, rmax]
def get_trace(grid, col_name_template, x_column, y_column, bubble_column, z_column=None, size_column=None,
3
Source : model.py
with MIT License
from acatovic
with MIT License
from acatovic
def sentence_similarity(sent1, sent2):
overlap = len(set(sent1).intersection(set(sent2)))
if overlap == 0:
return 0
return overlap / (np.log10(len(sent1)) + np.log10(len(sent2)))
def pagerank(A, eps=0.0001, d=0.85):
3
Source : bench.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def timer(s, v='', nloop=500, nrep=3):
units = ["s", "ms", "µs", "ns"]
scaling = [1, 1e3, 1e6, 1e9]
print("%s : %-50s : " % (v, s), end=' ')
varnames = ["%ss,nm%ss,%sl,nm%sl" % tuple(x*4) for x in 'xyz']
setup = 'from __main__ import numpy, ma, %s' % ','.join(varnames)
Timer = timeit.Timer(stmt=s, setup=setup)
best = min(Timer.repeat(nrep, nloop)) / nloop
if best > 0.0:
order = min(-int(numpy.floor(numpy.log10(best)) // 3), 3)
else:
order = 3
print("%d loops, best of %d: %.*g %s per loop" % (nloop, nrep,
3,
best * scaling[order],
units[order]))
def compare_functions_1v(func, nloop=500,
3
Source : test_filter_design.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def test_degenerate(self):
# 0-order filter is just a passthrough
# Even-order filters have DC gain of -rp dB
b, a = cheby1(0, 10*np.log10(2), 1, analog=True)
assert_array_almost_equal(b, [1/np.sqrt(2)])
assert_array_equal(a, [1])
# 1-order filter is same for all types
b, a = cheby1(1, 10*np.log10(2), 1, analog=True)
assert_array_almost_equal(b, [1])
assert_array_almost_equal(a, [1, 1])
z, p, k = cheby1(1, 0.1, 0.3, output='zpk')
assert_array_equal(z, [-1])
assert_allclose(p, [-5.390126972799615e-01], rtol=1e-14)
assert_allclose(k, 7.695063486399808e-01, rtol=1e-14)
def test_basic(self):
3
Source : test_filter_design.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def test_degenerate(self):
# 0-order filter is just a passthrough
# Stopband ripple factor doesn't matter
b, a = cheby2(0, 123.456, 1, analog=True)
assert_array_equal(b, [1])
assert_array_equal(a, [1])
# 1-order filter is same for all types
b, a = cheby2(1, 10*np.log10(2), 1, analog=True)
assert_array_almost_equal(b, [1])
assert_array_almost_equal(a, [1, 1])
z, p, k = cheby2(1, 50, 0.3, output='zpk')
assert_array_equal(z, [-1])
assert_allclose(p, [9.967826460175649e-01], rtol=1e-14)
assert_allclose(k, 1.608676991217512e-03, rtol=1e-14)
def test_basic(self):
3
Source : test_filter_design.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def test_degenerate(self):
# 0-order filter is just a passthrough
# Even-order filters have DC gain of -rp dB
# Stopband ripple factor doesn't matter
b, a = ellip(0, 10*np.log10(2), 123.456, 1, analog=True)
assert_array_almost_equal(b, [1/np.sqrt(2)])
assert_array_equal(a, [1])
# 1-order filter is same for all types
b, a = ellip(1, 10*np.log10(2), 1, 1, analog=True)
assert_array_almost_equal(b, [1])
assert_array_almost_equal(a, [1, 1])
z, p, k = ellip(1, 1, 55, 0.3, output='zpk')
assert_allclose(z, [-9.999999999999998e-01], rtol=1e-14)
assert_allclose(p, [-6.660721153525525e-04], rtol=1e-10)
assert_allclose(k, 5.003330360576763e-01, rtol=1e-14)
def test_basic(self):
3
Source : test_cdflib.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def values(self, n):
"""Return an array containing approximatively n numbers."""
m = max(1, n//3)
v1 = np.logspace(-30, np.log10(0.3), m)
v2 = np.linspace(0.3, 0.7, m + 1, endpoint=False)[1:]
v3 = 1 - np.logspace(np.log10(0.3), -15, m)
v = np.r_[v1, v2, v3]
return np.unique(v)
class EndpointFilter(object):
3
Source : test_sici.py
with GNU General Public License v3.0
from adityaprakash-bobby
with GNU General Public License v3.0
from adityaprakash-bobby
def test_shichi_consistency():
# Make sure the implementation of shichi for real arguments agrees
# with the implementation of shichi for complex arguments.
# On the negative real axis Cephes drops the imaginary part in chi
def shichi(x):
shi, chi = sc.shichi(x + 0j)
return shi.real, chi.real
# Overflow happens quickly, so limit range
x = np.r_[-np.logspace(np.log10(700), -30, 200), 0,
np.logspace(-30, np.log10(700), 200)]
shi, chi = sc.shichi(x)
dataset = np.column_stack((x, shi, chi))
FuncData(shichi, dataset, 0, (1, 2), rtol=1e-14).check()
3
Source : test_base.py
with GNU General Public License v3.0
from adopy
with GNU General Public License v3.0
from adopy
def grid_design():
return {
'stimulus': np.linspace(20 * np.log10(.05), 20 * np.log10(400), 120)
}
@pytest.fixture()
3
Source : test_base.py
with GNU General Public License v3.0
from adopy
with GNU General Public License v3.0
from adopy
def grid_param():
return {
'threshold': np.linspace(20 * np.log10(.1), 20 * np.log10(200), 100),
'slope': np.linspace(0, 10, 101)[0:],
'guess_rate': [0.5],
'lapse_rate': [0.05],
}
@pytest.fixture()
3
Source : test_psi.py
with GNU General Public License v3.0
from adopy
with GNU General Public License v3.0
from adopy
def grid_design():
stimulus = np.linspace(20 * np.log10(.05), 20 * np.log10(400), 20)
designs = dict(stimulus=stimulus)
return designs
@pytest.fixture()
3
Source : test_psi.py
with GNU General Public License v3.0
from adopy
with GNU General Public License v3.0
from adopy
def grid_param():
guess_rate = [0.5]
lapse_rate = [0.05]
threshold = np.linspace(20 * np.log10(.1), 20 * np.log10(200), 20)
slope = np.linspace(0, 10, 11)[1:]
params = dict(guess_rate=guess_rate, lapse_rate=lapse_rate,
threshold=threshold, slope=slope)
return params
@pytest.mark.parametrize('design_type', ['optimal', 'staircase', 'random'])
3
Source : plotting_utils.py
with MIT License
from aicherc
with MIT License
from aicherc
def logratios_boxplot(norm_grads, max_lag = 20):
ratios = np.log10(norm_grads[:,0:-1]/norm_grads[:,1:])
max_lag = min([max_lag, min(ratios.shape)])
dfs = []
for lag in range(1, max_lag):
df = pd.DataFrame()
df['ratio'] = np.diag(ratios, -lag)
df['lag'] = lag
dfs.append(df)
df = pd.concat(dfs, ignore_index = True)
fig, ax = plt.subplots(1,1)
sns.boxplot(x = 'lag', y='ratio', data=df, ax=ax)
ax.axhline(0, color='k', linestyle='--')
ax.set_ylim(-3,2)
ax.set_ylabel('log10 (norm grad t / norm grad t+1)')
return fig, ax
3
Source : ambiance.py
with Apache License 2.0
from airinnova
with Apache License 2.0
from airinnova
def from_density(cls, rho):
"""Return a new instance for given density value(s)"""
# Analogous to 'from_pressure()'
rho = cls._make_tensor(rho)
if (rho < CONST.rho_min - _EPS).any() or (rho > CONST.rho_max + _EPS).any():
raise ValueError(
"Value out of bounds." +
f" Lower limit: {CONST.rho_min:.2e} kg/m^3." +
f" Upper limit: {CONST.rho_max:.2f} kg/m^3."
)
def f(ht):
return np.log10(rho/cls(ht, check_bounds=False).density)
return cls(h=opt.newton(f, x0=2.33e3 - 16.3e3*np.log10(rho)))
def __str__(self):
3
Source : test_mlab.py
with MIT License
from alvarobartt
with MIT License
from alvarobartt
def test_logspace(xmin, xmax, N):
with pytest.warns(MatplotlibDeprecationWarning):
res = mlab.logspace(xmin, xmax, N)
targ = np.logspace(np.log10(xmin), np.log10(xmax), N)
assert_allclose(targ, res)
assert res.size == N
class TestStride(object):
3
Source : test_ticker.py
with MIT License
from alvarobartt
with MIT License
from alvarobartt
def _sub_labels(self, axis, subs=()):
"Test whether locator marks subs to be labeled"
fmt = axis.get_minor_formatter()
minor_tlocs = axis.get_minorticklocs()
fmt.set_locs(minor_tlocs)
coefs = minor_tlocs / 10**(np.floor(np.log10(minor_tlocs)))
label_expected = [np.round(c) in subs for c in coefs]
label_test = [fmt(x) != '' for x in minor_tlocs]
assert label_test == label_expected
@pytest.mark.style('default')
3
Source : ticker.py
with MIT License
from alvarobartt
with MIT License
from alvarobartt
def __call__(self, x, pos=None):
s = ''
if 0.01 < = x < = 0.99:
s = '{:.2f}'.format(x)
elif x < 0.01:
if is_decade(x):
s = '$10^{{{:.0f}}}$'.format(np.log10(x))
else:
s = '${:.5f}$'.format(x)
else: # x > 0.99
if is_decade(1-x):
s = '$1-10^{{{:.0f}}}$'.format(np.log10(1-x))
else:
s = '$1-{:.5f}$'.format(1-x)
return s
def format_data_short(self, value):
3
Source : colorbar.py
with MIT License
from alvarobartt
with MIT License
from alvarobartt
def _uniform_y(self, N):
'''
Return colorbar data coordinates for *N* uniformly
spaced boundaries.
'''
vmin, vmax = self._get_colorbar_limits()
if isinstance(self.norm, colors.LogNorm):
y = np.logspace(np.log10(vmin), np.log10(vmax), N)
else:
y = np.linspace(vmin, vmax, N)
return y
def _mesh(self):
3
Source : hod_bgs.py
with BSD 3-Clause "New" or "Revised" License
from amjsmith
with BSD 3-Clause "New" or "Revised" License
from amjsmith
def number_centrals_mean(self, log_mass, magnitude, redshift, f=None):
"""
Average number of central galaxies in each halo brighter than
some absolute magnitude threshold
Args:
log_mass: array of the log10 of halo mass (Msun/h)
magnitude: array of absolute magnitude threshold
redshift: array of halo redshifts
Returns:
array of mean number of central galaxies
"""
# use pseudo gaussian spline kernel
return spline.cumulative_spline_kernel(log_mass,
mean=np.log10(self.Mmin(magnitude, redshift, f)),
sig=self.sigma_logM(magnitude, redshift)/np.sqrt(2))
def number_satellites_mean(self, log_mass, magnitude, redshift, f=None):
3
Source : hod_bgs.py
with BSD 3-Clause "New" or "Revised" License
from amjsmith
with BSD 3-Clause "New" or "Revised" License
from amjsmith
def number_centrals_mean(self, log_mass, magnitude, redshift, f=1.0):
"""
Average number of central galaxies in each halo brighter than
some absolute magnitude threshold
Args:
log_mass: array of the log10 of halo mass (Msun/h)
magnitude: array of absolute magnitude threshold
redshift: array of halo redshifts
Returns:
array of mean number of central galaxies
"""
# use pseudo gaussian spline kernel
return spline.cumulative_spline_kernel(log_mass,
mean=np.log10(self.Mmin(magnitude, redshift, f)),
sig=self.sigma_logM(magnitude, redshift)/np.sqrt(2))
def number_satellites_mean(self, log_mass, magnitude, redshift, f=1.0):
3
Source : k_correction.py
with BSD 3-Clause "New" or "Revised" License
from amjsmith
with BSD 3-Clause "New" or "Revised" License
from amjsmith
def apparent_magnitude(self, absolute_magnitude, redshift, colour):
"""
Convert absolute magnitude to apparent magnitude
Args:
absolute_magnitude: array of absolute magnitudes (with h=1)
redshift: array of redshifts
colour: array of ^0.1(g-r) colour
Returns:
array of apparent magnitudes
"""
# Luminosity distance
D_L = (1.+redshift) * self.cosmo.comoving_distance(redshift)
return absolute_magnitude + 5*np.log10(D_L) + 25 + \
self.k(redshift,colour)
def absolute_magnitude(self, apparent_magnitude, redshift, colour):
3
Source : k_correction.py
with BSD 3-Clause "New" or "Revised" License
from amjsmith
with BSD 3-Clause "New" or "Revised" License
from amjsmith
def absolute_magnitude(self, apparent_magnitude, redshift, colour):
"""
Convert apparent magnitude to absolute magnitude
Args:
apparent_magnitude: array of apparent magnitudes
redshift: array of redshifts
colour: array of ^0.1(g-r) colour
Returns:
array of absolute magnitudes (with h=1)
"""
# Luminosity distance
D_L = (1.+redshift) * self.cosmo.comoving_distance(redshift)
return apparent_magnitude - 5*np.log10(D_L) - 25 - \
self.k(redshift,colour)
def magnitude_faint(self, redshift, mag_faint):
3
Source : luminosity_function.py
with BSD 3-Clause "New" or "Revised" License
from amjsmith
with BSD 3-Clause "New" or "Revised" License
from amjsmith
def lum2mag(luminosity):
"""
Convert luminosity to absolute magnitude
Args:
luminosity: array of luminsities [Lsun/h^2]
Returns:
array of absolute magnitude [M-5logh]
"""
return 4.76 - 2.5*np.log10(luminosity)
class LuminosityFunction(object):
3
Source : luminosity_function.py
with BSD 3-Clause "New" or "Revised" License
from amjsmith
with BSD 3-Clause "New" or "Revised" License
from amjsmith
def magnitude(self, number_density, redshift):
"""
Convert number density to absolute magnitude threshold
Args:
number_density: array of number densities [h^3/Mpc^3]
redshift: array of redshift
Returns:
array of absolute magnitude [M-5logh]
"""
points = np.array(list(zip(redshift, np.log10(number_density))))
return self._interpolator(points)
class LuminosityFunctionSchechter(LuminosityFunction):
3
Source : mass_function.py
with BSD 3-Clause "New" or "Revised" License
from amjsmith
with BSD 3-Clause "New" or "Revised" License
from amjsmith
def get_fit(self):
"""
Fits the Sheth-Tormen mass function to the measured mass function, returning the
best fit parameters
Returns:
an array of [dc, A, a, p]
"""
sigma = self.power_spectrum.sigma(10**self.__mass_bins, self.redshift)
mf = self.__mass_func / self.power_spectrum.cosmo.mean_density(0) * 10**self.__mass_bins
popt, pcov = curve_fit(self.__func, sigma, np.log10(mf), p0=[1,0.1,1.5,-0.5])
self.update_params(popt)
return popt
def update_params(self, fit_params):
3
Source : power_spectrum.py
with BSD 3-Clause "New" or "Revised" License
from amjsmith
with BSD 3-Clause "New" or "Revised" License
from amjsmith
def sigmaR_z0(self, R):
"""
Returns sigma(R), the rms mass fluctuation in spheres of radius R,
at redshift 0
Args:
R: array of comoving distance in units [Mpc/h]
Returns:
array of sigma
"""
return 10**splev(np.log10(R), self.__tck)
def sigmaR(self, R, z):
3
Source : jet_emitters.py
with BSD 3-Clause "New" or "Revised" License
from andreatramacere
with BSD 3-Clause "New" or "Revised" License
from andreatramacere
def set_bounds(self,a,b,log_val=False):
if log_val == False:
return [a,b]
else:
return np.log10([a,b])
def _set_log_val(self,a,log_val=False):
3
Source : jet_emitters.py
with BSD 3-Clause "New" or "Revised" License
from andreatramacere
with BSD 3-Clause "New" or "Revised" License
from andreatramacere
def _set_log_val(self,a,log_val=False):
if log_val == False:
return a
else:
return np.log10(a)
def _eval_func(self,gamma):
3
Source : jet_emitters.py
with BSD 3-Clause "New" or "Revised" License
from andreatramacere
with BSD 3-Clause "New" or "Revised" License
from andreatramacere
def set_grid(self):
gmin = self.parameters.get_par_by_name('gmin').val_lin
gmax = self.parameters.get_par_by_name('gmax').val_lin
self._gamma_grid = np.logspace(np.log10(gmin), np.log10(gmax), self._gamma_grid_size)
def eval_N(self):
3
Source : jet_emitters.py
with BSD 3-Clause "New" or "Revised" License
from andreatramacere
with BSD 3-Clause "New" or "Revised" License
from andreatramacere
def _array_func(self,gamma):
msk_nan=self._array_n_gamma>0
if msk_nan.sum()>1:
f_interp = interpolate.interp1d(np.log10(self._array_gamma[msk_nan]), np.log10(self._array_n_gamma[msk_nan]), bounds_error=False, kind='linear')
y = np.power(10., f_interp(np.log10(gamma)))
msk_nan = np.isnan(y)
y[msk_nan] = 0
else:
y = np.zeros(gamma.size)
return y
class InjEmittersDistribution(BaseEmittersDistribution):
3
Source : jet_emitters.py
with BSD 3-Clause "New" or "Revised" License
from andreatramacere
with BSD 3-Clause "New" or "Revised" License
from andreatramacere
def _array_func(self,gamma):
msk_nan=self._array_n_gamma>0
f_interp = interpolate.interp1d(np.log10(self._array_gamma[msk_nan]), np.log10(self._array_n_gamma[msk_nan]), bounds_error=False, kind='linear')
y = np.power(10., f_interp(np.log10(gamma)))
msk_nan = np.isnan(y)
y[msk_nan] = 0
return y
class JetkernelEmittersDistribution(EmittersDistribution):
3
Source : jet_model.py
with BSD 3-Clause "New" or "Revised" License
from andreatramacere
with BSD 3-Clause "New" or "Revised" License
from andreatramacere
def _eval_model(self, lin_nu, log_nu, init, loglog, phys_output=False, update_emitters=True):
log_model = None
lin_nu, lin_model = self.lin_func(lin_nu, init, phys_output, update_emitters)
if loglog is True:
log_model = np.log10(lin_model)
return lin_model, log_model
def _prepare_nu_model(self, nu, loglog):
3
Source : jet_model.py
with BSD 3-Clause "New" or "Revised" License
from andreatramacere
with BSD 3-Clause "New" or "Revised" License
from andreatramacere
def _prepare_nu_model(self, nu, loglog):
if nu is None:
lin_nu = np.logspace(np.log10(self.nu_min), np.log10(self.nu_max), self.nu_size)
log_nu = np.log10(lin_nu)
else:
if np.shape(nu) == ():
nu = np.array([nu])
if loglog is True:
lin_nu = np.power(10., nu)
log_nu = nu
else:
log_nu = np.log10(nu)
lin_nu = nu
return lin_nu, log_nu
@safe_run
3
Source : loglog_poly_model.py
with BSD 3-Clause "New" or "Revised" License
from andreatramacere
with BSD 3-Clause "New" or "Revised" License
from andreatramacere
def lin_func(self,nu):
nu_log=np.log10(nu)
return np.power(10.0,self.log_func(nu_log))
class LogLinear(LogLogModel):
3
Source : model_parameters.py
with BSD 3-Clause "New" or "Revised" License
from andreatramacere
with BSD 3-Clause "New" or "Revised" License
from andreatramacere
def log(self):
if self._val is None:
return None
if self._islog is True:
return self._val
else:
return np.log10(self._val)
@property
3
Source : model_parameters.py
with BSD 3-Clause "New" or "Revised" License
from andreatramacere
with BSD 3-Clause "New" or "Revised" License
from andreatramacere
def _eval_par_func(self):
#transform par name and value into a local var
_par_values= [None]*len(self._master_pars)
for ID, _user_par_ in enumerate(self._master_pars):
_par_values[ID] = _user_par_.val
#print('==> _eval_par_func',_user_par_.name,_par_values[ID])
exec(_user_par_.name + '=_par_values[ID]')
res = eval(self._depending_par_expr)
if self.islog is True:
res=np.log10(res)
return eval(self.par_expr)
def set(self, *args, skip_dep_par_warning=False, **keywords):
3
Source : plot_sedfit.py
with BSD 3-Clause "New" or "Revised" License
from andreatramacere
with BSD 3-Clause "New" or "Revised" License
from andreatramacere
def y_ev_transf_inv(x):
return x + np.log10(2.417E14)
def set_mpl():
3
Source : plot_sedfit.py
with BSD 3-Clause "New" or "Revised" License
from andreatramacere
with BSD 3-Clause "New" or "Revised" License
from andreatramacere
def plot(self,nu,y,y_label,y_min=None,y_max=None,label=None,line_style=None,color=None):
self.ax.plot(np.log10(nu), np.log10(y),label=label,ls=line_style,color=color)
self.ax.set_xlabel(r'log($ \nu $) (Hz)')
self.ax.set_ylabel(y_label)
self.ax.set_ylim(y_min, y_max)
self.ax.legend()
self.update_plot()
class PlotPdistr (BasePlot):
3
Source : plot_sedfit.py
with BSD 3-Clause "New" or "Revised" License
from andreatramacere
with BSD 3-Clause "New" or "Revised" License
from andreatramacere
def plot(self,nu,nuFnu,y_min=None,y_max=None):
self.ax.plot(np.log10(nu), np.log10(nuFnu))
self.ax.set_xlabel(r'log($ \nu $) (Hz)')
self.ax.set_ylabel(r'log($ \nu F_{\nu} $ ) (erg cm$^{-2}$ s$^{-1}$)')
self.ax.set_ylim(y_min, y_max)
self.update_plot()
class PlotSeedPhotons (BasePlot):
3
Source : plot_sedfit.py
with BSD 3-Clause "New" or "Revised" License
from andreatramacere
with BSD 3-Clause "New" or "Revised" License
from andreatramacere
def plot(self,nu,nuFnu,y_min=None,y_max=None):
self.ax.plot(np.log10(nu), np.log10(nuFnu))
self.ax.set_xlabel(r'log($ \nu $) (Hz)')
self.ax.set_ylabel(r'log(n ) (photons cm$^{-3}$ Hz$^{-1}$ ster$^{-1}$)')
self.ax.set_ylim(y_min, y_max)
self.update_plot()
3
Source : sherpa_plugin.py
with BSD 3-Clause "New" or "Revised" License
from andreatramacere
with BSD 3-Clause "New" or "Revised" License
from andreatramacere
def plot_model(self, fit_range, model_range=[1E10, 1E30], nu_grid_size=200, plot_obj=None, sed_data=None):
self._jetset_model.set_nu_grid(model_range[0], model_range[1], nu_grid_size)
self._jetset_model.eval()
plot_obj = self._jetset_model.plot_model(plot_obj=plot_obj, sed_data=sed_data)
plot_obj.add_model_residual_plot(data=sed_data, model=self._jetset_model,
fit_range=np.log10([fit_range[0], fit_range[1]]))
def plot_sherpa_model(sherpa_model, fit_range=None, model_range=[1E10, 1E30], nu_grid_size=200, sed_data=None,
3
Source : spectral_shapes.py
with BSD 3-Clause "New" or "Revised" License
from andreatramacere
with BSD 3-Clause "New" or "Revised" License
from andreatramacere
def get_residuals(self, log_log=False):
residuals = self.residuals
nu_residuals = self.nu_residuals
if log_log == False:
return nu_residuals, residuals
else:
return nu_residuals, np.log10(residuals)
def fill(self,nu=None,nuFnu=None,nu_residuals=None,residuals=None,log_log=False):
3
Source : data.py
with MIT License
from andyljones
with MIT License
from andyljones
def interp_curves(g, x='train_flops', y='elo', group='run'):
xl, xr = g[x].pipe(np.log10).min(), g[x].pipe(np.log10).max()
xs = np.linspace(xl, xr, 101)
ys = {}
for run, gg in g.sort_values(x).groupby(group):
xp = gg[x].pipe(np.log10).values
yp = gg[y].values
ys[run] = np.interp(xs, xp, yp, np.nan, np.nan)
return pd.DataFrame(ys, index=10**xs)
def interp_frontier(g, x='train_flops', y='elo', **kwargs):
3
Source : data.py
with MIT License
from andyljones
with MIT License
from andyljones
def train_test(ags):
df = ags.query('boardsize == 9').copy()
df['test_flops'] = df.test_nodes*(df.train_flops/df.samples)
df['train_flops_group'] = df.train_flops.pipe(np.log10).round(1).pipe(lambda s: 10**s)
frontiers = {}
for e in np.linspace(-1500, 0, 7):
frontiers[e] = df[ELO*df.elo > e].groupby('train_flops_group').test_flops.min().expanding().min()
frontiers = pd.concat(frontiers).unstack().T
frontiers = frontiers.pipe(np.log10).round(1).pipe(lambda df: 10**df)
frontiers = frontiers.where(frontiers.iloc[-1].eq(frontiers).cumsum().le(1))
frontiers = frontiers.stack().reset_index().sort_values('train_flops_group')
frontiers.columns = ['train_flops', 'elo', 'test_flops']
return frontiers
def train_test_model(frontiers):
3
Source : storage.py
with MIT License
from andyljones
with MIT License
from andyljones
def flops_savepoints(boardsize, n_snapshots=21, upper=None):
lower = BOUNDS[boardsize][0]
upper = upper or BOUNDS[boardsize][1]
return 10**np.linspace(np.log10(lower), np.log10(upper), n_snapshots)
class FlopsStorer:
3
Source : mass_attenuation.py
with GNU General Public License v3.0
from arcadelab
with GNU General Public License v3.0
from arcadelab
def log_interp(xInterp, x, y):
# xInterp is the single energy value to interpolate an absorption coefficient for,
# interpolating from the data from "x" (energy value array from slicing material_coefficients)
# and from "y" (absorption coefficient array from slicing material_coefficients)
xInterp = np.log10(xInterp.copy())
x = np.log10(x.copy())
y = np.log10(y.copy())
yInterp = np.power(10, np.interp(xInterp, x, y)) # np.interp is 1-D linear interpolation
return yInterp
See More Examples