aboutsummaryrefslogtreecommitdiffstats
path: root/astro/spectrum
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2017-12-13 19:24:21 +0800
committerAaron LI <aly@aaronly.me>2017-12-13 19:24:21 +0800
commit1af3eaa862ca54a137a50dc6ee012b2fd4573ac0 (patch)
treefb3afbeb5279b64f22263b3f5e6fe25bbdc57a34 /astro/spectrum
parent9b64cc3b0850d5917da4791c99b73f7e66b0cd67 (diff)
downloadatoolbox-1af3eaa862ca54a137a50dc6ee012b2fd4573ac0.tar.bz2
astro/crosstalk_deprojection.py: allow missing of info_e{min,max}
Diffstat (limited to 'astro/spectrum')
-rwxr-xr-xastro/spectrum/crosstalk_deprojection.py26
1 files changed, 19 insertions, 7 deletions
diff --git a/astro/spectrum/crosstalk_deprojection.py b/astro/spectrum/crosstalk_deprojection.py
index 6e1f271..43e5fb4 100755
--- a/astro/spectrum/crosstalk_deprojection.py
+++ b/astro/spectrum/crosstalk_deprojection.py
@@ -4,7 +4,10 @@
# 2016-03-26
#
# Change log:
-# 2017-12-13: Cleanup reading grouping/quality from file
+# 2017-12-13:
+# * Allow the missing of ``info_emin`` and ``info_emax``
+# * Do not use ``sys.stderr``
+# * Cleanup reading grouping/quality from file
# 2017-12-07:
# * Fix a list append error in ``cc_results``
# * Relax the exposure time validity check a bit
@@ -953,8 +956,11 @@ class SpectrumSet(Spectrum): # {{{
if verbose:
print(operation)
energy = self.energy
- eidx = ((energy >= CONFIGS["info_emin"]) &
- (energy <= CONFIGS["info_emax"]))
+ try:
+ eidx = ((energy >= CONFIGS["info_emin"]) &
+ (energy <= CONFIGS["info_emax"]))
+ except KeyError:
+ eidx = np.ones_like(energy, dtype=bool)
datasum1 = np.sum(self.spec_data[eidx])
spec_data_subbkg = self.spec_data - ratio * self.bkg.get_data()
datasum2 = np.sum(spec_data_subbkg[eidx])
@@ -1024,8 +1030,11 @@ class SpectrumSet(Spectrum): # {{{
spec_data_new = spec_data1 - spec_data2 * arf_ratio
self.set_data(spec_data_new, group_squeeze=group_squeeze)
energy_groupped = self.energy_groupped
- eidx = ((energy_groupped >= CONFIGS["info_emin"]) &
- (energy_groupped <= CONFIGS["info_emax"]))
+ try:
+ eidx = ((energy_groupped >= CONFIGS["info_emin"]) &
+ (energy_groupped <= CONFIGS["info_emax"]))
+ except KeyError:
+ eidx = np.ones_like(energy_groupped, dtype=bool)
datasum1 = np.sum(spec_data1[eidx])
datasum2 = np.sum(spec_data_new[eidx])
datacp = 100 * (datasum2-datasum1) / datasum1
@@ -1070,8 +1079,11 @@ class SpectrumSet(Spectrum): # {{{
spec_data_new = spec_data * (1 + arf_ratio)
self.set_data(spec_data_new, group_squeeze=group_squeeze)
energy_groupped = self.energy_groupped
- eidx = ((energy_groupped >= CONFIGS["info_emin"]) &
- (energy_groupped <= CONFIGS["info_emax"]))
+ try:
+ eidx = ((energy_groupped >= CONFIGS["info_emin"]) &
+ (energy_groupped <= CONFIGS["info_emax"]))
+ except KeyError:
+ eidx = np.ones_like(energy_groupped, dtype=bool)
datasum1 = np.sum(spec_data[eidx])
datasum2 = np.sum(spec_data_new[eidx])
datacp = 100 * (datasum2-datasum1) / datasum1