예제 #1
0
파일: rec_mod.py 프로젝트: eirikgje/cambown
    def get_tau(self, x):
        """ Uses a precomputed spline to find tau at x """

        #Hack to work with the ode solver that sometimes wants an x value
        #later than today
        if isinstance(x, np.ndarray):
            x[x > self.x_array[-1]] = self.x_array[-1]
        else:
            if x > self.x_array[-1]:
                x = self.x_array[-1]
        return np.exp(interpolation.splint(self.x_array, np.log(self.tau_array), self.tau_spline, x))
예제 #2
0
파일: rec_mod.py 프로젝트: eirikgje/cambown
    def get_tau_primed(self, x):
        """ Uses a spline of the derivative to find dtau/dx at x """

        #Hack to work with the ode solver that sometimes wants an x value
        #later than today
        if isinstance(x, np.ndarray):
            x[x > self.x_array[-1]] = self.x_array[-1]
        else:
            if x > self.x_array[-1]:
                x = self.x_array[-1]

        return -np.exp(interpolation.splint(self.x_array, np.log(-self.tau_der_array), self.tau_der_spline, x))
예제 #3
0
    def get_eta(self, x):
        """ Using input arrays, produces eta for a given value of x = ln a. """

        if self.eta_spline is None:
            if self.eta_array is None:
                #Initialize the eta array based on the scale factor values. 
                #We need to append to an array with a single entry because 
                #cumtrapz returns an array with one less value than the input 
                #array
                self.eta_array = np.append(np.array([self.eta_init]), s_o_l * cumtrapz(1 / (get_H_p(self.x_array, self.bg_params)), self.x_array))
            self.eta_spline = interpolation.cubic_spline(self.x_array, self.eta_array)
#            self.eta_splint = scipy.interpolate.interp1d(self.a_array, self.eta_array, kind='cubic')
        if isinstance(x, np.ndarray):
            x[x > self.x_array[-1]] = self.x_array[-1]
        elif isinstance(x, float):
            if x > self.x_array[-1]:
                x = self.x_array[-1]
        return interpolation.splint(self.x_array, self.eta_array, self.eta_spline, x)
예제 #4
0
파일: rec_mod.py 프로젝트: eirikgje/cambown
    def get_g_double_primed(self, x):
        """ Uses precomputed information to compute the double derivative of the visibility function. """

        return interpolation.splint(self.x_array, self.g_spline, self.g2_spline, x)
예제 #5
0
파일: rec_mod.py 프로젝트: eirikgje/cambown
    def get_g(self, x):
        """ Uses precomputed information to compute the visibility function. """

        return interpolation.splint(self.x_array, self.g_array, self.g_spline, x)
예제 #6
0
파일: rec_mod.py 프로젝트: eirikgje/cambown
    def get_ne(self, x):
        """ Uses a precomputed spline to find the electron density at x. """

        return np.exp(interpolation.splint(self.x_array, np.log(self.ne_array), self.ne_spline, x))