Ejemplo n.º 1
0
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()
Ejemplo n.º 2
0
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()
Ejemplo n.º 3
0
def plot_variances(chemnames, logprior, scale=1.0, return_var=False):
    """ 
    chemnames: list of chemical names 
    logprior: prior on params. logprior = log(1000.0) means parameters
    allowed to fluctuate by a factor of 1000 """
    times, bestfit, var = variances(chemnames, logprior)
    for key in bestfit.keys():
        Plotting.figure()
        Plotting.plot(times, bestfit[key] / scale)
        Plotting.hold(True)
        Plotting.plot(times,
                      bestfit[key] / scale + scipy.sqrt(var[key]) / scale,
                      'r--')
        Plotting.plot(times,
                      bestfit[key] / scale - scipy.sqrt(var[key]) / scale,
                      'r--')
        Plotting.title(key, fontsize=16)
        Plotting.xlabel('time (minutes)', fontsize=16)
        Plotting.ylabel('number of molecules', fontsize=16)
        xtics = Plotting.gca().get_xticklabels()
        ytics = Plotting.gca().get_yticklabels()
        Plotting.setp(xtics, size=16)
        Plotting.setp(ytics, size=16)
        #Plotting.axis([0.0,40.0,-.01,1.2e4])
    Plotting.show()
    if return_var:
        return times, bestfit, var
Ejemplo n.º 4
0
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
Ejemplo n.º 5
0
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
Ejemplo n.º 6
0
def plot_variances_log_chems(chemnames,logprior) :
    """
    chemnames: list of chemical names
    logprior: prior on params
    Plots the standard deviation of the chemicals when the variance
    is computed using logs of the chemical trajectories. This 
    makes sure the final plots do not have best_fit+-stddev that
    do not become negative """
    times, bestfit, var = variances_log_chems(chemnames,logprior)
    for key in bestfit.keys() :
        Plotting.figure()    
        Plotting.plot(times,bestfit[key])
        Plotting.hold(True)    
        Plotting.plot(times,bestfit[key]*scipy.exp(scipy.sqrt(var[key])),'r-')
        Plotting.plot(times,bestfit[key]*scipy.exp(-scipy.sqrt(var[key])),'r-')
        Plotting.title(key,fontsize=14)
        Plotting.xlabel('time')
        Plotting.ylabel('arb. units')
        #Plotting.axis([0.0,40.0,-.01,1.2e4])    
    Plotting.show()
Ejemplo n.º 7
0
def plot_variances_log_chems(chemnames, logprior):
    """
    chemnames: list of chemical names
    logprior: prior on params
    Plots the standard deviation of the chemicals when the variance
    is computed using logs of the chemical trajectories. This 
    makes sure the final plots do not have best_fit+-stddev that
    do not become negative """
    times, bestfit, var = variances_log_chems(chemnames, logprior)
    for key in list(bestfit.keys()):
        Plotting.figure()
        Plotting.plot(times, bestfit[key])
        Plotting.hold(True)
        Plotting.plot(times, bestfit[key] * scipy.exp(np.sqrt(var[key])), 'r-')
        Plotting.plot(times, bestfit[key] * scipy.exp(-np.sqrt(var[key])),
                      'r-')
        Plotting.title(key, fontsize=14)
        Plotting.xlabel('time')
        Plotting.ylabel('arb. units')
        #Plotting.axis([0.0,40.0,-.01,1.2e4])
    Plotting.show()
Ejemplo n.º 8
0
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
Ejemplo n.º 9
0
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
Ejemplo n.º 10
0
def plot_variances(chemnames,logprior,scale=1.0,return_var = False) :
    """ 
    chemnames: list of chemical names 
    logprior: prior on params. logprior = log(1000.0) means parameters
    allowed to fluctuate by a factor of 1000 """
    times, bestfit, var = variances(chemnames,logprior)
    for key in bestfit.keys() :
        Plotting.figure()    
        Plotting.plot(times,bestfit[key]/scale)
        Plotting.hold(True)    
        Plotting.plot(times,bestfit[key]/scale + scipy.sqrt(var[key])/scale,'r--')
        Plotting.plot(times,bestfit[key]/scale - scipy.sqrt(var[key])/scale,'r--')
        Plotting.title(key,fontsize=16)
        Plotting.xlabel('time (minutes)',fontsize=16)
        Plotting.ylabel('number of molecules',fontsize=16)
        xtics = Plotting.gca().get_xticklabels()
        ytics = Plotting.gca().get_yticklabels()
        Plotting.setp(xtics,size=16)
        Plotting.setp(ytics,size=16)
        #Plotting.axis([0.0,40.0,-.01,1.2e4])    
    Plotting.show()
    if return_var :
        return times, bestfit, var