diff options
author | Aaron LI <aaronly.me@outlook.com> | 2017-02-19 16:26:40 +0800 |
---|---|---|
committer | Aaron LI <aaronly.me@outlook.com> | 2017-02-19 16:26:40 +0800 |
commit | 2aaf7d8106e7d596654c9ae1cf0fa75fd642f3eb (patch) | |
tree | b524d1fa54a4ad6251d467175b71e9dfea5a6631 /scripts/spectrum.py | |
parent | 89adbc474890c50963537e8e32bdeff8aa3e10d1 (diff) | |
download | chandra-acis-analysis-2aaf7d8106e7d596654c9ae1cf0fa75fd642f3eb.tar.bz2 |
Setup module 'acispy' and clean 'scripts' directory
Setup a module 'acispy' to hold some generic Python modules for
better/easier reuse, and clean up the 'scripts' directory, which will be
used to hold the CLI tools.
Diffstat (limited to 'scripts/spectrum.py')
-rw-r--r-- | scripts/spectrum.py | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/scripts/spectrum.py b/scripts/spectrum.py deleted file mode 100644 index ad38b0d..0000000 --- a/scripts/spectrum.py +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright (c) 2017 Weitian LI <liweitianux@live.com> -# MIT license - -""" -Chandra ACIS spectrum. -""" - - -from astropy.io import fits - -from acis import ACIS - - -class Spectrum: - """ - Chandra ACIS spectrum - """ - def __init__(self, filepath): - self.filepath = filepath - self.fitsobj = fits.open(filepath) - ext_spec = self.fitsobj["SPECTRUM"] - self.header = ext_spec.header - # spectral data - self.channel = ext_spec.data.columns["CHANNEL"].array - self.counts = ext_spec.data.columns["COUNTS"].array - # spectral keywords - self.EXPOSURE = self.header.get("EXPOSURE") - self.BACKSCAL = self.header.get("BACKSCAL") - - def calc_pb_flux(self, elow=9500, ehigh=12000): - """ - Calculate the particle background flux: - flux = counts / exposure / area - - Parameters - ---------- - elow, ehigh : float, optional - Lower and upper energy limit for the particle background. - """ - chlow = ACIS.energy2channel(elow) - chhigh = ACIS.energy2channel(ehigh) - counts = self.counts[(chlow-1):chhigh].sum() - flux = counts / self.EXPOSURE / self.BACKSCAL - return flux |