Load, for analysis, data associated with a source, or manage a simulation
Overview
For a point source, and data selection, the class SourceData
is the user interface to source-oriented data. It relies on the modules load_data
for actual data, or simulation
for simulated data.
simkw = dict(src_flux=1e-6, tstart=0, tstop=1)
sim = Simulation('test_sim', **simkw )
simsd = SourceData(sim)
# test_eq(simsd.start, simkw['tstart'])
# test_eq(simsd.stop, simkw['tstop'])
# check_data();
import matplotlib.pyplot as plt
config=Config();
if config.valid:
week_range=(9,11)
config.verbose=1
config.use_kerr=True
source =PointSource('Geminga', config=config)
sdk = SourceData(source, config=config, week_range=week_range, )
print('Power-law weighted exposure\n', sdk.exposure.head())
config.use_kerr=False
source =PointSource('Geminga', config=config)
sdnk = SourceData(source, config=config, week_range=week_range, )
print('Source flux-weighted exposure:\n', sdnk.exposure.head())
expk = sdk.exposure
expnk = sdnk.exposure
plt.rc('font', size=12)
fig, axx = plt.subplots(2,2, figsize=(10,8))
(ax1,ax2,ax3,ax4) = axx.flatten()
ax1.plot(expk.cos_theta, expk.exp,'.');
ax1.set(title='powerlaw (Kerr) mode')
ax2.plot(expnk.cos_theta, expnk.exp,'.');
ax2.set(title='Use Source spectrum')
ratio = expnk.exp/expk.exp
ax3.hist(ratio, bins=np.linspace(0.75,1.25, 51))
ax3.set(title='non-Kerr/Kerr');
ax4.plot(expnk.cos_theta, ratio, '.');
ax4.set(xlabel='cos theta', ylabel='ratio');