From 34768fb777e7b3fe61cd3fc6d4b68ea1f0764fa5 Mon Sep 17 00:00:00 2001 From: William Lamb <60004701+astrolamb@users.noreply.github.com> Date: Fri, 21 Apr 2023 14:50:35 -0500 Subject: [PATCH 1/2] may model_general use mdc1 --- enterprise_extensions/models.py | 44 ++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/enterprise_extensions/models.py b/enterprise_extensions/models.py index 6f5d0c63..a1bddc10 100644 --- a/enterprise_extensions/models.py +++ b/enterprise_extensions/models.py @@ -628,7 +628,7 @@ def model_general(psrs, tm_var=False, tm_linear=False, tmparam_list=None, upper_limit_dm=None, dm_annual=False, dm_chrom=False, dmchrom_psd='powerlaw', dmchrom_idx=4, gequad=False, coefficients=False, pshift=False, select='backend', tm_marg=False, dense_like=False, - delta_common=None): + delta_common=None, mdc1=False): """ Reads in list of enterprise Pulsar instances and returns a PTA object instantiated with user-supplied options. @@ -758,6 +758,9 @@ def model_general(psrs, tm_var=False, tm_linear=False, tmparam_list=None, :param tm_marg: Use marginalized timing model. In many cases this will speed up the likelihood calculation significantly. :param dense_like: Use dense or sparse functions to evalute lnlikelihood + :param mdc1: Flag to ensure white noise signal is set-up properly for IPTA + MDC1 (found in enterprise.tests.data). If using MDC1, set to + True (default: False) Default PTA object composition: 1. fixed EFAC per backend/receiver system (per pulsar) @@ -882,21 +885,28 @@ def model_general(psrs, tm_var=False, tm_linear=False, tmparam_list=None, 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, - tnequad=tnequad, select=select) - if gequad: - s2 += white_signals.EquadNoise(log10_equad=parameter.Uniform(-8.5, -5), - selection=selections.Selection(selections.no_selection), - name='gequad') - if '1713' in p.name and dm_var: - tmin = p.toas.min() / const.day - tmax = p.toas.max() / const.day - s3 = s2 + chrom.dm_exponential_dip(tmin=tmin, tmax=tmax, idx=2, - sign=False, name='dmexp') - models.append(s3(p)) - else: - models.append(s2(p)) + if 'pta' in list(p.flags.keys()): + if 'NANOGrav' in p.flags['pta'] and not is_wideband: + s2 = s + white_noise_block(vary=white_vary, inc_ecorr=True, + tnequad=tnequad, select=select) + if gequad: + s2 += white_signals.EquadNoise(log10_equad=parameter.Uniform(-8.5, -5), + selection=selections.Selection(selections.no_selection), + name='gequad') + if '1713' in p.name and dm_var: + tmin = p.toas.min() / const.day + tmax = p.toas.max() / const.day + s3 = s2 + chrom.dm_exponential_dip(tmin=tmin, tmax=tmax, idx=2, + sign=False, name='dmexp') + models.append(s3(p)) + else: + models.append(s2(p)) + elif mdc1: + # if mock data challenge, efac is constant and no other white noise + efac = parameter.Constant(1.0) + wn = white_signals.MeasurementNoise(efac=efac) + s2 = s + wn + models.append(s2(p)) else: s4 = s + white_noise_block(vary=white_vary, inc_ecorr=False, tnequad=tnequad, select=select) @@ -920,7 +930,7 @@ def model_general(psrs, tm_var=False, tm_linear=False, tmparam_list=None, pta = signal_base.PTA(models) # set white noise parameters - if not white_vary or (is_wideband and use_dmdata): + if not mdc1 or white_vary or (is_wideband and use_dmdata): if noisedict is None: print('No noise dictionary provided!...') else: From 8c9e742dca655fc33ecaf7fbac544591d36e113e Mon Sep 17 00:00:00 2001 From: William G Lamb <60004701+astrolamb@users.noreply.github.com> Date: Mon, 17 Jul 2023 10:19:44 -0500 Subject: [PATCH 2/2] Update models.py fixed linting issues --- enterprise_extensions/models.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/enterprise_extensions/models.py b/enterprise_extensions/models.py index 3d0cad7f..a0b5986d 100644 --- a/enterprise_extensions/models.py +++ b/enterprise_extensions/models.py @@ -889,16 +889,16 @@ def model_general(psrs, tm_var=False, tm_linear=False, tmparam_list=None, if 'pta' in list(p.flags.keys()): if 'NANOGrav' in p.flags['pta'] and not is_wideband: s2 = s + white_noise_block(vary=white_vary, inc_ecorr=True, - tnequad=tnequad, select=select) + tnequad=tnequad, select=select) if gequad: s2 += white_signals.EquadNoise(log10_equad=parameter.Uniform(-8.5, -5), - selection=selections.Selection(selections.no_selection), - name='gequad') + selection=selections.Selection(selections.no_selection), + name='gequad') if '1713' in p.name and dm_var: tmin = p.toas.min() / const.day tmax = p.toas.max() / const.day s3 = s2 + chrom.dm_exponential_dip(tmin=tmin, tmax=tmax, idx=2, - sign=False, name='dmexp') + sign=False, name='dmexp') models.append(s3(p)) else: models.append(s2(p))