Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for GP Modeling code #1

Merged
merged 104 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
a6ab26d
Update tstart and tseg when truncating the lc
matteobachetti Sep 1, 2023
7f9ac55
Add changelog
matteobachetti Sep 1, 2023
c3790bc
Setup tests to verify correct update of meancounts and many other att…
matteobachetti Sep 6, 2023
5b338dc
Merge pull request #753 from StingraySoftware/fix_truncate
mgullik Sep 6, 2023
6e5bcd6
Reduced memory usage of EventList.from_lc()
pupperemeritus Sep 18, 2023
a656604
added changelog
pupperemeritus Sep 18, 2023
c6e71d5
Merge pull request #756 from pupperemeritus/EventListMemoryOptimization
matteobachetti Sep 18, 2023
965eedd
Speedup event creation a lot in from_lc
matteobachetti Sep 20, 2023
f17f59e
Add changelog
matteobachetti Sep 20, 2023
2286103
Fix non-integer counts
matteobachetti Sep 20, 2023
b0c30f5
Suppress warning about figurecanvasagg
matteobachetti Sep 16, 2023
c89490b
Merge pull request #757 from StingraySoftware/speedup_to_lc_further
mgullik Sep 20, 2023
f8a4160
Eliminate the legacy option from crossspectrum, and the tests
matteobachetti Sep 15, 2023
6d2d88b
Eliminate the legacy option from powerspectrum, and the tests
matteobachetti Sep 15, 2023
0274dc2
Eliminate large memory stuff
matteobachetti Sep 15, 2023
025c6c1
Add changelog
matteobachetti Sep 15, 2023
dd18aa0
Cleanup
matteobachetti Sep 15, 2023
33105d4
Save sub CS in fourier.py
matteobachetti Sep 15, 2023
aae9e99
Allow to save all sub spectra
matteobachetti Sep 15, 2023
16c2920
Allow the save_all option
matteobachetti Sep 15, 2023
723554b
Fix docstrings [docs only]
matteobachetti Sep 15, 2023
ca7d7db
Uniform names for output
matteobachetti Sep 15, 2023
2ede742
Allow the save_all option
matteobachetti Sep 15, 2023
7309b90
Suppress this specific test until better test in notebook
matteobachetti Sep 15, 2023
5f876b3
All no-good data options were already accounted for
matteobachetti Sep 15, 2023
9b87bca
Reinstate the different statistics test in crossspectrum
matteobachetti Sep 21, 2023
813e957
Fix behavior when only one input data set is empty
matteobachetti Sep 21, 2023
ba235bf
Test on Py3.11 as well
matteobachetti Sep 22, 2023
524d846
Mark change as breaking
matteobachetti Sep 22, 2023
2355c56
Update notebooks [docs only]
matteobachetti Sep 22, 2023
e3acafe
Merge pull request #755 from StingraySoftware/eliminate_legacy_interface
matteobachetti Sep 22, 2023
28fa666
Fix repo reference [docs only]
matteobachetti Sep 22, 2023
4e3bb28
Only run slow and fast tests in different batches
matteobachetti Sep 22, 2023
c6f9233
Mark slow tests
matteobachetti Sep 22, 2023
db8921e
Add changelog [docs only]
matteobachetti Sep 22, 2023
f2de188
Mark CCF test as xfailing
matteobachetti Sep 22, 2023
df03308
Fix bad option in pyproject
matteobachetti Sep 22, 2023
67087e3
Add slow tests with basic dependencies only
matteobachetti Sep 22, 2023
5fac201
Merge pull request #758 from matteobachetti/slow_tests
matteobachetti Sep 25, 2023
e6066c5
LSCross,Power Spectrum Classes implemented
pupperemeritus Jun 7, 2023
bf459e7
moved lsft funcs to fourier, added lombscargle to __init__.py
pupperemeritus Jun 7, 2023
1354896
Input of lsft_slow,fast changed to be non stingray specific, added c…
pupperemeritus Jun 10, 2023
7a71393
Removed LC and eventlist imports in fourier.py
pupperemeritus Jun 10, 2023
315a116
Typos and added fast version of lsft to fourier.py
pupperemeritus Jun 21, 2023
012c2e2
Integrating fast method into the cross,power spectrum classes
pupperemeritus Jun 21, 2023
ed68d75
Fixed the fast LSFT implementation and refactoring variable names
pupperemeritus Jun 28, 2023
f225487
Added basic tests, corrected algorithms wrt papers, typos in docstrings
pupperemeritus Jul 29, 2023
0b91e8b
Documentation, Algorithm Fixes, API Change
pupperemeritus Aug 20, 2023
a3bd5d2
Edited docs(core.rst,lscs,lsps), modified function, docstrings, forma…
pupperemeritus Aug 23, 2023
4eb2be5
Fixed Tests
pupperemeritus Aug 23, 2023
e1e6bc5
Improved Coverage
pupperemeritus Aug 31, 2023
9efe009
Comment code
matteobachetti Sep 5, 2023
fd91bc4
Test time lag
matteobachetti Sep 5, 2023
bc6541a
Phase lag fixes, code cleanup and optimization
pupperemeritus Sep 6, 2023
ed96e46
Test Coverage Improvement
pupperemeritus Sep 7, 2023
f5d47b1
Updated docs and rewrote the classes to use modern interface from Ave…
pupperemeritus Sep 17, 2023
0c37abc
Example eventlist test
pupperemeritus Sep 18, 2023
68fcf81
Code Cleanup, Tests and lc warning changes
pupperemeritus Sep 20, 2023
d89f0f5
method test fix
pupperemeritus Sep 21, 2023
ccf0af0
Reintroduced ls notebooks
pupperemeritus Sep 22, 2023
53521ff
Removed largememory
pupperemeritus Sep 22, 2023
c55c0d6
fix for python 3.11 tests
pupperemeritus Sep 22, 2023
8d23144
Fix the nphots parameter
matteobachetti Sep 26, 2023
1957239
Import all from lombscargle
matteobachetti Sep 26, 2023
da9e4b6
Make the autofrequency calculation more consistent and controllable
matteobachetti Sep 27, 2023
436db70
Test maxfreq <0
matteobachetti Sep 27, 2023
f9afbee
Allow for complex values in flux iterables
matteobachetti Sep 25, 2023
195dad7
Don't change dt if it's already binned
matteobachetti Sep 25, 2023
9267e68
Test
matteobachetti Sep 27, 2023
962543a
Add changelog [docs only]
matteobachetti Sep 27, 2023
03606c8
Update notebooks
matteobachetti Sep 28, 2023
42087dd
Add reference to Lomb-Scargle tutorial
matteobachetti Sep 28, 2023
609482b
Merge pull request #760 from StingraySoftware/fix_powerspectrum_from_…
mgullik Sep 28, 2023
8a162a5
Fix missing whitespace [docs only]
matteobachetti Sep 28, 2023
01a1533
Refresh front page [docs only]
matteobachetti Sep 28, 2023
be88264
Merge pull request #737 from pupperemeritus/LombScargle
matteobachetti Sep 28, 2023
fa329cb
Adding_gp_feature
Gaurav17Joshi Jun 12, 2023
647c72e
Added skew means
Gaurav17Joshi Jun 14, 2023
0e091ae
Added fred model
Gaurav17Joshi Jun 19, 2023
dbaee73
Combined GP, GPR class
Gaurav17Joshi Jun 27, 2023
ada63a0
Added kernel, mean tests
Gaurav17Joshi Jun 27, 2023
c1a08a3
Added Multimean and tests
Gaurav17Joshi Jun 27, 2023
827cdf7
Testing for get_pior_params
Gaurav17Joshi Jun 29, 2023
8fa0059
Changed the GP class
Gaurav17Joshi Jul 11, 2023
e00d438
Improved library imports
Gaurav17Joshi Jul 18, 2023
b031ed1
Primary tests for GPresult class
Gaurav17Joshi Jul 18, 2023
5d95841
Added docstrings
Gaurav17Joshi Jul 19, 2023
c013d4a
Plot function changed, tests added
Gaurav17Joshi Jul 19, 2023
3bf2079
Added testing skips
Gaurav17Joshi Jul 26, 2023
a14ca4a
Jax import changed
Gaurav17Joshi Aug 14, 2023
f3bef3f
added kernel and warnings
Gaurav17Joshi Aug 17, 2023
181e90a
Adding max samples option
Gaurav17Joshi Aug 20, 2023
b374d6b
Added log parameters
Gaurav17Joshi Aug 20, 2023
cb0a0f5
Changed Function Names
Gaurav17Joshi Aug 25, 2023
a2c03c0
Docstring changes
Gaurav17Joshi Aug 25, 2023
eeb241a
Changelog Changed
Gaurav17Joshi Aug 28, 2023
c73620b
Improved get_mean docs
Gaurav17Joshi Aug 28, 2023
2d0ba46
Docstrings Updated
Gaurav17Joshi Aug 30, 2023
c3778a3
Small doc change
Gaurav17Joshi Sep 5, 2023
d3447f4
Fixed usage of dict, added functions to __all__
dhuppenkothen Sep 29, 2023
1fc9f84
Added num_live_points as parameter
dhuppenkothen Sep 29, 2023
78e13f4
Fixed typo in changelog
dhuppenkothen Sep 29, 2023
f56c276
Added installation instructions for GP Modeling
dhuppenkothen Sep 29, 2023
bd2fd59
Merge branch 'features/GPtool' into GPTool_fixes
dhuppenkothen Sep 29, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 65 additions & 30 deletions .github/workflows/ci_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{github.event.pull_request.head.repo.full_name}}

