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

Chromatic noise updates #242

Open
wants to merge 161 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
161 commits
Select commit Hold shift + click to select a range
930aca4
Added sunssb calculatin to theta impact.
Hazboun6 Mar 3, 2020
5ac0875
Merge branch 'master' into jsh-solar_wind_models
Hazboun6 Mar 8, 2020
eb3a5fe
added to theta_impact docstring
Hazboun6 Mar 8, 2020
0107bc2
Added sunssb arg to functions.
Hazboun6 Mar 9, 2020
692d227
Added sunssb arg to solar_wind
Hazboun6 Mar 9, 2020
c2d6db4
Added sunssb arg to create_fourier_designmatrix_sw
Hazboun6 Mar 9, 2020
957fb2f
Added dm_solar_wind_r_to_p
Hazboun6 Mar 17, 2020
5a9b275
Added flag to be able to use log10_ne
Hazboun6 Mar 17, 2020
efd7883
Merge branch 'master' into jsh-solar_wind_models
Hazboun6 Mar 21, 2020
4e3987d
Added flag to model2a, model3a, modelgen to turn off rn model.
Hazboun6 Mar 27, 2020
f1b5270
Merged with master.
Hazboun6 Apr 1, 2020
ab8a118
Merged with master 2.
Hazboun6 Apr 1, 2020
ac7f846
Added option for dropout of intrinsic red noise.
Hazboun6 Apr 6, 2020
11ce811
Added dropout params to docstring
Hazboun6 Apr 6, 2020
15a2e57
Merging in recent master branch changes.
Hazboun6 Apr 22, 2020
52b6146
More merging
Hazboun6 Apr 22, 2020
f6786c8
More merging
Hazboun6 Apr 22, 2020
31d0d0d
More merging
Hazboun6 Apr 22, 2020
c27e0f6
No changes.
Hazboun6 May 3, 2020
8473114
space deletion
Hazboun6 Jun 15, 2020
ea4ae02
Tweaks to WN model for CHIME ECORR
Hazboun6 Jun 15, 2020
96b1b1d
Adding option to set dt for linear_interp_basis in single_pulsar_mode…
Jun 24, 2020
0018aae
Fixed syntax
Jun 24, 2020
a4b8db0
Merge pull request #5 from josephjsimon/jjs-test
Hazboun6 Jun 24, 2020
fc40557
Update binned sw model.
Hazboun6 Aug 19, 2020
ef10544
Update binned sw model 2.
Hazboun6 Aug 19, 2020
ea6c173
Update binned sw model 3.
Hazboun6 Aug 19, 2020
f94a09c
Update binned sw model 4.
Hazboun6 Aug 19, 2020
263b88b
Update binned sw model 5.
Hazboun6 Aug 19, 2020
b0b45a7
Update binned sw model 6.
Hazboun6 Aug 19, 2020
bd21519
Update binned sw model 7.
Hazboun6 Aug 19, 2020
4795dc5
Update binned sw model 8.
Hazboun6 Aug 19, 2020
8f53b10
Update binned sw model 9.
Hazboun6 Aug 20, 2020
ae995cd
Added combine flag to red noise blocks
Hazboun6 Sep 1, 2020
b576fc7
set zero to 1e-40
Hazboun6 Sep 1, 2020
76f990a
Merge branch 'jsh-solar_wind_models' into kludge_merge
Hazboun6 Oct 22, 2020
3c8b0fe
Merge pull request #7 from Hazboun6/kludge_merge
Hazboun6 Oct 22, 2020
b056a39
Added model 4a
Hazboun6 Oct 30, 2020
169dba4
fixed typo with rn in model general
Hazboun6 Dec 15, 2020
3d9ec7f
fixed typo with ss in model general
Hazboun6 Dec 15, 2020
44aeacc
fix typ in chromatic blk
Hazboun6 Jan 18, 2021
fe162d5
fix typ in chromatic blk
Hazboun6 Jan 18, 2021
b6fb100
adding broken powerlaw to model_general
Hazboun6 Feb 18, 2021
1a61f51
fix delta_common flag
Hazboun6 Feb 20, 2021
5a149a9
merging from master
Hazboun6 Feb 22, 2021
146f0d6
more conflict resolution
Hazboun6 Feb 23, 2021
a957753
fix merge conflict common_red
Hazboun6 Feb 23, 2021
d96fc26
add gw_crn to sampler flags
Hazboun6 Feb 24, 2021
98a897f
fix sampler issue
Hazboun6 Feb 24, 2021
0aa98d7
fixed broken power law
Hazboun6 Feb 24, 2021
69cb3be
make fbend prior based on Tspan
Hazboun6 Feb 25, 2021
641c53c
added general linear interpolant basis
Hazboun6 Mar 17, 2021
49a1e99
Merge branch 'master' into jsh-solar_wind_models
Hazboun6 Mar 17, 2021
a0c622d
further tweaks to general linear inter
Hazboun6 Mar 17, 2021
fb91ddb
change names in model_general
Hazboun6 Mar 20, 2021
2ac93f6
added white noise dropout models
Hazboun6 Mar 31, 2021
c3e29fb
fixed variables
Hazboun6 Mar 31, 2021
2a24d1a
add cov.npy load in
Hazboun6 May 14, 2021
e6a7861
small tweaks to cusp model
Hazboun6 Jul 2, 2021
4559f2c
starting to add new emp dist jump prop
Hazboun6 Aug 6, 2021
c506719
playing with new jump proposal
Hazboun6 Aug 9, 2021
d1095f6
small work on jp
Hazboun6 Aug 10, 2021
8152093
adding pulsar based jump props
Hazboun6 Aug 19, 2021
ea22134
adding pulsar based jump props 2
Hazboun6 Aug 19, 2021
e951d08
fix psr emp dist jp
Hazboun6 Aug 19, 2021
595f5b9
fix psr emp dist jp 2
Hazboun6 Aug 19, 2021
7bfc1d3
adding new chromatic gp JP
Hazboun6 Aug 19, 2021
14653fd
merging in master
Hazboun6 Nov 5, 2021
f188ba2
revert to standard dropout_rn
Hazboun6 Nov 5, 2021
723257f
merging from master
Hazboun6 Jan 20, 2022
51d0a0c
merging master into sw branch
Hazboun6 Feb 1, 2022
8a2784e
up the coverage
Hazboun6 Feb 1, 2022
a3f44e8
adding pulsars with sunssb attr
Hazboun6 Feb 1, 2022
3a86d9f
various solar wind upgrades
Hazboun6 Feb 1, 2022
c08d3c9
linting
Hazboun6 Feb 1, 2022
cec1ba1
tests for new solar wind functions
Hazboun6 Feb 1, 2022
7f4aa46
fix to signal
Hazboun6 Feb 1, 2022
38325cb
rm wn_dropout to another branch
Hazboun6 Feb 1, 2022
0bc1b8c
linting
Hazboun6 Feb 2, 2022
dca1887
matching WN models
Hazboun6 Feb 2, 2022
13ae6d7
multiple dt definitions
Hazboun6 Feb 2, 2022
45c01db
rm names from docstring
Hazboun6 Feb 2, 2022
f40529c
multiple dt definitions
Hazboun6 Feb 2, 2022
87b870a
f bend frequency range
Hazboun6 Feb 2, 2022
e0d2b81
Merge pull request #13 from Hazboun6/jsh-solar_wind_models
Hazboun6 Feb 2, 2022
8059587
Merge branch 'master' of https://github.com/Hazboun6/enterprise_exten…
Hazboun6 Feb 4, 2022
23f417a
added option for tnequad, default t2equad
Hazboun6 Feb 5, 2022
cba2455
move to enterprise-v3.3.0 for T2EQUAD support
Hazboun6 Feb 7, 2022
cbbc26a
Merge pull request #14 from Hazboun6/jsh-new_equad
Hazboun6 Feb 8, 2022
99b9afa
Merge branch 'master' of https://github.com/nanograv/enterprise_exten…
Hazboun6 Feb 10, 2022
62b0649
Merge branch 'master' of https://github.com/Hazboun6/enterprise_exten…
Hazboun6 Feb 10, 2022
740c93d
Merge branch 'master' of https://github.com/nanograv/enterprise_exten…
Hazboun6 Mar 21, 2022
9e48110
Merge branch 'master' of https://github.com/nanograv/enterprise_exten…
Hazboun6 May 5, 2022
a5d9740
added vary flag for DM and chrom models
Hazboun6 Sep 30, 2022
02a02c3
added vary flag to annual dm sinusoid
Hazboun6 Oct 4, 2022
16116b4
fixing gw log uniform draw for models with size!=0
Hazboun6 Oct 7, 2022
7d3657d
Merge branch 'emp_dists' into jsh-const-dmgp
Hazboun6 Oct 13, 2022
370990d
raise lower prior on periodic log10_p
Hazboun6 Oct 13, 2022
60daab1
tweak priors on chrom gp params
Hazboun6 Oct 13, 2022
e8bbfe4
tweak priors on chrom gp params 2
Hazboun6 Oct 13, 2022
9759f17
tweak to auto jump proposals dm_gp
Hazboun6 May 5, 2023
7ded58e
adding joe's fix
jeremy-baier May 13, 2023
e9c8a1d
added checks for fixed point
Hazboun6 May 17, 2023
29cbb4c
const dmgp fix for jump proposals additions
Hazboun6 May 18, 2023
539340d
fix elif in chromatic block for fixed point
Hazboun6 May 18, 2023
e91b674
Merge branch 'master' of github.com:nanograv/enterprise_extensions in…
Hazboun6 Aug 28, 2023
1a73738
adding Nfreqs options for freq DM/Chrom GP
Hazboun6 Aug 28, 2023
ac5349d
add varying chromatic index ability
Hazboun6 Aug 31, 2023
92f0906
move chromatic modeling out of dm
Hazboun6 Aug 31, 2023
a22fc66
edit docstring
Hazboun6 Aug 31, 2023
2826fc4
change docstring
Hazboun6 Sep 1, 2023
a355eae
fix typo
Hazboun6 Sep 2, 2023
237b11b
add Tspan kwarg to dmgp and chromgp
Hazboun6 Sep 2, 2023
0d6853e
add ridge prior dmx-like GP to chromatic GP block
Hazboun6 Sep 4, 2023
7f2cd42
added chrom_gp to setup sampler JP auto adds
Hazboun6 Sep 6, 2023
16b592e
adding the ridge rename
Jan 28, 2024
e21ffd3
starting the custom jump proposal for HM empirical distribution
jeremy-baier Jan 28, 2024
7f12411
hm emp distr JP
jeremy-baier Jan 29, 2024
d51a6de
hm emp bug fixes
jeremy-baier Jan 29, 2024
b6fd5ea
Merge remote-tracking branch 'hazgrav/jsh-const-dmgp-custom-hm-emp-di…
jeremy-baier May 21, 2024
68a34a5
tryna fix da hypermodel
jeremy-baier May 21, 2024
dad6b84
closing bracket
jeremy-baier May 21, 2024
970f64f
closing bracket correctly
jeremy-baier May 21, 2024
0badc42
closing next bracket
jeremy-baier May 21, 2024
efb5068
another fix for the for loop
jeremy-baier May 21, 2024
e1630e3
another fix for the for loop2
jeremy-baier May 21, 2024
5046281
changed it in lnprior too
jeremy-baier May 21, 2024
728e3c5
Merge remote-tracking branch 'hazgrav/jsh-const-dmgp-ranamed-ridge-pa…
jeremy-baier May 21, 2024
070d3a9
tryna rename ridge pt 2
jeremy-baier May 25, 2024
42e6515
yonk
jeremy-baier May 25, 2024
d9f031e
yonk
jeremy-baier May 25, 2024
bea161e
fixing some broken things
jeremy-baier May 28, 2024
b63de01
automatically save hm weights to chain directory
jeremy-baier Jun 3, 2024
42d3118
just a comment
jeremy-baier Jun 3, 2024
5d0b387
changing jump prop
jeremy-baier Jun 18, 2024
e501394
adding bjorns changes to move the log_weights to the PRIOR instead of…
jeremy-baier Aug 2, 2024
5b5cf3c
fixing something in the print for hypermodel weights
jeremy-baier Aug 8, 2024
4d48771
add: add gp_ecorr kwarg to model single puslar noise
jeremy-baier Sep 5, 2024
0b30f05
Merge branch 'master' of github.com:jeremy-baier/enterprise_extension…
jeremy-baier Sep 8, 2024
33d2b26
reformat: used black on sampler.py
jeremy-baier Sep 8, 2024
9170a54
Revert "reformat: used black on sampler.py"
jeremy-baier Sep 8, 2024
217409b
reformat: passing flake for sampler.py
jeremy-baier Sep 8, 2024
b7d2f0f
reformat: update code to pass flake8 for blocks.py
jeremy-baier Sep 8, 2024
6d73eed
reformat: update code to pass flake8 for chromatic.py
jeremy-baier Sep 8, 2024
83e8d29
reformat: update code so that hypermodel.py is passing flake8
jeremy-baier Sep 8, 2024
d89068d
reformat: update code so that models.py is passing flake8
jeremy-baier Sep 8, 2024
77e4829
update tests: updated the tests so that less tests will be breaking
jeremy-baier Sep 9, 2024
95bac43
add kwarg: added variable upper prior limit to chrom_gp_idx. default …
jeremy-baier Sep 9, 2024
4e9815b
add kwarg: added variable upper prior limit to chrom_gp_idx. default …
jeremy-baier Sep 9, 2024
02735b7
fixed linting
jeremy-baier Sep 9, 2024
3d6250b
add VEGAS to channelized backends
jeremy-baier Sep 9, 2024
2e08082
tests: add and fix tests; mend blocks accordingly
jeremy-baier Sep 9, 2024
f1fec8a
fix: add maximum scipy to avoid deprecation error in tests
jeremy-baier Sep 10, 2024
2cc153d
update: update ci_test.yml
jeremy-baier Sep 10, 2024
ed4590b
add Nitu+2024 SW model + test
blarsen10 Sep 11, 2024
0abcf33
attempt to fix accidental undoing of changes to gp_kernels and tests
blarsen10 Sep 11, 2024
9632217
linting, imports
blarsen10 Sep 12, 2024
d4d18d1
fixed bug in gp_ecorr kwarg
jeremy-baier Sep 18, 2024
bbf54e5
Update setup.py
Hazboun6 Sep 20, 2024
0305495
changing gp ecorr to be false by default
jeremy-baier Oct 15, 2024
557bf6c
500-->50000
jeremy-baier Nov 21, 2024
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 .github/workflows/ci_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
python-version: [3.7, 3.8, 3.9, '3.10']
os: [ubuntu-latest, macos-13]
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- name: Checkout repository
Expand Down
233 changes: 149 additions & 84 deletions enterprise_extensions/blocks.py

