3C454.3 analysis notebook¶

Reference paper: https://arxiv.org/pdf/1106.5162.pdf

In [1]:
from agilepy.api.AGAnalysis import AGAnalysis
In [2]:
# Interactive plots
%matplotlib widget
! root -q
   ------------------------------------------------------------------
  | Welcome to ROOT 6.26/06                        https://root.cern |
  | (c) 1995-2021, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for linuxx8664gcc on Jul 28 2022, 18:08:51                 |
  | From tags/v6-26-06@v6-26-06                                      |
  | With c++ (GCC) 8.5.0 20210514 (Red Hat 8.5.0-13)                 |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q'       |
   ------------------------------------------------------------------


Creating a configuration file¶

In [3]:
confFilePath = "$HOME/agilepy_conf.yaml"
In [4]:
AGAnalysis.getConfiguration(
    confFilePath = confFilePath,
    evtfile="$AGILE/agilepy-test-data/test_dataset_agn/EVT/EVT.index",
    logfile="$AGILE/agilepy-test-data/test_dataset_agn/LOG/LOG.index",
    userName = "username",
    sourceName = "3C454_3",
    tmin = 55513.0,
    tmax = 55521.0,
    timetype = "MJD",
    glon = 86.11,
    glat = -38.18,
    outputDir = "$HOME/agilepy_analysis",
    verboselvl = 0,
    userestapi=False
)

Obtaining the AGAnalysis object¶

In [5]:
ag = AGAnalysis(confFilePath)
In [6]:
#print all options of the configuration file
ag.setOptions(binsize=0.5, expstep=2, mapsize=25)
ag.setOptions(energybins=[[100, 50000]])
ag.printOptions()
{ 'ap': {'radius': 3, 'timeslot': 3600},
  'input': { 'datapath': 'None',
             'evtfile': '//agiletools/agilepy-test-data/test_dataset_agn/EVT/EVT.index',
             'logfile': '//agiletools/agilepy-test-data/test_dataset_agn/LOG/LOG.index',
             'userestapi': False},
  'maps': { 'binsize': 0.5,
            'energybins': [[100, 50000]],
            'expstep': 2,
            'fovbinnumber': 1,
            'mapsize': 25,
            'offaxisangle': 30,
            'proj': 'ARC',
            'projtype': 'WCS',
            'spectralindex': 2.1,
            'timestep': 160,
            'useEDPmatrixforEXP': False},
  'mle': { 'contourpoints': 40,
           'edpcorrection': 1,
           'expratio_maxthr': 15,
           'expratio_minthr': 0,
           'expratio_size': 10,
           'expratioevaluation': True,
           'fluxcorrection': 0,
           'integratortype': 1,
           'loccl': 5.99147,
           'mindefaulttolerance': 0.01,
           'minimizeralg': 'Migrad',
           'minimizerdefstrategy': 2,
           'minimizertype': 'Minuit',
           'ranal': 10,
           'ulcl': 2},
  'model': { 'emax_sources': 10000,
             'emin_sources': 100,
             'galcoeff': [-1],
             'galmode': 1,
             'galmode2': 0,
             'galmode2fit': 0,
             'isocoeff': [-1],
             'isomode': 1,
             'isomode2': 0,
             'isomode2fit': 0,
             'modelfile': None},
  'output': { 'filenameprefix': 'analysis_product',
              'logfilenameprefix': 'analysis_log',
              'outdir': PosixPath('/root/agilepy_analysis/username_3C454_3_20221022-165046'),
              'sourcename': '3C454_3',
              'username': 'username',
              'verboselvl': 0},
  'plotting': {'twocolumns': False},
  'selection': { 'albedorad': 80,
                 'bpointing': None,
                 'dq': 0,
                 'emax': 10000,
                 'emin': 100,
                 'filtercode': 5,
                 'fovradmax': 60,
                 'fovradmin': 0,
                 'glat': -38.18,
                 'glon': 86.110001,
                 'lonpole': 180,
                 'lpointing': None,
                 'maplistgen': 'None',
                 'phasecode': 6,
                 'proj': 'ARC',
                 'timelist': 'None',
                 'timetype': 'TT',
                 'tmax': 217382400.0,
                 'tmin': 216691200.0}}

Sources hypothesis¶

In [7]:
sources = ag.loadSourcesFromCatalog("2AGL", rangeDist = (0, 5), show=True)
-----------------------------------------------------------
 Source name: 2AGLJ2247+1558 (PointSource)
  * Spectrum type: PowerLaw
  * Free parameters: none
  * Initial source parameters:
	- flux (ph/cm2s): 6.0533e-08
	- index : 2.75651
	- Source position (l,b): (84.2229, -37.4782)
	- Distance from map center (deg): 1.6474

-----------------------------------------------------------
 Source name: 2AGLJ2254+1609 (PointSource)
  * Spectrum type: PowerLaw
  * Free parameters: none
  * Initial source parameters:
	- flux (ph/cm2s): 7.5094e-07
	- index : 2.20942
	- Source position (l,b): (86.1236, -38.1824)
	- Distance from map center (deg): 0.011

Adding a source at runtime¶

In [8]:
#newSourceDict = {
#    "glon" : 86.11,
#    "glat": -38.18,
#    "spectrumType" : "PowerLaw",
#    "flux": 100e-08,
#    "index": 2.1
#}
#s = ag.addSource("NEWSOURCE", newSourceDict)

#print(s)

Deleting sources¶

Selection params = [name, dist, flux, sqrtts]

In [9]:
deletedSources = ag.deleteSources('flux <= 10e-08', show = True)
-----------------------------------------------------------
 Source name: 2AGLJ2247+1558 (PointSource)
  * Spectrum type: PowerLaw
  * Free parameters: none
  * Initial source parameters:
	- flux (ph/cm2s): 6.0533e-08
	- index : 2.75651
	- Source position (l,b): (84.2229, -37.4782)
	- Distance from map center (deg): 1.6474

Selecting sources¶

In [10]:
sources = ag.selectSources("flux > 0", show = True)
-----------------------------------------------------------
 Source name: 2AGLJ2254+1609 (PointSource)
  * Spectrum type: PowerLaw
  * Free parameters: none
  * Initial source parameters:
	- flux (ph/cm2s): 7.5094e-07
	- index : 2.20942
	- Source position (l,b): (86.1236, -38.1824)
	- Distance from map center (deg): 0.011

