VERITAS ANALYSIS

[1]:
from vtspy import *

WARNING: version mismatch between CFITSIO header (v4.000999999999999) and linked library (v4.01).


WARNING: version mismatch between CFITSIO header (v4.000999999999999) and linked library (v4.01).


WARNING: version mismatch between CFITSIO header (v4.000999999999999) and linked library (v4.01).

Step 1. Generate a configuration file

[2]:
ls ./veritas
95127.anasum.fits  95130.anasum.fits  initial.pickle
95128.anasum.fits  analyzed.pickle    obs-index.fits.gz
95129.anasum.fits  hdu-index.fits.gz  simple.pickle
[3]:
config = JointConfig(files="./veritas/")
2022-06-23 13:10:08 INFO    : -------------------- Info --------------------
2022-06-23 13:10:08 INFO    : target: 1ES1218+304
2022-06-23 13:10:08 INFO    : localization:
2022-06-23 13:10:08 INFO    :   (ra, dec) : (185.3412470056114, 30.17694222440679)
2022-06-23 13:10:08 INFO    :   (glat, glon) : (82.73442268671826, 186.3593855387067)
2022-06-23 13:10:08 INFO    : time interval:
2022-06-23 13:10:08 INFO    :   veritas : 2020-01-01T11:15:10.479 - 2020-01-01T13:15:02.043
2022-06-23 13:10:08 INFO    :   fermi : 2020-01-01 00:00:00.000 - 2020-01-02 00:00:00.000
2022-06-23 13:10:08 INFO    : ---------------------------------------------
2022-06-23 13:10:08 INFO    : a configuration file (config.yaml) is created.
[4]:
config.print_config()
2022-06-23 13:10:08 INFO    :
fermi:
  binning:
    binsperdec: 8
    binsz: 0.08
    coordsys: CEL
    projtype: WCS
    roiwidth: 12
  data:
    evfile: ./fermi/EV00.lst
    ltcube: null
    scfile: ./fermi/SC00.fits
  fileio:
    logfile: ./fermi/log/fermipy.log
    outdir: ./fermi/
    usescratch: false
  gtlike:
    edisp: true
    edisp_disable:
    - isodiff
    - galdiff
    irfs: P8R3_SOURCE_V3
  model:
    catalogs: /Users/dtak/Research/scripts/vts-fermi/vtspy/refdata/gll_psc_v22.fit
    galdiff: $FERMI_DIFFUSE_DIR/gll_iem_v07.fits
    isodiff: $FERMI_DIFFUSE_DIR/iso_P8R3_SOURCE_V3_v1.txt
    src_roiwidth: 15
  selection:
    dec: 30.17694222440679
    emax: 300000
    emin: 100
    evclass: 128
    evtype: 3
    glat: 82.73442268671826
    glon: 186.3593855387067
    ra: 185.3412470056114
    target: 1ES1218+304
    tmax: 599616005.0
    tmin: 599529605.0
    zmax: 90
veritas:
  background:
    distance: 1.75
    file: /Users/dtak/Research/scripts/vts-fermi/vtspy/refdata/Hipparcos_MAG8_1997.dat
    magnitude: 7
    simbad: true
  cuts:
    bias_cut: 0
    eff_cut: 0
    th2cut: 0.008
  data:
    anasum: ./veritas
  fileio:
    outdir: ./veritas/
  selection:
    dec: 30.17694222440679
    emax: 10
    emin: 0.1
    exc_on_region_radius: 0.7
    exc_radius: 0.25
    format: mjd
    glat: 82.73442268671826
    glon: 186.3593855387067
    max_region_number: 6
    nbin: 6
    ra: 185.3412470056114
    radius: 2.0
    target: 1ES1218+304
    tmax: 58849.552106979165
    tmin: 58849.46887128472

Step 2. Analyze the VERITAS data

[5]:
veritas = VeritasAnalysis(overwrite=True)
2022-06-23 13:10:09 INFO    : Initialize the VERITAS analysis.
2022-06-23 13:10:09 INFO    : Load the data files.
2022-06-23 13:10:09 INFO    : Observations selected: 4 out of 4.
2022-06-23 13:10:09 INFO    : The number of observations is 4
2022-06-23 13:10:09 INFO    : Define exclusion regions.
2022-06-23 13:10:09 INFO    : Querying bright sources within FoV with Simbad.
2022-06-23 13:10:10 INFO    : 4 sources have been found.
2022-06-23 13:10:10 INFO    : Define ON- and OFF-regions.
2022-06-23 13:10:15 INFO    : N_on: 346, N_off: 391, alpha: 0.167, and sigma=21.2
2022-06-23 13:10:15 INFO    : The initial setup is saved [state_file = initial].
2022-06-23 13:10:15 INFO    : Completed (VERITAS initialization).

Plot ON- and OFF- regions

[6]:
veritas.plot("roi")
../_images/examples_Tutorial_1_VERITAS_analysis_9_0.png

Peek dataset

[7]:
veritas.peek_dataset()
../_images/examples_Tutorial_1_VERITAS_analysis_11_0.png

Apply additional cuts