# Found this solution at
# https://monadical.com/posts/filters-github-actions.html#Case-2-Pull-request
Expand All @@ -45,8 +48,9 @@ jobs:
ci-tests:
needs: check_commit
if: ${{ needs.check_commit.outputs.match != 'true' }}
name: ${{ matrix.os }}, ${{ matrix.tox_env }}
# name: ${{ matrix.os }}, ${{ matrix.tox_env }}
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
Expand All @@ -55,45 +59,71 @@ jobs:
# we select only a few, in order to conserve resources. If you add
# an additional environment, please include a comment to indicate
# why it is useful.
- os: ubuntu-latest
- name: Black test
os: ubuntu-latest
python: '3.10'
tox_env: 'black'
experimental: false

# Basic tests on the oldest & newest supported versions of Python,
# recording coverage data for the latter.
- os: ubuntu-latest
- name: Py3.8 with old Astropy version
os: ubuntu-latest
python: '3.8'
tox_env: 'py38-test'
- os: ubuntu-latest
tox_env: 'py38-test-astropy4-cov'
experimental: false

- name: Linux, Py3.10 with coverage
os: ubuntu-latest
python: '3.10'
tox_env: 'py310-test-cov'
experimental: false

# Basic tests on alternative operating systems.
- os: windows-latest
python: '3.10'
tox_env: 'py310-test'
- os: macos-latest
python: '3.10'
tox_env: 'py310-test'
- name: Windows, Py3.11 with coverage
os: windows-latest
python: '3.11'
tox_env: 'py311-test-cov'
experimental: false

