Skip to content
Open
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
bff247e
Started adding loggers
alexlyttle Jan 14, 2021
e27bee5
Added module-level log messages
alexlyttle Jan 14, 2021
cd9eda2
Removed new line
alexlyttle Jan 14, 2021
cf38574
Added stream handler to package logger
alexlyttle Jan 14, 2021
544c68a
Added default stream handler and logger level for pbjam
alexlyttle Jan 15, 2021
a8c3225
Added log wrapper and file_handler class
alexlyttle Jan 15, 2021
31fcd26
Imported new modules for logging
alexlyttle Jan 15, 2021
9960c3c
Added logging and file_hander
alexlyttle Jan 15, 2021
9307332
Renamed _logger to logger and implemented file_logger
alexlyttle Jan 15, 2021
e6bfd92
Moved handlers to config.py
alexlyttle Jan 16, 2021
d1d7a9b
Changed to file_logging
alexlyttle Jan 16, 2021
44b36be
Simplified base logger stream handlers to one console handler
alexlyttle Jan 16, 2021
f4d0c88
Removed config module
alexlyttle Jan 17, 2021
5a4c652
Renamed and simplified handlers and context manager
alexlyttle Jan 17, 2021
40930f7
Added open and close methods to file_logging
alexlyttle Jan 17, 2021
9aef7f3
Added more log decorators
alexlyttle Jan 17, 2021
f923aa1
Added jam for recording to log file
alexlyttle Jan 18, 2021
ce4df7d
Improved logging format
alexlyttle Jan 18, 2021
8755fd4
Fixed tests cleanup
alexlyttle Jan 18, 2021
a991bef
Added tests
alexlyttle Jan 18, 2021
597a223
Merge branch 'master' into issue175
alexlyttle Jan 19, 2021
102669f
Added function_logger class
alexlyttle Jan 20, 2021
24f99ef
Fixed bug in test
alexlyttle Jan 20, 2021
3a3c6c0
Removed loging from prior and likelihood
alexlyttle Jan 20, 2021
c855933
Added logs to many functions and tested session
alexlyttle Jan 21, 2021
6afb3e0
Added pretty printer
alexlyttle Jan 24, 2021
f1f071e
Fixed bug - changed from nested to cpnest
alexlyttle Jan 24, 2021
c0628f3
Bug fix - replaced depricated pm.stats with arviz
alexlyttle Jan 24, 2021
d56d895
Moved arviz funcs to be in pm_model context
alexlyttle Jan 24, 2021
d0d1af7
Added mason and moved pretty_printer
alexlyttle Jan 24, 2021
95dc4ae
Moved comment
alexlyttle Jan 24, 2021
24cb48d
Accounted for pymc3 future warning
alexlyttle Jan 24, 2021
72caaaa
Revert logger.warning to warning.warn to pass test
alexlyttle Jan 24, 2021
b625e60
Updated Python version
alexlyttle Jan 25, 2021
51ba926
Simplified file_logger class
alexlyttle Jan 25, 2021
bf7d060
Updated test
alexlyttle Jan 25, 2021
651af4a
Added session identifier attribute
alexlyttle Jan 25, 2021
4d0502c
Updated test
alexlyttle Jan 25, 2021
dec294f
Renamed to printer
alexlyttle Jan 25, 2021
aad9e8e
Privatised and tidied up
alexlyttle Jan 25, 2021
8b25522
Subclassed with file_logger
alexlyttle Jan 25, 2021
90dc373
Updated repr
alexlyttle Jan 25, 2021
30249b8
Tidied up and replaced print statements
alexlyttle Jan 25, 2021
47f4a0c
Reverted python version change in .travis.yml
alexlyttle Jan 25, 2021
822f10e
Removed comment
alexlyttle Feb 2, 2021
a0e22a9
Renamed log decorator to debug
alexlyttle Feb 2, 2021
6a09cf9
Set debugger equal to debug(logger)
alexlyttle Feb 3, 2021
8fb7774
Removed test for warning
alexlyttle Feb 3, 2021
96637bf
Changed varname from level to logging_level
alexlyttle Feb 3, 2021
865b0d2
Added debugger decorators everywhere!
alexlyttle Feb 3, 2021
659b3af
Changed warnings to logger warning
alexlyttle Feb 3, 2021
e0493d8
Added TODO messages
alexlyttle Feb 3, 2021
703d132
Tidy docs
alexlyttle Feb 4, 2021
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
17 changes: 16 additions & 1 deletion pbjam/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,27 @@
import os
PACKAGEDIR = os.path.abspath(os.path.dirname(__file__))

# Setup global pbjam logger
import logging
logger = logging.getLogger(__name__)
logger.setLevel('DEBUG') # <--- minimum level for global pbjam package logger

# Setup console handler
from .jar import _stream_handler
console_handler = _stream_handler(level='INFO')
logger.addHandler(console_handler)
logger.debug(f'Initializing {__name__}')

from .version import __version__
logger.debug(f'version == {__version__}')

from .priors import kde
from .session import session
from .asy_peakbag import asymp_spec_model, asymptotic_fit
from .peakbag import peakbag
from .ellone import ellone
from .star import star
from .mcmc import mcmc
from .mcmc import nested
from .mcmc import nested

logger.debug(f'Initialized {__name__}')
21 changes: 14 additions & 7 deletions pbjam/asy_peakbag.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@
import pandas as pd
import scipy.stats as scist
from .plotting import plotting
from .jar import normal
from .jar import normal, debug
from collections import OrderedDict
import warnings
import warnings, logging

logger = logging.getLogger(__name__)
debugger = debug(logger)


class asymp_spec_model():
"""Class for spectrum model using asymptotic relation.
Expand All @@ -35,7 +39,7 @@ class asymp_spec_model():
Number of radial order to fit.

"""

# @debugger
def __init__(self, f, norders):
self.f = np.array([f]).flatten()
self.norders = int(norders)
Expand Down Expand Up @@ -326,7 +330,7 @@ class asymptotic_fit(plotting, asymp_spec_model):
science results!

"""

# @debugger
def __init__(self, st, norders=None):

self.pg = st.pg
Expand Down Expand Up @@ -354,7 +358,11 @@ def __init__(self, st, norders=None):
self.path = st.path

st.asy_fit = self


def __repr__(self):
return f'<pbjam.asymptotic_fit norders={self.norders}>'

@debugger
def __call__(self, method, developer_mode):
""" Setup, run and parse the asymptotic relation fit.

Expand Down Expand Up @@ -400,7 +408,6 @@ def __call__(self, method, developer_mode):

return {'modeID': self.modeID, 'summary': self.summary}


def prior(self, p):
""" Calculates the log prior

Expand Down Expand Up @@ -514,7 +521,7 @@ def _get_summary_stats(self, fit):

return summary


@debugger
def get_modeIDs(self, fit, norders):
""" Set mode ID in a dataframe

Expand Down
2 changes: 1 addition & 1 deletion pbjam/data/pbjam_references.bib
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

@article{nested,
@article{cpnest,
title={johnveitch/cpnest: Minor optimisation},
DOI={10.5281/zenodo.835874},
publisher={Zenodo},
Expand Down
22 changes: 15 additions & 7 deletions pbjam/ellone.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,15 @@
from sklearn.preprocessing import MinMaxScaler
from sklearn.utils import shuffle as skshuffle
import hdbscan as Hdbscan
import warnings
import warnings, logging
from .plotting import plotting
import astropy.units as units
import lightkurve as lk
from .jar import debug

logger = logging.getLogger(__name__)
debugger = debug(logger)


class ellone(plotting):
""" Basic l=1 detection
Expand Down Expand Up @@ -71,7 +76,7 @@ class ellone(plotting):
instead, in which case the l=2,0 modes may be picked up instead of the l=1.

"""

def __init__(self, pbinst=None, f=None, s=None):

if pbinst:
Expand Down Expand Up @@ -101,7 +106,8 @@ def __init__(self, pbinst=None, f=None, s=None):
self.hdblabels = None
self.hdbX = None
self.hdb_clusterN = None


@debugger
def residual(self,):
""" Compute the residual after dividing out l=2,0

Expand Down Expand Up @@ -129,7 +135,7 @@ def residual(self,):
idx = (flad[0] <= self.f) & (self.f <= flad[-1])
res[idx] /= mod[i,:]
return res

def binning(self, nbin):
""" Simply mean-binning

Expand Down Expand Up @@ -177,7 +183,7 @@ def H0test(self, fbin, sbin, nbin, dnu, reject=0.1):
idx = k < reject
return idx, k


@debugger
def H0_inconsistent(self, dnu, Nmax, rejection_level):
""" Find bins inconsistent with noise

Expand Down Expand Up @@ -220,6 +226,7 @@ def H0_inconsistent(self, dnu, Nmax, rejection_level):

return nu, N, pH0s

@debugger
def clustering_preprocess(self, nu, N, limits = (0, 100000)):
""" Preprocess the samples before clustering

Expand Down Expand Up @@ -268,6 +275,7 @@ def span(self, x):

return max(x)-min(x)

@debugger
def clustering(self, nu, N, Nmax, outlier_limit=0.5, cluster_prob=0.9):
""" Perform HDBscan clustering

Expand Down Expand Up @@ -326,8 +334,7 @@ def clustering(self, nu, N, Nmax, outlier_limit=0.5, cluster_prob=0.9):

return nus[1:], nstds[1:]



@debugger
def get_ell1(self, dnu):
""" Estimate frequency of l=1 modes (p-modes)

Expand Down Expand Up @@ -380,6 +387,7 @@ def get_ell1(self, dnu):

return nul1s, nul1s_std

@debugger
def __call__(self, dnu, Nmax = 30, rejection_level = 0.1):
""" Perform all the steps to estimate l=1 frequencies

Expand Down
Loading