isgri 0.6.0__py3-none-any.whl → 0.7.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/__version__.py +1 -1
- isgri/catalog/__init__.py +2 -1
- isgri/catalog/builder.py +358 -16
- isgri/catalog/scwquery.py +45 -16
- isgri/cli/__init__.py +1 -1
- isgri/cli/main.py +185 -168
- isgri/cli/query.py +210 -172
- isgri/config.py +37 -9
- isgri/utils/file_loaders.py +171 -30
- isgri/utils/lightcurve.py +103 -13
- isgri/utils/pif.py +14 -0
- isgri/utils/quality.py +4 -3
- {isgri-0.6.0.dist-info → isgri-0.7.0.dist-info}/METADATA +93 -27
- isgri-0.7.0.dist-info/RECORD +21 -0
- isgri-0.6.0.dist-info/RECORD +0 -21
- {isgri-0.6.0.dist-info → isgri-0.7.0.dist-info}/WHEEL +0 -0
- {isgri-0.6.0.dist-info → isgri-0.7.0.dist-info}/entry_points.txt +0 -0
- {isgri-0.6.0.dist-info → isgri-0.7.0.dist-info}/licenses/LICENSE +0 -0
isgri/cli/main.py
CHANGED
|
@@ -1,168 +1,185 @@
|
|
|
1
|
-
import click
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
from ..catalog import ScwQuery
|
|
4
|
-
from ..__version__ import __version__
|
|
5
|
-
from ..config import Config
|
|
6
|
-
from .query import query_direct, query_interactive
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
@click.group()
|
|
10
|
-
@click.version_option(version=__version__)
|
|
11
|
-
def main():
|
|
12
|
-
"""ISGRI - INTEGRAL/ISGRI data analysis toolkit."""
|
|
13
|
-
pass
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
@main.command()
|
|
17
|
-
@click.option("--catalog", type=click.Path(), help="Path to catalog FITS file. If not provided, uses config value.")
|
|
18
|
-
@click.option("--tstart", help="Start time (YYYY-MM-DD or IJD)")
|
|
19
|
-
@click.option("--tstop", help="Stop time (YYYY-MM-DD or IJD)")
|
|
20
|
-
@click.option("--ra", help="Right ascension (degrees or HH:MM:SS)")
|
|
21
|
-
@click.option("--dec", help="Declination (degrees or DD:MM:SS)")
|
|
22
|
-
@click.option("--radius", type=float, help="Angular separation (degrees)")
|
|
23
|
-
@click.option("--fov", type=click.Choice(["full", "any"]), default="any", help="Field of view mode")
|
|
24
|
-
@click.option("--max-chi", type=float, help="Maximum chi-squared value")
|
|
25
|
-
@click.option("--chi-type", type=click.Choice(["RAW", "CUT", "GTI"]), default="CUT", help="Type of chi-squared value")
|
|
26
|
-
@click.option("--revolution", help="Revolution number")
|
|
27
|
-
@click.option(
|
|
28
|
-
"--output", "-o", type=click.Path(), help="Output file (.fits or .csv or any if --list-swids or --count)"
|
|
29
|
-
)
|
|
30
|
-
@click.option("--list-swids", is_flag=True, help="Only output SWID list")
|
|
31
|
-
@click.option("--count", is_flag=True, help="Only show count")
|
|
32
|
-
def query(catalog, tstart, tstop, ra, dec, radius, fov, max_chi, chi_type, revolution, output, list_swids, count):
|
|
33
|
-
"""
|
|
34
|
-
Query INTEGRAL science window catalog.
|
|
35
|
-
|
|
36
|
-
If no catalog path is provided, uses the default from configuration.
|
|
37
|
-
Multiple filters can be combined.
|
|
38
|
-
|
|
39
|
-
Examples:
|
|
40
|
-
Query by time range (IJD):
|
|
41
|
-
|
|
42
|
-
isgri query --tstart 3000 --tstop 3100
|
|
43
|
-
|
|
44
|
-
Query by time range (ISO date):
|
|
45
|
-
|
|
46
|
-
isgri query --tstart 2010-01-01 --tstop 2010-12-31
|
|
47
|
-
|
|
48
|
-
Query by sky position:
|
|
49
|
-
|
|
50
|
-
isgri query --ra 83.63 --dec 22.01 --fov full
|
|
51
|
-
isgri query --ra 83.63 --dec 22.01 --radius 5.0
|
|
52
|
-
|
|
53
|
-
Query with quality cut:
|
|
54
|
-
|
|
55
|
-
isgri query --max-chi 2.0 --chi-type CUT
|
|
56
|
-
|
|
57
|
-
Save results to file:
|
|
58
|
-
|
|
59
|
-
isgri query --tstart 3000 --tstop 3100 --output results.fits
|
|
60
|
-
|
|
61
|
-
Get only SWID list:
|
|
62
|
-
|
|
63
|
-
isgri query --tstart 3000 --tstop 3100 --list-swids
|
|
64
|
-
|
|
65
|
-
Count matching science windows:
|
|
66
|
-
|
|
67
|
-
isgri query --ra 83.63 --dec 22.01 --count
|
|
68
|
-
"""
|
|
69
|
-
if catalog is None:
|
|
70
|
-
cfg = Config()
|
|
71
|
-
catalog = cfg.catalog_path
|
|
72
|
-
|
|
73
|
-
if not catalog:
|
|
74
|
-
click.echo("Error: No catalog configured", err=True)
|
|
75
|
-
raise click.Abort()
|
|
76
|
-
|
|
77
|
-
if any(param is not None for param in [tstart, tstop, ra, dec, radius, max_chi, revolution]):
|
|
78
|
-
query_direct(
|
|
79
|
-
catalog, tstart, tstop, ra, dec, radius, fov, max_chi, chi_type, revolution, output, list_swids, count
|
|
80
|
-
)
|
|
81
|
-
else:
|
|
82
|
-
query_interactive(catalog)
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
@main.command()
|
|
86
|
-
def config():
|
|
87
|
-
"""
|
|
88
|
-
Show current configuration.
|
|
89
|
-
|
|
90
|
-
Displays paths to config file, archive directory,
|
|
91
|
-
along with their existence status.
|
|
92
|
-
"""
|
|
93
|
-
cfg = Config()
|
|
94
|
-
|
|
95
|
-
click.echo(f"Config file: {cfg.path}")
|
|
96
|
-
click.echo(f" Exists: {cfg.path.exists()}")
|
|
97
|
-
click.echo()
|
|
98
|
-
|
|
99
|
-
archive = cfg.archive_path
|
|
100
|
-
click.echo(f"Archive path: {archive if archive else '(not set)'}")
|
|
101
|
-
if archive:
|
|
102
|
-
click.echo(f" Exists: {archive.exists()}")
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
Set
|
|
132
|
-
|
|
133
|
-
isgri config-set --
|
|
134
|
-
|
|
135
|
-
Set
|
|
136
|
-
|
|
137
|
-
isgri config-set --
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
click.
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
1
|
+
import click
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from ..catalog import ScwQuery
|
|
4
|
+
from ..__version__ import __version__
|
|
5
|
+
from ..config import Config
|
|
6
|
+
from .query import query_direct, query_interactive
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@click.group()
|
|
10
|
+
@click.version_option(version=__version__)
|
|
11
|
+
def main():
|
|
12
|
+
"""ISGRI - INTEGRAL/ISGRI data analysis toolkit."""
|
|
13
|
+
pass
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@main.command()
|
|
17
|
+
@click.option("--catalog", type=click.Path(), help="Path to catalog FITS file. If not provided, uses config value.")
|
|
18
|
+
@click.option("--tstart", help="Start time (YYYY-MM-DD or IJD)")
|
|
19
|
+
@click.option("--tstop", help="Stop time (YYYY-MM-DD or IJD)")
|
|
20
|
+
@click.option("--ra", help="Right ascension (degrees or HH:MM:SS)")
|
|
21
|
+
@click.option("--dec", help="Declination (degrees or DD:MM:SS)")
|
|
22
|
+
@click.option("--radius", type=float, help="Angular separation (degrees)")
|
|
23
|
+
@click.option("--fov", type=click.Choice(["full", "any"]), default="any", help="Field of view mode")
|
|
24
|
+
@click.option("--max-chi", type=float, help="Maximum chi-squared value")
|
|
25
|
+
@click.option("--chi-type", type=click.Choice(["RAW", "CUT", "GTI"]), default="CUT", help="Type of chi-squared value")
|
|
26
|
+
@click.option("--revolution", help="Revolution number")
|
|
27
|
+
@click.option(
|
|
28
|
+
"--output", "-o", type=click.Path(), help="Output file (.fits or .csv or any if --list-swids or --count)"
|
|
29
|
+
)
|
|
30
|
+
@click.option("--list-swids", is_flag=True, help="Only output SWID list")
|
|
31
|
+
@click.option("--count", is_flag=True, help="Only show count")
|
|
32
|
+
def query(catalog, tstart, tstop, ra, dec, radius, fov, max_chi, chi_type, revolution, output, list_swids, count):
|
|
33
|
+
"""
|
|
34
|
+
Query INTEGRAL science window catalog.
|
|
35
|
+
|
|
36
|
+
If no catalog path is provided, uses the default from configuration.
|
|
37
|
+
Multiple filters can be combined.
|
|
38
|
+
|
|
39
|
+
Examples:
|
|
40
|
+
Query by time range (IJD):
|
|
41
|
+
|
|
42
|
+
isgri query --tstart 3000 --tstop 3100
|
|
43
|
+
|
|
44
|
+
Query by time range (ISO date):
|
|
45
|
+
|
|
46
|
+
isgri query --tstart 2010-01-01 --tstop 2010-12-31
|
|
47
|
+
|
|
48
|
+
Query by sky position:
|
|
49
|
+
|
|
50
|
+
isgri query --ra 83.63 --dec 22.01 --fov full
|
|
51
|
+
isgri query --ra 83.63 --dec 22.01 --radius 5.0
|
|
52
|
+
|
|
53
|
+
Query with quality cut:
|
|
54
|
+
|
|
55
|
+
isgri query --max-chi 2.0 --chi-type CUT
|
|
56
|
+
|
|
57
|
+
Save results to file:
|
|
58
|
+
|
|
59
|
+
isgri query --tstart 3000 --tstop 3100 --output results.fits
|
|
60
|
+
|
|
61
|
+
Get only SWID list:
|
|
62
|
+
|
|
63
|
+
isgri query --tstart 3000 --tstop 3100 --list-swids
|
|
64
|
+
|
|
65
|
+
Count matching science windows:
|
|
66
|
+
|
|
67
|
+
isgri query --ra 83.63 --dec 22.01 --count
|
|
68
|
+
"""
|
|
69
|
+
if catalog is None:
|
|
70
|
+
cfg = Config()
|
|
71
|
+
catalog = cfg.catalog_path
|
|
72
|
+
|
|
73
|
+
if not catalog:
|
|
74
|
+
click.echo("Error: No catalog configured", err=True)
|
|
75
|
+
raise click.Abort()
|
|
76
|
+
|
|
77
|
+
if any(param is not None for param in [tstart, tstop, ra, dec, radius, max_chi, revolution]):
|
|
78
|
+
query_direct(
|
|
79
|
+
catalog, tstart, tstop, ra, dec, radius, fov, max_chi, chi_type, revolution, output, list_swids, count
|
|
80
|
+
)
|
|
81
|
+
else:
|
|
82
|
+
query_interactive(catalog)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
@main.command()
|
|
86
|
+
def config():
|
|
87
|
+
"""
|
|
88
|
+
Show current configuration.
|
|
89
|
+
|
|
90
|
+
Displays paths to config file, archive directory, catalog file, and PIF directory,
|
|
91
|
+
along with their existence status.
|
|
92
|
+
"""
|
|
93
|
+
cfg = Config()
|
|
94
|
+
|
|
95
|
+
click.echo(f"Config file: {cfg.path}")
|
|
96
|
+
click.echo(f" Exists: {cfg.path.exists()}")
|
|
97
|
+
click.echo()
|
|
98
|
+
|
|
99
|
+
archive = cfg.archive_path
|
|
100
|
+
click.echo(f"Archive path: {archive if archive else '(not set)'}")
|
|
101
|
+
if archive:
|
|
102
|
+
click.echo(f" Exists: {archive.exists()}")
|
|
103
|
+
click.echo()
|
|
104
|
+
|
|
105
|
+
catalog = cfg.catalog_path
|
|
106
|
+
click.echo(f"Catalog path: {catalog if catalog else '(not set)'}")
|
|
107
|
+
if catalog:
|
|
108
|
+
click.echo(f" Exists: {catalog.exists()}")
|
|
109
|
+
click.echo()
|
|
110
|
+
|
|
111
|
+
pif = cfg.pif_path
|
|
112
|
+
click.echo(f"PIF path: {pif if pif else '(not set)'}")
|
|
113
|
+
if pif:
|
|
114
|
+
click.echo(f" Exists: {pif.exists()}")
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
@main.command()
|
|
118
|
+
@click.option("--archive", type=click.Path(), help="INTEGRAL archive directory path")
|
|
119
|
+
@click.option("--catalog", type=click.Path(), help="Catalog FITS file path")
|
|
120
|
+
@click.option("--pif", type=click.Path(), help="PIF directory path")
|
|
121
|
+
def config_set(archive, catalog, pif):
|
|
122
|
+
"""
|
|
123
|
+
Set configuration values.
|
|
124
|
+
|
|
125
|
+
Set default paths for archive directory, catalog file, and/or PIF directory.
|
|
126
|
+
Paths are expanded (~ becomes home directory) and resolved to absolute paths.
|
|
127
|
+
Warns if path doesn't exist but allows setting anyway.
|
|
128
|
+
|
|
129
|
+
Examples:
|
|
130
|
+
|
|
131
|
+
Set archive path:
|
|
132
|
+
|
|
133
|
+
isgri config-set --archive /anita/archivio/
|
|
134
|
+
|
|
135
|
+
Set catalog path:
|
|
136
|
+
|
|
137
|
+
isgri config-set --catalog ~/data/scw_catalog.fits
|
|
138
|
+
|
|
139
|
+
Set PIF path:
|
|
140
|
+
|
|
141
|
+
isgri config-set --pif ~/data/pif/
|
|
142
|
+
|
|
143
|
+
Set all at once:
|
|
144
|
+
|
|
145
|
+
isgri config-set --archive /anita/archivio/ --catalog ~/data/scw_catalog.fits --pif ~/data/pif/
|
|
146
|
+
"""
|
|
147
|
+
if not archive and not catalog and not pif:
|
|
148
|
+
click.echo("Error: Specify at least one option (--archive, --catalog, or --pif)", err=True)
|
|
149
|
+
raise click.Abort()
|
|
150
|
+
|
|
151
|
+
cfg = Config()
|
|
152
|
+
|
|
153
|
+
if archive:
|
|
154
|
+
archive_path = Path(archive).expanduser().resolve()
|
|
155
|
+
if not archive_path.exists():
|
|
156
|
+
click.echo(f"Warning: Archive path does not exist: {archive_path}", err=True)
|
|
157
|
+
if not click.confirm("Set anyway?"):
|
|
158
|
+
raise click.Abort()
|
|
159
|
+
cfg.set(archive_path=archive_path)
|
|
160
|
+
click.echo(f"✓ Archive path set to: {archive_path}")
|
|
161
|
+
|
|
162
|
+
if catalog:
|
|
163
|
+
catalog_path = Path(catalog).expanduser().resolve()
|
|
164
|
+
if not catalog_path.exists():
|
|
165
|
+
click.echo(f"Warning: Catalog file does not exist: {catalog_path}", err=True)
|
|
166
|
+
if not click.confirm("Set anyway?"):
|
|
167
|
+
raise click.Abort()
|
|
168
|
+
cfg.set(catalog_path=catalog_path)
|
|
169
|
+
click.echo(f"✓ Catalog path set to: {catalog_path}")
|
|
170
|
+
|
|
171
|
+
if pif:
|
|
172
|
+
pif_path = Path(pif).expanduser().resolve()
|
|
173
|
+
if not pif_path.exists():
|
|
174
|
+
click.echo(f"Warning: PIF path does not exist: {pif_path}", err=True)
|
|
175
|
+
if not click.confirm("Set anyway?"):
|
|
176
|
+
raise click.Abort()
|
|
177
|
+
cfg.set(pif_path=pif_path)
|
|
178
|
+
click.echo(f"✓ PIF path set to: {pif_path}")
|
|
179
|
+
|
|
180
|
+
click.echo()
|
|
181
|
+
click.echo(f"Configuration saved to: {cfg.path}")
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
if __name__ == "__main__":
|
|
185
|
+
main()
|