- name: Mac OS, Py3.11
os: macos-latest
python: '3.11'
tox_env: 'py311-test'
experimental: false

# Test with all optional dependencies installed.
- os: ubuntu-latest
python: '3.10'
tox_env: 'py310-test-alldeps-cov'
- name: Linux, Py3.11 all dependencies and coverage
os: ubuntu-latest
python: '3.11'
tox_env: 'py311-test-alldeps-cov'
use_remote_data: true
experimental: false

# Test with the various supported releases of Astropy.
- os: ubuntu-latest
python: '3.8'
tox_env: 'py38-test-astropy4-cov'
# Development version of dependencies
- name: Linux, Py3.11 with dev versions of dependencies
os: ubuntu-latest
python: '3.11'
tox_env: 'py311-test-devdeps'
experimental: false

- os: ubuntu-latest
python: '3.10'
tox_env: 'py310-test-astropy5'
# Test with all optional dependencies installed.
- name: Slow tests on Linux, Py3.11, all deps and coverage
os: ubuntu-latest
python: '3.11'
tox_env: 'py311-test-alldeps-cov'
use_remote_data: true
experimental: false
slow: true

# Development version of dependencies
- os: ubuntu-latest
python: '3.10'
tox_env: 'py310-test-devdeps'
# Test with all optional dependencies installed.
- name: Slow tests on Linux, Py3.11, basic deps and coverage
os: ubuntu-latest
python: '3.11'
tox_env: 'py311-test-cov'
use_remote_data: true
experimental: false
slow: true

