def getAxis(self,X,Y): """ return the proper axis limits for the plots """ out = [] mM = [(min(X),max(X)),(min(Y),max(Y))] for i,j in mM: #YJC: checking if values are negative, if yes, return 0 and break if j <0 or i <0: return 0 log_i = scipy.log10(i) d, I = scipy.modf(log_i) if log_i < 0: add = 0.5 *(scipy.absolute(d)<0.5) else: add = 0.5 *(scipy.absolute(d)>0.5) m = scipy.floor(log_i) + add out.append(10**m) log_j = scipy.log10(j) d, I = scipy.modf(log_j) if log_j < 0: add = - 0.5 *(scipy.absolute(d)>0.5) else: add = - 0.5 *(scipy.absolute(d)<0.5) m = scipy.ceil(log_j) + add out.append(10**m) return tuple(out)
def integrate(self,u,lambd): dt = self.dt Dt = self.Dt dx = self.dx alpha, steps = scipy.modf(Dt/dt) # we assume that u is the logarithm of the density # print "in integrate" # print "u: ", u # print "+++" y=scipy.exp(u) # print "y: ", y # print "+++" for i in range(int(steps)): rhs=self.rhs(y,lambd) y=y+rhs*dt rhs=self.rhs(y,lambd) y_new=y+rhs*dt y_Dt = alpha*y_new+(1-alpha)*y # print "y_Dt: ", y_Dt # print '++++' # print sum(y_Dt) # print "+++" u_Dt = scipy.log(y_Dt) # print "u_Dt: ", u_Dt # print "-------" return u_Dt
def integrate(self, u, lambd): dt = self.dt Dt = self.Dt dx = self.dx alpha, steps = scipy.modf(Dt / dt) y = scipy.array(u) # we assume that u is the logarithm of the density # print "in integrate" # print "u: ", u # print "+++" for i in range(int(steps)): rhs = self.rhs(y, lambd) y = y + rhs * dt rhs = self.rhs(y, lambd) y_new = y + rhs * dt y_Dt = alpha * y_new + (1 - alpha) * y # print '++++' u_Dt = scipy.array(y_Dt) # print sum(u_Dt) # print "+++" # print "u_Dt: ", u_Dt # print "-------" return u_Dt