Free a source's parameter¶

Freeable params = [flux, index, index1, index2, cutoffEnergy, pivotEnergy, curvature, pos]

In [11]:
affectedSources = ag.freeSources('name == "2AGLJ2254+1609"', "flux", True, show=True)
-----------------------------------------------------------
 Source name: 2AGLJ2254+1609 (PointSource)
  * Spectrum type: PowerLaw
  * Free parameters: flux
  * Initial source parameters:
	- flux (ph/cm2s): 7.5094e-07
	- index : 2.20942
	- Source position (l,b): (86.1236, -38.1824)
	- Distance from map center (deg): 0.011

In this example, only one source is affected.

Analysis¶

In [12]:
#Generate maps
maplistfile = ag.generateMaps()
Generating maps..please wait.
Fov bins loop:   0%|          | 0/1 [00:00<?, ?it/s]
Energy bins loop: 0it [00:00, ?it/s]
In [13]:
! cat $maplistfile
/root/agilepy_analysis/username_3C454_3_20221022-165046/maps/0/analysis_product_TN216691200.0_TX217382400.0_EN00100_EX50000_ID01.cts.gz /root/agilepy_analysis/username_3C454_3_20221022-165046/maps/0/analysis_product_TN216691200.0_TX217382400.0_EN00100_EX50000_ID01.exp.gz /root/agilepy_analysis/username_3C454_3_20221022-165046/maps/0/analysis_product_TN216691200.0_TX217382400.0_EN00100_EX50000_ID01.gas.gz 30 -1 -1
In [14]:
#Display counts map
ag.displayCtsSkyMaps(maplistFile=maplistfile, smooth=3, catalogRegions="2AGL", catalogRegionsColor="green")
Generating plot..please wait.
2022-10-22 16:51:13,406 [WARNING ] [AGAnalysis] singleMode has been turned off because only one map is going to be displayed.
WARNING: FITSFixedWarning: 'datfix' made the change 'Set DATEREF to '2004-01-01T00:01:06.184' from MJDREF.
Set MJD-OBS to 55513.000764 from DATE-OBS.
Set MJD-END to 55521.000764 from DATE-END'. [astropy.wcs.wcs]
Figure
Out[14]:
[None]
In [15]:
#Display exposure map
ag.displayExpSkyMaps()
Generating plot..please wait.
2022-10-22 16:51:15,236 [WARNING ] [AGAnalysis] singleMode has been turned off because only one map is going to be displayed.
WARNING: FITSFixedWarning: 'datfix' made the change 'Set DATEREF to '2004-01-01T00:01:06.184' from MJDREF.
Set MJD-OBS to 55513.000764 from DATE-OBS.
Set MJD-END to 55521.000764 from DATE-END'. [astropy.wcs.wcs]
Figure
Out[15]:
[None]
In [16]:
#Display diffuse emission map
ag.displayGasSkyMaps()
Generating plot..please wait.
2022-10-22 16:51:15,788 [WARNING ] [AGAnalysis] singleMode has been turned off because only one map is going to be displayed.
WARNING: FITSFixedWarning: 'datfix' made the change 'Set DATEREF to '2004-01-01T00:01:06.184' from MJDREF.
Set MJD-OBS to 55513.000764 from DATE-OBS.
Set MJD-END to 55521.000764 from DATE-END'. [astropy.wcs.wcs]
Figure
Out[16]:
[None]

Fix the diffuse emission coefficient to a default value. This is the default guidline for sources outside Galactic plane

In [17]:
ag.setOptions(galcoeff=[0.7])
In [18]:
#! cat $maplistfile
In [19]:
ag.printOptions("model")
{ 'emax_sources': 10000,
  'emin_sources': 100,
  'galcoeff': [0.7],
  'galmode': 1,
  'galmode2': 0,
  'galmode2fit': 0,
  'isocoeff': [-1],
  'isomode': 1,
  'isomode2': 0,
  'isomode2fit': 0,
  'modelfile': None}
In [20]:
#calculate a mean value of isotropic and diffuse emission coefficients. 
gal,iso,maplist = ag.calcBkg("2AGLJ2254+1609", galcoeff = [0.7], pastTimeWindow = 0)
Computing background coefficients..please wait.
<agilepy.core.MapList.MapList object at 0x7f723612d760>
Generating maps..please wait.
Fov bins loop:   0%|          | 0/1 [00:00<?, ?it/s]
Energy bins loop: 0it [00:00, ?it/s]
In [21]:
print(iso)
[9.39942]
In [22]:
#! cat $maplistfile
In [23]:
#ag.printOptions("model")
In [24]:
#Perform a maximum likelihood estimator
ag.mle()
Out[24]:
['/root/agilepy_analysis/username_3C454_3_20221022-165046/mle/0/analysis_product_2AGLJ2254+1609.source']
In [25]:
#Display the results
ag.selectSources("sqrtts > 0", show=True)
-----------------------------------------------------------
 Source name: 2AGLJ2254+1609 (PointSource) => sqrt(ts): 22.8362
  * Spectrum type: PowerLaw
  * Free parameters: flux
  * Initial source parameters:
	- flux (ph/cm2s): 7.5094e-07
	- index : 2.20942
	- Source position (l,b): (86.1236, -38.1824)
	- Distance from map center (deg): 0.011
  * Last MLE analysis (2022-10-22 16:51:42.411444):
	- flux (ph/cm2s): 7.5094e-07
	- index : 2.20942
	- counts: 20.3332
	- upper limit(ph/cm2s): 7.50937e-07
	- ergLog(erg/cm2s): 1.20391e-10
	- galCoeff: [0.7] +/- [6.91363e-310]
	- isoCoeff: [9.39942] +/- [6.91364e-310]
	- exposure(cm2s): 27077100.0
	- exp-ratio: 0
	- L_peak: 86.1236
	- B_peak: -38.1824
	- Distance from start pos: 0
	- ellipse position:
	    - L: -1
	    - B: -1
	    - Distance from start pos: -1
	    - radius of circle: -1
	    - ellipse:
		  - a: -1
		  - b: -1
		  - phi: -1
-----------------------------------------------------------
Out[25]:
[<agilepy.core.source.Source.PointSource at 0x7f723612d4c0>]

Light curve with default tmin and tmax¶

