def Nov18(): a =loadtxt('/home/chris/Dropbox/DataWeiss/151118/Dots with untreated alumina.csv', unpack = True, delimiter = ',', skiprows = 1,usecols = (0,1,7,9,11)) s = pf(a[0][0:150],a[4][0:150],1) a[4]-=polyval(a[0],s) for i in a[array([1,3,4])]:#[1:]: i-=i[150] r = findpeak(a[0],i,(405,420)) print r i-=i[150] i/=r[1] plot(a[0], i) legend(['as prep', 'alumina 4 mg', 'alumina 5.8 mg']) ylabel('absorbance') xlabel('wavelength') return 0
def findderivative(x,y,derivorder=1): window_len=25 # if spectrum.ndim != 1: # raise ValueError, "smooth only accepts 1 dimension arrays." # # if spectrum.size < window_len: # raise ValueError, "Input vector needs to be bigger than window size." retval = numpy.ndarray(y.shape) for i in range(y.size): i_min = max(0,i-window_len/2) i_max = min( i+window_len/2-1, y.size) fit = pf(x[i_min:i_max+1],y[i_min:i_max+1],min(5,window_len)) retval[i] = polyval(x[i],polyder(fit,derivorder),tensor=False) return retval
def exampleplot(): figure() ax1=subplot(121) ax2=subplot(122) c = linspace(0,10,1000) cmaxdot = 0.2 # subplot(121) for K in [100,1000,10000]: K=float(K) a = K #def b():return -ctot0*K - K*c +K*cmaxdot+1 #def d():return ctot0+c # #def cfree():return (-b()+sqrt(b()**2-4*a*d()))/(2*a) a=K b=1+K*cmaxdot-K*c d=-c cfree = (-b+sqrt(b**2-4*a*d))/(2*a) cfree2= (-b-sqrt(b**2-4*a*d))/(2*a) r = pf(c[10:15],cfree[10:15],1) #print r[0], (K+0.5*((1+K*cmaxdot-K*xlarge)**2+4*K*xlarge)**-0.5*(-2*K*(1+K*cmaxdot-K*xlarge)+4*K))/(2*K) M = (r[0]-0.5)**2 A = (M-0.5)#*xlarge**2 B = (2*M-1)#*xlarge C = M-0.5 print M,A,B,C,B**2 #print K,'estimated K=',(-B+sqrt(B**2-4*A*C))/(2*A) print 'early slope=', cfree[0]/c[1],cfree[0]/c[1]-c[1]*r[1] # plot(c[:10],(c[:10]-0.1)*r[1]+cfree[10]/c[10]) ax1.plot(c,cfree/c) ax2.plot(c,cfree/c) # plot(c,findderivative(c,cfree/c,derivorder=1)/200,'--') #plot(c,fd(c,cfree/c),'-.') #plot(c,K*cfree/(1+K*cfree)) # plot(c,cfree2) legend([1,10,100,1000]) ax1.set_ylabel('$\delta_{observed}$',fontsize=24) #ax2.set_ylabel('$\delta$',fontsize=24) ax1.set_xlabel('c$_{total}$ (mM)', fontsize=24) ax2.set_xlabel('c$_{total}$ (mM)', fontsize=24) ax2.set_xlim((0,0.4)) ax2.set_xticks([0,0.1,0.2,0.3,0.4,0.5]) ax1.set_yticks([0,1]) ax2.set_yticks([]) ax1.set_yticklabels(['$\delta_{bound}$','$\delta_{free}$'],fontsize=24) figure() ax1=subplot(211) ax2=subplot(212) for K in [50]: K=float(K) a = K #def b():return -ctot0*K - K*c +K*cmaxdot+1 #def d():return ctot0+c # #def cfree():return (-b()+sqrt(b()**2-4*a*d()))/(2*a) a=K b=1+K*cmaxdot-K*c d=-c cfree = (-b+sqrt(b**2-4*a*d))/(2*a) ax1.plot(c,cfree/c) ax2.plot(c,c-cfree)#K*cfree*cmaxdot/(1+K*cfree)) ax2.plot(c,cfree,'--') ax2.plot(c,c) legend(['bound', 'free', 'total'],loc=2) ax1.set_ylabel('$\delta_{observed}$',fontsize=24) ax2.set_xlabel('c$_{total}$ (mM)', fontsize=24) ax2.set_ylabel('c (mM)',fontsize=24) #ax2.set_xticks([0,0.1,0.2,0.3,0.4,0.5]) ax1.set_yticks([0,1]) ax1.set_xlim(0,1) ax2.set_xlim(0,1) #ax1.set_ylim(-0.1,1.1) ax2.set_ylim(0,1) ax1.set_yticklabels(['$\delta_{bound}$','$\delta_{free}$'],fontsize=24) # subplot(122) # for cinit in [0,0.1,0.2,0.5,1]: # a = K # #def b():return -ctot0*K - K*c +K*cmaxdot+1 # #def d():return ctot0+c # # # #def cfree():return (-b()+sqrt(b()**2-4*a*d()))/(2*a) # ctot = cinit+c # a=K # b=1+K*cmaxdot-K*ctot # d=-ctot # # cfree = (-b+sqrt(b**2-4*a*d))/(2*a) # # plot(c,cfree/ctot) # # plot(c,cfree2) # legend([0,0.1,0.2,0.5,1]) return 0