def genQuadPnts(self): # get quad points and weights x_uq = mkBlnkDbl2D() w_uq = mkBlnkDbl1D() print "Create an instance of Quad class" level = self.nord + 1 # Choose sparse quadrature level that is one higher than the order q = uqtkquad.Quad('LU', 'sparse', self.ndim, level, 0, 1) q.SetRule() q.GetRule(x_uq, w_uq) self.q = q print "Number of quad points is " + str(len(x_uq)) self.w_np = uqtk2NumpyDbl(w_uq) self.x_np = uqtk2NumpyDbl(x_uq) print self.x_np.shape # Map Quadrature points from the standard [-1,1] to the parameter values self.lam_np = 0.5*(self.parRanges[1,]+self.parRanges[0,]) + \ 0.5*(self.parRanges[1,]-self.parRanges[0,])*self.x_np self.saveDat(self.lam_np, 'x.dat') # locations at which to evaluate forward model self.saveDat(self.w_np, 'w.dat') # quadrature weights
def generate_qw(ndim, param, sp='full', type='LU'): # get quad points and weights x = uqtkarray.dblArray2D() w = uqtkarray.dblArray1D() #print 'Create an instance of Quad class' q = uqtkquad.Quad(type, sp, ndim, param) #print 'Now set and get the quadrature rule...' q.SetRule() q.GetRule(x, w) # print out x and w #print 'Displaying the quadrature points and weights:\n' #print x #print w n = len(x) # get quad points x_np = zeros((n, ndim)) x.getnpdblArray(x_np) # get quad weights w_np = zeros(n) w.getnpdblArray(w_np) xpts = array((x_np)) return xpts, w_np
def genQuadPnts(self): # get quad points and weights x_uq = mkBlnkDbl2D() w_uq = mkBlnkDbl1D() print "Create an instance of Quad class" level = 1 q = uqtkquad.Quad('LU', 'sparse', self.ndim, level, 0, 1) q.SetRule() q.GetRule(x_uq, w_uq) self.q = q print "Number of quad points is " + str(len(x_uq)) self.w_np = uqtk2NumpyDbl(w_uq) self.x_np = uqtk2NumpyDbl(x_uq) #self.x_np = self.x_np*self.prmsVal self.saveDat(self.x_np, 'x.dat') self.saveDat(self.w_np, 'w.dat')
try: import PyUQTk.array as uqtkarray import PyUQTk.quad as uqtkquad import PyUQTk.pce as uqtkpce except ImportError: print "PyUQTk array and quad module not found" # get quad points and weights x = uqtkarray.dblArray2D() w = uqtkarray.dblArray1D() print 'Create an instance of Quad class' ndim = 1 level = 8 q = uqtkquad.Quad('LU', 'full', ndim, level) print 'Now set and get the quadrature rule...' q.SetRule() q.GetRule(x, w) # print out x and w print 'Displaying the quadrature points and weights:\n' # print x # print w n = len(x) print 'Number of quad points is ', n, '\n' # conver to numpy arrays x_np = zeros((len(x), 1)) w_np = zeros(len(x)) x.getnpdblArray(x_np)