isgri 0.2.0__py3-none-any.whl → 0.3.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
isgri/utils/quality.py
CHANGED
|
@@ -62,7 +62,7 @@ class QualityMetrics:
|
|
|
62
62
|
time, counts = self.lightcurve.rebin_by_modules(
|
|
63
63
|
binsize=self.binsize, emin=self.emin, emax=self.emax, local_time=self.local_time
|
|
64
64
|
)
|
|
65
|
-
module_data = {"time": time, "counts": counts}
|
|
65
|
+
module_data = {"time": time, "counts": np.asarray(counts)}
|
|
66
66
|
self.module_data = module_data
|
|
67
67
|
return module_data
|
|
68
68
|
|
|
@@ -71,20 +71,36 @@ class QualityMetrics:
|
|
|
71
71
|
Compute reduced chi-squared for count data.
|
|
72
72
|
|
|
73
73
|
Args:
|
|
74
|
-
counts (ndarray): Count array(s) to analyze.
|
|
75
|
-
return_all (bool, optional): If True, returns
|
|
74
|
+
counts (ndarray): Count array(s) to analyze. Shape: (n_modules, n_bins) or (n_bins,)
|
|
75
|
+
return_all (bool, optional): If True, returns detailed results. If False, returns weighted mean. Defaults to False.
|
|
76
76
|
|
|
77
77
|
Returns:
|
|
78
|
-
|
|
78
|
+
If return_all=False:
|
|
79
|
+
float: Weighted mean chi-squared (weighted by total counts per module)
|
|
80
|
+
If return_all=True:
|
|
81
|
+
tuple: (chi_squared, dof, no_counts) where:
|
|
82
|
+
- chi_squared: Raw chi-squared values per module
|
|
83
|
+
- dof: Degrees of freedom per module (n_bins - 1 excluding NaN)
|
|
84
|
+
- no_counts: Total counts per module
|
|
79
85
|
"""
|
|
80
86
|
counts = np.asarray(counts)
|
|
81
87
|
counts = np.where(counts == 0, np.nan, counts)
|
|
82
88
|
mean_counts = np.nanmean(counts, axis=-1, keepdims=True)
|
|
83
89
|
chi_squared = np.nansum((counts - mean_counts) ** 2 / mean_counts, axis=-1)
|
|
84
|
-
|
|
90
|
+
|
|
91
|
+
# DOF = number of non-empty bins minus 1
|
|
92
|
+
nan_mask = ~np.isnan(counts)
|
|
93
|
+
dof = np.sum(nan_mask, axis=-1) - 1
|
|
94
|
+
no_counts = np.nansum(counts, axis=-1)
|
|
95
|
+
|
|
85
96
|
if return_all:
|
|
86
|
-
return chi_squared
|
|
87
|
-
|
|
97
|
+
return chi_squared, dof, no_counts
|
|
98
|
+
|
|
99
|
+
if np.sum(no_counts) == 0 or np.all(dof <= 0):
|
|
100
|
+
return np.nan
|
|
101
|
+
|
|
102
|
+
# Weight by total counts per module
|
|
103
|
+
return np.average(chi_squared / dof, weights=no_counts)
|
|
88
104
|
|
|
89
105
|
def raw_chi_squared(self, counts=None, return_all=False):
|
|
90
106
|
"""
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: isgri
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Python package for INTEGRAL IBIS/ISGRI lightcurve analysis
|
|
5
5
|
Author: Dominik Patryk Pacholski
|
|
6
6
|
License: MIT
|
|
7
7
|
License-File: LICENSE
|
|
8
8
|
Requires-Python: >=3.10
|
|
9
|
-
Requires-Dist: astropy
|
|
10
|
-
Requires-Dist: numpy
|
|
9
|
+
Requires-Dist: astropy
|
|
10
|
+
Requires-Dist: numpy
|
|
11
11
|
Description-Content-Type: text/markdown
|
|
12
12
|
|
|
13
13
|
# isgri
|
|
@@ -3,9 +3,9 @@ isgri/utils/__init__.py,sha256=H83Al7urc6LNW5KUzUBRdtRBUTahiZmkehKFiK90RrU,183
|
|
|
3
3
|
isgri/utils/file_loaders.py,sha256=HBQ-n-jFhcP1cxykemBFYTZ72ydJNQrZMUQTeZ2dSnw,5509
|
|
4
4
|
isgri/utils/lightcurve.py,sha256=VGRWcpOMnh8Rrbo-EETKAevhYYBZe55IuRQOw_cIfvY,10243
|
|
5
5
|
isgri/utils/pif.py,sha256=oxndfoZp-y9FO_TXcCP3dmesvh-sC7hAy2u_1YwGitw,1317
|
|
6
|
-
isgri/utils/quality.py,sha256=
|
|
6
|
+
isgri/utils/quality.py,sha256=TZGXnao6hQ2STlI8S8JIfaldPAfdMORQJ0IH_rilFu4,7930
|
|
7
7
|
isgri/utils/time_conversion.py,sha256=47aTXn6cvi-LjOptDY2W-rjeF_PjthZer61VIsJqsro,908
|
|
8
|
-
isgri-0.
|
|
9
|
-
isgri-0.
|
|
10
|
-
isgri-0.
|
|
11
|
-
isgri-0.
|
|
8
|
+
isgri-0.3.0.dist-info/METADATA,sha256=MofiJhRbXTPhMNOQAtOSc4QmsYEIm8ckXayvr2LTIMQ,1767
|
|
9
|
+
isgri-0.3.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
10
|
+
isgri-0.3.0.dist-info/licenses/LICENSE,sha256=Q8oxmHR1cSnEXSHCjY3qeXMtupZI_1ZQZ1MBt4oeANE,1102
|
|
11
|
+
isgri-0.3.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|