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

Draft:Enterprise extensions pipe #205

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
4a2e4ca
Adding config file for enterprise extensions functions
sophiehourihane Oct 10, 2022
66fc9fd
update models to add type hints for model_2a and model_3a
meyers-academic Oct 11, 2022
1349330
update data_class.py to read and apply type hints from code. update
meyers-academic Oct 11, 2022
a01c350
Merge pull request #1 from meyers-academic/enterprise_extensions_pipe
sophiehourihane Oct 12, 2022
193ffe8
Working PTA object dataclass from arbitrary module
sophiehourihane Oct 14, 2022
bc471fc
Adding way to evaluate functions from config.ini
sophiehourihane Oct 15, 2022
6056c12
type hints and reformatting
sophiehourihane Oct 18, 2022
3b17755
Adding signal_model options to data_class (BETA!)
sophiehourihane Oct 19, 2022
864b30c
Adding option to treat gp_ecorr as a gaussian process
sophiehourihane Oct 19, 2022
805d1fc
Adding option to use individual pulsar times for rednoise Tspan
sophiehourihane Oct 20, 2022
4a214ec
Fixing RunSettings dictionary initializations so they are not shared …
sophiehourihane Oct 20, 2022
163580a
Cleaning up example.ini and example_dataclass.py
sophiehourihane Oct 20, 2022
358cbc2
Simplifying logic so now enterprise extensions modules must be loaded…
sophiehourihane Oct 21, 2022
632b27a
adding gp_ecorr and individual_Tspan_for_red_noise to model_3a
sophiehourihane Oct 21, 2022
33d1284
Adding return statment so that dense_like actually returns a pta
sophiehourihane Oct 21, 2022
e5cf42b
Adding type hints to white_noise_block and model_1
sophiehourihane Oct 25, 2022
c36d17a
Adding get_noise_dict and get_pulsars, also adding way to load module…
sophiehourihane Oct 25, 2022
63e5944
making sure pulsars are loaded before calling create_pta_object_from_…
sophiehourihane Oct 28, 2022
12b2e39
Adding log10_equad parsing to noise dict parsing
sophiehourihane Nov 15, 2022
ab6a55b
adding small annotation
sophiehourihane Nov 15, 2022
6b05a65
increasing legibility
sophiehourihane Feb 14, 2023
92394fe
updating custom_function logic so that it stores all functions includ…
sophiehourihane Mar 2, 2023
6503013
Letting per_pulsar_signal take pulsar name as input for signals appli…
sophiehourihane Mar 25, 2023
b0c6b49
getting rid of unused parameter
sophiehourihane Mar 25, 2023
4ab0f5e
Fixing typo from EACH_PULSAR->EVERY_PULSAR that broke per_pulsar_sign…
sophiehourihane Apr 24, 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
4 changes: 2 additions & 2 deletions enterprise_extensions/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def channelized_backends(backend_flags):
return {flagval: backend_flags == flagval for flagval in flagvals}


