def plot_variances_subplot(chemnames, logprior): times, bestfit, var = variances(chemnames, logprior) nallplots = len(chemnames) # 9 at a time nfigs = nallplots / 9 # integer division -- no fractional part for figno in range(1, nfigs + 1): Plotting.figure() for i in range(0, 9): Plotting.subplot(3, 3, i + 1) chemind = i + (figno - 1) * 9 Plotting.plot(times, bestfit[chemnames[chemind]]) Plotting.hold(True) Plotting.plot( times, bestfit[chemnames[chemind]] + scipy.sqrt(var[chemnames[chemind]]), 'r-') Plotting.plot( times, bestfit[chemnames[chemind]] - scipy.sqrt(var[chemnames[chemind]]), 'r-') yt = Plotting.yticks() Plotting.axis([0, 100.0, yt[0], yt[-1]]) Plotting.title(chemnames[chemind]) Plotting.xlabel('time') Plotting.ylabel('arb. units') xt = Plotting.xticks() Plotting.xticks([xt[0], xt[-1]]) Plotting.savefig('./figs/variance_wt_' + i.__str__() + '.ps') Plotting.show()
def plot_variances_subplot(chemnames,logprior) : times, bestfit, var = variances(chemnames,logprior) nallplots = len(chemnames) # 9 at a time nfigs = nallplots/9 # integer division -- no fractional part for figno in range(1,nfigs+1) : Plotting.figure() for i in range(0,9) : Plotting.subplot(3,3,i+1) chemind = i+(figno-1)*9 Plotting.plot(times,bestfit[chemnames[chemind]]) Plotting.hold(True) Plotting.plot(times,bestfit[chemnames[chemind]] + scipy.sqrt(var[chemnames[chemind]]),'r-') Plotting.plot(times,bestfit[chemnames[chemind]] - scipy.sqrt(var[chemnames[chemind]]),'r-') yt = Plotting.yticks() Plotting.axis([0,100.0,yt[0],yt[-1]]) Plotting.title(chemnames[chemind]) Plotting.xlabel('time') Plotting.ylabel('arb. units') xt = Plotting.xticks() Plotting.xticks([xt[0],xt[-1]]) Plotting.savefig('./figs/variance_wt_'+i.__str__()+'.ps') Plotting.show()
def plot_variance_newpoint(chemnames,sensvect_design,logprior=1.0e20, return_data = True) : """ chemnames: list of chemical names sensvect_design: a sensivity vector of a quantity that is measurable This will plot the old and new variances of the chemicals in chemnames, given a new measurement that has sensitivity vector sensvect_design """ times,bestfit,var = variances(chemnames,logprior) times,varchange = variance_change(chemnames,sensvect_design,logprior) for key in bestfit.keys() : Plotting.figure() Plotting.plot(times,bestfit[key]) Plotting.hold(True) Plotting.plot(times,bestfit[key] + scipy.sqrt(var[key]),'r-') Plotting.plot(times,bestfit[key] - scipy.sqrt(var[key]),'r-') Plotting.plot(times,bestfit[key] + scipy.sqrt(var[key]+varchange[key]),'k--') Plotting.plot(times,bestfit[key] - scipy.sqrt(var[key]+varchange[key]),'k--') Plotting.title(key,fontsize=14) Plotting.xlabel('time') Plotting.ylabel('arb. units') Plotting.axis([0.0,40.0,-.01,1.2e4]) Plotting.show() if return_data : newvar = {} for ky in var.keys() : newvar[ky] = var[key] + varchange[key] return times,bestfit,newvar
def plot_variance_newweights(weights, chemnames, sensarray_design, logprior=1.0e20, scale=1.0, return_data=True): """ weights : a proposed set of weights for each of the row vectors in sensarray_design chemnames : a list of chemicals for which we will plot the variance logprior : as before This will plot the old and new variances on chemnames, similar to above. NOTE: the weights that are passed in do not necessarily have to sum to one. e.g. if the weights are normalized such that max(weights) = 1, then by scaling all the weights by 1/sigma, you are then assuming that the most accurate measurement has an error of size sigma. sigma for example could be 20% of the maximum value of a trajectory. """ times, bestfit, var = variances(chemnames, logprior) times, varchange = var_change_weighted(weights, chemnames, sensarray_design, logprior) for key in bestfit.keys(): Plotting.figure() Plotting.plot(times, scale * bestfit[key]) Plotting.hold(True) Plotting.plot(times, scale * bestfit[key] + scale * scipy.sqrt(var[key]), 'r-') Plotting.plot(times, scale * bestfit[key] - scale * scipy.sqrt(var[key]), 'r-') Plotting.plot( times, scale * bestfit[key] + scale * scipy.sqrt(var[key] + varchange[key]), 'k--') Plotting.plot( times, scale * bestfit[key] - scale * scipy.sqrt(var[key] + varchange[key]), 'k--') Plotting.title(key, fontsize=14) Plotting.xlabel('time') Plotting.ylabel('arb. units') Plotting.axis([0.0, 40.0, -.01, 1.2e4]) Plotting.show() if return_data: newvar = {} for ky in var.keys(): newvar[ky] = var[key] + varchange[key] return times, bestfit, newvar
def plot_variance_newpoint(chemnames, sensvect_design, logprior=1.0e20, return_data=True): """ chemnames: list of chemical names sensvect_design: a sensivity vector of a quantity that is measurable This will plot the old and new variances of the chemicals in chemnames, given a new measurement that has sensitivity vector sensvect_design """ times, bestfit, var = variances(chemnames, logprior) times, varchange = variance_change(chemnames, sensvect_design, logprior) for key in bestfit.keys(): Plotting.figure() Plotting.plot(times, bestfit[key]) Plotting.hold(True) Plotting.plot(times, bestfit[key] + scipy.sqrt(var[key]), 'r-') Plotting.plot(times, bestfit[key] - scipy.sqrt(var[key]), 'r-') Plotting.plot(times, bestfit[key] + scipy.sqrt(var[key] + varchange[key]), 'k--') Plotting.plot(times, bestfit[key] - scipy.sqrt(var[key] + varchange[key]), 'k--') Plotting.title(key, fontsize=14) Plotting.xlabel('time') Plotting.ylabel('arb. units') Plotting.axis([0.0, 40.0, -.01, 1.2e4]) Plotting.show() if return_data: newvar = {} for ky in var.keys(): newvar[ky] = var[key] + varchange[key] return times, bestfit, newvar
def plot_variance_newweights(weights,chemnames,sensarray_design,logprior=1.0e20,scale=1.0,return_data = True) : """ weights : a proposed set of weights for each of the row vectors in sensarray_design chemnames : a list of chemicals for which we will plot the variance logprior : as before This will plot the old and new variances on chemnames, similar to above. NOTE: the weights that are passed in do not necessarily have to sum to one. e.g. if the weights are normalized such that max(weights) = 1, then by scaling all the weights by 1/sigma, you are then assuming that the most accurate measurement has an error of size sigma. sigma for example could be 20% of the maximum value of a trajectory. """ times,bestfit,var = variances(chemnames,logprior) times,varchange = var_change_weighted(weights,chemnames,sensarray_design,logprior) for key in bestfit.keys() : Plotting.figure() Plotting.plot(times,scale*bestfit[key]) Plotting.hold(True) Plotting.plot(times,scale*bestfit[key] + scale*scipy.sqrt(var[key]),'r-') Plotting.plot(times,scale*bestfit[key] - scale*scipy.sqrt(var[key]),'r-') Plotting.plot(times,scale*bestfit[key] + scale*scipy.sqrt(var[key]+varchange[key]),'k--') Plotting.plot(times,scale*bestfit[key] - scale*scipy.sqrt(var[key]+varchange[key]),'k--') Plotting.title(key,fontsize=14) Plotting.xlabel('time') Plotting.ylabel('arb. units') Plotting.axis([0.0,40.0,-.01,1.2e4]) Plotting.show() if return_data : newvar = {} for ky in var.keys() : newvar[ky] = var[key] + varchange[key] return times,bestfit,newvar