steps:
- name: Check out repository
Expand All @@ -119,14 +149,19 @@ jobs:
python -c "import pip; print(f'pip {pip.__version__}')"
python -c "import setuptools; print(f'setuptools {setuptools.__version__}')"
python -c "import tox; print(f'tox {tox.__version__}')"
- name: Run tests
if: "! matrix.use_remote_data"
run: tox -e ${{ matrix.tox_env }}
- name: Run tests with remote data
if: "matrix.use_remote_data"
- name: Run quick tests
if: "(! matrix.use_remote_data) && (! matrix.slow)"
run: tox -e ${{ matrix.tox_env }} --
- name: Run quick tests with remote data
if: "matrix.use_remote_data && (! matrix.slow)"
run: |
pip install pytest-remotedata
tox -e ${{ matrix.tox_env }} -- --remote-data=any
- name: Run slow tests with remote data
if: "matrix.use_remote_data && matrix.slow"
run: |
pip install pytest-remotedata
tox -e ${{ matrix.tox_env }} -- --remote-data=any -m slow --run-slow
- name: Upload coverage to codecov
if: "endsWith(matrix.tox_env, '-cov')"
uses: codecov/codecov-action@v3
Expand Down
2 changes: 2 additions & 0 deletions docs/changes/737.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Implemented the Lomb Scargle Fourier Transform (fast and slow versions)
- Using which wrote the corresponding :class:`LombScargleCrossspectrum` and :class:`LombScarglePowerspectrum`
2 changes: 1 addition & 1 deletion docs/changes/739.feature.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ This is a JAX implementation of the GP tool by `Hubener et al <https://arxiv.org
for QPO detection and parameter analysis.

This feature makes use of tinygp library for Gaussian Processes implementation, and jaxns for nested sampling,
and is kept in the stingray.modeling.gpmodelling module.
and is kept in the stingray.modeling.gpmodeling module.

Main features of the module are:

Expand Down
1 change: 1 addition & 0 deletions docs/changes/753.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update tstart and tseg when using Lightcurve.truncate()
1 change: 1 addition & 0 deletions docs/changes/755.breaking.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove legacy interface and obsolete large data machinery.
1 change: 1 addition & 0 deletions docs/changes/756.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Changed list comprehension to generator expression to reduce memory usage.
1 change: 1 addition & 0 deletions docs/changes/757.trivial.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Speedup creation of events in ``EventList.from_lc``
Empty file added docs/changes/758.trivial.rst
Empty file.
2 changes: 2 additions & 0 deletions docs/changes/760.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
+ Fix a bug with segment sizes not exact multiples of dt when dealing with light curves
+ Fix a bug when light curve segments contain complex values
23 changes: 20 additions & 3 deletions docs/core.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Core Stingray Functionality
***************************

Here we show how many of the core Stingray classes and methods
work in practice. We start with basic data constructs for
event data and light curve data, and then show how to produce
Here we show how many of the core Stingray classes and methods
work in practice. We start with basic data constructs for
event data and light curve data, and then show how to produce
various Fourier products from these data sets.

Working with Event Data
Expand Down Expand Up @@ -85,3 +85,20 @@ Multi-taper Periodogram
:maxdepth: 2

notebooks/Multitaper/multitaper_example.ipynb


Lomb Scargle Crossspectrum
--------------------------
.. toctree::
:maxdepth: 2

notebooks/LombScargle/LombScargleCrossspectrum_tutorial.ipynb


Lomb Scargle Powerspectrum
--------------------------

.. toctree::
:maxdepth: 2

notebooks/LombScargle/LombScarglePowerspectrum_tutorial.ipynb
12 changes: 12 additions & 0 deletions docs/dataexplo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,15 @@ black hole binary using NICER data.
:maxdepth: 2

notebooks/Spectral Timing/Spectral Timing Exploration.ipynb


Studying very slow variability with the Lomb-Scargle periodogram
================================================================

In this Tutorial, we will show an example of how to use the Lomb-Scargle
periodogram and cross spectrum to study very slow variability in a light curve.

.. toctree::
:maxdepth: 2

notebooks/LombScargle/Very slow variability with Lomb-Scargle methods.ipynb
41 changes: 32 additions & 9 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,35 @@ Features
Current Capabilities
--------------------

Currently implemented functionality in this library comprises:
1. Data handling and simulation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

* loading event lists from fits files of a few missions (RXTE/PCA, NuSTAR/FPM, XMM-Newton/EPIC, NICER/XTI)
* constructing light curves from event data, various operations on light curves (e.g. addition, subtraction, joining, and truncation)
* simulating a light curve with a given power spectrum
* simulating a light curve from another light curve and a 1-d (time) or 2-d (time-energy) impulse response
* simulating an event list from a given light curve _and_ with a given energy spectrum
* Good Time Interval operations
* power spectra in Leahy, rms normalization, absolute rms and no normalization
* averaged power spectra
* dynamical power spectra

2. Fourier methods
~~~~~~~~~~~~~~~~~~
* power spectra and cross spectra in Leahy, rms normalization, absolute rms and no normalization
* averaged power spectra and cross spectra
* dynamical power spectra and cross spectra
* maximum likelihood fitting of periodograms/parametric models
* (averaged) cross spectra
* coherence, time lags
* cross correlation functions
* RMS spectra and lags (time vs energy, time vs frequency); *needs testing*
* Variability-Energy spectra, like covariance spectra and lags *needs testing*
* covariance spectra; *needs testing*
* bispectra; *needs testing*
* (Bayesian) quasi-periodic oscillation searches
* simulating a light curve with a given power spectrum
* simulating a light curve from another light curve and a 1-d (time) or 2-d (time-energy) impulse response
* simulating an event list from a given light curve _and_ with a given energy spectrum
* Lomb-Scargle periodograms and cross spectra

3. Other time series methods
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* pulsar searches with Epoch Folding, :math:`Z^2_n` test
* Gaussian Processes for QPO studies
* cross correlation functions

Future Plans
------------
Expand Down Expand Up @@ -104,6 +113,20 @@ To install all required and recommended dependencies in a recent installation, y

$ pip install astropy scipy matplotlib numpy h5py tqdm numba pint-pulsar emcee corner statsmodels pyfftw tbb

For the Gaussian Process modeling in `stingray.modeling.gpmodeling`, you'll need the following extra packages

+ jax
+ jaxns
+ tensorflow
+ tensorflow-probability
+ tinygp
+ etils
+ typing_extensions

Most of these are installed via ``pip``, but if you have an Nvidia GPU available, you'll want to take special care
following the installation instructions for jax and tensorflow(-probability) in order to enable GPU support and
take advantage of those speed-ups.

For development work, you will need the following extra libraries:

+ pytest
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ all =
pyfftw
h5py
pint-pulsar
zarr
numcodecs
pyyaml
xarray
Expand Down Expand Up @@ -107,6 +106,7 @@ filterwarnings =
ignore:Large Datasets may not be processed efficiently:UserWarning
ignore:.*is a deprecated alias for:DeprecationWarning
ignore:.*HIERARCH card will be created.*:
ignore:.*FigureCanvasAgg is non-interactive.*:UserWarning

;addopts = --disable-warnings

Expand Down
3 changes: 2 additions & 1 deletion stingray/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from stingray.events import *
from stingray.lightcurve import *
from stingray.utils import *
from stingray.lombscargle import *
from stingray.powerspectrum import *
from stingray.crossspectrum import *
from stingray.multitaper import *
Expand All @@ -22,4 +23,4 @@
from stingray.stats import *
from stingray.bispectrum import *
from stingray.varenergyspectrum import *
from stingray.largememory import *
from stingray.lombscargle import *
Loading