From b4b255eab8d7ee4bdeb7f83a7ad67d36c9ee7735 Mon Sep 17 00:00:00 2001 From: Chen Siyuan Date: Sat, 23 Dec 2023 21:06:06 +0800 Subject: [PATCH 1/3] add new EPTA and general selection functions --- enterprise/signals/selections.py | 86 ++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/enterprise/signals/selections.py b/enterprise/signals/selections.py index c701e7b0..9f2fba35 100644 --- a/enterprise/signals/selections.py +++ b/enterprise/signals/selections.py @@ -103,6 +103,24 @@ def by_band(flags): return {val: flags["B"] == val for val in flagvals} +def by_freq_band(bands = None): + def backends(freqs): + """Selection function to split by EPTA and custom frequency band values + bands: dict of bands and ranges + default recovers EPTA freq bands + """ + nonlocal bands + if isinstance(bands, dict): + pass + else: + bands = {"Band.1":[0,1000], "Band.2":[1000,2000], + "Band.3":[2000,3000], "Band.4":[3000,10000]} + return {val: (freqs>=fl) & (freqs=fl) & (freqs Date: Sun, 7 Apr 2024 21:43:44 +0800 Subject: [PATCH 2/3] liniting --- enterprise/signals/gp_bases.py | 1 - enterprise/signals/utils.py | 2 -- 2 files changed, 3 deletions(-) diff --git a/enterprise/signals/gp_bases.py b/enterprise/signals/gp_bases.py index 1847e54e..9b621f4e 100644 --- a/enterprise/signals/gp_bases.py +++ b/enterprise/signals/gp_bases.py @@ -219,7 +219,6 @@ def createfourierdesignmatrix_eph( @function def createfourierdesignmatrix_chromatic(toas, freqs, nmodes=30, Tspan=None, logf=False, fmin=None, fmax=None, idx=4): - """ Construct Scattering-variation fourier design matrix. diff --git a/enterprise/signals/utils.py b/enterprise/signals/utils.py index eff440e1..e2986f55 100644 --- a/enterprise/signals/utils.py +++ b/enterprise/signals/utils.py @@ -322,7 +322,6 @@ def create_stabletimingdesignmatrix(designmat, fastDesign=True): def make_ecc_interpolant(): - """ Make interpolation function from eccentricity file to determine number of harmonics to use for a given @@ -339,7 +338,6 @@ def make_ecc_interpolant(): def get_edot(F, mc, e): - """ Compute eccentricity derivative from Taylor et al. (2016) From d105ddd509405ba8800bf4065080a43010c9aa6d Mon Sep 17 00:00:00 2001 From: Chen Siyuan Date: Sun, 7 Apr 2024 21:50:21 +0800 Subject: [PATCH 3/3] more linting --- enterprise/signals/selections.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/enterprise/signals/selections.py b/enterprise/signals/selections.py index 9f2fba35..b0a570b8 100644 --- a/enterprise/signals/selections.py +++ b/enterprise/signals/selections.py @@ -103,7 +103,7 @@ def by_band(flags): return {val: flags["B"] == val for val in flagvals} -def by_freq_band(bands = None): +def by_freq_band(bands=None): def backends(freqs): """Selection function to split by EPTA and custom frequency band values bands: dict of bands and ranges @@ -113,10 +113,10 @@ def backends(freqs): if isinstance(bands, dict): pass else: - bands = {"Band.1":[0,1000], "Band.2":[1000,2000], - "Band.3":[2000,3000], "Band.4":[3000,10000]} - return {val: (freqs>=fl) & (freqs=fl) & (freqs= fl) & (freqs < fh) for val, (fl, fh) in bands.items() if any((freqs >= fl) & (freqs < fh)) + } return backends @@ -151,6 +151,7 @@ def by_index(name, idx): def indexvals(toas): """Selection function to split by ToA index values""" return {name: np.isin(np.arange(len(toas)), idx)} + return indexvals