def white_noise_block(vary=False, inc_ecorr=False, gp_ecorr=False,
efac1=False, select='backend', tnequad=False, name=None):
def white_noise_block(vary:bool=False, inc_ecorr:bool=False, gp_ecorr:bool=False,
efac1:bool=False, select:str='backend', tnequad:bool=False, name:str=None):
"""
Returns the white noise block of the model:

Expand Down
183 changes: 95 additions & 88 deletions enterprise_extensions/deterministic.py

Large diffs are not rendered by default.

71 changes: 45 additions & 26 deletions enterprise_extensions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,10 @@ def model_singlepsr_noise(psr, tm_var=False, tm_linear=False,
return pta


def model_1(psrs, psd='powerlaw', noisedict=None, white_vary=False,
components=30, upper_limit=False, bayesephem=False, tnequad=False,
be_type='orbel', is_wideband=False, use_dmdata=False,
select='backend', tm_marg=False, dense_like=False, tm_svd=False):
def model_1(psrs:list, psd:str='powerlaw', noisedict:dict=None, white_vary:bool=False,
components:int=30, upper_limit:bool=False, bayesephem:bool=False, tnequad:bool=False,
be_type:str='orbel', is_wideband:bool=False, use_dmdata:bool=False,
select:str='backend', tm_marg:bool=False, dense_like:bool=False, tm_svd:bool=False):
"""
Reads in list of enterprise Pulsar instance and returns a PTA
instantiated with only white and red noise:
Expand Down Expand Up @@ -461,13 +461,14 @@ def model_1(psrs, psd='powerlaw', noisedict=None, white_vary=False,
return pta


def model_2a(psrs, psd='powerlaw', noisedict=None, components=30,
n_rnfreqs=None, n_gwbfreqs=None, gamma_common=None,
delta_common=None, upper_limit=False, bayesephem=False,
be_type='setIII', white_vary=False, is_wideband=False,
use_dmdata=False, select='backend', tnequad=False,
pshift=False, pseed=None, psr_models=False,
tm_marg=False, dense_like=False, tm_svd=False):
def model_2a(psrs: list, psd: str='powerlaw', noisedict: dict=None, components: int=30,
n_rnfreqs: int=None, n_gwbfreqs: int=None, gamma_common: float=None,
delta_common: float=None, upper_limit: int=False, bayesephem: int=False,
be_type: str='setIII', white_vary: bool=False, is_wideband: bool=False,
use_dmdata: bool=False, select: str='backend', tnequad: bool=False,
pshift: bool=False, pseed: int=None, psr_models: bool=False,
tm_marg: bool=False, dense_like: bool=False, tm_svd: bool=False,
gp_ecorr: bool=False, individual_Tspan_for_red_noise: bool=False):
"""
Reads in list of enterprise Pulsar instance and returns a PTA
instantiated with model 2A from the analysis paper:
Expand Down Expand Up @@ -526,12 +527,20 @@ def model_2a(psrs, psd='powerlaw', noisedict=None, components=30,
up the likelihood calculation significantly.
:param dense_like: Use dense or sparse functions to evalute lnlikelihood
:param tm_svd: boolean for svd-stabilised timing model design matrix
:param gp_ecorr:
whether to use the Gaussian process model for ECORR
:param individual_Tspan_for_red_noise:
each pulsar has frequencies defined by 1/Tspan_pulsar for the red noise
"""

amp_prior = 'uniform' if upper_limit else 'log-uniform'

# find the maximum time span to set GW frequency sampling
Tspan = model_utils.get_tspan(psrs)
if individual_Tspan_for_red_noise:
Tspan_red_noise = None
else:
Tspan_red_noise = Tspan

if n_gwbfreqs is None:
n_gwbfreqs = components
Expand Down Expand Up @@ -563,7 +572,7 @@ def model_2a(psrs, psd='powerlaw', noisedict=None, components=30,
s = gp_signals.TimingModel(use_svd=tm_svd)

# red noise
s += red_noise_block(prior=amp_prior, Tspan=Tspan, components=n_rnfreqs)
s += red_noise_block(prior=amp_prior, Tspan=Tspan_red_noise, components=n_rnfreqs)

# common red noise block
s += common_red_noise_block(psd=psd, prior=amp_prior, Tspan=Tspan,
Expand All @@ -580,11 +589,11 @@ def model_2a(psrs, psd='powerlaw', noisedict=None, components=30,
models = []
for p in psrs:
if 'NANOGrav' in p.flags['pta'] and not is_wideband:
s2 = s + white_noise_block(vary=white_vary, inc_ecorr=True,
s2 = s + white_noise_block(vary=white_vary, inc_ecorr=True, gp_ecorr=gp_ecorr,
tnequad=tnequad, select=select)
models.append(s2(p))
else:
s3 = s + white_noise_block(vary=white_vary, inc_ecorr=False,
s3 = s + white_noise_block(vary=white_vary, inc_ecorr=False, gp_ecorr=gp_ecorr,
tnequad=tnequad, select=select)
models.append(s3(p))

Expand All @@ -610,7 +619,7 @@ def model_2a(psrs, psd='powerlaw', noisedict=None, components=30,
noisedict = noisedict
pta.set_default_params(noisedict)

return pta
return pta


def model_general(psrs, tm_var=False, tm_linear=False, tmparam_list=None,
Expand Down Expand Up @@ -1312,14 +1321,14 @@ def model_2d(psrs, psd='powerlaw', noisedict=None, white_vary=False,
return pta


def model_3a(psrs, psd='powerlaw', noisedict=None, white_vary=False,
components=30, n_rnfreqs=None, n_gwbfreqs=None,
gamma_common=None, delta_common=None, upper_limit=False,
bayesephem=False, be_type='setIII', is_wideband=False,
use_dmdata=False, select='backend',
tnequad=False,
pshift=False, pseed=None, psr_models=False,
tm_marg=False, dense_like=False, tm_svd=False):
def model_3a(psrs: list, psd: str='powerlaw', noisedict: dict=None, white_vary: bool=False,
components: int=30, n_rnfreqs: int=None, n_gwbfreqs: int=None,
gamma_common: float=None, delta_common: float=None, upper_limit: bool=False,
bayesephem: bool=False, be_type: str='setIII', is_wideband: bool=False,
use_dmdata: bool=False, select: str='backend', tnequad: bool=False,
pshift: bool=False, pseed: int=None, psr_models: bool=False,
tm_marg: bool=False, dense_like: bool=False, tm_svd: bool=False,
gp_ecorr: bool=False, individual_Tspan_for_red_noise: bool=False):
"""
Reads in list of enterprise Pulsar instance and returns a PTA
instantiated with model 3A from the analysis paper:
Expand Down Expand Up @@ -1378,12 +1387,20 @@ def model_3a(psrs, psd='powerlaw', noisedict=None, white_vary=False,
up the likelihood calculation significantly.
:param dense_like: Use dense or sparse functions to evalute lnlikelihood
:param tm_svd: boolean for svd-stabilised timing model design matrix
:param gp_ecorr:
whether to use the Gaussian process model for ECORR
:param individual_Tspan_for_red_noise:
each pulsar has frequencies defined by 1/Tspan_pulsar for the red noise
"""

amp_prior = 'uniform' if upper_limit else 'log-uniform'

# find the maximum time span to set GW frequency sampling
Tspan = model_utils.get_tspan(psrs)
if individual_Tspan_for_red_noise:
Tspan_red_noise = None
else:
Tspan_red_noise = Tspan

if n_gwbfreqs is None:
n_gwbfreqs = components
Expand Down Expand Up @@ -1415,7 +1432,7 @@ def model_3a(psrs, psd='powerlaw', noisedict=None, white_vary=False,
s = gp_signals.TimingModel(use_svd=tm_svd)

# red noise
s += red_noise_block(prior=amp_prior, Tspan=Tspan, components=n_rnfreqs)
s += red_noise_block(prior=amp_prior, Tspan=Tspan_red_noise, components=n_rnfreqs)

# common red noise block
s += common_red_noise_block(psd=psd, prior=amp_prior, Tspan=Tspan,
Expand All @@ -1432,11 +1449,13 @@ def model_3a(psrs, psd='powerlaw', noisedict=None, white_vary=False,
models = []
for p in psrs:
if 'NANOGrav' in p.flags['pta'] and not is_wideband:
s2 = s + white_noise_block(vary=white_vary, inc_ecorr=True,
s2 = s + white_noise_block(vary=white_vary,
gp_ecorr=gp_ecorr, inc_ecorr=True,
tnequad=tnequad, select=select)
models.append(s2(p))
else:
s3 = s + white_noise_block(vary=white_vary, inc_ecorr=False,
s3 = s + white_noise_block(vary=white_vary,
gp_ecorr=gp_ecorr, inc_ecorr=False,
tnequad=tnequad, select=select)
models.append(s3(p))

Expand Down
Empty file.
Loading