In [26]:
lightCurveData = ag.lightCurveMLE("2AGLJ2254+1609", binsize=86400)
Computing light curve bins..please wait.
Temporal bin loop:   0%|          | 0/8 [00:00<?, ?it/s]
Generating maps..please wait.
Fov bins loop:   0%|          | 0/1 [00:00<?, ?it/s]
Energy bins loop: 0it [00:00, ?it/s]
Generating maps..please wait.
Fov bins loop:   0%|          | 0/1 [00:00<?, ?it/s]
Energy bins loop: 0it [00:00, ?it/s]
Generating maps..please wait.
Fov bins loop:   0%|          | 0/1 [00:00<?, ?it/s]
Energy bins loop: 0it [00:00, ?it/s]
Generating maps..please wait.
Fov bins loop:   0%|          | 0/1 [00:00<?, ?it/s]
Energy bins loop: 0it [00:00, ?it/s]
Generating maps..please wait.
Fov bins loop:   0%|          | 0/1 [00:00<?, ?it/s]
Energy bins loop: 0it [00:00, ?it/s]
Generating maps..please wait.
Fov bins loop:   0%|          | 0/1 [00:00<?, ?it/s]
Energy bins loop: 0it [00:00, ?it/s]
Generating maps..please wait.
Fov bins loop:   0%|          | 0/1 [00:00<?, ?it/s]
Energy bins loop: 0it [00:00, ?it/s]
Generating maps..please wait.
Fov bins loop:   0%|          | 0/1 [00:00<?, ?it/s]
Energy bins loop: 0it [00:00, ?it/s]
In [27]:
cat $lightCurveData
time_start_mjd time_end_mjd sqrt(ts) flux flux_err flux_ul gal gal_error iso iso_error l_peak b_peak dist_peak l b r ell_dist a b phi exposure ExpRatio counts counts_err Index Index_Err Par2 Par2_Err Par3 Par3_Err Erglog Erglog_Err Erglog_UL time_start_utc time_end_utc time_start_tt time_end_tt Fix index ULConfidenceLevel SrcLocConfLevel start_l start_b start_flux typefun par2 par3 galmode2 galmode2fit isomode2 isomode2fit edpcor fluxcor integratortype expratioEval expratio_minthr expratio_maxthr expratio_size Emin emax fovmin fovmax albedo binsize expstep phasecode fit_cts fit_fitstatus0 fit_fcn0 fit_edm0 fit_nvpar0 fit_nparx0 fit_iter0 fit_fitstatus1 fit_fcn1 fit_edm1 fit_nvpar1 fit_nparx1 fit_iter1 fit_Likelihood1
55513.0 55514.0 5.547 628.598e-08 188.701e-08 1059.69e-08 0.7 0 9.39942 0 86.1236 -38.1824 0 -1 -1 -1 -1 -1 -1 -1 3438060.0 0 21.6116 6.48764 2.20942 0 0 0 0 0 1.00777e-09 3.02526e-10 1.69891e-09 2010-11-13T00:00:00.000 2010-11-14T00:00:00.000 216691200.0 216777600.0 1 2.20942 2 5.99147 86.1236 -38.1824 7.50937e-07 0 0 0 0 0 0 0 1 0 1 1 0 15 10 100 50000 0 60 80 0.5 0 6 58 -1 189.845 0.5 0 8 3 0 174.46 3.01283e-16 1 8 3 228.301
55514.0 55515.0 5.14501 550.725e-08 169.57e-08 940.41e-08 0.7 0 9.39942 0 86.1236 -38.1824 0 -1 -1 -1 -1 -1 -1 -1 3493990.0 0 19.2422 5.92475 2.20942 0 0 0 0 0 8.82926e-10 2.71855e-10 1.50767e-09 2010-11-14T00:00:00.000 2010-11-15T00:00:00.000 216777600.0 216864000.0 1 2.20942 2 5.99147 86.1236 -38.1824 7.50937e-07 0 0 0 0 0 0 0 1 0 1 1 0 15 10 100 50000 0 60 80 0.5 0 6 47 -1 156.687 0.5 0 8 3 0 143.451 4.77833e-15 1 8 3 190.451
55515.0 55516.0 7.70264 994.831e-08 226.083e-08 1498.17e-08 0.7 0 9.39942 0 86.1236 -38.1824 0 -1 -1 -1 -1 -1 -1 -1 3447230.0 0 34.2941 7.79361 2.20942 0 0 0 0 0 1.59492e-09 3.62458e-10 2.40187e-09 2010-11-15T00:00:00.000 2010-11-16T00:00:00.000 216864000.0 216950400.0 1 2.20942 2 5.99147 86.1236 -38.1824 7.50937e-07 0 0 0 0 0 0 0 1 0 1 1 0 15 10 100 50000 0 60 80 0.5 0 6 73 -1 230.912 0.5 0 8 3 0 201.247 6.02423e-18 1 8 3 268.702
55516.0 55517.0 8.03516 1118.38e-08 233.93e-08 1634.34e-08 0.7 0 9.39942 0 86.1236 -38.1824 0 -1 -1 -1 -1 -1 -1 -1 3579240.0 0 40.0296 8.37292 2.20942 0 0 0 0 0 1.793e-09 3.75038e-10 2.62018e-09 2010-11-16T00:00:00.000 2010-11-17T00:00:00.000 216950400.0 217036800.0 1 2.20942 2 5.99147 86.1236 -38.1824 7.50937e-07 0 0 0 0 0 0 0 1 0 1 1 0 15 10 100 50000 0 60 80 0.5 0 6 80 -1 248.717 0.5 0 8 3 0 216.435 1.60478e-14 1 8 3 289.504
55517.0 55518.0 17.1096 3660.72e-08 467.179e-08 4666.91e-08 0.7 0 9.39942 0 86.1236 -38.1824 0 -1 -1 -1 -1 -1 -1 -1 2153790.0 0 78.8444 10.0621 2.20942 0 0 0 0 0 5.86889e-09 7.48985e-10 7.48202e-09 2010-11-17T00:00:00.000 2010-11-18T00:00:00.000 217036800.0 217123200.0 1 2.20942 2 5.99147 86.1236 -38.1824 7.50937e-07 0 0 0 0 0 0 0 1 0 1 1 0 15 10 100 50000 0 60 80 0.5 0 6 90 -1 329.08 0.5 0 8 3 0 182.71 9.69287e-17 1 8 3 242.57
55518.0 55519.0 11.1229 75.0937e-08 0 75.0937e-08 0.7 6.8984e-310 9.39942 6.8984e-310 86.1236 -38.1824 0 -1 -1 -1 -1 -1 -1 -1 3789410.0 0 2.84561 0 2.20942 0 0 0 0 0 1.20391e-10 0 1.20391e-10 2010-11-18T00:00:00.000 2010-11-19T00:00:00.000 217123200.0 217209600.0 1 2.20942 2 5.99147 86.1236 -38.1824 7.50937e-07 0 0 0 0 0 0 0 1 0 1 1 0 15 10 100 50000 0 60 80 0.5 0 6 191 -1 612.63 0.5 0 8 3 4 550.77 12971400000.0 1 8 3 647.929
55519.0 55520.0 27.1698 5115.12e-08 420.66e-08 5998.11e-08 0.7 0 9.39942 0 86.1236 -38.1824 0 -1 -1 -1 -1 -1 -1 -1 3687280.0 0 188.609 15.5109 2.20942 0 0 0 0 0 8.2006e-09 6.74405e-10 9.61621e-09 2010-11-19T00:00:00.000 2010-11-20T00:00:00.000 217209600.0 217296000.0 1 2.20942 2 5.99147 86.1236 -38.1824 7.50937e-07 0 0 0 0 0 0 0 1 0 1 1 0 15 10 100 50000 0 60 80 0.5 0 6 213 -1 680.524 0.5 0 8 3 0 311.426 1.41401e-16 1 8 3 421.382
55520.0 55521.0 25.883 4665.29e-08 409.236e-08 5527.82e-08 0.7 0 9.39942 0 86.1236 -38.1824 0 -1 -1 -1 -1 -1 -1 -1 3475880.0 0 162.16 14.2246 2.20942 0 0 0 0 0 7.47943e-09 6.5609e-10 8.86224e-09 2010-11-20T00:00:00.000 2010-11-21T00:00:00.000 217296000.0 217382400.0 1 2.20942 2 5.99147 86.1236 -38.1824 7.50937e-07 0 0 0 0 0 0 0 1 0 1 1 0 15 10 100 50000 0 60 80 0.5 0 6 179 -1 600.212 0.5 0 8 3 0 265.249 8.1209e-17 1 8 3 344.357
In [28]:
print(lightCurveData)
/root/agilepy_analysis/username_3C454_3_20221022-165046/lc/0/light_curve_216691200_217382400.txt
In [29]:
ag.displayLightCurve("mle")
Generating plot..please wait.

