heapyx 0.2.1__tar.gz → 0.2.3__tar.gz
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.
- heapyx-0.2.3/PKG-INFO +159 -0
- heapyx-0.2.3/README.md +116 -0
- heapyx-0.2.3/heapy/__info__.py +1 -0
- {heapyx-0.2.1 → heapyx-0.2.3}/heapy/auto/baseline.py +6 -22
- {heapyx-0.2.1 → heapyx-0.2.3}/heapy/auto/polynomial.py +8 -20
- {heapyx-0.2.1 → heapyx-0.2.3}/heapy/auto/signal.py +223 -55
- {heapyx-0.2.1 → heapyx-0.2.3}/heapy/auto/signal_utils.py +2 -6
- heapyx-0.2.3/heapy/data/filefinder.py +545 -0
- {heapyx-0.2.1 → heapyx-0.2.3}/heapy/data/retrieve.py +20 -12
- {heapyx-0.2.1 → heapyx-0.2.3}/heapy/pipe/batpipe.py +6 -7
- {heapyx-0.2.1 → heapyx-0.2.3}/heapy/pipe/event.py +17 -9
- {heapyx-0.2.1 → heapyx-0.2.3}/heapy/pipe/image.py +6 -7
- heapyx-0.2.3/heapy/temp/cwt.py +418 -0
- {heapyx-0.2.1 → heapyx-0.2.3}/heapy/temp/lag.py +251 -177
- heapyx-0.2.3/heapy/temp/mvt.py +431 -0
- heapyx-0.2.3/heapy/temp/temp_utils.py +1879 -0
- heapyx-0.2.3/heapy/temp/txx.py +686 -0
- {heapyx-0.2.1 → heapyx-0.2.3}/heapy/util/data.py +21 -15
- heapyx-0.2.3/heapyx.egg-info/PKG-INFO +159 -0
- {heapyx-0.2.1 → heapyx-0.2.3}/heapyx.egg-info/SOURCES.txt +1 -2
- {heapyx-0.2.1 → heapyx-0.2.3}/heapyx.egg-info/requires.txt +4 -1
- {heapyx-0.2.1 → heapyx-0.2.3}/pyproject.toml +5 -1
- {heapyx-0.2.1 → heapyx-0.2.3}/setup.py +9 -6
- heapyx-0.2.1/PKG-INFO +0 -85
- heapyx-0.2.1/README.md +0 -45
- heapyx-0.2.1/heapy/__info__.py +0 -1
- heapyx-0.2.1/heapy/data/filefinder.py +0 -296
- heapyx-0.2.1/heapy/temp/mvt.py +0 -646
- heapyx-0.2.1/heapy/temp/mvt_cl.py +0 -970
- heapyx-0.2.1/heapy/temp/mvt_gm.py +0 -1104
- heapyx-0.2.1/heapy/temp/temp_utils.py +0 -347
- heapyx-0.2.1/heapy/temp/txx.py +0 -918
- heapyx-0.2.1/heapyx.egg-info/PKG-INFO +0 -85
- {heapyx-0.2.1 → heapyx-0.2.3}/LICENSE +0 -0
- {heapyx-0.2.1 → heapyx-0.2.3}/heapy/__init__.py +0 -0
- {heapyx-0.2.1 → heapyx-0.2.3}/heapy/auto/__init__.py +0 -0
- {heapyx-0.2.1 → heapyx-0.2.3}/heapy/data/__init__.py +0 -0
- {heapyx-0.2.1 → heapyx-0.2.3}/heapy/docs/McIlwainL_coeffs/McIlwainL_Coeffs.npy +0 -0
- {heapyx-0.2.1 → heapyx-0.2.3}/heapy/docs/psf_model/fxt_psf.cod +0 -0
- {heapyx-0.2.1 → heapyx-0.2.3}/heapy/docs/psf_model/fxt_psf.dat +0 -0
- {heapyx-0.2.1 → heapyx-0.2.3}/heapy/docs/psf_model/xrt_psf.cod +0 -0
- {heapyx-0.2.1 → heapyx-0.2.3}/heapy/geos/__init__.py +0 -0
- {heapyx-0.2.1 → heapyx-0.2.3}/heapy/geos/detector.py +0 -0
- {heapyx-0.2.1 → heapyx-0.2.3}/heapy/geos/geometry.py +0 -0
- {heapyx-0.2.1 → heapyx-0.2.3}/heapy/geos/localization.py +0 -0
- {heapyx-0.2.1 → heapyx-0.2.3}/heapy/geos/skymap.py +0 -0
- {heapyx-0.2.1 → heapyx-0.2.3}/heapy/pipe/__init__.py +0 -0
- {heapyx-0.2.1 → heapyx-0.2.3}/heapy/pipe/filter.py +0 -0
- {heapyx-0.2.1 → heapyx-0.2.3}/heapy/temp/__init__.py +0 -0
- {heapyx-0.2.1 → heapyx-0.2.3}/heapy/util/__init__.py +0 -0
- {heapyx-0.2.1 → heapyx-0.2.3}/heapy/util/coord.py +0 -0
- {heapyx-0.2.1 → heapyx-0.2.3}/heapy/util/file.py +0 -0
- {heapyx-0.2.1 → heapyx-0.2.3}/heapy/util/significance.py +0 -0
- {heapyx-0.2.1 → heapyx-0.2.3}/heapy/util/time.py +0 -0
- {heapyx-0.2.1 → heapyx-0.2.3}/heapy/util/tools.py +0 -0
- {heapyx-0.2.1 → heapyx-0.2.3}/heapyx.egg-info/dependency_links.txt +0 -0
- {heapyx-0.2.1 → heapyx-0.2.3}/heapyx.egg-info/top_level.txt +0 -0
- {heapyx-0.2.1 → heapyx-0.2.3}/setup.cfg +0 -0
heapyx-0.2.3/PKG-INFO
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: heapyx
|
|
3
|
+
Version: 0.2.3
|
|
4
|
+
Summary: High-energy (X-ray and gamma-ray) astronomical data analysis tools
|
|
5
|
+
Home-page: https://github.com/jyangch/heapy
|
|
6
|
+
Author: Jun Yang
|
|
7
|
+
Author-email: jyang@smail.nju.edu.cn
|
|
8
|
+
License: GPLv3
|
|
9
|
+
Project-URL: Source Code, https://github.com/jyangch/heapy
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
12
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
13
|
+
Classifier: Operating System :: MacOS
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering :: Astronomy
|
|
15
|
+
Requires-Python: >=3.10
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
License-File: LICENSE
|
|
18
|
+
Requires-Dist: numpy>=1.20.4
|
|
19
|
+
Requires-Dist: pandas>=1.4.2
|
|
20
|
+
Requires-Dist: scipy>=1.8.0
|
|
21
|
+
Requires-Dist: astropy>=5.2.2
|
|
22
|
+
Requires-Dist: matplotlib>=3.2.1
|
|
23
|
+
Requires-Dist: tqdm>=4.64.1
|
|
24
|
+
Requires-Dist: plotly>=5.22.0
|
|
25
|
+
Requires-Dist: kaleido>=0.2.1
|
|
26
|
+
Requires-Dist: pybaselines>=1.1.0
|
|
27
|
+
Requires-Dist: pycwt>=0.3.0a22
|
|
28
|
+
Requires-Dist: scikit-learn>=1.0
|
|
29
|
+
Requires-Dist: healpy>=1.16
|
|
30
|
+
Requires-Dist: cartopy>=0.21
|
|
31
|
+
Dynamic: author
|
|
32
|
+
Dynamic: author-email
|
|
33
|
+
Dynamic: classifier
|
|
34
|
+
Dynamic: description
|
|
35
|
+
Dynamic: description-content-type
|
|
36
|
+
Dynamic: home-page
|
|
37
|
+
Dynamic: license
|
|
38
|
+
Dynamic: license-file
|
|
39
|
+
Dynamic: project-url
|
|
40
|
+
Dynamic: requires-dist
|
|
41
|
+
Dynamic: requires-python
|
|
42
|
+
Dynamic: summary
|
|
43
|
+
|
|
44
|
+
<h1 align="center">HEAPY</h1>
|
|
45
|
+
|
|
46
|
+
<p align="center">
|
|
47
|
+
<strong>A Python toolkit for data reduction, temporal analysis, and spectral extraction of X-ray and gamma-ray transients.</strong>
|
|
48
|
+
</p>
|
|
49
|
+
|
|
50
|
+
<p align="center">
|
|
51
|
+
<a href="https://pypi.org/project/heapyx/"><img alt="PyPI" src="https://img.shields.io/pypi/v/heapyx?color=4F46E5&labelColor=1f2937&logo=pypi&logoColor=white"></a>
|
|
52
|
+
<a href="https://github.com/jyangch/heapy/tree/main/examples"><img alt="Examples" src="https://img.shields.io/badge/docs-examples-06B6D4?labelColor=1f2937"></a>
|
|
53
|
+
<a href="https://www.gnu.org/licenses/gpl-3.0"><img alt="License GPL-3.0" src="https://img.shields.io/badge/license-GPL--3.0-9CA3AF?labelColor=1f2937"></a>
|
|
54
|
+
</p>
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
`Heapy` is a Python toolkit for data reduction, temporal analysis, and
|
|
59
|
+
spectral extraction of X-ray and gamma-ray transients. It pulls event and response data from mission
|
|
60
|
+
archives, reduces time-tagged-event (TTE) and image data into light curves
|
|
61
|
+
and OGIP spectra, separates burst signals from fitted backgrounds, and
|
|
62
|
+
measures durations, spectral lags, and source localizations — across
|
|
63
|
+
[`Fermi`](https://gammaray.nsstc.nasa.gov/gbm/)/GBM, GECAM, GRID,
|
|
64
|
+
[`Einstein Probe`](https://ep.bao.ac.cn/) (WXT/FXT), and
|
|
65
|
+
[`Swift`](https://swift.gsfc.nasa.gov/) (XRT/BAT). It bridges to
|
|
66
|
+
[`HEASoft`](https://heasarc.gsfc.nasa.gov/docs/software/heasoft/) and
|
|
67
|
+
[`gbm_drm_gen`](https://github.com/grburgess/gbm_drm_gen) for mission-specific
|
|
68
|
+
reduction and response generation.
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
## Features
|
|
72
|
+
|
|
73
|
+
- **Data retrieval.** Pull event, position, and response files straight
|
|
74
|
+
from mission archives by burst ID, UTC window, or observation ID
|
|
75
|
+
(`gbmRetrieve`, `gecamRetrieve`, `gridRetrieve`, `epRetrieve`,
|
|
76
|
+
`swiftRetrieve`).
|
|
77
|
+
- **Multi-mission event reduction.** One `Event` interface across
|
|
78
|
+
Fermi/GBM TTE, GECAM, GRID, Einstein Probe (WXT/FXT), and Swift
|
|
79
|
+
(XRT/BAT).
|
|
80
|
+
- **Light curves.** Extract and rebin light curves with automatic
|
|
81
|
+
background fitting.
|
|
82
|
+
- **Signal detection.** Bayesian-block signal/background separation with
|
|
83
|
+
three noise regimes — Poisson + polynomial background (`pgSignal`),
|
|
84
|
+
Poisson + supplied background (`ppSignal`), and Gaussian (`ggSignal`).
|
|
85
|
+
- **OGIP spectra.** Generate source and background `PHA`/`PHA2` spectra,
|
|
86
|
+
and — for Fermi/GBM — response matrices via `gbm_drm_gen`.
|
|
87
|
+
- **Timing analysis.** Duration measurements (`T90`/`Txx`) and
|
|
88
|
+
spectral-lag estimation.
|
|
89
|
+
- **Localization & geometry.** Detector geometry, sky maps, and source
|
|
90
|
+
localization.
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
## Installation
|
|
94
|
+
|
|
95
|
+
`Heapy` requires Python 3.10 or later and is available on PyPI:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
pip install heapyx
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Optional: `HEASoft`
|
|
102
|
+
|
|
103
|
+
For some missions (e.g., `Swift`), `heapy` invokes `HEASoft` tools such as
|
|
104
|
+
`xselect` and `ximage`. Ensure
|
|
105
|
+
[`HEASoft`](https://heasarc.gsfc.nasa.gov/docs/software/heasoft/#install) is
|
|
106
|
+
installed, along with the
|
|
107
|
+
[`Calibration Database`](https://heasarc.gsfc.nasa.gov/docs/heasarc/caldb/install.html)
|
|
108
|
+
(CALDB) for the mission you are processing.
|
|
109
|
+
|
|
110
|
+
### Optional: Fermi GBM response generator
|
|
111
|
+
|
|
112
|
+
To build response matrices for Fermi/GBM, `heapy` calls
|
|
113
|
+
[`gbm_drm_gen`](https://github.com/grburgess/gbm_drm_gen). The forked
|
|
114
|
+
packages below are fine-tuned for newer `numpy`/`astropy` and use TTE
|
|
115
|
+
instead of CSPEC data:
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
git clone https://github.com/jyangch/responsum.git
|
|
119
|
+
pip3 install ./responsum
|
|
120
|
+
|
|
121
|
+
git clone https://github.com/jyangch/gbmgeometry.git
|
|
122
|
+
pip3 install ./gbmgeometry
|
|
123
|
+
|
|
124
|
+
git clone https://github.com/jyangch/gbm_drm_gen.git
|
|
125
|
+
pip3 install ./gbm_drm_gen
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
## Documentation
|
|
130
|
+
|
|
131
|
+
Browse the [examples](https://github.com/jyangch/heapy/tree/main/examples)
|
|
132
|
+
for typical workflows end to end.
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
## Citation
|
|
136
|
+
|
|
137
|
+
If you use `HEAPY` in your research, please include a software citation in
|
|
138
|
+
your reference list and state the version used in your methods section.
|
|
139
|
+
Citation metadata are available in [CITATION.cff](CITATION.cff).
|
|
140
|
+
|
|
141
|
+
Until a DOI-backed release is available, the repository can be cited as:
|
|
142
|
+
|
|
143
|
+
> Yang, J. HEAPY: A Python toolkit for data reduction, temporal analysis, and
|
|
144
|
+
> spectral extraction of X-ray and gamma-ray transients [Computer software].
|
|
145
|
+
> https://github.com/jyangch/heapy
|
|
146
|
+
|
|
147
|
+
```bibtex
|
|
148
|
+
@software{heapy,
|
|
149
|
+
author = {Yang, Jun},
|
|
150
|
+
title = {{HEAPY}: A Python toolkit for data reduction, temporal analysis, and
|
|
151
|
+
spectral extraction of X-ray and gamma-ray transients},
|
|
152
|
+
url = {https://github.com/jyangch/heapy}
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## License
|
|
157
|
+
|
|
158
|
+
`Heapy` is distributed under the
|
|
159
|
+
[GPL-3.0](https://www.gnu.org/licenses/gpl-3.0-standalone.html) license.
|
heapyx-0.2.3/README.md
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
<h1 align="center">HEAPY</h1>
|
|
2
|
+
|
|
3
|
+
<p align="center">
|
|
4
|
+
<strong>A Python toolkit for data reduction, temporal analysis, and spectral extraction of X-ray and gamma-ray transients.</strong>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<a href="https://pypi.org/project/heapyx/"><img alt="PyPI" src="https://img.shields.io/pypi/v/heapyx?color=4F46E5&labelColor=1f2937&logo=pypi&logoColor=white"></a>
|
|
9
|
+
<a href="https://github.com/jyangch/heapy/tree/main/examples"><img alt="Examples" src="https://img.shields.io/badge/docs-examples-06B6D4?labelColor=1f2937"></a>
|
|
10
|
+
<a href="https://www.gnu.org/licenses/gpl-3.0"><img alt="License GPL-3.0" src="https://img.shields.io/badge/license-GPL--3.0-9CA3AF?labelColor=1f2937"></a>
|
|
11
|
+
</p>
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
`Heapy` is a Python toolkit for data reduction, temporal analysis, and
|
|
16
|
+
spectral extraction of X-ray and gamma-ray transients. It pulls event and response data from mission
|
|
17
|
+
archives, reduces time-tagged-event (TTE) and image data into light curves
|
|
18
|
+
and OGIP spectra, separates burst signals from fitted backgrounds, and
|
|
19
|
+
measures durations, spectral lags, and source localizations — across
|
|
20
|
+
[`Fermi`](https://gammaray.nsstc.nasa.gov/gbm/)/GBM, GECAM, GRID,
|
|
21
|
+
[`Einstein Probe`](https://ep.bao.ac.cn/) (WXT/FXT), and
|
|
22
|
+
[`Swift`](https://swift.gsfc.nasa.gov/) (XRT/BAT). It bridges to
|
|
23
|
+
[`HEASoft`](https://heasarc.gsfc.nasa.gov/docs/software/heasoft/) and
|
|
24
|
+
[`gbm_drm_gen`](https://github.com/grburgess/gbm_drm_gen) for mission-specific
|
|
25
|
+
reduction and response generation.
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
## Features
|
|
29
|
+
|
|
30
|
+
- **Data retrieval.** Pull event, position, and response files straight
|
|
31
|
+
from mission archives by burst ID, UTC window, or observation ID
|
|
32
|
+
(`gbmRetrieve`, `gecamRetrieve`, `gridRetrieve`, `epRetrieve`,
|
|
33
|
+
`swiftRetrieve`).
|
|
34
|
+
- **Multi-mission event reduction.** One `Event` interface across
|
|
35
|
+
Fermi/GBM TTE, GECAM, GRID, Einstein Probe (WXT/FXT), and Swift
|
|
36
|
+
(XRT/BAT).
|
|
37
|
+
- **Light curves.** Extract and rebin light curves with automatic
|
|
38
|
+
background fitting.
|
|
39
|
+
- **Signal detection.** Bayesian-block signal/background separation with
|
|
40
|
+
three noise regimes — Poisson + polynomial background (`pgSignal`),
|
|
41
|
+
Poisson + supplied background (`ppSignal`), and Gaussian (`ggSignal`).
|
|
42
|
+
- **OGIP spectra.** Generate source and background `PHA`/`PHA2` spectra,
|
|
43
|
+
and — for Fermi/GBM — response matrices via `gbm_drm_gen`.
|
|
44
|
+
- **Timing analysis.** Duration measurements (`T90`/`Txx`) and
|
|
45
|
+
spectral-lag estimation.
|
|
46
|
+
- **Localization & geometry.** Detector geometry, sky maps, and source
|
|
47
|
+
localization.
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
## Installation
|
|
51
|
+
|
|
52
|
+
`Heapy` requires Python 3.10 or later and is available on PyPI:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pip install heapyx
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Optional: `HEASoft`
|
|
59
|
+
|
|
60
|
+
For some missions (e.g., `Swift`), `heapy` invokes `HEASoft` tools such as
|
|
61
|
+
`xselect` and `ximage`. Ensure
|
|
62
|
+
[`HEASoft`](https://heasarc.gsfc.nasa.gov/docs/software/heasoft/#install) is
|
|
63
|
+
installed, along with the
|
|
64
|
+
[`Calibration Database`](https://heasarc.gsfc.nasa.gov/docs/heasarc/caldb/install.html)
|
|
65
|
+
(CALDB) for the mission you are processing.
|
|
66
|
+
|
|
67
|
+
### Optional: Fermi GBM response generator
|
|
68
|
+
|
|
69
|
+
To build response matrices for Fermi/GBM, `heapy` calls
|
|
70
|
+
[`gbm_drm_gen`](https://github.com/grburgess/gbm_drm_gen). The forked
|
|
71
|
+
packages below are fine-tuned for newer `numpy`/`astropy` and use TTE
|
|
72
|
+
instead of CSPEC data:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
git clone https://github.com/jyangch/responsum.git
|
|
76
|
+
pip3 install ./responsum
|
|
77
|
+
|
|
78
|
+
git clone https://github.com/jyangch/gbmgeometry.git
|
|
79
|
+
pip3 install ./gbmgeometry
|
|
80
|
+
|
|
81
|
+
git clone https://github.com/jyangch/gbm_drm_gen.git
|
|
82
|
+
pip3 install ./gbm_drm_gen
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
## Documentation
|
|
87
|
+
|
|
88
|
+
Browse the [examples](https://github.com/jyangch/heapy/tree/main/examples)
|
|
89
|
+
for typical workflows end to end.
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
## Citation
|
|
93
|
+
|
|
94
|
+
If you use `HEAPY` in your research, please include a software citation in
|
|
95
|
+
your reference list and state the version used in your methods section.
|
|
96
|
+
Citation metadata are available in [CITATION.cff](CITATION.cff).
|
|
97
|
+
|
|
98
|
+
Until a DOI-backed release is available, the repository can be cited as:
|
|
99
|
+
|
|
100
|
+
> Yang, J. HEAPY: A Python toolkit for data reduction, temporal analysis, and
|
|
101
|
+
> spectral extraction of X-ray and gamma-ray transients [Computer software].
|
|
102
|
+
> https://github.com/jyangch/heapy
|
|
103
|
+
|
|
104
|
+
```bibtex
|
|
105
|
+
@software{heapy,
|
|
106
|
+
author = {Yang, Jun},
|
|
107
|
+
title = {{HEAPY}: A Python toolkit for data reduction, temporal analysis, and
|
|
108
|
+
spectral extraction of X-ray and gamma-ray transients},
|
|
109
|
+
url = {https://github.com/jyangch/heapy}
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## License
|
|
114
|
+
|
|
115
|
+
`Heapy` is distributed under the
|
|
116
|
+
[GPL-3.0](https://www.gnu.org/licenses/gpl-3.0-standalone.html) license.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '0.2.3'
|
|
@@ -6,8 +6,6 @@ The fitted baseline is stored on the instance and can be evaluated at
|
|
|
6
6
|
arbitrary abscissae via cubic spline interpolation.
|
|
7
7
|
"""
|
|
8
8
|
|
|
9
|
-
import warnings
|
|
10
|
-
|
|
11
9
|
from astropy.stats import mad_std, sigma_clip
|
|
12
10
|
import numpy as np
|
|
13
11
|
import pybaselines
|
|
@@ -134,8 +132,9 @@ class Baseline:
|
|
|
134
132
|
"""Evaluate the fitted baseline at ``x`` via cubic spline interpolation.
|
|
135
133
|
|
|
136
134
|
Args:
|
|
137
|
-
x: Query abscissae; values
|
|
138
|
-
extrapolated and trigger a
|
|
135
|
+
x: Query abscissae; values more than one fitted-bin spacing
|
|
136
|
+
outside the fitting range are extrapolated and trigger a
|
|
137
|
+
``UserWarning``.
|
|
139
138
|
|
|
140
139
|
Returns:
|
|
141
140
|
Interpolated baseline values at ``x``.
|
|
@@ -143,14 +142,6 @@ class Baseline:
|
|
|
143
142
|
|
|
144
143
|
x = np.asarray(x)
|
|
145
144
|
|
|
146
|
-
if min(x) < min(self.x - self.dx / 1.8):
|
|
147
|
-
msg = f'Extrapolation may be imprecise: {min(x):f} < {min(self.x - self.dx / 1.8):f}'
|
|
148
|
-
warnings.warn(msg, UserWarning, stacklevel=2)
|
|
149
|
-
|
|
150
|
-
if max(x) > max(self.x + self.dx / 1.8):
|
|
151
|
-
msg = f'Extrapolation may be imprecise: {max(x):f} > {max(self.x + self.dx / 1.8):f}'
|
|
152
|
-
warnings.warn(msg, UserWarning, stacklevel=2)
|
|
153
|
-
|
|
154
145
|
interp = CubicSpline(self.x, self.mo, extrapolate=True)
|
|
155
146
|
|
|
156
147
|
return interp(x)
|
|
@@ -166,8 +157,9 @@ class Baseline:
|
|
|
166
157
|
point is irrelevant.
|
|
167
158
|
|
|
168
159
|
Args:
|
|
169
|
-
x: Query abscissae; values
|
|
170
|
-
extrapolated and trigger a
|
|
160
|
+
x: Query abscissae; values more than one fitted-bin spacing
|
|
161
|
+
outside the fitting range are extrapolated and trigger a
|
|
162
|
+
``UserWarning``.
|
|
171
163
|
|
|
172
164
|
Returns:
|
|
173
165
|
Antiderivative values at ``x``.
|
|
@@ -175,14 +167,6 @@ class Baseline:
|
|
|
175
167
|
|
|
176
168
|
x = np.asarray(x)
|
|
177
169
|
|
|
178
|
-
if min(x) < min(self.x - self.dx / 1.8):
|
|
179
|
-
msg = f'Extrapolation may be imprecise: {min(x):f} < {min(self.x - self.dx / 1.8):f}'
|
|
180
|
-
warnings.warn(msg, UserWarning, stacklevel=2)
|
|
181
|
-
|
|
182
|
-
if max(x) > max(self.x + self.dx / 1.8):
|
|
183
|
-
msg = f'Extrapolation may be imprecise: {max(x):f} > {max(self.x + self.dx / 1.8):f}'
|
|
184
|
-
warnings.warn(msg, UserWarning, stacklevel=2)
|
|
185
|
-
|
|
186
170
|
antider = CubicSpline(self.x, self.mo, extrapolate=True).antiderivative()
|
|
187
171
|
|
|
188
172
|
return antider(x)
|
|
@@ -101,8 +101,9 @@ class Polynomial:
|
|
|
101
101
|
def val(self, x):
|
|
102
102
|
"""Evaluate the fitted polynomial and its 1-sigma uncertainty at ``x``.
|
|
103
103
|
|
|
104
|
-
Emits a ``UserWarning`` when ``x`` falls
|
|
105
|
-
range. Requires a prior
|
|
104
|
+
Emits a ``UserWarning`` when ``x`` falls more than one
|
|
105
|
+
fitted-bin spacing outside the fitting range. Requires a prior
|
|
106
|
+
:meth:`fit` call.
|
|
106
107
|
|
|
107
108
|
Args:
|
|
108
109
|
x: Query abscissae.
|
|
@@ -117,14 +118,6 @@ class Polynomial:
|
|
|
117
118
|
|
|
118
119
|
x = np.array(x)
|
|
119
120
|
|
|
120
|
-
if min(x) < min(self.x - self.dx / 1.8):
|
|
121
|
-
msg = f'Extrapolation may be imprecise: {min(x):f} < {min(self.x - self.dx / 1.8):f}'
|
|
122
|
-
warnings.warn(msg, UserWarning, stacklevel=2)
|
|
123
|
-
|
|
124
|
-
if max(x) > max(self.x + self.dx / 1.8):
|
|
125
|
-
msg = f'Extrapolation may be imprecise: {max(x):f} > {max(self.x + self.dx / 1.8):f}'
|
|
126
|
-
warnings.warn(msg, UserWarning, stacklevel=2)
|
|
127
|
-
|
|
128
121
|
assert self.ls_res is not None, 'you should first perform fitting'
|
|
129
122
|
|
|
130
123
|
mo, err = self.ls_polyval(x, coeff=self.ls_res['coeff'], covar=self.ls_res['covar'])
|
|
@@ -138,7 +131,9 @@ class Polynomial:
|
|
|
138
131
|
via the linear map ``c_int[k] = c[k] / (deg + 1 - k)``. Intended
|
|
139
132
|
as a ``bkg_integral`` callable for time-rescaling Bayesian blocks
|
|
140
133
|
where only differences ``F(t1) - F(t0)`` enter, so the choice
|
|
141
|
-
of integration constant is irrelevant.
|
|
134
|
+
of integration constant is irrelevant. Emits a ``UserWarning``
|
|
135
|
+
when ``x`` falls more than one fitted-bin spacing outside the
|
|
136
|
+
fitting range.
|
|
142
137
|
|
|
143
138
|
Args:
|
|
144
139
|
x: Query abscissae.
|
|
@@ -152,14 +147,6 @@ class Polynomial:
|
|
|
152
147
|
|
|
153
148
|
x = np.array(x)
|
|
154
149
|
|
|
155
|
-
if min(x) < min(self.x - self.dx / 1.8):
|
|
156
|
-
msg = f'Extrapolation may be imprecise: {min(x):f} < {min(self.x - self.dx / 1.8):f}'
|
|
157
|
-
warnings.warn(msg, UserWarning, stacklevel=2)
|
|
158
|
-
|
|
159
|
-
if max(x) > max(self.x + self.dx / 1.8):
|
|
160
|
-
msg = f'Extrapolation may be imprecise: {max(x):f} > {max(self.x + self.dx / 1.8):f}'
|
|
161
|
-
warnings.warn(msg, UserWarning, stacklevel=2)
|
|
162
|
-
|
|
163
150
|
assert self.ls_res is not None, 'you should first perform fitting'
|
|
164
151
|
|
|
165
152
|
coeff = self.ls_res['coeff']
|
|
@@ -306,7 +293,8 @@ class Polynomial:
|
|
|
306
293
|
lhs = np.vander(x, order)
|
|
307
294
|
|
|
308
295
|
# evaluate the model values at given x
|
|
309
|
-
mo = coeff @ lhs.T
|
|
296
|
+
# mo = coeff @ lhs.T
|
|
297
|
+
mo = np.polyval(coeff, x)
|
|
310
298
|
# or
|
|
311
299
|
# mo = np.zeros_like(x)
|
|
312
300
|
# for ci in coeff:
|