コード例 #1
0
ファイル: plotTovProfiles.py プロジェクト: jeffdk/eosDriver
def findPointOfHalfM(modelData, fract=0.5):
    M = modelData['m'][-1]
    Mfract = M * fract
    #i = lookupIndexBisect(M / 2.0, modelData['m'])
    rho = linInterp(Mfract, modelData['m'], modelData['rho'])
    r = linInterp(Mfract, modelData['m'], modelData['r'])
    p = linInterp(Mfract, modelData['m'], modelData['p'])

    return {'rho': rho, 'r': r, 'p': p}
コード例 #2
0
ファイル: inference.py プロジェクト: gatsby-sahani/gp-sde
    def predict_conditionalParams(self, idx, t):
        # interpolate points off grid
        T = t.size()[0]
        b_linp = torch.zeros(T, 1, self.nLatent).type(float_type)
        A_linp = torch.zeros(T, self.nLatent, self.nLatent).type(float_type)
        for i in range(T):
            b_linp[i, :, :] = linInterp(t[i], self.b_grid[idx],
                                        self.t_grid[idx])
            A_linp[i, :, :] = linInterp(t[i], self.A_grid[idx],
                                        self.t_grid[idx])

        return A_linp, b_linp
コード例 #3
0
ファイル: inference.py プロジェクト: gatsby-sahani/gp-sde
    def predict_marginals(self, idx, t):
        # function to evaluate GP at new points for trial idx
        # solve for m, S on grid
        m, S = self.solveForward_GaussMarkov_grid(self.initialMean[idx],
                                                  self.initialCov[idx], idx)

        # interpolate points off grid
        T = t.size()[0]
        m_linp = torch.zeros(T, 1, self.nLatent).type(float_type)
        S_linp = torch.zeros(T, self.nLatent, self.nLatent).type(float_type)
        for i in range(T):
            m_linp[i, :, :] = linInterp(t[i], m, self.t_grid[idx])
            S_linp[i, :, :] = linInterp(t[i], S, self.t_grid[idx])

        return m_linp, S_linp
コード例 #4
0
ファイル: eosDriver.py プロジェクト: jeffdk/eosDriver
 def rhobFromEdCached(self, ed):
     """
     Does linear interpolation in logspace of self.cachedRhobVsEd
     to invert rhob from given ed
     """
     answer = linInterp(numpy.log10(ed),
                        self.cachedRhobVsEd[0],
                        self.cachedRhobVsEd[1])
     return numpy.power(10.0, answer)
コード例 #5
0
ファイル: eosDriver.py プロジェクト: jeffdk/eosDriver
        def quantityOfSolveVar(x):
            #Here we construct the point to interpolate at, but we
            # must do it carefully since we don't know apriori what
            # solveVar is
            point = []
            #todo factor this for out of quantityOfSolveVar
            for indVar in self.indVars:
                if indVar not in pointDict:
                    #print "NOT", indVar
                    value = x
                else:
                    value = pointDict[indVar]
                    if indVar == 'logtemp':
                        value = pointAsFunctionOfSolveVar(x)
                #print indVar, value
                point.append(value)
            point = tuple(point)
            if setBetaEqInSolve:
#                tempPointDict = {self.indVars[i]: point[i]
#                                 for i in range(len(self.indVars)) if not self.indVars[i] == 'ye'}
                for i in range(len(self.indVars)):
                    print self.indVars[i]
                tempPointDict = []
                print "Should not have gotten to this point; debug me!"
                sys.exit()
                yeForSolve = linInterp(tempPointDict['logrho'],
                                       cachedBetaEqYeVsRhos[0],
                                       cachedBetaEqYeVsRhos[1])
                tempPointDict.update({'ye': yeForSolve})
                point = self.pointFromDict(tempPointDict)
                del tempPointDict
            answer = function(x, multidimInterp(point, indVarsTable,
                                                self.h5file[quantity][...],
                                                linInterp, 2)
                              ) - target
            return answer