Commit bd9b5d41 authored by Colm Talbot's avatar Colm Talbot Committed by Gregory Ashton

modify imports to reduce tupak references

parent 0f0d24ff
......@@ -16,12 +16,10 @@ https://monash.docs.ligo.org/tupak/installation.html.
"""
from __future__ import print_function, division, absolute_import
from __future__ import absolute_import
import tupak.core
import tupak.gw
import tupak.hyper
from . import core, gw, hyper
from tupak.core import utils, likelihood, prior, result, sampler
from tupak.core.sampler import run_sampler
from tupak.core.likelihood import Likelihood
from .core import utils, likelihood, prior, result, sampler
from .core.sampler import run_sampler
from .core.likelihood import Likelihood
from __future__ import absolute_import
import tupak.core.likelihood
import tupak.core.prior
import tupak.core.result
import tupak.core.sampler
import tupak.core.utils
\ No newline at end of file
from . import likelihood, prior, result, sampler, utils
from __future__ import division, print_function
import copy
import numpy as np
from scipy.special import gammaln
from tupak.core.utils import infer_parameters_from_function
import copy
from .utils import infer_parameters_from_function
class Likelihood(object):
......
......@@ -9,8 +9,8 @@ import os
from collections import OrderedDict
from future.utils import iteritems
from tupak.core.utils import logger
from tupak.core import utils
from .utils import logger
from . import utils
import tupak # noqa
import inspect
......
......@@ -8,9 +8,9 @@ import matplotlib
import matplotlib.pyplot as plt
from collections import OrderedDict
from tupak.core import utils
from tupak.core.utils import logger
from tupak.core.prior import PriorSet, DeltaFunction
from . import utils
from .utils import logger
from .prior import PriorSet, DeltaFunction
def result_file_name(outdir, label):
......
from __future__ import absolute_import
import tupak.gw.conversion
import tupak.gw.detector
import tupak.gw.likelihood
import tupak.gw.prior
import tupak.gw.source
import tupak.gw.utils
import tupak.gw.waveform_generator
from . import calibration
from . import (calibration, conversion, detector, likelihood, prior, source,
utils, waveform_generator)
from tupak.gw.waveform_generator import WaveformGenerator
from tupak.gw.likelihood import GravitationalWaveTransient
from .waveform_generator import WaveformGenerator
from .likelihood import GravitationalWaveTransient
from __future__ import division
import tupak
import numpy as np
import pandas as pd
from tupak.core.utils import logger
from ..core.utils import logger, solar_mass
from ..core.prior import DeltaFunction
try:
from astropy.cosmology import z_at_value, Planck15
......@@ -535,7 +535,7 @@ def fill_from_fixed_priors(sample, priors):
output_sample = sample.copy()
if priors is not None:
for name in priors:
if isinstance(priors[name], tupak.core.prior.DeltaFunction):
if isinstance(priors[name], DeltaFunction):
output_sample[name] = priors[name].peak
return output_sample
......@@ -610,8 +610,8 @@ def generate_component_spins(sample):
output_sample['tilt_1'], output_sample['tilt_2'],
output_sample['phi_12'], output_sample['a_1'],
output_sample['a_2'],
output_sample['mass_1'] * tupak.core.utils.solar_mass,
output_sample['mass_2'] * tupak.core.utils.solar_mass,
output_sample['mass_1'] * solar_mass,
output_sample['mass_2'] * solar_mass,
output_sample['reference_frequency'], output_sample['phase'])
output_sample['phi_1'] =\
......@@ -637,8 +637,8 @@ def generate_component_spins(sample):
output_sample['tilt_1'][ii], output_sample['tilt_2'][ii],
output_sample['phi_12'][ii], output_sample['a_1'][ii],
output_sample['a_2'][ii],
output_sample['mass_1'][ii] * tupak.core.utils.solar_mass,
output_sample['mass_2'][ii] * tupak.core.utils.solar_mass,
output_sample['mass_1'][ii] * solar_mass,
output_sample['mass_2'][ii] * solar_mass,
output_sample['reference_frequency'][ii],
output_sample['phase'][ii])
......
......@@ -7,9 +7,9 @@ import numpy as np
from scipy.signal.windows import tukey
from scipy.interpolate import interp1d
from tupak.gw import utils as gwutils
from tupak.core import utils
from tupak.core.utils import logger
from . import utils as gwutils
from ..core import utils
from ..core.utils import logger
from .calibration import Recalibrate
try:
......
......@@ -8,11 +8,14 @@ except ImportError:
from scipy.misc import logsumexp
from scipy.special import i0e
import tupak
from tupak.core import likelihood as likelihood
from tupak.core.utils import logger
from tupak.gw.prior import BBHPriorSet
from tupak.core.prior import Uniform
from ..core import likelihood
from ..core.utils import logger
from ..core.prior import Prior, Uniform
from .detector import InterferometerList
from .prior import BBHPriorSet
from .source import lal_binary_black_hole
from .utils import noise_weighted_inner_product
from .waveform_generator import WaveformGenerator
class GravitationalWaveTransient(likelihood.Likelihood):
......@@ -57,7 +60,7 @@ class GravitationalWaveTransient(likelihood.Likelihood):
self.waveform_generator = waveform_generator
likelihood.Likelihood.__init__(self, dict())
self.interferometers = tupak.gw.detector.InterferometerList(interferometers)
self.interferometers = InterferometerList(interferometers)
self.time_marginalization = time_marginalization
self.distance_marginalization = distance_marginalization
self.phase_marginalization = phase_marginalization
......@@ -111,7 +114,7 @@ class GravitationalWaveTransient(likelihood.Likelihood):
def _check_prior_is_set(self, key):
if key not in self.prior or not isinstance(
self.prior[key], tupak.core.prior.Prior):
self.prior[key], Prior):
logger.warning(
'Prior not provided for {}, using the BBH default.'.format(key))
if key == 'geocent_time':
......@@ -138,7 +141,7 @@ class GravitationalWaveTransient(likelihood.Likelihood):
def noise_log_likelihood(self):
log_l = 0
for interferometer in self.interferometers:
log_l -= tupak.gw.utils.noise_weighted_inner_product(
log_l -= noise_weighted_inner_product(
interferometer.frequency_domain_strain,
interferometer.frequency_domain_strain,
interferometer.power_spectral_density_array,
......@@ -381,8 +384,10 @@ def get_binary_black_hole_likelihood(interferometers):
tupak.GravitationalWaveTransient: The likelihood to pass to `run_sampler`
"""
waveform_generator = tupak.gw.waveform_generator.WaveformGenerator(
duration=interferometers.duration, sampling_frequency=interferometers.sampling_frequency,
frequency_domain_source_model=tupak.gw.source.lal_binary_black_hole,
waveform_arguments={'waveform_approximant': 'IMRPhenomPv2', 'reference_frequency': 50})
return tupak.gw.likelihood.GravitationalWaveTransient(interferometers, waveform_generator)
waveform_generator = WaveformGenerator(
duration=interferometers.duration,
sampling_frequency=interferometers.sampling_frequency,
frequency_domain_source_model=lal_binary_black_hole,
waveform_arguments={'waveform_approximant': 'IMRPhenomPv2',
'reference_frequency': 50})
return GravitationalWaveTransient(interferometers, waveform_generator)
import os
import numpy as np
from scipy.interpolate import UnivariateSpline
from ..core.prior import (PriorSet, Uniform, FromFile, Prior, DeltaFunction,
Gaussian, Interped)
from ..core.utils import logger
import numpy as np
from scipy.interpolate import UnivariateSpline
class UniformComovingVolume(FromFile):
......
......@@ -2,8 +2,8 @@ from __future__ import division, print_function
import numpy as np
from tupak.core.utils import logger
from tupak.core import utils
from ..core import utils
from ..core.utils import logger
try:
import lalsimulation as lalsim
......
......@@ -3,7 +3,8 @@ import os
import numpy as np
from ..core.utils import (gps_time_to_gmst, ra_dec_to_theta_phi, speed_of_light, logger)
from ..core.utils import (gps_time_to_gmst, ra_dec_to_theta_phi,
speed_of_light, logger)
try:
from gwpy.timeseries import TimeSeries
......
from tupak.core import utils
import numpy as np
from ..core import utils
class WaveformGenerator(object):
......
from __future__ import absolute_import
import tupak.hyper.likelihood
import tupak.hyper.model
from . import likelihood, model
Markdown is supported
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