Large diffs are not rendered by default.

98 changes: 71 additions & 27 deletions enterprise_extensions/chromatic/chromatic.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def dmx_delay(toas, freqs, dmx_ids, **kwargs):
return wf


def dm_exponential_dip(tmin, tmax, idx=2, sign='negative', name='dmexp'):
def dm_exponential_dip(tmin, tmax, idx=2, sign='negative', name='dmexp', vary=True):
"""
Returns chromatic exponential dip (i.e. TOA advance):

Expand All @@ -216,15 +216,24 @@ def dm_exponential_dip(tmin, tmax, idx=2, sign='negative', name='dmexp'):
:param sign:
set sign of dip: 'positive', 'negative', or 'vary'
:param name: Name of signal
:param vary: Whether to vary the parameters or use constant values.

:return dmexp:
chromatic exponential dip waveform.
"""
t0_dmexp = parameter.Uniform(tmin, tmax)
log10_Amp_dmexp = parameter.Uniform(-10, -2)
log10_tau_dmexp = parameter.Uniform(0, 2.5)
if sign == 'vary':
if vary:
t0_dmexp = parameter.Uniform(tmin, tmax)
log10_Amp_dmexp = parameter.Uniform(-10, -2)
log10_tau_dmexp = parameter.Uniform(0, 2.5)
else:
t0_dmexp = parameter.Constant()
log10_Amp_dmexp = parameter.Constant()
log10_tau_dmexp = parameter.Constant()

