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

Istall from pip:

pip install wtlike

Demo

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

from wtlike import *
weekly = WtLike('BL Lac') # how to define 7-day bins for the full dataset.
weekly.plot(ylim=(-0.8,15)); #plot takes plt.plot args.
SourceData: photons and exposure for BL Lac: Restoring from cache with key "BL Lac_data"
WtLike: Source BL Lac with:
	 data:       310,969 photons from   2008-08-04 to 2021-05-06
	 exposure: 3,177,752 intervals from 2008-08-04 to 2021-05-06
CellData: Bin photon data into 665 1-week bins from 54683.0 to 59338.0
LightCurve: select 656 cells for fitting with e>0.5 & n>2

png

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

len(weekly.cells)
665
hourly_at_end = weekly.view((-5,0, 1/24)) # for the last 5 days, 1-hour bins
hourly_at_end.plot(); # Accepts plt.plot args, e.g. xlim, ylim, etc.
CellData: Bin photon data into 120 1-hour bins from 59335.0 to 59340.0
LightCurve: select 81 cells for fitting with e>0.5 & n>2

png

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

hourly_at_end.plot_BB(fmt='o');
Partitioned 81 cells into 4 blocks, using LikelihoodFitness 
LightCurve: Loaded 4 / 4 cells for fitting

png

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

hourly_at_end.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 59335.42 0.83 178 6.70 404.1 (-0.655, 0.689) 7.89
1 59336.69 1.71 205 2.38 170.0 (-0.308, 0.323) 2.93
2 59338.02 0.96 222 8.70 573.6 (-0.734, 0.767) 10.01
3 59339.23 1.46 217 4.48 369.4 (-0.434, 0.454) 5.25

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.5.tar.gz (56.7 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: wtlike-0.1.5.tar.gz
  • Upload date:
  • Size: 56.7 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.5.tar.gz
Algorithm Hash digest
SHA256 ca90b9916b6243d2b42c69694e0a82a4e8dfc33a88e9a6efaef5f33203ce79b4
MD5 7188e91767cc8fd8ee03d5ca5887714f
BLAKE2b-256 cd6c0e940499f590153948c9536505d129dd9f92afde9648971bb579049822f2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: wtlike-0.1.5-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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 1d4f9d2511fbb022e2e13e530327375c77ffc0f1b6f1e378d540e82b8923ebfa
MD5 fac3c154175c9feb42944761ed44605a
BLAKE2b-256 32a4275ba096fd9f33ef91e29fecd77c90574cc9439a98e3145e38e753b015a0

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