Combine the FT2 spacecraft livetime information with the effective area to produce exposure for a given direction and spectrum
The spacecraft information is a list, for 30-s intervals, of the livetime and instrument $\theta$ of the source.
We need a weighted effective area
as a function of $\theta$. This requires a weighting function of energy, or a spectrum. Matthew used a simple power law with index -2.1. implemented in by the class KerrAeff
. But here we have the actual source spectrum available. Also, the data here excludes low-energy Back events the class SourceAeff
uses both.
nbins = 16
f = lambda x: x**-2
ee = np.logspace(2,4,nbins+1)
r = 1e-2-1e-4
print(f'Errors:\n\tLinear: {simpson(f(ee), ee)/r-1:+6.1e}'
f'\n\tLog: {simpson( f(ee)*ee, np.log(ee) )/r-1:+6.1e}')
from wtlike.sources import PointSource
config=Config()
# source_name='LS 5039' #'Geminga'
def aeffplots(ke,se):
ct = np.linspace(0.4, 1.0, 25)
fig, (ax1,ax2) = plt.subplots(1,2, figsize=(8,4), sharey=True)
plt.subplots_adjust(wspace=0.05)
ax1.semilogx(ke.edom, ke.wts/ke.wts[0], '.-', label='power law')
ax1.semilogx(se.edom, se.wts/se.wts[0], '.-', label=f'{source_name} spectrum')
ax1.legend();ax1.grid(alpha=0.5)
ax1.set(title='energy dependence', ylabel='relative weight')
ax2.plot(ct, se(ct)/se(1), '.-', label='power law')
ax2.plot(ct, ke(ct)/ke(1), '.-', label=f'{source_name} spectrum')
ax2.set( title='angular dependence',xlim=(0.4,1.0), ylim=(0, None),)
ax2.grid(alpha=0.5); ax2.legend();
if config.valid:
source_name='Geminga'
source=PointSource(source_name)
ke = KerrAeff(config, source)
se = SourceAeff(config, source)
aeffplots(ke,se)