Skip to content

Commit ba680ce

Browse files
committed
Merge branch 'main' into dl3_reader
2 parents a5f98dd + f9a3e45 commit ba680ce

File tree

5 files changed

+79
-329
lines changed

5 files changed

+79
-329
lines changed

src/pybkgmodel/camera.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import numpy
1+
import numpy as np
22
import scipy.special
33
import scipy.optimize
44

@@ -36,7 +36,7 @@ def solid_angle_lat_lon_rectangle(theta_E, theta_W, phi_N, phi_S):
3636
phi_S = phi_S.to(u.Unit("rad"))
3737
theta_E = theta_E.to(u.Unit("rad"))
3838
theta_W = theta_W.to(u.Unit("rad"))
39-
solid_angle = (numpy.sin(phi_N) - numpy.sin(phi_S)) * (theta_E.to_value() - theta_W.to_value()) * u.sr
39+
solid_angle = (np.sin(phi_N) - np.sin(phi_S)) * (theta_E.to_value() - theta_W.to_value()) * u.sr
4040

4141
return solid_angle
4242

@@ -58,7 +58,7 @@ def cstat(y, model_y):
5858
2 * log-likelihood value.
5959
6060
"""
61-
val = -2 * numpy.sum(y * numpy.log(model_y) - model_y - scipy.special.gammaln(y+1))
61+
val = -2 * np.sum(y * np.log(model_y) - model_y - scipy.special.gammaln(y+1))
6262

6363
return val
6464

@@ -117,16 +117,16 @@ def nodespec_integral(energy_edges, dnde):
117117
if isinstance(dnde.unit, u.DexUnit):
118118
dnde = dnde.physical
119119

120-
energy = numpy.sqrt(energy_edges[1:] * energy_edges[:-1])
121-
counts = numpy.zeros(len(energy)) * u.one
120+
energy = np.sqrt(energy_edges[1:] * energy_edges[:-1])
121+
counts = np.zeros(len(energy)) * u.one
122122

123123
xunit = u.DexUnit(energy_edges.unit)
124124
yunit = u.DexUnit(dnde.unit)
125125

126-
dx = numpy.diff(energy.to(xunit).value)
127-
dy = numpy.diff(dnde.to(yunit).value)
126+
dx = np.diff(energy.to(xunit).value)
127+
dy = np.diff(dnde.to(yunit).value)
128128
indicies = dy / dx
129-
indicies = numpy.concatenate(
129+
indicies = np.concatenate(
130130
(indicies[:1], indicies, indicies[-1:])
131131
)
132132

@@ -169,12 +169,12 @@ def __init__(self, counts, xedges, yedges, energy_edges, center=None, mask=None,
169169
ny = yedges.size - 1
170170

171171
if mask is None:
172-
mask = numpy.ones((nx, ny), dtype=bool)
172+
mask = np.ones((nx, ny), dtype=np.bool)
173173

174174
if exposure is None:
175-
exposure = numpy.ones((nx, ny), dtype=numpy.float) * u.s
175+
exposure = np.ones((nx, ny), dtype=np.float) * u.s
176176
elif exposure.shape == ():
177-
exposure = numpy.repeat(exposure, nx * ny).reshape((nx, ny))
177+
exposure = np.repeat(exposure, nx * ny).reshape((nx, ny))
178178

179179
self.raw_counts = counts
180180
self.xedges = xedges
@@ -244,7 +244,7 @@ def differential_rate(self, index=None):
244244
Parameters
245245
----------
246246
index: float
247-
Power law spectral index to assume.
247+
Power law spectral index to assume.
248248
If none, will be dynamically determined assuming
249249
a "node function" for the spectral shape.
250250
@@ -269,7 +269,7 @@ def differential_rate(self, index=None):
269269
dnde_unit = u.DexUnit(dnde.unit)
270270
for xi in range(self.rate.shape[1]):
271271
for yi in range(self.rate.shape[2]):
272-
if not numpy.any(dnde[:, xi, yi] == 0):
272+
if not np.any(dnde[:, xi, yi] == 0):
273273
opt = scipy.optimize.minimize(
274274
lambda x: node_cnt_diff((x*dnde_unit).physical, self.energy_edges, self.counts[:, xi, yi], poisson=True),
275275
x0=dnde[:, xi, yi].to(dnde_unit).value
@@ -318,7 +318,7 @@ def mask_region(self, region):
318318
# Set up an "Airy's zenithal" projection
319319
# Vector properties may be set with Python lists, or np arrays
320320
dummy_wcs.wcs.crpix = [-234.75, 8.3393]
321-
dummy_wcs.wcs.cdelt = numpy.array([-0.066667, 0.066667])
321+
dummy_wcs.wcs.cdelt = np.array([-0.066667, 0.066667])
322322
dummy_wcs.wcs.crval = [0, -90]
323323
dummy_wcs.wcs.ctype = ["RA---AIR", "DEC--AIR"]
324324
dummy_wcs.wcs.set_pv([(2, 1, 45.0)])
@@ -329,7 +329,7 @@ def mask_region(self, region):
329329
def mask_reset(self):
330330
"""_summary_
331331
"""
332-
self.mask = numpy.ones((self.xedges.size - 1, self.yedges.size - 1), dtype=bool)
332+
self.mask = np.ones((self.xedges.size - 1, self.yedges.size - 1), dtype=np.bool)
333333

334334

335335
def plot(self, energy_bin_id=0, ax_unit='deg', val_unit='1/s', **kwargs):
@@ -394,7 +394,7 @@ def get_pixel_areas(self):
394394
for i in range(nx):
395395
for j in range(ny):
396396
area[i, j] = solid_angle_lat_lon_rectangle(self.xedges[i], self.xedges[i+1], self.yedges[j], self.yedges[j+1])
397-
397+
398398
return area
399399

400400
def to_hdu(self, name='BACKGROUND'):

0 commit comments

Comments
 (0)