Commit a15ba554 authored by Rhiannon Udall's avatar Rhiannon Udall
Browse files

PSD flexibility

parent f8e09402
Pipeline #469319 failed with stages
in 33 minutes and 40 seconds
import logging
from copy import deepcopy
import numpy as np
from dynesty.nestedsamplers import MultiEllipsoidSampler
from dynesty.utils import reflect, unitcheck
logger = logging.getLogger(__name__)
def update_walks_based_on_acceptance(state, blob, target):
r"""
......@@ -329,7 +332,7 @@ def sample_rwalk_bilby(args):
u_prop=u_prop,
periodic=periodic,
reflective=reflective,
nonbounded=nonbounded
nonbounded=nonbounded,
)
else:
fail = (np.min(u_prop) < 0) or (np.max(u_prop) > 1)
......@@ -396,7 +399,7 @@ def propose_diff_evo(u, live, rstate, **kwargs):
diff = live[second] - live[first]
if rstate.uniform(0, 1) < 0.5:
diff *= 2.38 / n**0.5
diff *= (100**rstate.uniform(0, 1)) / 10
diff *= (100 ** rstate.uniform(0, 1)) / 10
u_prop = u + diff
return u_prop
......@@ -434,6 +437,8 @@ def propose_ensemble_snooker(u, live, rstate, **kwargs):
z2 = live[choices[2]]
delta = u - z
norm = np.linalg.norm(delta)
if norm == 0 or norm is np.nan:
logger.info(f"{u},{z}, {delta}")
delta /= norm
u_prop = u + 1.7 * delta * (np.dot(u, z1) - np.dot(u, z2))
ln_jacobian = (n - 1.0) * np.log(np.linalg.norm(u_prop - z) / norm)
......
......@@ -303,7 +303,7 @@ def load_data_from_cache_file(
def load_data_by_channel_name(
channel_name, start_time, segment_duration, psd_duration, psd_start_time,
sampling_frequency=4096, roll_off=0.2,
overlap=0, outdir=None):
overlap=0, power_spectral_density=None, outdir=None):
""" Helper routine to generate an interferometer from a channel name
This function creates an empty interferometer specified in the name
of the channel. It calls `ifo.set_strain_data_from_channel_name` to
......@@ -327,7 +327,8 @@ def load_data_by_channel_name(
Sampling frequency
outdir: str, optional
The output directory in which the data is saved
power_spectral_density : PowerSpectralDensity, optional
If passed, use this power spectral density instead of generating one
Returns
=======
ifo: bilby.gw.detector.Interferometer
......@@ -346,16 +347,19 @@ def load_data_by_channel_name(
duration=segment_duration,
start_time=start_time)
ifo.power_spectral_density = \
PowerSpectralDensity.from_channel_name(
channel=channel_name,
psd_start_time=psd_start_time,
psd_duration=psd_duration,
fft_length=segment_duration,
sampling_frequency=sampling_frequency,
roll_off=roll_off,
overlap=overlap,
name=det,
outdir=outdir,
analysis_segment_start_time=start_time)
if power_spectral_density is None:
ifo.power_spectral_density = \
PowerSpectralDensity.from_channel_name(
channel=channel_name,
psd_start_time=psd_start_time,
psd_duration=psd_duration,
fft_length=segment_duration,
sampling_frequency=sampling_frequency,
roll_off=roll_off,
overlap=overlap,
name=det,
outdir=outdir,
analysis_segment_start_time=start_time)
else:
ifo.power_spectral_density = power_spectral_density
return ifo
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment