Skip to content

Commit

Permalink
add tests for bayesian blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
juanep97 committed Dec 13, 2023
1 parent c049e11 commit da2dd2e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mutis/flares/bayblocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def get_flare_list(self):
np.where((np.abs(np.diff(np.asarray(self.inflare, dtype=int))) == 1))[0]+1)

# (groups contains the groups of indices of self.inflare/self.values
# that corresond to flares or no flares)
# that correspond to flares or no flares)

#print(self.inflare)
#print([list(grp) for grp in groups])
Expand Down
16 changes: 16 additions & 0 deletions mutis/tests/test_bayblocks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import unittest
import numpy as np
from mutis.flares.bayblocks import BayesianBlocks
from mutis import Signal

def test_bayblocks():
# test the bayblock algorithm with a signal that corresponds to 3 gaussian pulses in a row
t = np.linspace(0, 6, 50)
y = np.exp(-(t-1)**2/0.1) + np.exp(-(t-3)**2/0.1) + np.exp(-(t-5)**2/0.1)
dy = 0.1 * np.abs(y)
signal = Signal(t, y, dy)
bayblocks = BayesianBlocks(signal, p=1e-1)
bayblocks.get_flares()
bayblocks.signal.plot()
bayblocks.plot()
assert len(bayblocks.get_flare_list()) == 3

0 comments on commit da2dd2e

Please sign in to comment.