Light curve with explicit tmin and tmax¶

In [30]:
lightCurveData = ag.lightCurveMLE("2AGLJ2254+1609", tmin=55513.0, tmax=55515.0, timetype="MJD", binsize=86400)
Computing light curve bins..please wait.
Temporal bin loop:   0%|          | 0/2 [00:00<?, ?it/s]
Generating maps..please wait.
Fov bins loop:   0%|          | 0/1 [00:00<?, ?it/s]
Energy bins loop: 0it [00:00, ?it/s]
Generating maps..please wait.
Fov bins loop:   0%|          | 0/1 [00:00<?, ?it/s]
Energy bins loop: 0it [00:00, ?it/s]
In [31]:
#cat $lightCurveData
In [32]:
ag.displayLightCurve("mle")
Generating plot..please wait.

Evaluation of spectral index of pre-flare period 55513.00-55517.00¶

Select a set of energy bins. Usualy the AGILE team use the following (in MeV): [100, 300], [300, 1000], [1000, 3000], [3000, 10000], [10000, 50000]].

In the following lines the default value for all gal coefficient is kept fixed.

In [33]:
ag.setOptionTimeMJD(55513.0, 55517.0)
ag.setOptions(energybins=[[100, 300], [300, 1000], [1000, 3000], [3000, 10000], [10000, 50000]])
ag.setOptions(galcoeff=[0.7, 0.7, 0.7, 0.7, 0.7])
ag.setOptions(isocoeff=[-1, -1, -1, -1, -1])
In [34]:
ag.printOptions("maps")
{ 'binsize': 0.5,
  'energybins': [ [100, 300],
                  [300, 1000],
                  [1000, 3000],
                  [3000, 10000],
                  [10000, 50000]],
  'expstep': 2,
  'fovbinnumber': 1,
  'mapsize': 25,
  'offaxisangle': 30,
  'proj': 'ARC',
  'projtype': 'WCS',
  'spectralindex': 2.1,
  'timestep': 160,
  'useEDPmatrixforEXP': False}
In [35]:
maplistfile = ag.generateMaps()
Generating maps..please wait.
Fov bins loop:   0%|          | 0/1 [00:00<?, ?it/s]
Energy bins loop: 0it [00:00, ?it/s]

Free the index spectral parameter. The spectral index is calculated over the energy ranges selected above.

In [36]:
affectedSources = ag.freeSources('name == "2AGLJ2254+1609"', "index", True, show=True)
-----------------------------------------------------------
 Source name: 2AGLJ2254+1609 (PointSource) => sqrt(ts): 22.8362
  * Spectrum type: PowerLaw
  * Free parameters: flux index
  * Initial source parameters:
	- flux (ph/cm2s): 7.5094e-07
	- index : 2.20942
	- Source position (l,b): (86.1236, -38.1824)
	- Distance from map center (deg): 0.011
  * Last MLE analysis (2022-10-22 16:51:42.411444):
	- flux (ph/cm2s): 7.5094e-07
	- index : 2.20942
	- counts: 20.3332
	- upper limit(ph/cm2s): 7.50937e-07
	- ergLog(erg/cm2s): 1.20391e-10
	- galCoeff: [0.7] +/- [6.91363e-310]
	- isoCoeff: [9.39942] +/- [6.91364e-310]
	- exposure(cm2s): 27077100.0
	- exp-ratio: 0
	- L_peak: 86.1236
	- B_peak: -38.1824
	- Distance from start pos: 0
	- ellipse position:
	    - L: -1
	    - B: -1
	    - Distance from start pos: -1
	    - radius of circle: -1
	    - ellipse:
		  - a: -1
		  - b: -1
		  - phi: -1
