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.

class SourceData[source]

SourceData(source, config=None, clear=False, week_range=None, key='')

Load the photon data near the source and the associated exposure. --or-- Use a Simulation object to generate data

Either from:

  1. config.wtlike_data/'data_files', the Path to folder with list of pickle files
  2. the cache, with key {source.name}_data
  • source : name, PointSource, or Simulation
  • config : basic configuration
  • source : PointSource object if specified
  • clear : if set, overwrite the cached results

Calculate the values for

  • S, B : sums of w and 1-w
  • exptot : total associated exposure
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'])
generated 547 photons
SourceData: Source test_sim with:
	 data:           547 simulated photons over 1.0 days.
	 exposure:       288 intervals,  average effective area 3000 cm^2 for 0.1 Ms
	 rates:  source 1.09e-06/s, background 1.02e-06/s,
# check_data();

Exmaine exposure, cos_theta

is there a dependence on using the Kerr weighted exposure?

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');
There is no link to 4FGL catalog file: set "catalog_file" in your config.yaml or specify if in the Config() call
SourceData:  Geminga: Restoring from cache with key "PSR J0633+1746_weeks_9-11"
SourceData: Source Geminga with:
	 data:         4,606 photons from 2008-08-04 to 2008-08-20
	 exposure:    11,300 intervals,  average effective area 3025 cm^2 for 0.3 Ms
	 rates:  source 3.40e-06/s, background 1.11e-06/s, TS 2276709.9
Power-law weighted exposure
           start          stop   livetime  cos_theta            exp
0  54682.656038  54682.656375  25.041281   0.818062  107108.507812
1  54682.656375  54682.656722  25.894482   0.818352  110809.656250
2  54682.656722  54682.657069  25.907866   0.817781  110765.039062
3  54682.657069  54682.657416  25.952616   0.816321  110695.335938
4  54682.657416  54682.657764  26.067915   0.813964  110763.945312
There is no link to 4FGL catalog file: set "catalog_file" in your config.yaml or specify if in the Config() call
SourceData:  Geminga: Restoring from cache with key "PSR J0633+1746_weeks_9-11"
SourceData: Source Geminga with:
	 data:         4,606 photons from 2008-08-04 to 2008-08-20
	 exposure:    11,300 intervals,  average effective area 3025 cm^2 for 0.3 Ms
	 rates:  source 3.40e-06/s, background 1.11e-06/s, TS 2276709.9
Source flux-weighted exposure:
           start          stop   livetime  cos_theta            exp
0  54682.656038  54682.656375  25.041281   0.818062  107108.507812
1  54682.656375  54682.656722  25.894482   0.818352  110809.656250
2  54682.656722  54682.657069  25.907866   0.817781  110765.039062
3  54682.657069  54682.657416  25.952616   0.816321  110695.335938
4  54682.657416  54682.657764  26.067915   0.813964  110763.945312