if sign == 'vary' and vary:
sign_param = parameter.Uniform(-1.0, 1.0)
elif sign == 'vary' and not vary:
sign_param = parameter.Constant()
elif sign == 'positive':
sign_param = 1.0
else:
Expand All @@ -238,7 +247,7 @@ def dm_exponential_dip(tmin, tmax, idx=2, sign='negative', name='dmexp'):


def dm_exponential_cusp(tmin, tmax, idx=2, sign='negative',
symmetric=False, name='dm_cusp'):
symmetric=False, name='dm_cusp', vary=True):
"""
Returns chromatic exponential cusp (i.e. TOA advance):

Expand All @@ -250,25 +259,35 @@ def dm_exponential_cusp(tmin, tmax, idx=2, sign='negative',
:param sign:
set sign of dip: 'positive', 'negative', or 'vary'
:param name: Name of signal
:param vary: Whether to vary the parameters or use constant values.

:return dmexp:
chromatic exponential dip waveform.
"""
t0_dm_cusp = parameter.Uniform(tmin, tmax)
log10_Amp_dm_cusp = parameter.Uniform(-10, -2)
log10_tau_dm_cusp_pre = parameter.Uniform(0, 2.5)
if vary:
t0_dm_cusp = parameter.Uniform(tmin, tmax)
log10_Amp_dm_cusp = parameter.Uniform(-10, -2)
log10_tau_dm_cusp_pre = parameter.Uniform(0, 2.5)
else:
t0_dm_cusp = parameter.Constant()
log10_Amp_dm_cusp = parameter.Constant()
log10_tau_dm_cusp_pre = parameter.Constant()