[8]:
veritas.construct_dataset(eff_cut=15, bias_cut=15)
2022-06-23 13:10:25 INFO    : N_on: 222, N_off: 163, alpha: 0.167, and sigma=19.7
[9]:
veritas.peek_dataset()
../_images/examples_Tutorial_1_VERITAS_analysis_14_0.png

Perform a fit and do high-level analyses

[10]:
veritas.fit(model="PowerLaw")
veritas.plot("fit")
print(veritas.fit_results.total_stat)
2022-06-23 13:10:29 INFO    : Fit successfully.
2022-06-23 13:10:29 INFO    : The state is saved as 'simple'. You can load the state by vtspy.VeritasAnalysis('simple').
8.286826202930362
../_images/examples_Tutorial_1_VERITAS_analysis_16_2.png
[11]:
ls ./veritas
95127.anasum.fits  95130.anasum.fits  initial.pickle
95128.anasum.fits  analyzed.pickle    obs-index.fits.gz
95129.anasum.fits  hdu-index.fits.gz  simple.pickle
[12]:
veritas.analysis()
2022-06-23 13:10:31 INFO    : Generating flux points and SED...
2022-06-23 13:10:39 INFO    : Completed.
2022-06-23 13:10:40 INFO    : The state is saved as 'analyzed'. You can load the state by vtspy.VeritasAnalysis('analyzed').

Plot the results

[13]:
veritas.plot("flux")
../_images/examples_Tutorial_1_VERITAS_analysis_20_0.png
[14]:
veritas.plot("sed")
../_images/examples_Tutorial_1_VERITAS_analysis_21_0.png
[15]:
veritas.print_flux()
[15]:
Table length=6
e_refe_mine_maxe2dndee2dnde_erre2dnde_errpe2dnde_errne2dnde_ultssqrt_tsnprednpred_excessstatis_ulcountssuccessnorm_scanstat_scan
TeVTeVTeVTeV / (cm2 s)TeV / (cm2 s)TeV / (cm2 s)TeV / (cm2 s)TeV / (cm2 s)
float64float64float64float64float64float64float64float64float64float64float64[1]float32[1]float64boolfloat64[1]boolfloat64[11]float64[11]
0.1410.1000.200nannannannannannannannan0.00.000False0.0False0.200 .. 5.000nan .. nan
0.3160.2000.5011.582e-111.423e-121.460e-121.388e-121.881e-11284.76716.875165.3151504825863144.201682.921False165.0True0.200 .. 5.000149.504 .. 665.632
0.7080.5011.0006.846e-121.137e-121.193e-121.082e-129.346e-1292.3819.61245.0166119358871940.6861040.025False45.0True0.200 .. 5.00048.890 .. 162.791
1.4131.0001.9952.564e-129.189e-131.019e-128.296e-134.813e-1217.9204.23310.1656607995662248.8635271.825False10.0True0.200 .. 5.00010.565 .. 50.277
3.1621.9955.0128.344e-135.900e-137.366e-134.600e-132.625e-126.3002.5101.99998767123527691.99998771.484False2.0True0.200 .. 5.0003.789 .. 16.942
7.0795.01210.000nannan6.345e-13nannan-0.000-0.0005.257018186085354e-055.257018e-050.000True0.0False0.200 .. 5.0000.141 .. 3.533

Generate light curve

[16]:
veritas.analysis(jobs="lc", nbins=2)
2022-06-23 13:10:43 INFO    : Generating lightcurve...
2022-06-23 13:10:43 INFO    : The number of time intervals is 2
2022-06-23 13:10:46 INFO    : Generating lightcurve is completed.
2022-06-23 13:10:46 INFO    : The state is saved as 'analyzed'. You can load the state by vtspy.VeritasAnalysis('analyzed').
[17]:
veritas.plot("lc")
../_images/examples_Tutorial_1_VERITAS_analysis_25_0.png
[18]:
veritas.print_lightcurve()
[18]:
Table length=2
time_mintime_maxe_refe_mine_maxefluxeflux_erreflux_errpeflux_errneflux_ultssqrt_tsnprednpred_excessstatis_ulcountssuccessnorm_scanstat_scan
TeVTeVTeVTeV / (cm2 s)TeV / (cm2 s)TeV / (cm2 s)TeV / (cm2 s)TeV / (cm2 s)
float64float64float64[1]float64[1]float64[1]float64[1]float64[1]float64[1]float64[1]float64[1]float64[1]float64[1]float64[1,4]float64[1,4]float64[1]bool[1]float64[1,4]bool[1]float64[1,11]float64[1,11]
58849.4696720254658849.511289872681.00000000000000020.1000000000000000210.0000000000000025.4265711779484334e-119.085111481890766e-129.524792391156496e-128.659349138480458e-127.422092077215183e-1183.397864140940839.132243105663626nan .. nannan .. nan6.177400630136317Falsenan .. nanTrue0.2 .. 4.99999999999999950.91140798765545 .. 178.51796246786486
58849.5112898726858849.55290771991.00000000000000020.1000000000000000210.0000000000000024.713645818327796e-115.136351735128114e-125.2719693767906815e-124.973648952852488e-125.801252050317832e-11203.7859200534167314.27536059276320853.71317737321075 .. nan48.0087890625 .. nan31.92495604248873False53.0 .. nanTrue0.2 .. 4.999999999999999129.62314417037635 .. 544.9638753391071
[ ]: