Skip to main content

Time-dependent analysis of point sources in Fermi-LAT data

Project description

The wtlike package

Code for generating fermi-LAT light curves.

GitHub Links

Context

This package has code that was adapted to the nbdev code/tests/documentation environment from the github package lat-timing to manage light curves of Fermi-LAT sources.
It is based on a paper by Matthew Kerr, which derives the weighted likelihood formalism used here, specifically with the Bayesian Block to detect and characterize variability of a gamma-ray source.

Also, I've ported some code from my jupydoc documentation package supporting enhanced documentation combining Markdown and code, such that the Markdown reflects execution of the code.

Installation

Currently in pre-alpha, and must be cloned. This includes the nbdev support as well.

Demo

The following code cell loads the data for the BL Lac blazar, and plots by default, a daily light curve for the full fermi mission

from wtlike import *
wtl = WtLike('BL Lac', bins=(0,0,7)) # how to define 7-day bins for the full dataset. Default is (0,0,1).
wtl.plot_flux();
photons and exposure for BL Lac: Saving to cache with key "BL Lac__data"
Assembling photon data and exposure for source BL Lac from folder "/home/burnett/wtlike_data/data_files", with 664 files, last=week_673.pkl
	Using weeks (None, None)
........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Week at 2018-04-03 14:23 has only 0 photons
.
Week at 2018-04-05 01:08 has only 0 photons
.
Week at 2018-04-12 01:05 has only 0 photons
.
Week at 2018-04-19 01:05 has only 0 photons
..........
Week at 2018-06-28 00:56 has only 0 photons
.......
Week at 2018-08-16 00:58 has only 0 photons
........
Week at 2018-10-11 00:59 has only 0 photons
....................................................................................................................................
Load weights from file /mnt/c/Users/thbur/OneDrive/fermi/wtlike-data/weight_files/BL_Lac_weights.pkl
	Found: P88Y6076 at (92.60, -10.44)
	Applyng weights: 0 / 404789 photon pixels are outside weight region
	95324 weights set to NaN
BBanalysis: Source BL Lac with:
	 data:       404,789 photons from   2008-08-04 to 2021-04-28
	 exposure: 3,171,944 intervals from 2008-08-04 to 2021-04-28
Bin photon data into 664.0 1-week bins from 54683.0 to 59331.0
Loaded 656 / 664 cells with at least 1 photons and exposure > 1e-06 for light curve analysis

png

The variable wtl has lots of capabilities. To examine a subset of the data at the end of the current data, we create a new WtLike object and plot it.

wtl2 = wtl.view((-5,0, 1/24)) # for the last 5 days, 1-hour bins
wtl2.plot_flux(fmt='o'); # Accepts plt.plot args, e.g. xlim, ylim, etc.
Bin photon data into 120.0 1-hour bins from 59328.0 to 59333.0
Loaded 107 / 120 cells with at least 1 photons and exposure > 1e-06 for light curve analysis

png

Or, to do a Bayesian Block partiton with these 1-hour bins, perform fits, and overplot the result, just run the following.

wtl2.plot_BB(fmt='o');
Partitioned 107 cells into 8 blocks, using LikelihoodFitness 
Loaded 8 / 8 cells for fitting

png

Finally, let's look at the values plotted above:

wtl2.bb_table()
<style scoped> .dataframe tbody tr th:only-of-type { vertical-align: middle; }
.dataframe tbody tr th {
    vertical-align: top;
}

.dataframe thead th {
    text-align: right;
}
</style>
t tw n flux ts errors limit
0 59328.73 1.46 312 0.33 88.3 (-0.049, 0.051) 0.41
1 59330.02 1.12 362 0.76 231.8 (-0.078, 0.08) 0.90
2 59330.83 0.50 290 1.83 439.6 (-0.155, 0.162) 2.10
3 59331.17 0.17 229 7.32 727.3 (-0.563, 0.588) 8.33
4 59331.31 0.12 103 3.67 242.3 (-0.445, 0.475) 4.50
5 59331.67 0.58 236 1.01 200.0 (-0.116, 0.121) 1.22
6 59332.35 0.79 213 0.48 87.9 (-0.075, 0.079) 0.61
7 59332.88 0.25 101 1.56 130.9 (-0.222, 0.238) 1.97

Input data

There are three data sources which wtlike needs to function:

  • The photon/spacecraft data
  • A table of weights for each source
  • An effective area IRF table

These must be found under a folder, which by default is ~/wtlike_data. In that folder there must be (perhaps links to) three folders named data_files, weight_files, aeff_files. A copy of what I'm using is at /afs/slac/g/glast/users/burnett/wtlike_data

Module summary

Configuration config

Implements basic configuration information, Config, a cache system Cache, point source info PointSource, and time conversion

Photon and Spacecraft Data data_man

This module manages conversion of the weekly FT1 (photons) and FT2 (spacecraft) files, downloaded from GSFC, to a folder containing pickled files, each with tables of photons, space craft data, and a list of GTI times derived from the FT1 file. The total size of this is 2.8 GB. A class WeeklyData exports the results.

Source data source_data

The module depends on a specific source. It extracts the photons within a disk, and calculates the exposure for this direction. It assumes that a weigtht analysis has been done for this source, which it uses to apply a weight to each photon. This is handled by the class SourceData.

Cell data cell_data

The next step is to define a set of time bins. This module, implementing the class CellData(SourceData), creates a set of cells.

The light-curve light_curve

The the class LightCurve(CellData) uses the set of cell defined by its super class, and evaluates the likelihood for each. This function is represented by a Poisson-like function for further analysis. It creates a table with this information for plotting a light curve.

Bayesian Blocks bayesian

THis module defines the class BBanalysis(LightCurve). INheriting from LightCurve, it adds Bayesian block capability. It is the class returned by `from wtlike import WtLike'

Simulation simulation

A light curve can be also generated with a simulation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wtlike-0.1.4.tar.gz (57.3 kB view details)

Uploaded Source

Built Distribution

wtlike-0.1.4-py3-none-any.whl (61.5 kB view details)

Uploaded Python 3

File details

Details for the file wtlike-0.1.4.tar.gz.

File metadata

  • Download URL: wtlike-0.1.4.tar.gz
  • Upload date:
  • Size: 57.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.7.6

File hashes

Hashes for wtlike-0.1.4.tar.gz
Algorithm Hash digest
SHA256 5562230f073390768c7b6cafa9be206f4f91472d6b758a3e42e2684eda63646b
MD5 404bbecc40c7ad96df74253203ea7245
BLAKE2b-256 48498e391acf6c17b3fa26f942eacebd9d4f577f6725d54f912f63410d725272

See more details on using hashes here.

File details

Details for the file wtlike-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: wtlike-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 61.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.7.6

File hashes

Hashes for wtlike-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 61b69fae498f0e01aa6cb7fd2371aa726489fa2e93adb899fe83402198b0900f
MD5 51332803106102cdaddd68289d81f489
BLAKE2b-256 9934e278665e037921631f302c6ae0aa4309af8add91a259fa892bf43cc5fba9

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page