-----------------------------------------------------------
In [37]:
ag.mle()
Out[37]:
['/root/agilepy_analysis/username_3C454_3_20221022-165046/mle/1/analysis_product_2AGLJ2254+1609.source']
In [38]:
selectedSources = ag.selectSources('flux > 0', show=True)
-----------------------------------------------------------
 Source name: 2AGLJ2254+1609 (PointSource) => sqrt(ts): 10.2859
  * Spectrum type: PowerLaw
  * Free parameters: flux index
  * Initial source parameters:
	- flux (ph/cm2s): 7.5094e-07
	- index : 2.20942
	- Source position (l,b): (86.1236, -38.1824)
	- Distance from map center (deg): 0.011
  * Last MLE analysis (2022-10-22 16:54:30.561309):
	- flux (ph/cm2s): 8.7534e-06 +/- 1.6280e-06
	- index : 2.51349 +/- 0.173183
	- counts: 119.659 +/- 22.2551
	- upper limit(ph/cm2s): 1.14728e-05
	- ergLog(erg/cm2s): 1.40335e-09 +/- 2.61004e-10
	- galCoeff: [0.7, 0.7, 0.7, 0.7, 0.7]
	- isoCoeff: [5.24455, 3.14799, 0.953585, 1.61154e-10, 0.557564] +/- [0.520858, 0.209864, 0.0514486, 0.000108251, 0.000721513]
	- exposure(cm2s): 13670100.0
	- exp-ratio: 0
	- L_peak: 86.1236
	- B_peak: -38.1824
	- Distance from start pos: 0
	- ellipse position:
	    - L: -1
	    - B: -1
	    - Distance from start pos: -1
	    - radius of circle: -1
	    - ellipse:
		  - a: -1
		  - b: -1
		  - phi: -1
-----------------------------------------------------------

Calculate the light curve. The index must be kept fixed. Position could be fixed or free. Flux must be free.

In [39]:
ag.setOptions(energybins=[[100, 50000]])
ag.setOptions(galcoeff=[0.7])
affectedSources = ag.freeSources('name == "2AGLJ2254+1609"', "index", False, show=False)
affectedSources = ag.freeSources('name == "2AGLJ2254+1609"', "pos", True, show=True)
#selectedSources = ag.selectSources('flux > 0', show=True)
lightCurveData1 = ag.lightCurveMLE("2AGLJ2254+1609", tmin=55513.0, tmax=55517.0, timetype="MJD", binsize=86400)
-----------------------------------------------------------
 Source name: 2AGLJ2254+1609 (PointSource) => sqrt(ts): 10.2859
  * Spectrum type: PowerLaw
  * Free parameters: flux pos
  * Initial source parameters:
	- flux (ph/cm2s): 7.5094e-07
	- index : 2.20942
	- Source position (l,b): (86.1236, -38.1824)
	- Distance from map center (deg): 0.011
  * Last MLE analysis (2022-10-22 16:54:30.561309):
	- flux (ph/cm2s): 8.7534e-06 +/- 1.6280e-06
	- index : 2.51349 +/- 0.173183
	- counts: 119.659 +/- 22.2551
	- upper limit(ph/cm2s): 1.14728e-05
	- ergLog(erg/cm2s): 1.40335e-09 +/- 2.61004e-10
	- galCoeff: [0.7, 0.7, 0.7, 0.7, 0.7]
	- isoCoeff: [5.24455, 3.14799, 0.953585, 1.61154e-10, 0.557564] +/- [0.520858, 0.209864, 0.0514486, 0.000108251, 0.000721513]
	- exposure(cm2s): 13670100.0
	- exp-ratio: 0
	- L_peak: 86.1236
	- B_peak: -38.1824
	- Distance from start pos: 0
	- ellipse position:
	    - L: -1
	    - B: -1
	    - Distance from start pos: -1
	    - radius of circle: -1
	    - ellipse:
		  - a: -1
		  - b: -1
		  - phi: -1
-----------------------------------------------------------
Computing light curve bins..please wait.
Temporal bin loop:   0%|          | 0/4 [00:00<?, ?it/s]
Generating maps..please wait.
Fov bins loop:   0%|          | 0/1 [00:00<?, ?it/s]
Energy bins loop: 0it [00:00, ?it/s]
Generating maps..please wait.
Fov bins loop:   0%|          | 0/1 [00:00<?, ?it/s]
Energy bins loop: 0it [00:00, ?it/s]
Generating maps..please wait.
Fov bins loop:   0%|          | 0/1 [00:00<?, ?it/s]
Energy bins loop: 0it [00:00, ?it/s]
Generating maps..please wait.
Fov bins loop:   0%|          | 0/1 [00:00<?, ?it/s]
Energy bins loop: 0it [00:00, ?it/s]
In [40]:
print(lightCurveData1)
ag.displayLightCurve("mle")
/root/agilepy_analysis/username_3C454_3_20221022-165046/lc/2/light_curve_216691200_217036800.txt
Generating plot..please wait.
In [41]:
! cat $lightCurveData1
time_start_mjd time_end_mjd sqrt(ts) flux flux_err flux_ul gal gal_error iso iso_error l_peak b_peak dist_peak l b r ell_dist a b phi exposure ExpRatio counts counts_err Index Index_Err Par2 Par2_Err Par3 Par3_Err Erglog Erglog_Err Erglog_UL time_start_utc time_end_utc time_start_tt time_end_tt Fix index ULConfidenceLevel SrcLocConfLevel start_l start_b start_flux typefun par2 par3 galmode2 galmode2fit isomode2 isomode2fit edpcor fluxcor integratortype expratioEval expratio_minthr expratio_maxthr expratio_size Emin emax fovmin fovmax albedo binsize expstep phasecode fit_cts fit_fitstatus0 fit_fcn0 fit_edm0 fit_nvpar0 fit_nparx0 fit_iter0 fit_fitstatus1 fit_fcn1 fit_edm1 fit_nvpar1 fit_nparx1 fit_iter1 fit_Likelihood1
55513.0 55514.0 4.32035 642.979e-08 232.549e-08 1180.75e-08 0.7 0 10.991 0.508972 85.9102 -37.9369 0.297486 86.2013 1.1427 1.08087 0.0702603 0.887659 1.1427 28.6357 3364190.0 0 21.631 7.82338 2.51349 0 0 0 0 0 1.03083e-09 3.72824e-10 1.89299e-09 2010-11-13T00:00:00.000 2010-11-14T00:00:00.000 216691200.0 216777600.0 3 2.51349 2 5.99147 86.1236 -38.1824 8.75337e-06 0 0 0 0 0 0 0 1 0 1 1 0 15 10 100 50000 0 60 80 0.5 0 6 58 0 182.447 1.18453e-09 1 8 25 0 173.114 6.88593e-07 2 8 25 226.956
55514.0 55515.0 5.36336 786.759e-08 225.657e-08 1298.53e-08 0.7 0 5.54233 0.524937 85.5303 -37.8277 0.586852 85.2635 0.941887 1.19558 0.775158 1.35608 0.941887 14.6594 3535790.0 0 27.8182 7.97875 2.51349 0 0 0 0 0 1.26134e-09 3.61775e-10 2.08181e-09 2010-11-14T00:00:00.000 2010-11-15T00:00:00.000 216777600.0 216864000.0 3 2.51349 2 5.99147 86.1236 -38.1824 8.75337e-06 0 0 0 0 0 0 0 1 0 1 1 0 15 10 100 50000 0 60 80 0.5 0 6 46 0 152.285 2.30385e-10 1 8 30 0 137.902 1.83574e-09 2 8 30 183.902
55515.0 55516.0 5.3458 944.251e-08 270.486e-08 1553.45e-08 0.7 0 12.6982 0.516907 86.0458 -38.325 0.155178 86.3895 1.03513 1.02488 0.458338 0.896505 1.03513 63.9542 3417240.0 0 32.2673 9.24315 2.51349 0 0 0 0 0 1.51383e-09 4.33645e-10 2.4905e-09 2010-11-15T00:00:00.000 2010-11-16T00:00:00.000 216864000.0 216950400.0 3 2.51349 2 5.99147 86.1236 -38.1824 8.75337e-06 0 0 0 0 0 0 0 1 0 1 1 0 15 10 100 50000 0 60 80 0.5 0 6 73 0 213.424 2.14724e-08 1 8 25 0 199.135 2.1518e-09 2 8 25 266.59
55516.0 55517.0 5.46583 1003.54e-08 277.996e-08 1622.63e-08 0.7 0 13.2396 0.538427 86.4269 -37.9295 0.347829 86.2991 0.673445 0.842059 0.375079 0.941951 0.673445 74.8598 3559640.0 0 35.7224 9.89566 2.51349 0 0 0 0 0 1.60888e-09 4.45685e-10 2.60142e-09 2010-11-16T00:00:00.000 2010-11-17T00:00:00.000 216950400.0 217036800.0 3 2.51349 2 5.99147 86.1236 -38.1824 8.75337e-06 0 0 0 0 0 0 0 1 0 1 1 0 15 10 100 50000 0 60 80 0.5 0 6 80 0 227.167 2.47288e-07 1 8 25 0 212.229 5.3908e-09 2 8 25 285.297

