def test_warnings(): # ticket 1334 with np.errstate(all='raise'): # these should raise no fp warnings orth.eval_legendre(1, 0) orth.eval_laguerre(1, 1) orth.eval_gegenbauer(1, 1, 0)
def test_warnings(): # ticket 1334 olderr = np.seterr(all='raise') try: # these should raise no fp warnings orth.eval_legendre(1, 0) orth.eval_laguerre(1, 1) orth.eval_gegenbauer(1, 1, 0) finally: np.seterr(**olderr)
def param(V, T, P, aerosols=[], accom=0.1, mus=[], sigmas=[], Ns=[], kappas=[], pcm=RUNS.keys()[0], level="expansion_order_4", pcm_N=False): if aerosols: d = _unpack_aerosols(aerosols) mu = d['mus'][0] sigma = d['sigmas'][0] kappa = d['kappas'][0] N = d['Ns'][0] else: ## Assert that the aerosol was already decomposed into component vars assert mus mu = mus[0] assert sigmas sigma = sigmas[0] assert Ns N = Ns[0] assert kappas kappa = kappas[0] logN = np.log10(N) logmu = np.log10(mu) logV = np.log10(V) ## Project into orthogonal polynomial space z = project([logN, logmu, sigma, kappa, logV, T, P, accom]) coeffs = RUNS_SAVE[pcm][level]['coeffs'] orders = RUNS_SAVE[pcm][level]['orders'] max_orders = RUNS_SAVE[pcm][level]['max_orders'] #nterms = len(coeffs) #nvars = len(z) ## Step 1) Evaluate the necessary polynomial orders poly_evals = [] for zi, order in zip(z, max_orders): poly_evals.append([op.eval_legendre(n, zi) for n in xrange(order+1)]) poly_evals = np.array(poly_evals) evaluation = poly_eval(orders, coeffs, poly_evals) ## Step 3) This gives us log10(Smax), so now we return Smax Smax = 10.**(evaluation) n_act, act_frac = lognormal_activation(Smax, mu*1e-6, sigma, N, kappa, T=T) return Smax, n_act, act_frac
from scipy.special.orthogonal import eval_legendre import matplotlib.pyplot as plt import numpy as np psi = lambda n,x: eval_legendre(n, x) x = np.linspace(-5, 5, 500) for n in xrange(6): plt.plot(x, psi(n,x), label=r"$P_"+str(n)+r"(x)$") plt.grid(True) plt.xlim(-1,1) plt.ylim(-1.5,1.5) plt.xlabel(r"$x$") plt.ylabel(r"$P_n(x)$") plt.legend(loc="lower center", ncol=6, prop={'size': 10}) plt.title(r"Legendre polynomials $P_n$") #plt.show() plt.savefig('legendre.pdf')