isgri 0.4.0__py3-none-any.whl → 0.5.1__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/__init__.py +1 -0
- isgri/__version__.py +1 -0
- isgri/catalog/__init__.py +3 -3
- isgri/catalog/builder.py +90 -0
- isgri/catalog/scwquery.py +524 -517
- isgri/catalog/wcs.py +190 -190
- isgri/cli.py +224 -0
- isgri/config.py +151 -0
- isgri/utils/file_loaders.py +392 -389
- isgri/utils/lightcurve.py +409 -409
- isgri/utils/pif.py +286 -286
- isgri/utils/quality.py +389 -389
- isgri/utils/time_conversion.py +210 -210
- {isgri-0.4.0.dist-info → isgri-0.5.1.dist-info}/METADATA +68 -11
- isgri-0.5.1.dist-info/RECORD +19 -0
- {isgri-0.4.0.dist-info → isgri-0.5.1.dist-info}/WHEEL +1 -1
- isgri-0.5.1.dist-info/entry_points.txt +2 -0
- isgri-0.4.0.dist-info/RECORD +0 -14
- {isgri-0.4.0.dist-info → isgri-0.5.1.dist-info}/licenses/LICENSE +0 -0
isgri/__init__.py
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .__version__ import __version__
|
isgri/__version__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.5.1"
|
isgri/catalog/__init__.py
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
from .scwquery import ScwQuery
|
|
2
|
-
|
|
3
|
-
__all__ = ["ScwQuery"]
|
|
1
|
+
from .scwquery import ScwQuery
|
|
2
|
+
|
|
3
|
+
__all__ = ["ScwQuery"]
|
isgri/catalog/builder.py
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
from isgri.utils import LightCurve, QualityMetrics
|
|
2
|
+
import numpy as np
|
|
3
|
+
import os, subprocess
|
|
4
|
+
from typing import Optional
|
|
5
|
+
from joblib import Parallel, delayed # type: ignore
|
|
6
|
+
import multiprocessing
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class CatalogBuilder:
|
|
10
|
+
def __init__(
|
|
11
|
+
self,
|
|
12
|
+
archive_path: str,
|
|
13
|
+
catalog_path: str,
|
|
14
|
+
lightcurve_cache: Optional[str] = None,
|
|
15
|
+
n_cores: Optional[int] = None,
|
|
16
|
+
):
|
|
17
|
+
self.archive_path = archive_path
|
|
18
|
+
self.catalog_path = catalog_path
|
|
19
|
+
self.lightcurve_cache = lightcurve_cache
|
|
20
|
+
self.n_cores = n_cores if n_cores is not None else multiprocessing.cpu_count()
|
|
21
|
+
self.catalog = self._load_catalog()
|
|
22
|
+
|
|
23
|
+
def _load_catalog(self):
|
|
24
|
+
if not os.path.exists(self.catalog_path):
|
|
25
|
+
empty_structure = CatalogStructure.get_empty_structure()
|
|
26
|
+
return empty_structure
|
|
27
|
+
else:
|
|
28
|
+
catalog = CatalogStructure.load_from_fits(self.catalog_path)
|
|
29
|
+
return catalog
|
|
30
|
+
|
|
31
|
+
def _process_scw(self, path) -> tuple[dict, list]:
|
|
32
|
+
lc = LightCurve.load_data(path)
|
|
33
|
+
|
|
34
|
+
time, full_counts = lc.rebin(1, emin=15, emax=1000, local_time=False)
|
|
35
|
+
_, module_counts = lc.rebin_by_modules(1, emin=15, emax=1000, local_time=False)
|
|
36
|
+
module_counts.insert(0, full_counts)
|
|
37
|
+
module_counts = np.array(module_counts)
|
|
38
|
+
quality = QualityMetrics.compute(lc)
|
|
39
|
+
quality.module_data = {"time": time, "counts": module_counts[1:]}
|
|
40
|
+
raw_chisq = quality.raw_chi_squared()
|
|
41
|
+
clipped_chisq = quality.sigma_clip_chi_squared()
|
|
42
|
+
gti_chisq = quality.gti_chi_squared()
|
|
43
|
+
|
|
44
|
+
# cnames = [
|
|
45
|
+
# ("REVOL", int),
|
|
46
|
+
# ("SWID", "S12"),
|
|
47
|
+
# ("TSTART", float),
|
|
48
|
+
# ("TSTOP", float),
|
|
49
|
+
# ("TELAPSE", float),
|
|
50
|
+
# ("RA_SCX", float),
|
|
51
|
+
# ("DEC_SCX", float),
|
|
52
|
+
# ("RA_SCZ", float),
|
|
53
|
+
# ("DEC_SCZ", float),
|
|
54
|
+
# ("NoEVTS", int),
|
|
55
|
+
# ("LCs", np.ndarray),
|
|
56
|
+
# ("GTIs", np.ndarray),
|
|
57
|
+
# ("CHI", float),
|
|
58
|
+
# ("CUT_CHI", float),
|
|
59
|
+
# ("GTI_CHI", float),
|
|
60
|
+
# ]
|
|
61
|
+
table_data = {
|
|
62
|
+
"REVOL": lc.metadata["REVOL"],
|
|
63
|
+
"SWID": lc.metadata["SWID"],
|
|
64
|
+
"TSTART": lc.metadata["TSTART"],
|
|
65
|
+
"TSTOP": lc.metadata["TSTOP"],
|
|
66
|
+
"ONTIME": lc.metadata["TELAPSE"],
|
|
67
|
+
"RA_SCX": lc.metadata["RA_SCX"],
|
|
68
|
+
"DEC_SCX": lc.metadata["DEC_SCX"],
|
|
69
|
+
"RA_SCZ": lc.metadata["RA_SCZ"],
|
|
70
|
+
"DEC_SCZ": lc.metadata["DEC_SCZ"],
|
|
71
|
+
"NoEVTS": len(lc.time),
|
|
72
|
+
"CHI": raw_chisq,
|
|
73
|
+
"CUT_CHI": clipped_chisq,
|
|
74
|
+
"GTI_CHI": gti_chisq,
|
|
75
|
+
}
|
|
76
|
+
array_data = [lc.metadata["SWID"], time, module_counts, lc.gti]
|
|
77
|
+
return table_data, array_data
|
|
78
|
+
|
|
79
|
+
def _process_rev(self, rev_paths: list[str]) -> tuple[list[dict], list[list]]:
|
|
80
|
+
data = Parallel(n_jobs=self.n_cores, backend="multiprocessing")(
|
|
81
|
+
delayed(self._process_scw)(path) for path in rev_paths
|
|
82
|
+
)
|
|
83
|
+
table_data_list, array_data_list = zip(*data)
|
|
84
|
+
return table_data_list, array_data_list
|
|
85
|
+
|
|
86
|
+
def _find_scws(self) -> tuple[np.ndarray[str], np.ndarray[str]]:
|
|
87
|
+
# Find all SCW files in the archive
|
|
88
|
+
scws_files = subprocess.run(
|
|
89
|
+
["ls", f"{self.archive_path}/*", "|", "isgri_events.fits.gz"], capture_output=True, text=True
|
|
90
|
+
)
|