Evaluation of spectral index of flare period 55517.00-55521.00¶

In [42]:
ag.setOptionTimeMJD(55517.0, 55521.0)
ag.setOptions(energybins=[[100, 300], [300, 1000], [1000, 3000], [3000, 10000], [10000, 50000]])
ag.setOptions(galcoeff=[0.7, 0.7, 0.7, 0.7, 0.7])
ag.setOptions(isocoeff=[-1, -1, -1, -1, -1])
In [43]:
maplistfile = ag.generateMaps()
Generating maps..please wait.
Fov bins loop:   0%|          | 0/1 [00:00<?, ?it/s]
Energy bins loop: 0it [00:00, ?it/s]
In [44]:
affectedSources = ag.freeSources('name == "2AGLJ2254+1609"', "index", True, show=True)
-----------------------------------------------------------
 Source name: 2AGLJ2254+1609 (PointSource) => sqrt(ts): 10.2859
  * Spectrum type: PowerLaw
  * Free parameters: flux index pos
  * Initial source parameters:
	- flux (ph/cm2s): 7.5094e-07
	- index : 2.20942
	- Source position (l,b): (86.1236, -38.1824)
	- Distance from map center (deg): 0.011
  * Last MLE analysis (2022-10-22 16:54:30.561309):
	- flux (ph/cm2s): 8.7534e-06 +/- 1.6280e-06
	- index : 2.51349 +/- 0.173183
	- counts: 119.659 +/- 22.2551
	- upper limit(ph/cm2s): 1.14728e-05
	- ergLog(erg/cm2s): 1.40335e-09 +/- 2.61004e-10
	- galCoeff: [0.7, 0.7, 0.7, 0.7, 0.7]
	- isoCoeff: [5.24455, 3.14799, 0.953585, 1.61154e-10, 0.557564] +/- [0.520858, 0.209864, 0.0514486, 0.000108251, 0.000721513]
	- exposure(cm2s): 13670100.0
	- exp-ratio: 0
	- L_peak: 86.1236
	- B_peak: -38.1824
	- Distance from start pos: 0
	- ellipse position:
	    - L: -1
	    - B: -1
	    - Distance from start pos: -1
	    - radius of circle: -1
	    - ellipse:
		  - a: -1
		  - b: -1
		  - phi: -1
-----------------------------------------------------------
In [45]:
ag.mle()
Out[45]:
['/root/agilepy_analysis/username_3C454_3_20221022-165046/mle/2/analysis_product_2AGLJ2254+1609.source']
In [46]:
selectedSources = ag.selectSources('flux > 0', show=True)
-----------------------------------------------------------
 Source name: 2AGLJ2254+1609 (PointSource) => sqrt(ts): 35.0979
  * Spectrum type: PowerLaw
  * Free parameters: flux index pos
  * Initial source parameters:
	- flux (ph/cm2s): 8.7534e-06 +/- 1.6280e-06
	- index : 2.51349 +/- 0.173183
	- Source position (l,b): (86.1236, -38.1824)
	- Distance from map center (deg): 0.011
  * Last MLE analysis (2022-10-22 16:56:32.451189):
	- flux (ph/cm2s): 4.3186e-05 +/- 2.4314e-06
	- index : 2.07417 +/- 0.0530753
	- counts: 570.131 +/- 32.0983
	- upper limit(ph/cm2s): 4.7782e-05
	- ergLog(erg/cm2s): 6.92359e-09 +/- 3.89797e-10
	- galCoeff: [0.7, 0.7, 0.7, 0.7, 0.7]
	- isoCoeff: [5.49271, 3.58341, 0.434697, 0.0863532, 1.17448] +/- [0.385953, 0.208589, 0.0921811, 0.0461491, 0.0269005]
	- exposure(cm2s): 13201800.0
	- exp-ratio: 0
	- L_peak: 86.0861
	- B_peak: -38.1857
	- Distance from start pos: 0.0296635
	- ellipse position:
	    - L: -1
	    - B: -1
	    - Distance from start pos: -1
	    - radius of circle: -1
	    - ellipse:
		  - a: -1
		  - b: -1
		  - phi: -1
-----------------------------------------------------------
In [47]:
ag.setOptions(energybins=[[100, 50000]])
ag.setOptions(galcoeff=[0.7])
affectedSources = ag.freeSources('name == "2AGLJ2254+1609"', "index", False, show=True)
affectedSources = ag.freeSources('name == "2AGLJ2254+1609"', "pos", True, show=True)
#selectedSources = ag.selectSources('flux > 0', show=True)
lightCurveData2 = ag.lightCurveMLE("2AGLJ2254+1609", tmin=55517.0, tmax=55521.0, timetype="MJD", binsize=86400)
-----------------------------------------------------------
 Source name: 2AGLJ2254+1609 (PointSource) => sqrt(ts): 35.0979
  * Spectrum type: PowerLaw
  * Free parameters: flux pos
  * Initial source parameters:
	- flux (ph/cm2s): 8.7534e-06 +/- 1.6280e-06
	- index : 2.51349 +/- 0.173183
	- Source position (l,b): (86.1236, -38.1824)
	- Distance from map center (deg): 0.011
  * Last MLE analysis (2022-10-22 16:56:32.451189):
	- flux (ph/cm2s): 4.3186e-05 +/- 2.4314e-06
	- index : 2.07417 +/- 0.0530753
	- counts: 570.131 +/- 32.0983
	- upper limit(ph/cm2s): 4.7782e-05
	- ergLog(erg/cm2s): 6.92359e-09 +/- 3.89797e-10
	- galCoeff: [0.7, 0.7, 0.7, 0.7, 0.7]
	- isoCoeff: [5.49271, 3.58341, 0.434697, 0.0863532, 1.17448] +/- [0.385953, 0.208589, 0.0921811, 0.0461491, 0.0269005]
	- exposure(cm2s): 13201800.0
	- exp-ratio: 0
	- L_peak: 86.0861
	- B_peak: -38.1857
	- Distance from start pos: 0.0296635
	- ellipse position:
	    - L: -1
	    - B: -1
	    - Distance from start pos: -1
	    - radius of circle: -1
	    - ellipse:
		  - a: -1
		  - b: -1
		  - phi: -1
-----------------------------------------------------------
Computing light curve bins..please wait.
Temporal bin loop:   0%|          | 0/4 [00:00<?, ?it/s]
Generating maps..please wait.
Fov bins loop:   0%|          | 0/1 [00:00<?, ?it/s]
Energy bins loop: 0it [00:00, ?it/s]
Generating maps..please wait.
Fov bins loop:   0%|          | 0/1 [00:00<?, ?it/s]
Energy bins loop: 0it [00:00, ?it/s]
Generating maps..please wait.
Fov bins loop:   0%|          | 0/1 [00:00<?, ?it/s]
Energy bins loop: 0it [00:00, ?it/s]
Generating maps..please wait.
Fov bins loop:   0%|          | 0/1 [00:00<?, ?it/s]
Energy bins loop: 0it [00:00, ?it/s]
In [48]:
print(lightCurveData2)
ag.displayLightCurve("mle")
/root/agilepy_analysis/username_3C454_3_20221022-165046/lc/3/light_curve_217036800_217382400.txt
Generating plot..please wait.

Merge light curves¶

The two light curve calculated with two different spectral indexes are merged and displayed.

