In [ ]:
import numpy as np
import matplotlib.pyplot as plt

%matplotlib inline

In [ ]:
from newdust import *
from newdust.halos import *

from scipy.integrate import trapz

In [ ]:
NE, NTH = 50, 200
EVALS   = np.logspace(-1, 1, NE)   # keV
THVALS  = np.logspace(-1, 4, NTH)  # arcsec
GPOP    = grainpop.make_MRN_drude(md=1.e-6)['RGD']

In [ ]:
uni_halo = Halo(EVALS, THVALS, unit='kev')
scr_halo = Halo(EVALS, THVALS, unit='kev')

In [ ]:
%%time
galhalo.uniformISM(uni_halo, GPOP)

In [ ]:
plt.plot(THVALS, uni_halo.norm_int[-1,:])
plt.loglog()

In [ ]:
alph_grid = np.repeat(THVALS.reshape(1, NTH), NE, axis=0)
int_halo  = trapz(uni_halo.norm_int * 2.0 * np.pi * alph_grid, THVALS, axis=1)

In [ ]:
plt.plot(EVALS, int_halo)
plt.plot(EVALS, uni_halo.taux, 'ro')
plt.loglog()

In [ ]:
plt.plot(EVALS, int_halo/uni_halo.taux-1.0)

In [ ]:
FABS = 1.0 * np.power(EVALS, -2.0) * np.exp(-0.1 * np.power(EVALS, -3.5))

In [ ]:
plt.plot(EVALS, FABS)

In [ ]:
uni_halo.calculate_intensity(FABS)

In [ ]:
plt.plot(THVALS, uni_halo.intensity)
plt.loglog()

In [ ]:
tot_halo = trapz(uni_halo.intensity * 2.0 * np.pi * THVALS, THVALS)

In [ ]:
tot_halo

In [ ]:
np.sum(uni_halo.fhalo) / tot_halo

In [ ]:
t1 = uni_halo[0:5.1]
t2 = uni_halo[5.1:]

In [ ]:
plt.plot(uni_halo.lam, uni_halo.taux, 'b-')
plt.plot(t1.lam, t1.taux, 'rs')
plt.plot(t2.lam, t2.taux, 'rs')
plt.loglog()

In [ ]:
plt.plot(EVALS, np.append(t1.taux, t2.taux))
plt.loglog()

In [ ]: