isgri 0.2.0__py3-none-any.whl → 0.4.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.
@@ -1,39 +1,210 @@
1
+ """
2
+ Time Conversion Utilities for INTEGRAL
3
+ =======================================
4
+
5
+ Convert between INTEGRAL Julian Date (IJD) and other time formats.
6
+
7
+ INTEGRAL uses IJD as its standard time format:
8
+ - IJD 0.0 = 2000-01-01 00:00:00 TT (Terrestrial Time)
9
+ - IJD = MJD - 51544.0
10
+ - IJD uses TT time scale (atomic time)
11
+
12
+ Functions
13
+ ---------
14
+ ijd2utc : Convert IJD to UTC ISO format
15
+ utc2ijd : Convert UTC ISO format to IJD
16
+ ijd2mjd : Convert IJD to Modified Julian Date
17
+ mjd2ijd : Convert Modified Julian Date to IJD
18
+
19
+ Examples
20
+ --------
21
+ >>> from isgri.utils import ijd2utc, utc2ijd
22
+ >>>
23
+ >>> # Convert IJD to readable format
24
+ >>> utc_str = ijd2utc(3000.5)
25
+ >>> print(utc_str)
26
+ 2008-03-17 11:58:55.816
27
+ >>>
28
+ >>> # Round trip conversion
29
+ >>> ijd = utc2ijd("2010-01-01 12:00:00")
30
+ >>> print(f"IJD: {ijd:.3f}")
31
+ IJD: 3653.500
32
+
33
+ Notes
34
+ -----
35
+ - IJD uses TT (Terrestrial Time) scale for consistency with spacecraft clock
36
+ - UTC conversions account for leap seconds automatically
37
+ - Precision: ~1 microsecond for typical astronomical observations
38
+ """
39
+
1
40
  from astropy.time import Time
41
+ from typing import Union
42
+ import numpy as np
43
+ from numpy.typing import NDArray
44
+
45
+ # INTEGRAL epoch: MJD 51544.0 = 2000-01-01 00:00:00 TT
46
+ INTEGRAL_EPOCH_MJD = 51544.0
2
47
 
3
48
 
4
- def ijd2utc(t):
49
+ def ijd2utc(ijd_time: Union[float, NDArray[np.float64]]) -> Union[str, NDArray[np.str_]]:
5
50
  """
6
- Converts IJD (INTEGRAL Julian Date) time to UTC ISO format.
51
+ Convert IJD (INTEGRAL Julian Date) to UTC ISO format.
52
+
53
+ Parameters
54
+ ----------
55
+ ijd_time : float or ndarray
56
+ IJD time value(s). Can be scalar or array.
57
+
58
+ Returns
59
+ -------
60
+ utc_str : str or ndarray of str
61
+ UTC time in ISO format 'YYYY-MM-DD HH:MM:SS.sss'
62
+ Scalar if input is scalar, array if input is array.
63
+
64
+ Examples
65
+ --------
66
+ >>> ijd2utc(0.0)
67
+ '1999-12-31 23:58:55.816'
7
68
 
8
- Args:
9
- t (float or ndarray): IJD time value(s).
69
+ >>> ijd2utc(1000.5)
70
+ '2002-09-27 11:58:55.816'
10
71
 
11
- Returns:
12
- str or ndarray: UTC time in ISO format (YYYY-MM-DD HH:MM:SS.sss).
72
+ >>> # Array conversion
73
+ >>> ijds = np.array([0.0, 1000.0, 2000.0])
74
+ >>> utcs = ijd2utc(ijds)
75
+ >>> print(utcs[0])
76
+ 1999-12-31 23:58:55.816
13
77
 
14
- Examples:
15
- >>> ijd2utc(0.0)
16
- '1999-12-31 23:58:55.817'
17
- >>> ijd2utc(1000.5)
18
- '2002-09-27 11:58:55.816'
78
+ See Also
79
+ --------
80
+ utc2ijd : Inverse conversion (UTC to IJD)
81
+ ijd2mjd : Convert IJD to MJD
82
+
83
+ Notes
84
+ -----
85
+ - IJD 0.0 corresponds to 2000-01-01 00:00:00 TT
86
+ - Accounts for leap seconds via UTC scale
87
+ - Output precision is milliseconds (3 decimal places)
19
88
  """
20
- return Time(t + 51544, format="mjd", scale="tt").utc.iso
89
+ mjd = ijd_time + INTEGRAL_EPOCH_MJD
90
+ t = Time(mjd, format="mjd", scale="tt")
91
+ return t.utc.iso
21
92
 
22
93
 
23
- def utc2ijd(t):
94
+ def utc2ijd(utc_time: Union[str, NDArray[np.str_]]) -> Union[float, NDArray[np.float64]]:
24
95
  """
25
- Converts UTC ISO format time to IJD (INTEGRAL Julian Date).
96
+ Convert UTC ISO format to IJD (INTEGRAL Julian Date).
97
+
98
+ Parameters
99
+ ----------
100
+ utc_time : str or ndarray of str
101
+ UTC time in ISO format. Accepts:
102
+ - 'YYYY-MM-DD HH:MM:SS' (space separator)
103
+ - 'YYYY-MM-DDTHH:MM:SS' (T separator)
104
+ - Can include fractional seconds
105
+
106
+ Returns
107
+ -------
108
+ ijd_time : float or ndarray
109
+ IJD time value(s)
110
+
111
+ Examples
112
+ --------
113
+ >>> utc2ijd('1999-12-31 23:58:55.816')
114
+ 0.0
115
+
116
+ >>> utc2ijd('2002-09-27 00:00:00')
117
+ 1000.0
118
+
119
+ >>> # ISO 8601 format (with T separator)
120
+ >>> utc2ijd('2010-01-01T12:00:00')
121
+ 3653.5
122
+
123
+ >>> # Array conversion
124
+ >>> utcs = ['2000-01-01 00:00:00', '2000-01-02 00:00:00']
125
+ >>> ijds = utc2ijd(utcs)
126
+ >>> print(ijds)
127
+ [0.00074287 1.00074287]
128
+
129
+ See Also
130
+ --------
131
+ ijd2utc : Inverse conversion (IJD to UTC)
132
+ mjd2ijd : Convert MJD to IJD
133
+
134
+ Notes
135
+ -----
136
+ - Automatically handles both space and T separators
137
+ - Accounts for leap seconds
138
+ - Returns TT (Terrestrial Time) scale
139
+ """
140
+ # Handle T separator in ISO 8601 format
141
+ if isinstance(utc_time, str):
142
+ utc_time = utc_time.replace("T", " ")
143
+ elif isinstance(utc_time, np.ndarray):
144
+ # Vectorized string replacement for arrays
145
+ utc_time = np.char.replace(utc_time, "T", " ")
146
+
147
+ t = Time(utc_time, format="iso", scale="utc")
148
+ return t.tt.mjd - INTEGRAL_EPOCH_MJD
149
+
150
+
151
+ def ijd2mjd(ijd_time: Union[float, NDArray[np.float64]]) -> Union[float, NDArray[np.float64]]:
152
+ """
153
+ Convert IJD to Modified Julian Date (MJD).
154
+
155
+ Simple offset: MJD = IJD + 51544.0
156
+
157
+ Parameters
158
+ ----------
159
+ ijd_time : float or ndarray
160
+ IJD time value(s)
161
+
162
+ Returns
163
+ -------
164
+ mjd_time : float or ndarray
165
+ MJD time value(s)
166
+
167
+ Examples
168
+ --------
169
+ >>> ijd2mjd(0.0)
170
+ 51544.0
171
+
172
+ >>> ijd2mjd(3653.5)
173
+ 55197.5
174
+
175
+ See Also
176
+ --------
177
+ mjd2ijd : Inverse conversion
178
+ """
179
+ return ijd_time + INTEGRAL_EPOCH_MJD
180
+
181
+
182
+ def mjd2ijd(mjd_time: Union[float, NDArray[np.float64]]) -> Union[float, NDArray[np.float64]]:
183
+ """
184
+ Convert Modified Julian Date (MJD) to IJD.
185
+
186
+ Simple offset: IJD = MJD - 51544.0
187
+
188
+ Parameters
189
+ ----------
190
+ mjd_time : float or ndarray
191
+ MJD time value(s)
192
+
193
+ Returns
194
+ -------
195
+ ijd_time : float or ndarray
196
+ IJD time value(s)
26
197
 
27
- Args:
28
- t (str or ndarray): UTC time in ISO format (YYYY-MM-DD HH:MM:SS).
198
+ Examples
199
+ --------
200
+ >>> mjd2ijd(51544.0)
201
+ 0.0
29
202
 
30
- Returns:
31
- float or ndarray: IJD time value(s).
203
+ >>> mjd2ijd(55197.5)
204
+ 3653.5
32
205
 
33
- Examples:
34
- >>> utc2ijd('1999-12-31 23:58:55.817')
35
- 0.0
36
- >>> utc2ijd('2002-09-27 00:00:00')
37
- 1000.0
206
+ See Also
207
+ --------
208
+ ijd2mjd : Inverse conversion
38
209
  """
39
- return Time(t, format="iso", scale="utc").tt.mjd - 51544
210
+ return mjd_time - INTEGRAL_EPOCH_MJD
@@ -0,0 +1,107 @@
1
+ Metadata-Version: 2.4
2
+ Name: isgri
3
+ Version: 0.4.0
4
+ Summary: Python package for INTEGRAL IBIS/ISGRI lightcurve analysis
5
+ Author: Dominik Patryk Pacholski
6
+ License: MIT
7
+ License-File: LICENSE
8
+ Requires-Python: >=3.10
9
+ Requires-Dist: astropy
10
+ Requires-Dist: numpy
11
+ Description-Content-Type: text/markdown
12
+
13
+ # ISGRI
14
+
15
+ Python toolkit for INTEGRAL/ISGRI data analysis.
16
+
17
+ ## Features
18
+
19
+ ### 📊 SCW Catalog Query
20
+ Query INTEGRAL Science Window catalogs with a fluent Python API:
21
+ - Filter by time, position, quality, revolution
22
+ - Calculate detector offsets
23
+ - Export results to FITS/CSV
24
+
25
+ ### 💡 Light Curve Analysis
26
+ Extract and analyze ISGRI light curves:
27
+ - Event loading with PIF weighting
28
+ - Custom time binning
29
+ - Module-by-module analysis
30
+ - Quality metrics (chi-squared tests)
31
+ - Time conversions (IJD ↔ UTC)
32
+
33
+
34
+ ## Installation
35
+
36
+ ```bash
37
+ pip install isgri
38
+ ```
39
+
40
+ ## Quick Start
41
+
42
+ ### Query SCW Catalog
43
+
44
+ ```python
45
+ from isgri.catalog import ScwQuery
46
+
47
+ # Load catalog
48
+ cat = ScwQuery("path_to_catalog.fits")
49
+
50
+ # Find Crab observations in 2010 with good quality
51
+ results = (cat
52
+ .time(tstart="2010-01-01", tstop="2010-12-31")
53
+ .quality(max_chi=2.0)
54
+ .position(ra=83.63, dec=22.01, fov_mode="full")
55
+ .get()
56
+ )
57
+
58
+ print(f"Found {len(results)} observations")
59
+ ```
60
+
61
+ ### Analyze Light Curves
62
+
63
+ ```python
64
+ from isgri.utils import LightCurve, QualityMetrics
65
+
66
+ # Load events with PIF weighting
67
+ lc = LightCurve.load_data(
68
+ events_path="isgri_events.fits",
69
+ pif_path="source_model.fits",
70
+ pif_threshold=0.5
71
+ )
72
+
73
+ # Create 1-second binned light curve
74
+ time, counts = lc.rebin(binsize=1.0, emin=20, emax=100)
75
+
76
+ # Compute quality metrics
77
+ qm = QualityMetrics(lc, binsize=1.0, emin=20, emax=100)
78
+ chi = qm.raw_chi_squared()
79
+ print(f"Chisq/dof = {chi:.2f}")
80
+ ```
81
+
82
+ ## Documentation
83
+
84
+ - **Catalog Tutorial**: [scwquery_walkthrough.ipynb](https://github.com/dominp/isgri/blob/main/demo/scwquery_walkthrough.ipynb)
85
+ - **Light Curve Tutorial**: [lightcurve_walkthrough.ipynb](https://github.com/dominp/isgri/blob/main/demo/lightcurve_walkthrough.ipynb)
86
+ - **API Reference**: Use `help()` in Python or see docstrings
87
+
88
+ ## Project Structure
89
+
90
+ ```
91
+ isgri/
92
+ ├── catalog/ # SCW catalog query tools
93
+ │ ├── scwquery.py # Main query interface
94
+ │ └── wcs.py # Coordinate transformations
95
+ └── utils/ # Light curve analysis utilities
96
+ ├── lightcurve.py # Light curve class
97
+ ├── quality.py # Quality metrics
98
+ ├── pif.py # PIF tools
99
+ ├── file_loaders.py
100
+ └── time_conversion.py
101
+ ```
102
+
103
+ ## Requirements
104
+
105
+ - Python ≥ 3.10
106
+ - astropy
107
+ - numpy
@@ -0,0 +1,14 @@
1
+ isgri/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ isgri/catalog/__init__.py,sha256=5GTSWfc32HA8z9Q-6taYxPpQi8vTlFfqXUbdJVPITvE,55
3
+ isgri/catalog/scwquery.py,sha256=QAZhbbrXOoTghYXotQxZODGNFFIp9XLv_lZ1nwyYBY8,16821
4
+ isgri/catalog/wcs.py,sha256=KJfIpo-sMVLUBfkv6CGUyTfaBXWpfDQPJEvVhXne-48,5372
5
+ isgri/utils/__init__.py,sha256=H83Al7urc6LNW5KUzUBRdtRBUTahiZmkehKFiK90RrU,183
6
+ isgri/utils/file_loaders.py,sha256=_1KBqxUnQUXs1fD4GSP7-nDsYi9HblpNFkKyG2037To,12000
7
+ isgri/utils/lightcurve.py,sha256=yQMk4H9k7zZ8JvrtPQF6_mZVbk5_MIq_zMOT3lyKZgw,13724
8
+ isgri/utils/pif.py,sha256=UsLKNaso4h-ztkaUotm-XSePx7ZJDQlz3vRKDOaoxfA,8362
9
+ isgri/utils/quality.py,sha256=FKCvvDQ_Ys6zm-nKvwHt8_Mz58XFEWvj7keCHf_4sc0,12959
10
+ isgri/utils/time_conversion.py,sha256=RU9NQtPAWZI-HQf5SS1fMCvsozrgBAApIGp8xIxBc2I,4994
11
+ isgri-0.4.0.dist-info/METADATA,sha256=A2d8vquGiiGsfEkUXjfcbgz5O2v7cJsiHkgV9x-jS5k,2583
12
+ isgri-0.4.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
13
+ isgri-0.4.0.dist-info/licenses/LICENSE,sha256=Q8oxmHR1cSnEXSHCjY3qeXMtupZI_1ZQZ1MBt4oeANE,1102
14
+ isgri-0.4.0.dist-info/RECORD,,
@@ -1,66 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: isgri
3
- Version: 0.2.0
4
- Summary: Python package for INTEGRAL IBIS/ISGRI lightcurve analysis
5
- Author: Dominik Patryk Pacholski
6
- License: MIT
7
- License-File: LICENSE
8
- Requires-Python: >=3.10
9
- Requires-Dist: astropy>=7.2.0
10
- Requires-Dist: numpy>=2.3.5
11
- Description-Content-Type: text/markdown
12
-
13
- # isgri
14
-
15
- Python package for ISGRI (INTEGRAL Soft Gamma-Ray Imager) lightcurve analysis.
16
-
17
- ## Installation
18
-
19
- ```bash
20
- pip install isgri
21
- ```
22
-
23
- Or from source:
24
- ```bash
25
- git clone https://github.com/dominp/isgri.git
26
- cd isgri
27
- pip install -e .
28
- ```
29
-
30
- ## Quick Start
31
-
32
- ```python
33
- from isgri.utils import LightCurve, QualityMetrics
34
-
35
- # Load data
36
- lc = LightCurve.load_data(
37
- events_path='/path/to/isgri_events.fits',
38
- pif_path='/path/to/source_model.fits'
39
- )
40
-
41
- # Create lightcurve
42
- time, counts = lc.rebin(binsize=1.0, emin=30, emax=300)
43
-
44
- # Create lightcurve per each module
45
- times, module_counts = lc.rebin_by_modules(binsize=1.0, emin=30, emax=300)
46
-
47
- # Compute quality metrics
48
- qm = QualityMetrics(lc, binsize=1.0, emin=30, emax=300)
49
- chi = qm.raw_chi_squared()
50
- ```
51
-
52
- **About PIF files:** PIF (Pixel Illumination Fraction) files contain per-pixel sensitivity maps generated by OSA task `ii_pif`. They weight events based on source position to improve signal-to-noise ratio. Using PIF files is recommended but optional.
53
-
54
- ## Features
55
-
56
- - Load ISGRI events and PIF files
57
- - Rebin lightcurves with custom binning
58
- - Module-by-module analysis (8 detector modules)
59
- - Quality metrics (chi-squared variability tests)
60
- - Time conversions (IJD ↔ UTC)
61
- - Custom event filtering
62
-
63
- ## Documentation
64
-
65
- - **Tutorial**: - **Tutorial**: See [demo notebook](https://github.com/dominp/isgri/blob/main/demo/lightcurve_walkthrough.ipynb) on GitHub
66
- - **API docs**: All functions have docstrings - use `help(LightCurve)`
@@ -1,11 +0,0 @@
1
- isgri/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- isgri/utils/__init__.py,sha256=H83Al7urc6LNW5KUzUBRdtRBUTahiZmkehKFiK90RrU,183
3
- isgri/utils/file_loaders.py,sha256=HBQ-n-jFhcP1cxykemBFYTZ72ydJNQrZMUQTeZ2dSnw,5509
4
- isgri/utils/lightcurve.py,sha256=VGRWcpOMnh8Rrbo-EETKAevhYYBZe55IuRQOw_cIfvY,10243
5
- isgri/utils/pif.py,sha256=oxndfoZp-y9FO_TXcCP3dmesvh-sC7hAy2u_1YwGitw,1317
6
- isgri/utils/quality.py,sha256=vNOkIFOkOTP1FAy_1-t5Xvi38gp6UNgXJN3T-DtM8es,7209
7
- isgri/utils/time_conversion.py,sha256=47aTXn6cvi-LjOptDY2W-rjeF_PjthZer61VIsJqsro,908
8
- isgri-0.2.0.dist-info/METADATA,sha256=n3Wxho_x45DSjVi1QQs3eTVmU9_HP1sLsuXFttTMns0,1781
9
- isgri-0.2.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
10
- isgri-0.2.0.dist-info/licenses/LICENSE,sha256=Q8oxmHR1cSnEXSHCjY3qeXMtupZI_1ZQZ1MBt4oeANE,1102
11
- isgri-0.2.0.dist-info/RECORD,,
File without changes