isgri 0.7.0__py3-none-any.whl → 0.7.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/__version__.py +1 -1
- isgri/catalog/builder.py +13 -1
- isgri/cli/builder.py +102 -0
- isgri/cli/main.py +3 -0
- {isgri-0.7.0.dist-info → isgri-0.7.1.dist-info}/METADATA +57 -1
- {isgri-0.7.0.dist-info → isgri-0.7.1.dist-info}/RECORD +9 -8
- {isgri-0.7.0.dist-info → isgri-0.7.1.dist-info}/WHEEL +0 -0
- {isgri-0.7.0.dist-info → isgri-0.7.1.dist-info}/entry_points.txt +0 -0
- {isgri-0.7.0.dist-info → isgri-0.7.1.dist-info}/licenses/LICENSE +0 -0
isgri/__version__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.7.
|
|
1
|
+
__version__ = "0.7.1"
|
isgri/catalog/builder.py
CHANGED
|
@@ -306,7 +306,14 @@ class CatalogBuilder:
|
|
|
306
306
|
data = Parallel(n_jobs=self.n_cores, backend="multiprocessing")(
|
|
307
307
|
delayed(self._process_scw)(path) for path in rev_paths
|
|
308
308
|
)
|
|
309
|
-
|
|
309
|
+
|
|
310
|
+
# Filter out None results
|
|
311
|
+
valid_data = [d for d in data if d[0] is not None]
|
|
312
|
+
|
|
313
|
+
if not valid_data:
|
|
314
|
+
return None, None
|
|
315
|
+
|
|
316
|
+
table_data_list, array_data_dicts = zip(*valid_data)
|
|
310
317
|
|
|
311
318
|
dtype = [("SWID", "U16"), ("TIME", "O"), ("COUNTS", "O"), ("MODULE_COUNTS", "O"), ("GTIS", "O")]
|
|
312
319
|
array_data = np.empty(len(array_data_dicts), dtype=dtype)
|
|
@@ -426,6 +433,11 @@ class CatalogBuilder:
|
|
|
426
433
|
for revolution, rev_paths in revolutions.items():
|
|
427
434
|
print(f"Processing revolution {revolution} with {len(rev_paths)} ScWs...")
|
|
428
435
|
table_data_rows, array_data_list = self._process_rev(rev_paths)
|
|
436
|
+
|
|
437
|
+
if table_data_rows is None:
|
|
438
|
+
print(f"No valid ScWs found in revolution {revolution}, skipping.")
|
|
439
|
+
continue
|
|
440
|
+
|
|
429
441
|
print(f"Adding {len(table_data_rows)} ScWs from revolution {revolution} to catalog.")
|
|
430
442
|
self._add_catalog_data(table_data_rows)
|
|
431
443
|
if self.lightcurve_cache is not None:
|
isgri/cli/builder.py
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import click
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from ..catalog.builder import CatalogBuilder
|
|
4
|
+
from ..config import Config
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@click.command()
|
|
8
|
+
@click.option(
|
|
9
|
+
"--archive", type=click.Path(), help="Path to INTEGRAL archive directory. If not provided, uses config value."
|
|
10
|
+
)
|
|
11
|
+
@click.option("--catalog", type=click.Path(), help="Path to catalog FITS file. If not provided, uses config value.")
|
|
12
|
+
@click.option("--cache", type=click.Path(), help="Path to light curve cache directory. Optional.")
|
|
13
|
+
@click.option("--cores", type=int, help="Number of CPU cores for parallel processing. Defaults to all available.")
|
|
14
|
+
def update(archive, catalog, cache, cores):
|
|
15
|
+
"""
|
|
16
|
+
Update science window catalog from archive.
|
|
17
|
+
|
|
18
|
+
Scans the INTEGRAL archive for new science windows not present in the catalog,
|
|
19
|
+
processes them in parallel by revolution, and adds results to the catalog.
|
|
20
|
+
|
|
21
|
+
If archive or catalog paths are not provided, uses values from configuration.
|
|
22
|
+
Optionally caches light curve arrays to the specified directory.
|
|
23
|
+
|
|
24
|
+
Examples:
|
|
25
|
+
|
|
26
|
+
Update using configured paths:
|
|
27
|
+
|
|
28
|
+
isgri update
|
|
29
|
+
|
|
30
|
+
Update with custom paths:
|
|
31
|
+
|
|
32
|
+
isgri update --archive /anita/archivio/ --catalog ~/data/catalog.fits
|
|
33
|
+
|
|
34
|
+
Update with light curve caching:
|
|
35
|
+
|
|
36
|
+
isgri update --cache ~/data/lightcurves/
|
|
37
|
+
|
|
38
|
+
Update using 4 CPU cores:
|
|
39
|
+
|
|
40
|
+
isgri update --cores 4
|
|
41
|
+
"""
|
|
42
|
+
if archive is None or catalog is None:
|
|
43
|
+
cfg = Config()
|
|
44
|
+
|
|
45
|
+
if archive is None:
|
|
46
|
+
archive = cfg.archive_path
|
|
47
|
+
if not archive:
|
|
48
|
+
click.echo("Error: No archive path configured", err=True)
|
|
49
|
+
raise click.Abort()
|
|
50
|
+
|
|
51
|
+
if catalog is None:
|
|
52
|
+
catalog = cfg.catalog_path
|
|
53
|
+
if not catalog:
|
|
54
|
+
click.echo("Error: No catalog path configured", err=True)
|
|
55
|
+
raise click.Abort()
|
|
56
|
+
|
|
57
|
+
archive_path = Path(archive).expanduser().resolve()
|
|
58
|
+
catalog_path = Path(catalog).expanduser().resolve()
|
|
59
|
+
cache_path = Path(cache).expanduser().resolve() if cache else None
|
|
60
|
+
|
|
61
|
+
if not archive_path.exists():
|
|
62
|
+
click.echo(f"Error: Archive directory does not exist: {archive_path}", err=True)
|
|
63
|
+
raise click.Abort()
|
|
64
|
+
|
|
65
|
+
if not catalog_path.parent.exists():
|
|
66
|
+
click.echo(f"Warning: Catalog directory does not exist: {catalog_path.parent}", err=True)
|
|
67
|
+
if not click.confirm("Create new catalog file?"):
|
|
68
|
+
raise click.Abort()
|
|
69
|
+
|
|
70
|
+
if cache_path and not cache_path.exists():
|
|
71
|
+
click.echo(f"Warning: Cache directory does not exist: {cache_path}", err=True)
|
|
72
|
+
if not click.confirm("Create directory?"):
|
|
73
|
+
raise click.Abort()
|
|
74
|
+
cache_path.mkdir(parents=True, exist_ok=True)
|
|
75
|
+
click.echo(f"✓ Created cache directory: {cache_path}")
|
|
76
|
+
|
|
77
|
+
click.echo(f"Archive: {archive_path}")
|
|
78
|
+
click.echo(f"Catalog: {catalog_path}")
|
|
79
|
+
if cache_path:
|
|
80
|
+
click.echo(f"Cache: {cache_path}")
|
|
81
|
+
else:
|
|
82
|
+
click.echo("Cache: (none)")
|
|
83
|
+
if cores:
|
|
84
|
+
click.echo(f"CPU cores: {cores}")
|
|
85
|
+
click.echo()
|
|
86
|
+
|
|
87
|
+
try:
|
|
88
|
+
builder = CatalogBuilder(
|
|
89
|
+
archive_path=str(archive_path),
|
|
90
|
+
catalog_path=str(catalog_path),
|
|
91
|
+
lightcurve_cache=str(cache_path) if cache_path else None,
|
|
92
|
+
n_cores=cores,
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
builder.update_catalog()
|
|
96
|
+
|
|
97
|
+
click.echo()
|
|
98
|
+
click.echo("Catalog update complete")
|
|
99
|
+
|
|
100
|
+
except Exception as e:
|
|
101
|
+
click.echo(f"Error during catalog update: {e}", err=True)
|
|
102
|
+
raise click.Abort()
|
isgri/cli/main.py
CHANGED
|
@@ -4,6 +4,7 @@ from ..catalog import ScwQuery
|
|
|
4
4
|
from ..__version__ import __version__
|
|
5
5
|
from ..config import Config
|
|
6
6
|
from .query import query_direct, query_interactive
|
|
7
|
+
from .builder import update
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
@click.group()
|
|
@@ -181,5 +182,7 @@ def config_set(archive, catalog, pif):
|
|
|
181
182
|
click.echo(f"Configuration saved to: {cfg.path}")
|
|
182
183
|
|
|
183
184
|
|
|
185
|
+
main.add_command(update)
|
|
186
|
+
|
|
184
187
|
if __name__ == "__main__":
|
|
185
188
|
main()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: isgri
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.1
|
|
4
4
|
Summary: Python package for INTEGRAL IBIS/ISGRI lightcurve analysis
|
|
5
5
|
Author: Dominik Patryk Pacholski
|
|
6
6
|
License: MIT
|
|
@@ -26,6 +26,7 @@ Query catalogs directly from the terminal:
|
|
|
26
26
|
- Interactive and direct query modes
|
|
27
27
|
- Filter by time, position, quality, revolution
|
|
28
28
|
- Export results to FITS/CSV or SWID lists
|
|
29
|
+
- Update catalogs with new science windows from archive
|
|
29
30
|
|
|
30
31
|
### SCW Catalog Query
|
|
31
32
|
Query INTEGRAL Science Window catalogs with a fluent Python API:
|
|
@@ -33,6 +34,13 @@ Query INTEGRAL Science Window catalogs with a fluent Python API:
|
|
|
33
34
|
- Calculate detector offsets
|
|
34
35
|
- Export results to any auto detectable astropy table extension or in table aligned data for any other extension
|
|
35
36
|
|
|
37
|
+
### Catalog Builder
|
|
38
|
+
Build and update INTEGRAL/ISGRI science window catalogs:
|
|
39
|
+
- Automatic discovery of new science windows in archive
|
|
40
|
+
- Parallel processing of quality metrics
|
|
41
|
+
- Optional light curve caching
|
|
42
|
+
- Incremental catalog updates
|
|
43
|
+
|
|
36
44
|
### Light Curve Analysis
|
|
37
45
|
Extract and analyze ISGRI light curves:
|
|
38
46
|
- Load from file paths or SWID/source lookup
|
|
@@ -60,6 +68,9 @@ isgri config-set --archive /path/to/archive --catalog ~/data/scw_catalog.fits --
|
|
|
60
68
|
# View current config
|
|
61
69
|
isgri config
|
|
62
70
|
|
|
71
|
+
# Update catalog from archive
|
|
72
|
+
isgri update
|
|
73
|
+
|
|
63
74
|
# Interactive catalog query
|
|
64
75
|
isgri query
|
|
65
76
|
# query> time
|
|
@@ -109,6 +120,51 @@ swids = cat.get_swids()
|
|
|
109
120
|
print(f"Found {len(results)} observations")
|
|
110
121
|
```
|
|
111
122
|
|
|
123
|
+
### Build/Update SCW Catalog
|
|
124
|
+
|
|
125
|
+
#### Command Line
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
# Update catalog using configured paths
|
|
129
|
+
isgri update
|
|
130
|
+
|
|
131
|
+
# Update with custom paths
|
|
132
|
+
isgri update --archive /anita/archivio/ --catalog ~/data/catalog.fits
|
|
133
|
+
|
|
134
|
+
# Enable light curve caching (15-1000 keV, 1s bins)
|
|
135
|
+
isgri update --cache ~/data/lightcurves/
|
|
136
|
+
|
|
137
|
+
# Limit CPU cores for parallel processing
|
|
138
|
+
isgri update --cores 4
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
#### Python API
|
|
142
|
+
|
|
143
|
+
```python
|
|
144
|
+
from isgri.catalog import CatalogBuilder
|
|
145
|
+
|
|
146
|
+
# Create builder instance
|
|
147
|
+
builder = CatalogBuilder(
|
|
148
|
+
archive_path="/path/to/archive",
|
|
149
|
+
catalog_path="scw_catalog.fits",
|
|
150
|
+
lightcurve_cache="/path/to/cache", # optional
|
|
151
|
+
n_cores=8
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
# Update catalog with new science windows
|
|
155
|
+
builder.update_catalog()
|
|
156
|
+
|
|
157
|
+
# Find all science windows in archive
|
|
158
|
+
swids, paths = builder.find_scws()
|
|
159
|
+
print(f"Found {len(swids)} science windows")
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
The builder:
|
|
163
|
+
- Scans archive for new ScWs not in catalog
|
|
164
|
+
- Computes quality metrics (raw, sigma-clipped, GTI-filtered chi-squared)
|
|
165
|
+
- Processes in parallel by revolution
|
|
166
|
+
- Optionally caches 1s light curves (15-1000 keV)
|
|
167
|
+
|
|
112
168
|
### Analyze Light Curves
|
|
113
169
|
|
|
114
170
|
```python
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
isgri/__init__.py,sha256=V2hnOxXKcjMiusdGP8sOAR4QsBlWHQ0pZZMN2Cean6o,38
|
|
2
|
-
isgri/__version__.py,sha256=
|
|
2
|
+
isgri/__version__.py,sha256=tUukPDbH9wVBvn9_DYqm0p_Q7TagQGM_2ZX042hSuUs,21
|
|
3
3
|
isgri/config.py,sha256=8hziHnQN_dnS3FkOtrPUUV1QLJ9HmGiPzDuAiq3GoXc,5044
|
|
4
4
|
isgri/catalog/__init__.py,sha256=IGfzGcGx1F1zplj7YIUuzE5Cvvxg7XJi0zu0aBXI0-A,113
|
|
5
|
-
isgri/catalog/builder.py,sha256=
|
|
5
|
+
isgri/catalog/builder.py,sha256=J1Z_p699hoQtiQjYw5-jvf0aSIIOcpe8djbCjh-NOng,15779
|
|
6
6
|
isgri/catalog/scwquery.py,sha256=v7nR6-6PmYaBunFeGtmDWPqDkUBUvwjv2jtM1RbGQx4,20397
|
|
7
7
|
isgri/catalog/wcs.py,sha256=mD6bZxiBxKYpuYCl8f2tSCc8uuWFzMRL2jf5SuFAhfg,5562
|
|
8
8
|
isgri/cli/__init__.py,sha256=SCIcTdOvfEkrZd1doOtOnvCj8PmdRuXu18YYJQxfFrs,24
|
|
9
|
-
isgri/cli/
|
|
9
|
+
isgri/cli/builder.py,sha256=dCp9ECl9MoThTRXAkXXazafHYSMQF0FLHKDzlWwT7vE,3494
|
|
10
|
+
isgri/cli/main.py,sha256=SQxx1NdYQ7WjLINgvtyO4-rPdcVLhXnixU00pDqgVg8,6436
|
|
10
11
|
isgri/cli/query.py,sha256=jIAJ8Ghr73OivSIqTjqYE-y-gn9hw4-QpEeH-z6Bny0,8012
|
|
11
12
|
isgri/utils/__init__.py,sha256=H83Al7urc6LNW5KUzUBRdtRBUTahiZmkehKFiK90RrU,183
|
|
12
13
|
isgri/utils/file_loaders.py,sha256=E4-0QA6r1QAX1gV1Dd5qhKPDXZIdSEk7AWdOQrovHGo,17423
|
|
@@ -14,8 +15,8 @@ isgri/utils/lightcurve.py,sha256=v_JNLzf1SBvFLzrU7ZXpSj44eRKaZChiO4gvS2_O35Y,174
|
|
|
14
15
|
isgri/utils/pif.py,sha256=sAtzQhe3spLS41UkP1yZsqGPxe3IHLmIGA_d3bVg2v4,9121
|
|
15
16
|
isgri/utils/quality.py,sha256=7CbYaNstoX60AYz2_ym-xjMkiDLpkYgQfaTStYuQZtk,13409
|
|
16
17
|
isgri/utils/time_conversion.py,sha256=MNPVjrsrmwRDbCWmqdWN0xRs8PtHkFGli-H2cYwF9Ns,5204
|
|
17
|
-
isgri-0.7.
|
|
18
|
-
isgri-0.7.
|
|
19
|
-
isgri-0.7.
|
|
20
|
-
isgri-0.7.
|
|
21
|
-
isgri-0.7.
|
|
18
|
+
isgri-0.7.1.dist-info/METADATA,sha256=1Wi7eyxKCtpzFek7iCRLI_JaQqsiPiEdxRWZiOQeF_o,6499
|
|
19
|
+
isgri-0.7.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
20
|
+
isgri-0.7.1.dist-info/entry_points.txt,sha256=aM2K4RGihbwsj9crjPG-BvWhErcdtZt3tJqT6AaOojU,46
|
|
21
|
+
isgri-0.7.1.dist-info/licenses/LICENSE,sha256=Q8oxmHR1cSnEXSHCjY3qeXMtupZI_1ZQZ1MBt4oeANE,1102
|
|
22
|
+
isgri-0.7.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|