Skip to content

Commit a3c6fad

Browse files
committed
Commit changes made to cosipy/response/ files between December 2024 and today
1 parent 8a5f136 commit a3c6fad

File tree

4 files changed

+76
-47
lines changed

4 files changed

+76
-47
lines changed

cosipy/response/DetectorResponse.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ def __init__(self, coord, **kwargs):
4444

4545
def _set_mapping(self):
4646
self.mapping = {}
47-
target_names = ['Ei', 'Em', 'Phi', 'PsiChi', 'SigmaTau', 'Dist']
47+
target_names = ['Ei', 'Em', 'Phi', 'PsiChi']
4848
numlabels = len(self.axes.labels)
4949

50-
for key, label in zip(target_names[:numlabels], self.axes.labels):
50+
for key, label in zip(target_names, self.axes.labels):
5151
self.mapping[key] = label # Format: key_target : label
5252
# Example: {'Ei': 'Ei', 'Em': 'eps', 'Phi': 'Phi', 'PsiChi': 'PsiChi'}
5353

@@ -203,7 +203,8 @@ def get_spectral_response(self, copy = True):
203203
# Cache the spectral response
204204
if self._spec is None:
205205
spec = self.project(['Ei','Em'])
206-
self._spec = DetectorResponse(edges=spec.axes,
206+
self._spec = DetectorResponse(coord = self.coord,
207+
edges = spec.axes,
207208
contents = spec.contents,
208209
unit = spec.unit)
209210

cosipy/response/FullDetectorResponse.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from .PointSourceResponse import PointSourceResponse
22
from .DetectorResponse import DetectorResponse
3-
from .ListModePSR import ListModePSR
43
from astromodels.core.model_parser import ModelParser
54
import matplotlib.pyplot as plt
65
from astropy.time import Time
@@ -508,7 +507,10 @@ def _open_rsp(cls, filename, Spectrumfile=None,norm="Linear" ,single_pixel = Fal
508507
pass
509508

510509
# create a .h5 file with the good structure
511-
filename = filename.replace(".rsp.gz","_nside{0}.area.h5".format(nside))
510+
try:
511+
filename = filename.replace(".rsp.gz","_nside{0}.area.h5".format(nside))
512+
except:
513+
filename = str(filename).replace(".rsp.gz", "_nside{0}.area.h5".format(nside))
512514
f = h5.File(filename, mode='w')
513515

514516
drm = f.create_group('DRM')

cosipy/response/PointSourceResponse.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from scipy import integrate
88

99
from threeML import DiracDelta, Constant, Line, Quadratic, Cubic, Quartic, StepFunction, StepFunctionUpper, Cosine_Prior, Uniform_prior, PhAbs, Gaussian
10+
from astromodels.functions.function import CompositeFunction
1011

1112

1213
class PointSourceResponse(Histogram):
@@ -80,6 +81,8 @@ def get_expectation(self, spectrum):
8081
spectrum_unit = u.dimensionless_unscaled
8182
elif isinstance(spectrum, Gaussian):
8283
spectrum_unit = spectrum.F.unit / spectrum.sigma.unit
84+
elif isinstance(spectrum, CompositeFunction): # Ad-hoc fix to make a double Gaussian composite model to work
85+
spectrum_unit = spectrum.F_1.unit / spectrum.sigma_1.unit
8386
else:
8487
try:
8588
spectrum_unit = spectrum.K.unit

0 commit comments

Comments
 (0)