def __init__(self, path, data, command_line): # Standard initialization, reads the .data Likelihood.__init__(self, path, data, command_line) # Extra needed cosmological paramters self.need_cosmo_arguments(data, { 'output': 'tCl pCl lCl', 'lensing': 'yes' }) try: import pywlik except ImportError: raise io_mp.MissingLibraryError( "You must first activate the binaries from the wmap wrapper." + " Please run : \n " + "]$ source /path/to/wrapper_wmap/bin/clik_profile.sh\n " + "and try again.") # try importing the wrapper_wmap self.wmaplike = pywlik.wlik(self.large_data_directory, self.ttmin, self.ttmax, self.temin, self.temax, self.use_gibbs, self.use_lowlpol) # self.cls = np.loadtxt(self.cl_test_file) # loglike = self.wmaplike(self.cls) # print "got %g expected %g"%(loglike,-845.483) self.l_max = max(self.ttmax, self.temax) self.need_cosmo_arguments(data, {'l_max_scalars': self.l_max}) # deal with nuisance parameters try: self.use_nuisance except: self.use_nuisance = [] self.read_contamination_spectra(data) pass
Since there are a lot of file manipulation involved, the "pandas" library has to be installed -- it is an 8-fold improvement in speed over numpy, and a 2-fold improvement over a fast Python implementation. The "numexpr" library is also needed for doing the fast array manipulations, done with blas daxpy function in the original c++ code. Both can be installed with pip (Python package manager) easily. """ import numpy as np import scipy.linalg as la import montepython.io_mp as io_mp try: import numexpr as ne except ImportError: raise io_mp.MissingLibraryError( "This likelihood has intensive array manipulations. You " "have to install the numexpr Python package. Please type:\n" "(sudo) pip install numexpr --user") from montepython.likelihood_class import Likelihood_sn class Pantheon(Likelihood_sn): def __init__(self, path, data, command_line): # Unusual construction, since the data files are not distributed # alongside Pantheon (size problems) try: Likelihood_sn.__init__(self, path, data, command_line) except IOError: raise io_mp.LikelihoodError( "The Pantheon data files were not found. Please check if " "the following files are in the data/Pantheon directory: "