In [49]:
mergedfilename = "/tmp/lightcurve3C.txt"
In [50]:
! cat $lightCurveData1 > $mergedfilename
! sed '1d' $lightCurveData2 >> $mergedfilename
! cat $mergedfilename
time_start_mjd time_end_mjd sqrt(ts) flux flux_err flux_ul gal gal_error iso iso_error l_peak b_peak dist_peak l b r ell_dist a b phi exposure ExpRatio counts counts_err Index Index_Err Par2 Par2_Err Par3 Par3_Err Erglog Erglog_Err Erglog_UL time_start_utc time_end_utc time_start_tt time_end_tt Fix index ULConfidenceLevel SrcLocConfLevel start_l start_b start_flux typefun par2 par3 galmode2 galmode2fit isomode2 isomode2fit edpcor fluxcor integratortype expratioEval expratio_minthr expratio_maxthr expratio_size Emin emax fovmin fovmax albedo binsize expstep phasecode fit_cts fit_fitstatus0 fit_fcn0 fit_edm0 fit_nvpar0 fit_nparx0 fit_iter0 fit_fitstatus1 fit_fcn1 fit_edm1 fit_nvpar1 fit_nparx1 fit_iter1 fit_Likelihood1
55513.0 55514.0 4.32035 642.979e-08 232.549e-08 1180.75e-08 0.7 0 10.991 0.508972 85.9102 -37.9369 0.297486 86.2013 1.1427 1.08087 0.0702603 0.887659 1.1427 28.6357 3364190.0 0 21.631 7.82338 2.51349 0 0 0 0 0 1.03083e-09 3.72824e-10 1.89299e-09 2010-11-13T00:00:00.000 2010-11-14T00:00:00.000 216691200.0 216777600.0 3 2.51349 2 5.99147 86.1236 -38.1824 8.75337e-06 0 0 0 0 0 0 0 1 0 1 1 0 15 10 100 50000 0 60 80 0.5 0 6 58 0 182.447 1.18453e-09 1 8 25 0 173.114 6.88593e-07 2 8 25 226.956
55514.0 55515.0 5.36336 786.759e-08 225.657e-08 1298.53e-08 0.7 0 5.54233 0.524937 85.5303 -37.8277 0.586852 85.2635 0.941887 1.19558 0.775158 1.35608 0.941887 14.6594 3535790.0 0 27.8182 7.97875 2.51349 0 0 0 0 0 1.26134e-09 3.61775e-10 2.08181e-09 2010-11-14T00:00:00.000 2010-11-15T00:00:00.000 216777600.0 216864000.0 3 2.51349 2 5.99147 86.1236 -38.1824 8.75337e-06 0 0 0 0 0 0 0 1 0 1 1 0 15 10 100 50000 0 60 80 0.5 0 6 46 0 152.285 2.30385e-10 1 8 30 0 137.902 1.83574e-09 2 8 30 183.902
55515.0 55516.0 5.3458 944.251e-08 270.486e-08 1553.45e-08 0.7 0 12.6982 0.516907 86.0458 -38.325 0.155178 86.3895 1.03513 1.02488 0.458338 0.896505 1.03513 63.9542 3417240.0 0 32.2673 9.24315 2.51349 0 0 0 0 0 1.51383e-09 4.33645e-10 2.4905e-09 2010-11-15T00:00:00.000 2010-11-16T00:00:00.000 216864000.0 216950400.0 3 2.51349 2 5.99147 86.1236 -38.1824 8.75337e-06 0 0 0 0 0 0 0 1 0 1 1 0 15 10 100 50000 0 60 80 0.5 0 6 73 0 213.424 2.14724e-08 1 8 25 0 199.135 2.1518e-09 2 8 25 266.59
55516.0 55517.0 5.46583 1003.54e-08 277.996e-08 1622.63e-08 0.7 0 13.2396 0.538427 86.4269 -37.9295 0.347829 86.2991 0.673445 0.842059 0.375079 0.941951 0.673445 74.8598 3559640.0 0 35.7224 9.89566 2.51349 0 0 0 0 0 1.60888e-09 4.45685e-10 2.60142e-09 2010-11-16T00:00:00.000 2010-11-17T00:00:00.000 216950400.0 217036800.0 3 2.51349 2 5.99147 86.1236 -38.1824 8.75337e-06 0 0 0 0 0 0 0 1 0 1 1 0 15 10 100 50000 0 60 80 0.5 0 6 80 0 227.167 2.47288e-07 1 8 25 0 212.229 5.3908e-09 2 8 25 285.297
55517.0 55518.0 13.1053 3734.65e-08 531.808e-08 4880.65e-08 0.7 0 6.1927 0.499738 86.2441 -38.083 0.161214 86.2403 0.315681 0.353646 0.168543 0.341006 0.315681 -0.192557 2163990.0 0 80.8174 11.5082 2.07417 0 0 0 0 0 5.98742e-09 8.52597e-10 7.82469e-09 2010-11-17T00:00:00.000 2010-11-18T00:00:00.000 217036800.0 217123200.0 3 2.07417 2 5.99147 86.0861 -38.1857 4.31859e-05 0 0 0 0 0 0 0 1 0 1 1 0 15 10 100 50000 0 60 80 0.5 0 6 89 0 264.492 4.85487e-10 1 8 32 0 178.617 8.39699e-07 2 8 32 237.476
55518.0 55519.0 19.1765 4671.39e-08 427.706e-08 5570.3e-08 0.7 0 6.39072 0.437794 86.0691 -38.2228 0.0394434 86.0549 0.287045 0.263238 0.0898637 0.204302 0.287045 11.199 3811480.0 0 178.049 16.3019 2.07417 0 0 0 0 0 7.4892e-09 6.85702e-10 8.93033e-09 2010-11-18T00:00:00.000 2010-11-19T00:00:00.000 217123200.0 217209600.0 3 2.07417 2 5.99147 86.0861 -38.1857 4.31859e-05 0 0 0 0 0 0 0 1 0 1 1 0 15 10 100 50000 0 60 80 0.5 0 6 190 0 451.806 3.6681e-10 1 8 27 0 267.937 4.56625e-12 2 8 27 364.096
55519.0 55520.0 18.5179 4495.2e-08 443.196e-08 5429.8e-08 0.7 0 15.9092 0.433659 85.9694 -38.2509 0.112471 85.9189 0.281349 0.250222 0.151572 0.190268 0.281349 83.4971 3713430.0 0 166.926 16.4578 2.07417 0 0 0 0 0 7.20673e-09 7.10535e-10 8.7051e-09 2010-11-19T00:00:00.000 2010-11-20T00:00:00.000 217209600.0 217296000.0 3 2.07417 2 5.99147 86.0861 -38.1857 4.31859e-05 0 0 0 0 0 0 0 1 0 1 1 0 15 10 100 50000 0 60 80 0.5 0 6 214 0 482.082 8.05123e-10 1 8 30 0 310.627 1.64936e-09 2 8 30 421.583
55520.0 55521.0 19.3112 4666.43e-08 448.328e-08 5612.13e-08 0.7 0 7.78736 0.425641 86.1123 -38.1832 0.0207589 -1 -1 -1 -1 -1 -1 -1 3475880.0 0 162.199 15.5833 2.07417 0 0 0 0 0 7.48125e-09 7.18763e-10 8.9974e-09 2010-11-20T00:00:00.000 2010-11-21T00:00:00.000 217296000.0 217382400.0 3 2.07417 2 5.99147 86.0861 -38.1857 4.31859e-05 0 0 0 0 0 0 0 1 0 1 1 0 15 10 100 50000 0 60 80 0.5 0 6 178 0 448.111 2.02693e-09 1 8 27 0 261.65 5.33366e-07 2 8 27 339.758
In [51]:
ag.displayLightCurve("mle", filename=mergedfilename)
Generating plot..please wait.

Display additional fields¶

displayGenericColumns() allow to display a column of the result file.

time_start_mjd time_end_mjd sqrt(ts) flux flux_err flux_ul gal gal_error iso iso_error l_peak b_peak dist_peak l b r ell_dist a b phi exposure ExpRatio counts counts_err Index Index_Err Par2 Par2_Err Par3 Par3_Err Erglog Erglog_Err Erglog_UL time_start_utc time_end_utc time_start_tt time_end_tt Fix index ULConfidenceLevel SrcLocConfLevel start_l start_b start_flux typefun par2 par3 galmode2 galmode2fit isomode2 isomode2fit edpcor fluxcor integratortype expratioEval expratio_minthr expratio_maxthr expratio_size Emin emax fovmin fovmax albedo binsize expstep phasecode fit_cts fit_fitstatus0 fit_fcn0 fit_edm0 fit_nvpar0 fit_nparx0 fit_iter0 fit_fitstatus1 fit_fcn1 fit_edm1 fit_nvpar1 fit_nparx1 fit_iter1 fit_Likelihood1

In [52]:
ag.displayGenericColumns(mergedfilename, ["exposure"], um=["cm^2 s sr"])

Cleaning up¶

In [53]:
ag.deleteAnalysisDir()
Out[53]:
True