Skip to content

Commit

Permalink
Merge pull request #1 from dhuppenkothen/GPTool_fixes
Browse files Browse the repository at this point in the history
Fixes for GP Modeling code
  • Loading branch information
Gaurav17Joshi authored Sep 29, 2023
2 parents d86b274 + bd2fd59 commit e9ef4df
Show file tree
Hide file tree
Showing 46 changed files with 1,920 additions and 2,773 deletions.
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

0 comments on commit e9ef4df

Please sign in to comment.