if sign == 'vary':
if sign == 'vary' and vary:
sign_param = parameter.Uniform(-1.0, 1.0)
elif sign == 'vary' and not vary:
sign_param = parameter.Constant()
elif sign == 'positive':
sign_param = 1.0
else:
sign_param = -1.0

if symmetric:
log10_tau_dm_cusp_post = 1
else:
elif vary:
log10_tau_dm_cusp_post = parameter.Uniform(0, 2.5)
else:
log10_tau_dm_cusp_post = parameter.Constant()

wf = chrom_exp_cusp(log10_Amp=log10_Amp_dm_cusp, sign_param=sign_param,
t0=t0_dm_cusp, log10_tau_pre=log10_tau_dm_cusp_pre,
Expand All @@ -280,7 +299,7 @@ def dm_exponential_cusp(tmin, tmax, idx=2, sign='negative',


def dm_dual_exp_cusp(tmin, tmax, idx1=2, idx2=4, sign='negative',
symmetric=False, name='dual_dm_cusp'):
symmetric=False, name='dual_dm_cusp', vary=True):
"""
Returns chromatic exponential cusp (i.e. TOA advance):

Expand All @@ -292,18 +311,28 @@ def dm_dual_exp_cusp(tmin, tmax, idx1=2, idx2=4, sign='negative',
:param sign:
set sign of dip: 'positive', 'negative', or 'vary'
:param name: Name of signal
:param vary: Whether to vary the parameters or use constant values.

:return dmexp:
chromatic exponential dip waveform.
"""
t0_dual_cusp = parameter.Uniform(tmin, tmax)
log10_Amp_dual_cusp_1 = parameter.Uniform(-10, -2)
log10_Amp_dual_cusp_2 = parameter.Uniform(-10, -2)
log10_tau_dual_cusp_pre_1 = parameter.Uniform(0, 2.5)
log10_tau_dual_cusp_pre_2 = parameter.Uniform(0, 2.5)
if vary:
t0_dual_cusp = parameter.Uniform(tmin, tmax)
log10_Amp_dual_cusp_1 = parameter.Uniform(-10, -2)
log10_Amp_dual_cusp_2 = parameter.Uniform(-10, -2)
log10_tau_dual_cusp_pre_1 = parameter.Uniform(0, 2.5)
log10_tau_dual_cusp_pre_2 = parameter.Uniform(0, 2.5)
else:
t0_dual_cusp = parameter.Constant()
log10_Amp_dual_cusp_1 = parameter.Constant()
log10_Amp_dual_cusp_2 = parameter.Constant()
log10_tau_dual_cusp_pre_1 = parameter.Constant()
log10_tau_dual_cusp_pre_2 = parameter.Constant()

if sign == 'vary':
if sign == 'vary' and vary:
sign_param = parameter.Uniform(-1.0, 1.0)
elif sign == 'vary' and not vary:
sign_param = parameter.Constant()
elif sign == 'positive':
sign_param = 1.0
else:
Expand All @@ -312,9 +341,12 @@ def dm_dual_exp_cusp(tmin, tmax, idx1=2, idx2=4, sign='negative',
if symmetric:
log10_tau_dual_cusp_post_1 = 1
log10_tau_dual_cusp_post_2 = 1
else:
elif vary:
log10_tau_dual_cusp_post_1 = parameter.Uniform(0, 2.5)
log10_tau_dual_cusp_post_2 = parameter.Uniform(0, 2.5)
else:
log10_tau_dual_cusp_post_1 = parameter.Constant()
log10_tau_dual_cusp_post_2 = parameter.Constant()

wf = chrom_dual_exp_cusp(t0=t0_dual_cusp, sign_param=sign_param,
symmetric=symmetric,
Expand All @@ -330,41 +362,53 @@ def dm_dual_exp_cusp(tmin, tmax, idx1=2, idx2=4, sign='negative',
return dm_cusp


def dmx_signal(dmx_data, name='dmx_signal'):
def dmx_signal(dmx_data, name='dmx_signal', vary=True):
"""
Returns DMX signal:

:param dmx_data: dictionary of DMX data for each pulsar from parfile.
:param name: Name of signal.
:param vary: Whether to vary the parameters or use constant values.

:return dmx_sig:
dmx signal waveform.
"""
dmx = {}
for dmx_id in sorted(dmx_data):
dmx_data_tmp = dmx_data[dmx_id]
dmx.update({dmx_id: parameter.Normal(mu=dmx_data_tmp['DMX_VAL'],
sigma=dmx_data_tmp['DMX_ERR'])})
if vary:
for dmx_id in sorted(dmx_data):
dmx_data_tmp = dmx_data[dmx_id]
dmx.update({dmx_id: parameter.Normal(mu=dmx_data_tmp['DMX_VAL'],
sigma=dmx_data_tmp['DMX_ERR'])})
else:
for dmx_id in sorted(dmx_data):
dmx_data_tmp = dmx_data[dmx_id]
dmx.update({dmx_id: parameter.Constant()})

wf = dmx_delay(dmx_ids=dmx_data, **dmx)
dmx_sig = deterministic_signals.Deterministic(wf, name=name)

return dmx_sig


def dm_annual_signal(idx=2, name='dm_s1yr'):
def dm_annual_signal(idx=2, name='dm_s1yr', vary=True):
"""
Returns chromatic annual signal (i.e. TOA advance):

:param idx:
index of radio frequency dependence (i.e. DM is 2). If this is set
to 'vary' then the index will vary from 1 - 6
:param name: Name of signal
:param vary: Whether to vary the parameters or use constant values.

:return dm1yr:
chromatic annual waveform.
"""
log10_Amp_dm1yr = parameter.Uniform(-10, -2)
phase_dm1yr = parameter.Uniform(0, 2*np.pi)
if vary:
log10_Amp_dm1yr = parameter.Uniform(-10, -2)
phase_dm1yr = parameter.Uniform(0, 2*np.pi)
else:
log10_Amp_dm1yr = parameter.Constant()
phase_dm1yr = parameter.Constant()

wf = chrom_yearly_sinusoid(log10_Amp=log10_Amp_dm1yr,
phase=phase_dm1yr, idx=idx)
Expand Down
8 changes: 7 additions & 1 deletion enterprise_extensions/chromatic/solar_wind.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def solar_wind_block(n_earth=None, ACE_prior=False, include_swgp=True,
Prior function for solar wind Gaussian process. Default is a power law.
:param swgp_basis:
Basis to be used for solar wind Gaussian process.
Options includes ['powerlaw'.'periodic','sq_exp']
Options includes ['powerlaw','periodic','sq_exp','triangular']
:param Tspan:
Sets frequency sampling f_i = i / Tspan. Default will
use overall time span for individual pulsar. Default is to use 15
Expand Down Expand Up @@ -241,6 +241,12 @@ def solar_wind_block(n_earth=None, ACE_prior=False, include_swgp=True,
sw_prior = gpk.se_dm_kernel(log10_sigma=log10_sigma,
log10_ell=log10_ell)

elif swgp_basis == 'triangular':
# white noise kernel for SW DM, using delta n_earth as coefficients
log10_sigma_ne = parameter.Uniform(-4, 2)
sw_basis = gpk.sw_dm_triangular_basis()
sw_prior = gpk.sw_dm_wn_prior(log10_sigma_ne=log10_sigma_ne)

gp_sw = gp_signals.BasisGP(sw_prior, sw_basis, name='gp_sw')
sw_model += gp_sw

Expand Down
64 changes: 56 additions & 8 deletions enterprise_extensions/gp_kernels.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# -*- coding: utf-8 -*-

import numpy as np
from enterprise.signals import signal_base, utils
from enterprise.signals import signal_base, utils, parameter
import enterprise.constants as const
from enterprise_extensions import chromatic as chrom

__all__ = ['linear_interp_basis_dm',
'linear_interp_basis_freq',
Expand Down Expand Up @@ -47,9 +49,9 @@ def linear_interp_basis_freq(freqs, df=64):


@signal_base.function
def dmx_ridge_prior(avetoas, log10_sigma=-7):
def dmx_ridge_prior(avetoas, log10_sigma_ridge=-7):
"""DMX-like signal with Gaussian prior"""
sigma = 10**log10_sigma
sigma = 10**log10_sigma_ridge
return sigma**2 * np.ones_like(avetoas)


Expand All @@ -64,7 +66,7 @@ def periodic_kernel(avetoas, log10_sigma=-7, log10_ell=2,
l = 10**log10_ell * 86400
p = 10**log10_p * 3.16e7
gam_p = 10**log10_gam_p
d = np.eye(r.shape[0]) * (sigma/500)**2
d = np.eye(r.shape[0]) * (sigma/50000.)**2
K = sigma**2 * np.exp(-r**2/2/l**2 - gam_p*np.sin(np.pi*r/p)**2) + d
return K

Expand All @@ -76,7 +78,7 @@ def se_kernel(avefreqs, log10_sigma=-7, log10_lam=3):

lam = 10**log10_lam
sigma = 10**log10_sigma
d = np.eye(tm.shape[0]) * (sigma/500)**2
d = np.eye(tm.shape[0]) * (sigma/50000.)**2
return sigma**2 * np.exp(-tm**2/2/lam) + d


Expand All @@ -88,11 +90,57 @@ def se_dm_kernel(avetoas, log10_sigma=-7, log10_ell=2):
# Convert everything into seconds
l = 10**log10_ell * 86400
sigma = 10**log10_sigma
d = np.eye(r.shape[0]) * (sigma/500)**2
d = np.eye(r.shape[0]) * (sigma/50000.)**2
K = sigma**2 * np.exp(-r**2/2/l**2) + d
return K


@signal_base.function
def sw_dm_triangular_basis(toas, planetssb, sunssb, pos_t, freqs, fref=1400):
"""
Construct SWGP basis from Nitu et al 2024 using triangle functions centered on SW conjunctions
:param toas: vector of time series in seconds
:param planetssb: solar system barycenter positions
:param pos_t: pulsar position as 3-vector
:param freqs: radio frequencies of observations [MHz]
:param fref: reference frequency [MHz]

:return: V: Nc x Ntoa design matrix
:return: Tc: SW conjunctions
"""

# First get SW conjunctions
theta, R_earth, _, _ = chrom.solar_wind.theta_impact(planetssb, sunssb, pos_t)
# Estimate conjunction times using TOA of closest approach
toa_min_theta = toas[np.argmin(theta)]
Tc = toa_min_theta + np.arange(100)*const.yr - 50*const.yr # This might break after the NANOGrav 50 yr dataset
Tc = Tc[(Tc > np.min(toas))*(Tc < np.max(toas))]

# Set up triangular basis matrix functions
Nc = len(Tc)
Nt = len(toas)
Lambda = np.max(np.array([1 - np.abs(toas[:, None] - Tc[None, :])/const.yr, np.zeros((Nt, Nc))]), axis=0)

# Geometric factor (units of DM)
S_theta = chrom.solar_wind.dm_solar(1.0, theta, R_earth)

# Convert from DM to a time delay
S_theta *= 1e-12/const.DM_K/freqs**2

# return basis and conjunctions
V = S_theta[:, None]*Lambda
return V, Tc


@parameter.function
def sw_dm_wn_prior(Tc, log10_sigma_ne=-4):
"""
Gaussian prior on variance of n_earth at SW conjunctions
"""
sigma_ne = 10**log10_sigma_ne
return sigma_ne**2 * np.ones_like(Tc)


@signal_base.function
def get_tf_quantization_matrix(toas, freqs, dt=30*86400, df=None, dm=False, dm_idx=2):
"""
Expand Down Expand Up @@ -164,7 +212,7 @@ def tf_kernel(labels, log10_sigma=-7, log10_ell=2, log10_gam_p=0,
gam_p = 10**log10_gam_p
alpha_wgt = 10**log10_alpha_wgt

d = np.eye(r.shape[0]) * (sigma/500)**2
d = np.eye(r.shape[0]) * (sigma/50000.)**2
Kt = sigma**2 * np.exp(-r**2/2/l**2 - gam_p*np.sin(np.pi*r/p)**2)
Kv = (1+r2**2/2/alpha_wgt/l2**2)**(-alpha_wgt)

Expand All @@ -190,7 +238,7 @@ def sf_kernel(labels, log10_sigma=-7, log10_ell=2,
l2 = 10**log10_ell2
alpha_wgt = 10**log10_alpha_wgt

d = np.eye(r.shape[0]) * (sigma/500)**2
d = np.eye(r.shape[0]) * (sigma/50000.)**2
Kt = sigma**2 * np.exp(-r**2/2/l**2)
Kv = (1+r2**2/2/alpha_wgt/l2**2)**(-alpha_wgt)

Expand Down
Loading
Loading