Пример #1
0
def plotStats(numBars,numTrials,trialStats):
    f = pltUtil.pFigure()
    tickLabelX = np.arange(0,numBars)
    colorCycler = pltUtil.cycleColors()
    ax = plt.subplot(1,1,1)
    axRSQ = pltUtil.secondAxis(ax,'RSQ',[0,1.0])
    wid = 1/(numTrials*numBars)
    plt.title('Comparison of Surface Modeling Parameters')
    barDict = dict(elinewidth=4, ecolor='m')
    for t in range(numTrials):
        # XXX fix this to make it more general...
        RSQ = trialStats[t,-1]
        numMeanStd = numParams-1
        middle = int(numMeanStd/2)
        meanVals = trialStats[t,0:middle]
        stdVals = trialStats[t,middle:numMeanStd] 
        numVals = len(meanVals)
        xVals = tickLabelX+wid*t
        mColor = next(colorCycler)
        mLabel = trials[t]
        ax.bar(xVals[0:numVals],meanVals,yerr=0.2*stdVals,
               color=mColor,error_kw = barDict,align='center',label=mLabel)
        axRSQ.bar(xVals[numVals],RSQ,width=wid,color=mColor,align='center',
                  label=mLabel)
        # only the second time, add a third axis
    ax.legend(loc='upper left')
    ax.set_ylabel('Tau value (seconds)')
    plt.xlim([-0.5,max(xVals)*1.1])
    plt.xticks(tickLabelX, statsLabel)
    pltUtil.saveFigure(f,"Comparison")
Пример #2
0
def plotAlignments(outDir,alignments,scoreOptimal,label):
    fontSize = 25
    scores = [ getAlignScore(a) for a in alignments ] 
    fig = pPlotUtil.figure(xSize=24,ySize=12)
    plt.subplot(1,2,1)
    meanScore,stdevScore,bins = plotScoreHistograms(scores,fontSize,'k')
    plt.title("Shuffled DNA alignment Histogram",
              fontsize=fontSize)
    pdfFunc = norm(loc=meanScore,scale=stdevScore).pdf(bins)
    plotPDF = lambda :  plt.plot(bins,pdfFunc,'g--',linewidth=3.0,
                                 label="Normal(mean,var)")
    plotPDF()
    plt.legend(fontsize=fontSize)
    ax = plt.subplot(1,2,2)
    plotScoreHistograms(scores,fontSize)
    plotPDF()
    zScore = (scoreOptimal-meanScore)/stdevScore
    print("Z Score for {:s} is {:.2f}".format(label,zScore))
    # ??? is this the real p Value? Dont think so
    extrProb = 1-norm().cdf(zScore)
    plt.title(("Histogram of optimal alignment score for {:d} trials\n" + 
               "Optimal score: {:d}*sigma from shuffled mean.\n"
               "P(shuffled score>=optimal) ~ {:.5g}").\
              format(len(scores),int(zScore),extrProb),fontsize=fontSize)
    plt.axvline(scoreOptimal,color='r',linestyle='--',
                label="Optimal global alignment score using {:s}: {:d}".\
                format(label,int(scoreOptimal)))
    plt.legend(loc='best',fontsize=fontSize)
    pPlotUtil.savefig(fig,outDir+ "q2Histograms" + label)
Пример #3
0
def plotErrorAnalysis(mean,std,params,labels,fullOutput):
    rowsPerPlot = min(4,len(mean))
    fig = pPlotUtil.figure(xSize=rowsPerPlot*6,ySize=len(mean)*4)
    nTrials = len(mean)
    colors = pPlotUtil.cmap(nTrials)
    minP = min([ min(p) for p in params] )
    maxP = max([ max(p) for p in params] )
    lowerAcc = min([min(acc.flatten()) for acc in mean])
    lowerBounds = [(meanV[:,1]-stdV[:,1]) for meanV,stdV in zip(mean,std) ]
    validLowerBound = np.array([np.max(bound) for bound in lowerBounds ])
    bestIdx = np.array([np.argmax(bound) for bound in lowerBounds ] )
    sortedBestValid = np.argsort(validLowerBound)[::-1]
    for idx in sortedBestValid:
        print("{:s} has lower accuracy of {:.3f} at condition {:.2g}".\
            format(labels[idx],validLowerBound[idx],bestIdx[idx]))
    i=0
    fontsize=20
    for meanV,stdV,pVals,lab in zip(mean,std,params,labels):
        ax=plt.subplot(np.ceil(nTrials/rowsPerPlot),rowsPerPlot,i+1)
        plt.errorbar(pVals,meanV[:,0],stdV[:,0],fmt='o-',color=colors[i],
                     label='train')
        plt.errorbar(pVals,meanV[:,1],stdV[:,1],fmt='x--',color=colors[i],
                     label='vld')
        ax.set_xscale('log')
        plt.axhline(0.8,color='r',linestyle='--')
        plt.ylim([lowerAcc*0.9,1])
        plt.xlim([minP*0.7,maxP*1.3]) 
        plt.title(lab,fontsize=fontsize)
        i+=1
        plt.xlabel('Classifier parameter')
        plt.ylabel('Accuracy')
    pPlotUtil.savefig(fig,fullOutput + 'allAcc')
Пример #4
0
def PlotFec(sep,force,surfIdx = None,normalizeSep=True,normalizeFor=True,
            filterN=None,sensibleUnits=True):
    """
    Plot a force extension curve

    :param sep: The separation in meters
    :param force: The force in meters
    :param surfIdx: The index between approach and retract. if not present, 
    intuits approximate index from minmmum Sep
    :param normalizeSep: If true, then zeros sep to its minimum 
    :paran normalizeFor: If true, then zeros force to the median-filtered last
    5% of data, by separation (presummably, already detached) 
    :param filterT: Plots the raw data in grey, and filters 
    the force to the Number of points given. If none, assumes default % of curve
    :param sensibleUnits: Plots in nm and pN, defaults to true
    """
    if (surfIdx is None):
        surfIdx = np.argmin(sep)
    sepUnits,forceUnits = NormalizeSepForce(sep,force,surfIdx,normalizeSep,
                                            normalizeFor,sensibleUnits)
    if (filterN is None):
        filterN = int(np.ceil(DEF_FILTER_CONST*sepUnits.size))
    # POST: go ahead and normalize/color
    sepAppr = sepUnits[:surfIdx]
    sepRetr = sepUnits[surfIdx:]
    forceAppr = forceUnits[:surfIdx]
    forceRetr = forceUnits[surfIdx:]
    PlotFilteredSepForce(sepAppr,forceAppr,filterN=filterN,color='r',
                         label="Approach")
    PlotFilteredSepForce(sepRetr,forceRetr,filterN=filterN,color='b',
                         label="Retract")
    plt.xlim([min(sepUnits),max(sepUnits)])
    pPlotUtil.lazyLabel("Separation [nm]","Force [pN]","Force Extension Curve")
    return sepUnits,forceUnits
def saveAsSubplot(XByStages,YByStages,c1ByStages,c2ByStages,outputDir,
                  fileFormat):

    maxX = 0
    maxY = 0
    # number of times given by columns
    if (len(XByStages) == 0):
        print("For {:s}, didn't find any files...".format(outputDir))
        return
    nTimes = [ X.shape[1]-1 for X in XByStages]
    maxTimes = np.max(nTimes)
    numStages = len(XByStages)
    subPlots = numStages+1
    for i in range(numStages):
        maxX = max(XByStages[i].max(),maxX)
        maxY = max(YByStages[i].max(),maxY)
    rawImage = np.zeros((maxY,maxX))
    normV = matplotlib.colors.Normalize()
    cmap = greyToGreen
    nColors = 64
    for t in range(maxTimes):
        fig = plt.figure(dpi=500,figsize=(12,8))
        rawImage[:,:] = 0
        xVals = XByStages[0][:,t]
        goodIdx = xVals.nonzero()
        rawX = np.floor(xVals[goodIdx]).astype(np.uint64)-1
        rawY = np.floor(YByStages[0][:,t][goodIdx]).astype(np.uint64)-1
        rawIntensity = (c1ByStages[0][:,t][goodIdx]+
                        c2ByStages[0][:,t][goodIdx])
        rawImage[rawY,rawX] = 1.
        counter =1
        ax = plt.subplot(1,subPlots,counter)
        plt.title('Raw')
        plt.imshow(rawImage,interpolation='sinc',cmap=cmaps.gray,
                   aspect='auto',filterrad=4,origin='lower')
        hideAxis()
        counter += 1
        for i in range(numStages):
            plt.subplot(1,subPlots,counter)
            timeIdx = min(t,nTimes[i])
            plt.title('Filter #{:d}'.format(i))
            subAx = plotSingle(XByStages[i],YByStages[i],c1ByStages[i],
                               c2ByStages[i],maxX,maxY,timeIdx,cmap,nColors)
            counter += 1
        ### XXX TODO: add in colorbar based on fluorescence
        # Add an axes at position rect [left, bottom, width, height] 
        axis = fig.add_axes([0.2, 0.05,0.7, 0.025])
        m = plt.cm.ScalarMappable(cmap=greyToGreen)
        offsetTick = 4
        m.set_array([0,nColors-1])
        cbar = fig.colorbar(cax=axis,mappable=m,orientation='horizontal',
                            ticks=[offsetTick,nColors-1-offsetTick],
                            ticklocation='bottom')
        cbar.ax.set_xticklabels(['Unfolded', 'Folded'],fontsize=12)
        # save it
        pUtil.savefig(fig,outputDir + fileFormat.format(t),tight=False)
Пример #6
0
def plotScoreHistograms(scores,fontSize,edgecolor='none'):
    meanScore = np.mean(scores)
    stdevScore = np.std(scores)
    step = 1
    bins = np.arange(min(scores)-step,max(scores)+step,1)
    plt.hist(scores, bins,normed=True,label="Distr. "+
             "mean:{:.3g}, var: {:.3g})".format(meanScore,stdevScore**2),
             alpha=0.25,edgecolor=edgecolor)
    plt.xlabel("Optimal alignment score for sequence",fontsize=fontSize)
    plt.ylabel("Occurence of score",fontsize=fontSize)
    pPlotUtil.tickAxisFont()
    return meanScore,stdevScore,bins
Пример #7
0
def plotAccuracies(outDir,label,accMean,accStd,fitParam):
    fig = pPlotUtil.figure()
    plt.errorbar(fitParam,accMean[:,0],accStd[:,0],fmt='ro-',
                 label="Training Set")
    plt.errorbar(fitParam,accMean[:,1],accStd[:,1],fmt='kx-',
                 label="Validation Set")
    plt.xscale('log', nonposy='clip')
    plt.axhline(1,color='b',linestyle='--',label='max')
    plt.xlabel("Fit parameter")
    plt.ylabel("Accuracy")
    plt.xlim([min(fitParam)*0.7,max(fitParam)*1.3])
    plt.legend(loc='best')
    plt.title('Accuracy vs fit parameter for fitter: {:s}'.format(label))
    pPlotUtil.savefig(fig,outDir + "accuracies")
Пример #8
0
def predict(fitter,x,yReal,rawDat,label,saveDir,colNames,fitterCoeff,objClass,
            featureObjects,saveBad=False,saveCoeffs=True,plot=True):
    try:
        yPred = fitter.predict(x)
    except TypeError:
        yPred = fitter.predict(x.toarray())
    cm = confusion_matrix(yReal,yPred)
    acc= accuracy_score(yReal,yPred)
    # Show confusion matrix in a separate window
    if (saveBad):
        # XXX could profile?
        profileLosers(saveDir,label,yPred,yReal,rawDat,objClass,x,
                      featureObjects)
    if (plot):
        fig = pPlotUtil.figure()
        ax = plt.subplot(1,1,1)
        numCols = colNames.size
        coeffs = fitterCoeff(fitter)
        nCoeffs = coeffs.size
        xRange = range(nCoeffs)
        saveName = saveDir + label + "coeffs"
        sortIdx = np.argsort(coeffs)[::-1]
        sortedCoeffs = coeffs[sortIdx]
        sortedNames = colNames[sortIdx]
        sortedFeatures = [featureObjects[s] for s in sortIdx]
        stacked = np.vstack((sortedNames,sortedCoeffs)).T
        np.savetxt(saveName,stacked,fmt=["%s","%.3g"],delimiter="\t")
        print numCols, " Columns"
        maxToPlot = min(numCols//2,25) # on each side

        if( numCols == nCoeffs):
    # then we have a coefficient per feature (column), so use them for ticks
            coeffsToPlot = list(sortedCoeffs[:maxToPlot]) + \
                           list(sortedCoeffs[-maxToPlot:])
            labelsToPlot = list(sortedNames[:maxToPlot]) +\
                           list(sortedNames[-maxToPlot:])
            featuresPlotted = list(sortedFeatures[:maxToPlot]) + \
                              list(sortedFeatures[-maxToPlot:])
            xToPlot = range(len(coeffsToPlot))
            ax.bar(xToPlot,coeffsToPlot,align='center')
            ax.set_xticks(xToPlot)
            ax.set_xticklabels(labelsToPlot,rotation='vertical')
            plt.xlabel("coefficient name")
            plt.ylabel("Predictor strength")
        else:
            plt.plot(xRange,coeffs,'ro-')
            plt.xlabel("Fitter Coefficients")
            plt.ylabel("Predictor strength")
        pPlotUtil.savefig(fig,saveName)
    return acc
Пример #9
0
def PlotFec(sep,
            force,
            surfIdx=None,
            normalizeSep=True,
            normalizeFor=True,
            filterN=None,
            sensibleUnits=True):
    """
    Plot a force extension curve

    :param sep: The separation in meters
    :param force: The force in meters
    :param surfIdx: The index between approach and retract. if not present, 
    intuits approximate index from minmmum Sep
    :param normalizeSep: If true, then zeros sep to its minimum 
    :paran normalizeFor: If true, then zeros force to the median-filtered last
    5% of data, by separation (presummably, already detached) 
    :param filterT: Plots the raw data in grey, and filters 
    the force to the Number of points given. If none, assumes default % of curve
    :param sensibleUnits: Plots in nm and pN, defaults to true
    """
    if (surfIdx is None):
        surfIdx = np.argmin(sep)
    sepUnits, forceUnits = NormalizeSepForce(sep, force, surfIdx, normalizeSep,
                                             normalizeFor, sensibleUnits)
    if (filterN is None):
        filterN = int(np.ceil(DEF_FILTER_CONST * sepUnits.size))
    # POST: go ahead and normalize/color
    sepAppr = sepUnits[:surfIdx]
    sepRetr = sepUnits[surfIdx:]
    forceAppr = forceUnits[:surfIdx]
    forceRetr = forceUnits[surfIdx:]
    PlotFilteredSepForce(sepAppr,
                         forceAppr,
                         filterN=filterN,
                         color='r',
                         label="Approach")
    PlotFilteredSepForce(sepRetr,
                         forceRetr,
                         filterN=filterN,
                         color='b',
                         label="Retract")
    plt.xlim([min(sepUnits), max(sepUnits)])
    pPlotUtil.lazyLabel("Separation [nm]", "Force [pN]",
                        "Force Extension Curve")
    return sepUnits, forceUnits
Пример #10
0
def plotSingleHist(n, p, xTrials, outDir):
    # coverage is just a plotting artifact
    fig = pPlotUtil.figure()
    # mu: expected value of Binomial(n,p)
    # effectie variance
    dist,distMean,distVar,normalStd,normalDist,xVals,nBins = \
                            getDeltaModelDistr(n,p,xTrials)
    normV = normHist(dist,nBins,\
                     label=("Actual Distr: Mean={:.4f},Stdev={:.4f}").\
                     format(distMean,np.sqrt(distVar)))
    rawPDF = normalDist.pdf(xVals)
    plt.plot(xVals,rawPDF,'r--',linewidth=5.0,
             label="Theorertical Distr: Stdev={:.4f}".\
             format(normalStd))
    plt.title("Histogram for g(xBar)-g(mu) for n={:d},p={:.2f}".\
              format(int(n),p),fontsize=g_title)
    plt.xlabel("(g(Xbar)-g(mu)) ~ Normal(0,[g'(x)*sigma]^2/n)",
               fontsize=g_label)
    plt.ylabel("Proportion", fontsize=g_label)
    plt.legend(frameon=False)
    pPlotUtil.tickAxisFont()
    catArr = list(rawPDF) + list(normV)
    plt.ylim([0, max(catArr) * 1.2])
    plt.xlim([-max(nBins), max(nBins)])
    pPlotUtil.tickAxisFont()
    pPlotUtil.savefig(fig, outDir + "trial_n{:d}".format(int(n)))
    #return the statistics for plotting
    return distMean, distVar, normalStd**2
Пример #11
0
def plotBinomials(dataMatrix, nVals, p):
    nTrials = nVals.size  # rows are the trials
    # same the mean and variances...
    means = np.zeros(nTrials)
    varReal = np.zeros(nTrials)
    varDist = np.zeros(nTrials)
    for i, n in enumerate(nVals):
        means[i],varReal[i],varDist[i] =\
                    plotSingleHist(n,p,dataMatrix[i,:],outDir)
    # plot the means and variances
    fig = pPlotUtil.figure()
    plt.subplot(1, 2, 1)
    plt.title("Mean of g(xBar)-g(mu) approaches 0", fontsize=fontsize)
    expMean = 0
    plt.plot(nVals, means, 'ko', label="Actual Mean")
    plt.axhline(expMean,
                color='b',
                linestyle='--',
                label="Expected Mean: {:.2g}".format(expMean))
    plt.ylim(-min(means), max(means) * 1.1)
    plt.xlabel("Value of n for binomial", fontsize=fontsize)
    plt.ylabel("Value of g(xBar)-g(mu)", fontsize=fontsize)
    plt.legend(fontsize=fontsize)
    pPlotUtil.tickAxisFont()
    plt.subplot(1, 2, 2)
    plt.semilogy(nVals, varReal, 'ko', label="Actual Variance")
    plt.semilogy(nVals, varDist, 'b--', label="Expected Variance")
    plt.title("Variance of g(xBar)-g(mu)\n approaches expected",
              fontsize=fontsize)
    plt.xlabel("Value of n for binomial", fontsize=fontsize)
    plt.ylabel("Value of g(xBar) variance", fontsize=fontsize)
    pPlotUtil.tickAxisFont()
    plt.legend(fontsize=fontsize)
    pPlotUtil.savefig(fig, outDir + "MeanVar")
Пример #12
0
def plotSingleHist(n,p,xTrials,outDir):
    # coverage is just a plotting artifact
    fig = pPlotUtil.figure()
    # mu: expected value of Binomial(n,p)
    # effectie variance
    dist,distMean,distVar,normalStd,normalDist,xVals,nBins = \
                            getDeltaModelDistr(n,p,xTrials)
    normV = normHist(dist,nBins,\
                     label=("Actual Distr: Mean={:.4f},Stdev={:.4f}").\
                     format(distMean,np.sqrt(distVar)))
    rawPDF = normalDist.pdf(xVals)
    plt.plot(xVals,rawPDF,'r--',linewidth=5.0,
             label="Theorertical Distr: Stdev={:.4f}".\
             format(normalStd))
    plt.title("Histogram for g(xBar)-g(mu) for n={:d},p={:.2f}".\
              format(int(n),p),fontsize=g_title)
    plt.xlabel("(g(Xbar)-g(mu)) ~ Normal(0,[g'(x)*sigma]^2/n)",
               fontsize=g_label)
    plt.ylabel("Proportion",fontsize=g_label)
    plt.legend(frameon=False)
    pPlotUtil.tickAxisFont()
    catArr = list(rawPDF) + list(normV)
    plt.ylim([0,max(catArr)*1.2])
    plt.xlim([-max(nBins),max(nBins)])
    pPlotUtil.tickAxisFont()
    pPlotUtil.savefig(fig,outDir + "trial_n{:d}".format(int(n)))
    #return the statistics for plotting
    return distMean,distVar,normalStd**2
Пример #13
0
def plotBinomials(dataMatrix,nVals,p):
    nTrials = nVals.size # rows are the trials
    # same the mean and variances...
    means = np.zeros(nTrials)
    varReal = np.zeros(nTrials)
    varDist = np.zeros(nTrials)
    for i,n in enumerate(nVals):
        means[i],varReal[i],varDist[i] =\
                    plotSingleHist(n,p,dataMatrix[i,:],outDir)
    # plot the means and variances
    fig = pPlotUtil.figure()
    plt.subplot(1,2,1)
    plt.title("Mean of g(xBar)-g(mu) approaches 0",fontsize=fontsize)
    expMean = 0
    plt.plot(nVals,means,'ko',label="Actual Mean")
    plt.axhline(expMean,color='b',linestyle='--',
                label="Expected Mean: {:.2g}".format(expMean))
    plt.ylim(-min(means),max(means)*1.1)
    plt.xlabel("Value of n for binomial",fontsize=fontsize)
    plt.ylabel("Value of g(xBar)-g(mu)",fontsize=fontsize)
    plt.legend(fontsize=fontsize)
    pPlotUtil.tickAxisFont()
    plt.subplot(1,2,2)
    plt.semilogy(nVals,varReal,'ko',label="Actual Variance")
    plt.semilogy(nVals,varDist,'b--',label="Expected Variance")    
    plt.title("Variance of g(xBar)-g(mu)\n approaches expected",
              fontsize=fontsize)
    plt.xlabel("Value of n for binomial",fontsize=fontsize)
    plt.ylabel("Value of g(xBar) variance",fontsize=fontsize)
    pPlotUtil.tickAxisFont()
    plt.legend(fontsize=fontsize)
    pPlotUtil.savefig(fig,outDir + "MeanVar")
Пример #14
0
def plotFec(expect,algorithm,inFile,saveAs):
    time,sep,force = HDF5Util.GetTimeSepForce(inFile)
    fig = pPlotUtil.figure()
    IgorUtil.PlotFec(sep,force)
    # limit the axis to close to the touchoff (10% of range)
    # (plotFEC starts at 0)
    minV = min(sep)
    rangeSepNm = 1e9 * abs(max(sep)-minV)
    rangeX = [0,rangeSepNm/10]
    plt.xlim(rangeX)
    # plot the expected and algorithm locations as nm, normalized to min
    norm  = lambda x : (x-minV)*1e9
    plt.axvline(norm(expect),
                label="Expected surface location",lw=3,linestyle="--",
                color="g")
    plt.axvline(norm(algorithm),label="Algorithm surface location",lw=3,
                linestyle="--",color="k")
    pPlotUtil.legend()
    pPlotUtil.savefig(fig,saveAs)
Пример #15
0
def plotAll(kArrs,outDir):
    maxKeach = [max(k) for k in kArrs ]
    maxK = max(maxKeach)
    bins = range(maxK+1)
    numTrials = len(kArr)
    means  = np.array([np.mean(k) for k in kArrs])
    stdevs = np.array([np.std(k) for k in kArrs])
    for i,k in enumerate(kArrs):
        fig = pPlotUtil.figure()
        plt.hist(k,bins=bins,align='left',label='Data from {:d} sequences'.
                 format(int(numOligos)),normed=True)
        mean = means[i]
        plt.axvline(mean,color='r',label="Mean:{:.3f}".format(mean),
                    linewidth=2.0)
        plt.xlim([0,maxK])
        plt.xlabel('K, minimum k-mer with at most 1 occurence in DNA sequence')
        plt.ylabel('Proportion of occurences')
        plt.title('K histogram (normalized) for DNA sequences  of length {:d}'.
                  format(lengths[i]))
        plt.legend()
        pPlotUtil.savefig(fig,outDir + "k{:d}".format(i))
    return means,stdevs
Пример #16
0
def profileLosers(saveDir,label,yPred,yActual,rawDat,dataClass,featureMat,
                  featureObjects):
    # get what we got wrong
    badIdx,predictedDeath,predictedSurv = getIdxMistakes(yPred,yActual)
    nSurv = len(predictedSurv)
    nDead = len(predictedDeath)
    fig = pPlotUtil.figure(xSize=16,ySize=12,dpi=200)
    # get the matrix, all features 0 --> 1
    toPlot = getNormalizedFeatureMatrix(badIdx,featureMat,
                                        lambda x: sortByPred(x,yPred,yActual))
    # get the number of non-zero elements in each column
    aspectStr = plotFeatMatr(toPlot,featureObjects,featureMat,saveDir,label,
                             badIdx)
    plt.axhline(len(predictedSurv),linewidth=3,color='c')
    plt.title("Line Divides {:d} actual deceased from {:d} actual survived".\
                format(nSurv,nDead),y=1.3,fontsize=g_title)
    plt.legend(loc="upper right", bbox_to_anchor=(0.4, -0.4))
    
    badVals = rawDat[badIdx,:]
    np.savetxt(saveDir + 'debug_{:s}.csv'.format(label),badVals,fmt="%s",
               delimiter=',')
    pPlotUtil.savefig(fig,saveDir + "mOut" + label,tight=True)
Пример #17
0
    def __init__(self, dialog, parent):

        Ui_CaliperImport.__init__(self)
        self.setupUi(dialog)
        self.dialog = dialog
        self.parent = parent

        self.ciLASData_fields = mdl.get_ciLASData_fields()
        self.ciOpenFile_pushButton.clicked.connect(self.open_file)
        self.ciValueDecimalPoint_radioButton.clicked.connect(
            self.setup_valueDecimalPoint)
        self.ciValueDecimalComma_radioButton.clicked.connect(
            self.setup_valueDecimalComma)

        self.unitRepresentations = mdl.get_lengthUnits()

        self.ciMDvalueUnit_comboBox.addItems(self.unitRepresentations)
        i = self.unitRepresentations.index(self.ciLASData_fields.MD.unit)
        self.ciMDvalueUnit_comboBox.setCurrentIndex(i)

        self.ciIDvalueUnit_comboBox.addItems(self.unitRepresentations)
        i = self.unitRepresentations.index(self.ciLASData_fields.CD.unit)
        self.ciIDvalueUnit_comboBox.setCurrentIndex(i)

        self.ciApplyAndDraw_pushButton.clicked.connect(
            self.applyAndDraw_caliperData)
        self.ciCommaDelimiter_checkBox.stateChanged.connect(
            self.setNumberPattern)
        self.ciHoleIDsmoothing_slider.valueChanged.connect(
            self.update_ciHoleIDsmoothing_label)
        self.ciHoleIDsmoothing_slider.sliderReleased.connect(
            self.draw_caliperData)
        #self.ciHoleIDsmoothing_slider.actionTriggered.connect( self.update_sliderValue )
        self.ciAccept_pushButton.clicked.connect(self.makeResults_and_done)

        self.ciHoleIDsmoothing_graphicsView.axes.set_position(
            [0.23, 0.1, 0.7, 0.85])
        self.ciHoleIDsmoothing_graphicsView_ylimits = [None, None]
        self.ciHoleIDsmoothing_graphicsView_yselection = []
        zp = pu.ZoomPan()
        zp.zoomYD_factory(self.ciHoleIDsmoothing_graphicsView.axes,
                          self.ciHoleIDsmoothing_graphicsView_ylimits)
        zp.panYD_factory(self.ciHoleIDsmoothing_graphicsView.axes,
                         self.ciHoleIDsmoothing_graphicsView_ylimits)
        #ypressfunction3=self.snapshot )

        self.setup_valueDecimalPoint()

        dialog.setAttribute(Qt.WA_DeleteOnClose)
        dialog.exec_()
Пример #18
0
def plotAll(outDir,gXBar,normalStd,label):
    fig = plt.figure()
    fontSize = 18
    positionX = np.arange(gXBar.size)
    plt.plot(positionX,gXBar,'ro',label="Data for K-hat")
    plt.errorbar(x=positionX,y=gXBar,yerr=normalStd,fmt='bx',
                 label="Theory")
    plt.xlabel("Position on codon",fontsize=fontSize)
    plt.ylabel("K-hat, E[substitutions/homologous base].",
               fontsize=fontSize)
    plt.legend(loc='best',fontsize=fontSize)
    fudge = 0.1
    plt.xlim([-fudge,max(positionX)+fudge])
    plt.title("K-hat versus expected K \n"+
              "lambda={:.3g}[1/year], tau={:.3g}[years]".\
              format(lambdaV,tau),fontsize=fontSize)
    pPlotUtil.savefig(fig,outDir + "q2_4_Khat" + label)
    delim = "\t"
    print(delim.join(["Pos","K-Hat(var)","K-hat(stdv)"]))
    for i,(measured,theoryStd) \
        in enumerate(zip(gXBar,normalStd)):
        print("{:d}\t{:.3g}({:.3g})\t{:.3g}".format(i,measured,
                                                    theoryStd**2,theoryStd))
def ProcessData(dataByObject,frameRate):
    # frameRate is in second
    # frames appearing is the first data point
    util.ReportMessage("ProcessData")
    timeIndex = 0
    meanIndex = 0
    times = [ np.multiply(obj[timeIndex][meanIndex],frameRate)
              for obj in dataByObject]
    deltaTimes = [ np.gradient(t) if len(t) > 1 else 0 for t in times ]
    numTimes = [len(t) for t in times]
    # xy is the second data point
    xyIndex = 1
    xIndex = 0
    yIndex = 1
    xVals = [ obj[xyIndex][xIndex] for obj in dataByObject]
    yVals = [ obj[xyIndex][yIndex] for obj in dataByObject]
    MSD = [ 1/(np.arange(1,1+len(x))) * (sqDeltaSum(x) + sqDeltaSum(y))
            if len(x) > 1 else np.array([0]) for x,y in zip(xVals,yVals) ]
    velX = getVelocity(xVals,deltaTimes)
    velY = getVelocity(yVals,deltaTimes)
    # channel 1 (FRET donor) is the third
    donorIndex = 2
    channel1 = [ obj[donorIndex][meanIndex] for obj in dataByObject]
    # channel 2 (FRET acceptor) is the fourth
    acceptorIndex = 3
    channel2 = [ obj[acceptorIndex][meanIndex] for obj in dataByObject]
    #FRET Ratio is donor/acceptor (1/2)
    # XXX should probably check for a div/0 here...
    channel1Flatten=np.concatenate(channel1)
    channel2Flatten=np.concatenate(channel2)
    maxXAxis = max(len(channel1Flatten),len(channel2Flatten))
    fretRatio = [ np.divide(c1,c2) for c1,c2 in  zip(channel1,channel2)]
    toCompare = [channel1Flatten,channel2Flatten]
    plotUtil.compareHist('Intensity (au)','Protein Count','FRET Intensities'
                         ,maxXAxis,toCompare,
                         ['Donor Channel','Acceptor Channel'])
    return velX,velY,times,numTimes,fretRatio,MSD
Пример #20
0
	def __init__(self, dialog, parent):
		
		Ui_SpacingSetup.__init__(self)
		zp = pu.ZoomPan()
		self.setupUi(dialog)
		self.dialog = dialog
		self.parent = parent
		self.centralizerCount = 0

		self.ssAccept_pushButton.clicked.connect( self.makeResults_and_done )

		self.ssNextSpacing_fields = mdl.get_ssNextSpacing_fields()
		self.ssCentralizerLocations_fields = mdl.get_ssCentralizerLocations_fields()
		#mdl.calculate_axialForce_field(self)	

		self.__init__ssCentralizerLocations_tableWidget()
		self.__init__ssNextSpacing_tableWidget()

		self.stage = parent.currentWellboreInnerStageDataItem

		self.max_MD = self.stage['MD']
		self.min_MD = self.max_MD-self.stage['Length']
		self.IPOD = self.stage['PipeProps'].OD[0]

		self.centralizers = copy.deepcopy(self.stage['Centralization'])
		del self.centralizers['Mode']
		del self.centralizers['Fields']

		MD, ID, mean_ID, lim_ID = mdl.get_LASMDandCALID_intoInterval(self)
		self.MD = MD
		self.ID = ID
		self.mean_ID = mean_ID

		#-------------------------------------------------

		self.ssCaliperMap_graphicsView.axes.set_position([0.2,0.15,0.75,0.8])
		self.ssCaliperMap_graphicsView_ylimits    = [None,None]
		self.ssCaliperMap_graphicsView_yselection = []

		self.ssSOVisualization_graphicsView.axes.set_position([0.2,0.15,0.75,0.8])
		self.ssSOVisualization_graphicsView_ylimits    = [None,None]
		self.ssSOVisualization_graphicsView_yselection = []
		
		zp.zoomYD_factory(	(self.ssCaliperMap_graphicsView.axes, self.ssSOVisualization_graphicsView.axes),
							(self.ssCaliperMap_graphicsView_ylimits, self.ssSOVisualization_graphicsView_ylimits)  )
		zp.panYD_factory(	(self.ssCaliperMap_graphicsView.axes, self.ssSOVisualization_graphicsView.axes), 
							(self.ssCaliperMap_graphicsView_ylimits, self.ssSOVisualization_graphicsView_ylimits), 
							(self.ssCaliperMap_graphicsView_yselection, self.ssSOVisualization_graphicsView_yselection),
							ypressfunction1=self.highlight_MDlocation,
							ypressfunction3=self.choose_MDlocation )

		self.ssCaliperMap_graphicsView.axes.clear()
		self.ssSOVisualization_graphicsView.axes.clear()

		#-------------------------------------------------

		self.ssCaliperMap_graphicsView.axes.fill_betweenx( MD, -ID, +ID, alpha=0.5, color='C0')
		factors = mu.np.linspace(1,2,11)
		for factor in factors[1:]:
			IPOD = self.IPOD*factor
			self.ssCaliperMap_graphicsView.axes.fill_betweenx( MD, +IPOD, +ID, where=IPOD<ID, alpha=0.05, color='C3')
			self.ssCaliperMap_graphicsView.axes.fill_betweenx( MD, -IPOD, -ID, where=IPOD<ID, alpha=0.05, color='C3')

		self.ssCaliperMap_graphicsView.axes.plot( [ -self.IPOD, -self.IPOD], [MD[0],MD[-1]], 'C1', lw=2 )
		self.ssCaliperMap_graphicsView.axes.plot( [ +self.IPOD, +self.IPOD], [MD[0],MD[-1]], 'C1', lw=2 )

		MDHeaderName = self.ssCentralizerLocations_fields.MD.headerName
		IDHeaderName = self.ssCentralizerLocations_fields.ID.headerName

		self.ssCaliperMap_graphicsView.axes.set_xlabel( IDHeaderName )
		self.ssCaliperMap_graphicsView.axes.set_ylabel( MDHeaderName )
		self.ssCaliperMap_graphicsView.axes.set_xlim( -lim_ID, lim_ID )
		self.ssCaliperMap_graphicsView.axes.set_ylim( self.max_MD, self.min_MD ) 
		self.ssCaliperMap_graphicsView.draw()

		#-------------------------------------------------

		SOHeaderName = self.ssCentralizerLocations_fields.SOatC.headerName +'  &  '+ self.ssCentralizerLocations_fields.SOatM.headerName
		if self.ssCentralizerLocations_fields.SOatC.unit=='%':
			self.max_SO = 100
			self.min_SO = 67
			self.ΔSO = 10
		elif self.ssCentralizerLocations_fields.SOatC.unit=='1':
			self.max_SO = 1
			self.min_SO = 0.67
			self.ΔSO = 0.1

		self.ssSOVisualization_graphicsView.axes.set_xlabel( SOHeaderName )
		self.ssSOVisualization_graphicsView.axes.set_ylabel( MDHeaderName )
		self.ssSOVisualization_graphicsView.axes.set_xlim( -self.ΔSO, self.max_SO+self.ΔSO )
		self.ssSOVisualization_graphicsView.axes.set_ylim( self.max_MD, self.min_MD )
		#self.ssSOVisualization_graphicsView.axes.grid()
		self.ssSOVisualization_graphicsView.axes.plot( [self.min_SO, self.min_SO], [self.max_MD, self.min_MD], 'C3--', lw=2 )
		self.ssSOVisualization_graphicsView.axes.plot( [0, 0], [self.max_MD, self.min_MD], 'k-', lw=1, alpha=0.3 )
		self.ssSOVisualization_graphicsView.axes.plot( [self.max_SO, self.max_SO], [self.max_MD, self.min_MD], 'k-', lw=1, alpha=0.3 )
		self.ssSOVisualization_graphicsView.draw()

		#-------------------------------------------------

		min_EW,min_NS,min_VD,min_index = mdl2.get_ASCCoordinates_from_MD(parent, self.min_MD, unit=parent.s2DataSurvey_fields.MD.unit)
		max_EW,max_NS,max_VD,max_index = mdl2.get_ASCCoordinates_from_MD(parent, self.max_MD, unit=parent.s2DataSurvey_fields.MD.unit)
		EW = parent.s2DataSurvey_fields.EW[min_index:max_index+1]
		NS = parent.s2DataSurvey_fields.NS[min_index:max_index+1]
		VD = parent.s2DataSurvey_fields.TVD[min_index:max_index+1]
		
		EW[0] = min_EW
		NS[0] = min_NS
		VD[0] = min_VD
		EW[-1] = max_EW
		NS[-1] = max_NS
		VD[-1] = max_VD

		curve, = self.ssWellbore3D_graphicsView.axes.plot( EW, NS, VD )

		self.ssWellbore3D_graphicsView.axes.set_xlabel( parent.s2DataSurvey_fields.EW.headerName )
		self.ssWellbore3D_graphicsView.axes.set_ylabel( parent.s2DataSurvey_fields.NS.headerName )
		self.ssWellbore3D_graphicsView.axes.set_zlabel( parent.s2DataSurvey_fields.TVD.headerName )

		max_EW = max(parent.s2DataSurvey_fields.EW)
		min_EW = min(parent.s2DataSurvey_fields.EW)
		max_NS = max(parent.s2DataSurvey_fields.NS)
		min_NS = min(parent.s2DataSurvey_fields.NS)
		ΔEW = max_EW - min_EW
		ΔNS = max_NS - min_NS

		if ΔEW>ΔNS:
			self.ssWellbore3D_graphicsView.axes.set_xlim( min_EW, max_EW )
			Δ = (ΔEW-ΔNS)/2
			self.ssWellbore3D_graphicsView.axes.set_ylim( min_NS-Δ, max_NS+Δ )
		elif ΔNS>ΔEW:
			self.ssWellbore3D_graphicsView.axes.set_ylim( min_NS, max_NS )
			Δ = (ΔNS-ΔEW)/2
			self.ssWellbore3D_graphicsView.axes.set_xlim( min_EW-Δ, max_EW+Δ )
		else:
			self.ssWellbore3D_graphicsView.axes.set_xlim( min_EW, max_EW )
			self.ssWellbore3D_graphicsView.axes.set_ylim( min_NS, max_NS )


		self.ssWellbore3D_graphicsView.axes.set_zlim( max(VD), min(VD) )
		self.ssWellbore3D_graphicsView.axes.mouse_init()
		#zp.point3D_factory(self.s2TriDView_graphicsView.axes, dot, curve)
		zp.zoom3D_factory( self.ssWellbore3D_graphicsView.axes, curve )
		self.ssWellbore3D_graphicsView.draw()

		dialog.setAttribute(Qt.WA_DeleteOnClose)
		dialog.exec_()
Пример #21
0
    def __init__(self, dialog, parent):

        Ui_GraphWindow.__init__(self)
        zp = pu.ZoomPan()
        self.setupUi(dialog)
        self.dialog = dialog
        self.parent = parent

        #self.lsAccept_pushButton.clicked.connect( self.makeResults_and_done )

        #-------------------------------------------------

        #self.lsCaliperMap_graphicsView.axes.set_position([0.2,0.15,0.75,0.8])

        #-------------------------------------------------

        EW = parent.v2ASCComplements_fields.EW
        NS = parent.v2ASCComplements_fields.NS
        VD = parent.v2ASCComplements_fields.TVD

        max_VD = max(VD)
        min_VD = min(VD)
        max_EW = max(EW)
        min_EW = min(EW)
        max_NS = max(NS)
        min_NS = min(NS)

        ΔVD = max_VD - min_VD
        ΔEW = max_EW - min_EW
        ΔNS = max_NS - min_NS

        Δ = max([ΔVD, ΔEW, ΔNS])

        if ΔVD == Δ:
            self.gwColoredWellbore_graphicsView.axes.set_xlim(
                min_EW - (Δ - ΔEW) / 2, max_EW + (Δ - ΔEW) / 2)
            self.gwColoredWellbore_graphicsView.axes.set_ylim(
                min_NS - (Δ - ΔNS) / 2, max_NS + (Δ - ΔNS) / 2)
            self.gwColoredWellbore_graphicsView.axes.set_zlim(max_VD, min_VD)
        elif ΔNS == Δ:
            self.gwColoredWellbore_graphicsView.axes.set_xlim(
                min_EW - (Δ - ΔEW) / 2, max_EW + (Δ - ΔEW) / 2)
            self.gwColoredWellbore_graphicsView.axes.set_ylim(min_NS, max_NS)
            self.gwColoredWellbore_graphicsView.axes.set_zlim(
                max_VD + (Δ - ΔVD) / 2, min_VD - (Δ - ΔVD) / 2)
        elif ΔEW == Δ:
            self.gwColoredWellbore_graphicsView.axes.set_xlim(min_EW, max_EW)
            self.gwColoredWellbore_graphicsView.axes.set_ylim(
                min_NS - (Δ - ΔNS) / 2, max_NS + (Δ - ΔNS) / 2)
            self.gwColoredWellbore_graphicsView.axes.set_zlim(
                max_VD + (Δ - ΔVD) / 2, min_VD - (Δ - ΔVD) / 2)

        X, Y, Z, C = mu.render_wellbore(parent.v2ASCComplements_fields, 50, 15)
        SO = mu.np.interp(parent.v2ASCComplements_fields.MD, parent.v3SOs_MD,
                          parent.v3SOs_SO)
        C = SO * C

        print(C.min(), C.max())

        lis = pu.LightSource(270, 45)
        rgb = lis.shade(C,
                        cmap=pu.cm.coolwarm,
                        vert_exag=1,
                        blend_mode='soft',
                        vmin=0,
                        vmax=100)
        surface = self.gwColoredWellbore_graphicsView.axes.plot_surface(
            X,
            Y,
            Z,
            facecolors=rgb,
            linewidth=0,
            antialiased=False,
            vmin=0,
            vmax=100)

        #mappable = pu.plt.cm.ScalarMappable(cmap=pu.cm.bwr)
        #mappable.set_array(C)
        #surface = self.gwColoredWellbore_graphicsView.axes.plot_surface(X,Y,Z, cmap=mappable.cmap, linewidth=0, antialiased=False)
        #fig = self.gwColoredWellbore_graphicsView.axes.get_figure()
        #fig.colorbar(mappable, shrink=0.2, aspect=5, orientation='horizontal', location='bottom')

        self.gwColoredWellbore_graphicsView.axes.set_xlabel(EW.headerName)
        self.gwColoredWellbore_graphicsView.axes.set_ylabel(NS.headerName)
        self.gwColoredWellbore_graphicsView.axes.set_zlabel(VD.headerName)

        self.gwColoredWellbore_graphicsView.axes.mouse_init()

        #curve, = self.gwColoredWellbore_graphicsView.axes.plot( EW, NS, VD, lw=2 )
        #zp.point3D_factory(self.s2TriDView_graphicsView.axes, dot, curve)
        #zp.zoom3D_factory( self.gwColoredWellbore_graphicsView.axes, curve )
        #self.gwColoredWellbore_graphicsView.draw()

        #dialog.setAttribute(Qt.WA_DeleteOnClose)
        dialog.exec_()
Пример #22
0
def draw_survey_plots( self ):

	self.s2SectionView_graphicsView.axes.clear()
	self.s2PlanView_graphicsView.axes.clear()
	self.s2TriDView_graphicsView.axes.clear()
	self.s2Dogleg_graphicsView.axes.clear()

	color='C1' if self.s2SurveyTortuosity_checkBox.isChecked() else 'C0'
	self.s2SectionView_graphicsView.axes.plot( 	self.v2ASCComplements_fields.HD, 
												self.v2ASCComplements_fields.TVD, color=color )
	self.s2SectionView_graphicsView.axes.set_xlabel( self.v2ASCComplements_fields.HD.headerName )
	self.s2SectionView_graphicsView.axes.set_ylabel( self.v2ASCComplements_fields.TVD.headerName )
	self.s2SectionView_graphicsView.axes.set_ylim(	max(self.v2ASCComplements_fields.TVD), 
													min(self.v2ASCComplements_fields.TVD) )
	self.s2SectionView_graphicsView.axes.grid()
	self.s2SectionView_graphicsView.draw()
	
	self.s2PlanView_graphicsView.axes.plot( self.v2ASCComplements_fields.EW, 
											self.v2ASCComplements_fields.NS, color=color )
	self.s2PlanView_graphicsView.axes.set_xlabel( self.v2ASCComplements_fields.EW.headerName )
	self.s2PlanView_graphicsView.axes.set_ylabel( self.v2ASCComplements_fields.NS.headerName )
	self.s2PlanView_graphicsView.axes.grid()
	self.s2PlanView_graphicsView.draw()
	
	"""
	X,Y,Z,C = mu.render_wellbore( self.v2ASCComplements_fields, 100, 20 )
	lis = pu.LightSource(270, 45)
	rgb = lis.shade(mu.np.cos(C/500), cmap=pu.cm.RdYlBu, vert_exag=1, blend_mode='soft')
	self.s2TriDView_graphicsView.axes.plot_surface(X,Y,Z, linewidth=0, facecolors=rgb, antialiased=False)
	"""
	
	curve, = self.s2TriDView_graphicsView.axes.plot(self.v2ASCComplements_fields.EW, 
													self.v2ASCComplements_fields.NS, 
													self.v2ASCComplements_fields.TVD, color=color, lw=3 )
	self.s2TriDView_graphicsView.axes.plot( [0,0], [0,0], 
											[self.v2ASCComplements_fields.TVD[0], 
											self.v2ASCComplements_fields.TVD[-1]],'r--', lw=1 )
	self.s2TriDView_graphicsView.axes.plot( [0,self.v2ASCComplements_fields.EW[-1]],
											[0,self.v2ASCComplements_fields.NS[-1]], 
											[self.v2ASCComplements_fields.TVD[-1], 
											self.v2ASCComplements_fields.TVD[-1]],'g--', lw=1 )
	#dot,   = self.s2TriDView_graphicsView.axes.plot( [0],[0],[0],'bo' )
	self.s2TriDView_graphicsView.axes.set_xlabel( self.v2ASCComplements_fields.EW.headerName )
	self.s2TriDView_graphicsView.axes.set_ylabel( self.v2ASCComplements_fields.NS.headerName )
	self.s2TriDView_graphicsView.axes.set_zlabel( self.v2ASCComplements_fields.TVD.headerName )

	
	max_VD = max(self.v2ASCComplements_fields.TVD)
	min_VD = min(self.v2ASCComplements_fields.TVD)
	max_EW = max(self.v2ASCComplements_fields.EW)
	min_EW = min(self.v2ASCComplements_fields.EW)
	max_NS = max(self.v2ASCComplements_fields.NS)
	min_NS = min(self.v2ASCComplements_fields.NS)
	
	ΔVD = max_VD - min_VD
	ΔEW = max_EW - min_EW
	ΔNS = max_NS - min_NS

	Δ = max( [ΔVD, ΔEW, ΔNS] )

	ar = self.s2AspectRatio_verticalSlider.sliderPosition()

	if ΔVD==Δ:
		self.s2TriDView_graphicsView.axes.set_xlim( min_EW-(Δ/ar-ΔEW)/2, max_EW+(Δ/ar-ΔEW)/2 )
		self.s2TriDView_graphicsView.axes.set_ylim( min_NS-(Δ/ar-ΔNS)/2, max_NS+(Δ/ar-ΔNS)/2 )
		self.s2TriDView_graphicsView.axes.set_zlim( max_VD, min_VD )
	elif ΔNS==Δ:
		self.s2TriDView_graphicsView.axes.set_xlim( min_EW-(Δ-ΔEW)/2, max_EW+(Δ-ΔEW)/2 )
		self.s2TriDView_graphicsView.axes.set_ylim( min_NS, max_NS )
		self.s2TriDView_graphicsView.axes.set_zlim( max_VD+(Δ-ΔVD)/2, min_VD-(Δ-ΔVD)/2 )
	elif ΔEW==Δ:
		self.s2TriDView_graphicsView.axes.set_xlim( min_EW, max_EW )
		self.s2TriDView_graphicsView.axes.set_ylim( min_NS-(Δ-ΔNS)/2, max_NS+(Δ-ΔNS)/2 )
		self.s2TriDView_graphicsView.axes.set_zlim( max_VD+(Δ-ΔVD)/2, min_VD-(Δ-ΔVD)/2 )


	self.s2TriDView_graphicsView.axes.mouse_init()
	zp = pu.ZoomPan()
	#zp.point3D_factory(self.s2TriDView_graphicsView.axes, dot, curve)
	#zp.zoom3D_factory( self.s2TriDView_graphicsView.axes, curve )
	self.s2TriDView_graphicsView.draw()
	
	zp.zoom2D_factory( self.s2Dogleg_graphicsView.axes )
	zp.pan2D_factory( self.s2Dogleg_graphicsView.axes )

	self.s2Dogleg_graphicsView.axes.plot(	self.v2ASCComplements_fields.DL, 
											self.v2ASCComplements_fields.MD, color=color )
	self.s2Dogleg_graphicsView.axes.set_xlabel( self.v2ASCComplements_fields.DL.headerName )
	self.s2Dogleg_graphicsView.axes.set_ylabel( self.v2ASCComplements_fields.MD.headerName )
	self.s2Dogleg_graphicsView.axes.set_ylim(	max(self.v2ASCComplements_fields.MD), 
												min(self.v2ASCComplements_fields.MD) )
	self.s2Dogleg_graphicsView.axes.grid()
	self.s2Dogleg_graphicsView.draw()
	def __init__(self, dialog, parent):

		Ui_DiagramWindow.__init__(self)
		#zp = pu.ZoomPan()
		self.setupUi(dialog)
		self.dialog = dialog
		self.parent = parent

		self.dwWellboreSchematic_graphicsView

		self.dwWellboreSchematic_graphicsView.axes.set_position([0.2,0.15,0.75,0.8])
		zp = pu.ZoomPan()
		zp.zoom2D_factory( self.dwWellboreSchematic_graphicsView.axes )
		zp.pan2D_factory( self.dwWellboreSchematic_graphicsView.axes )
		self.dwWellboreSchematic_graphicsView.axes.clear()

		MDs = self.parent.v3Forces_fields.MD[:]

		for stage in self.parent.v3WellboreInnerStageData.values():
			MDbot = stage['MDbot']
			MDs.append(MDbot)

		for stage in self.parent.v3WellboreOuterStageData.values():
			MDbot = stage['WellboreProps'].MDbot[0]
			MDs.append(MDbot)

		MDs.sort()
		MDunit = MDbot.unit
		factor = max(self.parent.v3Forces_fields.HD)/mdl.get_outerStage_at_MD( self.parent, 0.0, MDunit )['WellboreProps'].ID[0]*0.2

		HDu_i = []
		VDu_i = []
		HDd_i = []
		VDd_i = []
		HDu_o = []
		VDu_o = []
		HDd_o = []
		VDd_o = []

		for MD in MDs:
			ew,ns,VD,HD,i = mdl.get_ASCCoordinates_from_MD(self.parent, MD, MDunit)

			T = mdl.get_ASCT_from_MD(self.parent, MD, MDunit)
			t = mu.np.array([ T[3], T[2], 0 ])
			t = t.reshape(1,-1)
			normt = mu.np.linalg.norm(t)
			if normt!=0.0:
				t /=normt
			u = mu.np.array([ 0, 0, 1 ])
			u = u.reshape(1,-1)
			nu = mu.np_cross(t,u)

			d = mu.np.array([ 0, 0, -1 ])
			d = d.reshape(1,-1)
			nd = mu.np_cross(t,d)

			innerStage = mdl.get_innerStage_at_MD(self.parent, MD, MDunit)
			factor_i = factor*innerStage['PipeProps'].OD[0]

			outerStage = mdl.get_outerStage_at_MD(self.parent, MD, MDunit)
			if outerStage['PipeBase']==None:
				noise = 0.1*(mu.np.random.rand()-0.5)+1
			else:
				noise = 1
			factor_o = factor*outerStage['WellboreProps'].ID[0]*noise

			HDu_i.append( HD+nu[0][0]*factor_i )
			VDu_i.append( VD+nu[0][1]*factor_i )
			HDd_i.append( HD+nd[0][0]*factor_i )
			VDd_i.append( VD+nd[0][1]*factor_i )
			HDu_o.append( HD+nu[0][0]*factor_o )
			VDu_o.append( VD+nu[0][1]*factor_o )
			HDd_o.append( HD+nd[0][0]*factor_o )
			VDd_o.append( VD+nd[0][1]*factor_o )

		max_VD = max( self.parent.v3Forces_fields.TVD )
		min_VD = min( self.parent.v3Forces_fields.TVD )
		delta = (max_VD-min_VD)*0.55

		self.dwWellboreSchematic_graphicsView.axes.axis('equal')
		self.dwWellboreSchematic_graphicsView.axes.set_ylim( max_VD+delta, min_VD-delta )
		self.dwWellboreSchematic_graphicsView.axes.set_xlabel( self.parent.v3Forces_fields.HD.headerName )
		self.dwWellboreSchematic_graphicsView.axes.set_ylabel( self.parent.v3Forces_fields.TVD.headerName )
		
		self.dwWellboreSchematic_graphicsView.axes.plot( self.parent.v3Forces_fields.HD, self.parent.v3Forces_fields.TVD, 'k--', lw=1 )
		self.dwWellboreSchematic_graphicsView.axes.plot( HDu_i, VDu_i, 'C1', lw=3 )
		self.dwWellboreSchematic_graphicsView.axes.plot( HDd_i, VDd_i, 'C1', lw=3 )
		self.dwWellboreSchematic_graphicsView.axes.plot( HDu_o, VDu_o, 'C0', lw=3 )
		self.dwWellboreSchematic_graphicsView.axes.plot( HDd_o, VDd_o, 'C0', lw=3 )

		for stage in self.parent.v3WellboreInnerStageData.values():
			MDbot = stage['MDbot']

			EW,NS,VD,HD,i = mdl.get_ASCCoordinates_from_MD(self.parent, MDbot)

			T = mdl.get_ASCT_from_MD(self.parent, MDbot, MDbot.unit)
			t = mu.np.array([ T[3], T[2], 0 ])
			t = t.reshape(1,-1)
			normt = mu.np.linalg.norm(t)
			if normt!=0.0:
				t /=normt
			u = mu.np.array([ 0, 0, 1 ])
			u = u.reshape(1,-1)
			nu = mu.np_cross(t,u)
			nu *= 0.3*max_VD

			d = mu.np.array([ 0, 0, -1 ])
			d = d.reshape(1,-1)
			nd = mu.np_cross(t,d)
			nd *= 0.3*max_VD

			self.dwWellboreSchematic_graphicsView.axes.arrow(HD, VD, nu[0][0], nu[0][1], head_width=0, head_length=0, fc='k', ec='k', lw=0.5, alpha=0.5)
			self.dwWellboreSchematic_graphicsView.axes.arrow(HD, VD, nd[0][0], nd[0][1], head_width=0, head_length=0, fc='k', ec='k', lw=0.5, alpha=0.5)
			

		dialog.setAttribute(Qt.WA_DeleteOnClose)
		dialog.exec_()
Пример #24
0
from matplotlib import cm
from matplotlib.ticker import LinearLocator, FormatStrFormatter


def plotKMesh(length,kVals,q,ax):
    kMesh,qMesh = np.meshgrid(kVals,q)
    func = (length-kMesh+1) * qMesh**(kMesh)
    surf = ax.plot_trisurf(kMesh.flatten(), qMesh.flatten(), func.flatten(),
                           cmap=cm.hot,linewidth=0.0,antialiased=True)
    ax.set_xlabel('k-mer size')
    ax.set_ylabel('q, maximum probability')
    ax.set_zlabel('f(k,q,k)')
    ax.set_title(('f(k,q,k), 0<q<1 and 0<k<{:d} (l={:d})').
                 format(int(max(kVals)),length))

length = 128
nK = length*5
nQ = 150
q = np.linspace(0,1,nQ)

fig = pPlotUtil.figure()
ax1 = fig.add_subplot(1,2,1,projection='3d')
# plot for 'all k's', give a sense of 'global' decreasing
plotKMesh(length,np.linspace(0,length+1,nK),q,ax1)
ax2 = fig.add_subplot(1,2,2,projection='3d')
# plot for 'small k's', give a sense of detail decreasing
smallK = np.floor(np.log(length))
plotKMesh(length,np.linspace(0,smallK,nK),q,ax2)
pPlotUtil.savefig(fig,'q4')

Пример #25
0
# need to add the utilities class. Want 'home' to be platform independent
# import the patrick-specific utilities
import GenUtilities  as pGenUtil
import PlotUtilities as pPlotUtil
import CheckpointUtilities as pCheckUtil

from scipy.stats import norm
outDir = "./out/"
pGenUtil.ensureDirExists(outDir)

mean = 0 
stdev = 1
epsilon = stdev/100 
nPoints = 1000
normDist = norm(loc=mean,scale=stdev)
offsets = np.linspace(mean-3*stdev,mean+3*stdev,nPoints)
probability = 2*(normDist.cdf((offsets+epsilon-mean)/stdev)-
                 normDist.cdf((offsets-epsilon-mean)/stdev))

fig = pPlotUtil.figure()
plt.plot(offsets,probability,'r-',
         label="mu = {:.1f}, sigma = {:.1f}, epsilon = {:.2f}".\
         format(mean,stdev,epsilon))
plt.xlabel("offset for CDF, c0")
plt.ylabel("Probability (arbitrary units) to land within epsilon of c0")
plt.axvline(0,color='k',linestyle='--',
            label="Maximum probability when centered near mu")
plt.legend(loc='best')
plt.title("Probability of landing within epsilon of c0 maximized near mu")
pPlotUtil.savefig(fig,outDir + "q1_1")
sigma_pose[1,1] = 0.2**2
sigma_pose[2,2] = (5*pi/180)**2
posEstimator.setInitialCovariance(sigma_pose)
posEstimator.setInitialPose(poseStart)
#posEstimator.setTimestep(T)



# Move robot and plot true and odo poses:
pos_odo = [myWorld.getTrueRobotPose()]
pos_true = [posEstimator.getPose()]

for t in range(n):
    # plot covariance:
    if t % 10 == 0:
        PlotUtilities.plotPoseCovariance(posEstimator.getPose(), posEstimator.getCovariance(), 'b')

    # move robot
    motion = motionCircle[t]
    print("v = ", motion[0], "omega = ", motion[1]*180/pi)
    myRobot.move(motion)

    # add true pose
    pos_true.append(myWorld.getTrueRobotPose())

    # odo pose:
    posEstimator.integrateMovement(motion,myRobot.getSigmaMotion())
    pos_odo.append(posEstimator.getPose())

    # Gib Daten vom Distanzsensor aus:
    distanceSensorData = myRobot.sense()
Пример #27
0
def plotSpotDist(mLabels,spots,outPath,subtractMean):
    colors = ['r', 'g', 'b', 'y','k']
    nColors = len(colors)
    # go to nm
    mLabelsNm = mLabels *  1e9
    mSetSpots = sorted(set(spots))
    labelsBySpot = []
    rawBySpot = []
    flattenedFromMean = []
    # first, get the spot-wise labelling
    for i,spot in enumerate(mSetSpots):
        # get the indices of the spots
        spotIdx = np.where(abs((spots - spot)) < 1e-9)[0]
        thisSpotLabels = mLabelsNm[spotIdx]
        meanV = np.mean(thisSpotLabels)
        if (subtractMean):
            thisSpotLabels -= meanV
        labelsBySpot.append(thisSpotLabels)
        flattenedFromMean.extend(thisSpotLabels)
        if (subtractMean):
            rawBySpot.append(thisSpotLabels + meanV)
        else:
            rawBySpot.append(thisSpotLabels)        
    #  get the min and max from the labelsBySpot array
    bins = np.linspace(min(flattenedFromMean),max(flattenedFromMean),10)
    fig = pPlotUtil.figure(xSize=12,ySize=12)
    ax = fig.add_subplot(111, projection='3d',)
    for i,thisSpotLabels in enumerate(labelsBySpot):
        mColor = colors[i % nColors]
        height,left = np.histogram(thisSpotLabels,bins=bins)
        ax.bar(left[:-1], height, zs=i,zdir='y', color=mColor, alpha=0.7,
               edgecolor="none",linewidth=0)
    xStr = r'$\Delta$ from Expected Surface Loc. [nm]'
    pPlotUtil.lazyLabel(xStr,
                        "Surface Position (arb)",
                    "Dependence of Surface Location Distribution on Position",
                        zlab="Count")
    pPlotUtil.savefig(fig,outPath + "AllSpots.png")
    # get a figure showing the mean surface location, assuming
    # we reshape into an Nx(whatever) array
    N = 5
    # -1: infer dimension
    meanVals = [np.mean(mList) for mList in rawBySpot]
    meanSurf = np.reshape(meanVals,(-1,N))
    meanSurf -= np.min(meanSurf)
    fig = pPlotUtil.figure(ySize=14,xSize=10)
    ax = fig.add_subplot(111, projection='3d')
    # convert to nm (XXX assuming grid is 1micron for each)
    Nx = N
    Ny = meanSurf.shape[0]
    x = np.linspace(0, Nx, Nx) * 1e3
    y = np.linspace(0, Ny, Ny) * 1e3
    xv, yv = np.meshgrid(x, y)
    ax.plot_wireframe(xv,yv,meanSurf)
    pPlotUtil.lazyLabel("X Location [nm]","Y Location [nm]",
                        "Surface Position Varies with height")
    pPlotUtil.zlabel("Surface height (relative to min)")
    pPlotUtil.savefig(fig,outPath + "Surface.png")
    fig = pPlotUtil.figure(ySize=14,xSize=10)
    plt.subplot(2,1,1)
    nPoints = len(flattenedFromMean)
    vals,edges,_=plt.hist(flattenedFromMean,bins=bins)
    # add a 'fudge' factor to make plotting better,
    fudgeX = (max(edges)-min(edges))*0.05
    xlim = [min(edges)-fudgeX,max(edges)+fudgeX]
    yLim = [0,max(vals)]
    pPlotUtil.lazyLabel(xStr,
                        "Number of counts",
                        "Algorithm finds surface within 10nm, >98%, N={:d}".\
                        format(nPoints))
    normed = [0,max(vals)/sum(vals)]
    plt.xlim(xlim)
    propAx = pPlotUtil.secondAxis(plt.gca(),"Proportion",normed,yColor="Red")
    propAx.axhline("0.05",color='r',
                   label="5% of Curves",linestyle='--',linewidth=4.0)
    pPlotUtil.legend()
    # plot the CDF 
    plt.subplot(2,1,2)
    # add a zero at the start, so the plot matches the PDF
    cdf = np.zeros(edges.size)
    cdf[1:] = np.cumsum(vals/sum(vals))
    mX = edges
    plt.plot(mX,cdf,linestyle='--',linewidth=4,color='k')
    plt.xlim(xlim)
    pPlotUtil.lazyLabel(xStr,
                        "Cummulative Proportion",
                        ("Cummulative Density Function," +
                         "Surface Detection Performance"))
    plt.gca().fill_between(mX, 0, cdf,alpha=0.3)
    pPlotUtil.savefig(fig,outPath + "FlatSpots.png")
def AnalyzeTraces(velX,velY,times,numTimes,fretRatio,MSD,frameRate):
    util.ReportMessage("AnalyzeTraces")
    proteinYStr = '# Proteins'
    numProteins = len(numTimes)
    numBins = max(numTimes)
    fig = plotUtil.pFigure()
    titleStr = "Raw distribution of protein appearances"
    ax = fig.add_subplot(1,1,1)
    plotUtil.histogramPlot(ax,'Frame duration of protein',proteinYStr,
                           titleStr,numTimes,numBins)
    plotUtil.saveFigure(fig,"Protein_Distribution")

    fig = plotUtil.pFigure()
    # save the MSD and R^2 of the MSD
    numStats = 2
    msdMatrix = np.zeros((numProteins,numStats))
    plotCount = 1
    numPlots = 2
    msdAx = plt.subplot(numPlots,1,plotCount)
    allMSDs = np.concatenate(MSD)
    allTimes= np.concatenate(times)
    for i in range(numProteins):
        # get the X and Y values to fit...
        tmpMSD = MSD[i]
        # multiple the times by four, per the diffusion formulae
        tmpTimes = times[i]*2
        tmpTimes -= tmpTimes[0]
        if (len(tmpTimes) < 3):
            # nothing valid here. set everything to 0 and flag 0 RSQ later
            # we need at least three values to be able to get a Diffusion Coefficient
            # and an uncertainty.
            msdMatrix[i,:] = 0
            continue
        # linear fit
        deg = 1
        polyVals = np.polyfit(tmpTimes,tmpMSD,deg)
        polyFunc = np.poly1d(polyVals)
        fitVals = polyFunc(tmpTimes)
        slope, intercept, r_value, p_value, std_err = \
                        stats.linregress(fitVals,tmpMSD)
        rSquared = r_value**2
        # MSD (slope) is given by the slope, first coeff returned
        diffCoeff = polyVals[0]
        if (diffCoeff < 0):
            # ignore diffusion coefficients less than 0
            continue
        msdMatrix[i,0] = diffCoeff
        msdMatrix[i,1] = rSquared
    rawRsqVals = msdMatrix[:,1]
    goodIndices = np.where(rawRsqVals > 0)[0]
    goodMsds = np.take(msdMatrix,goodIndices,axis=0)
    msdVals =  goodMsds[:,0]
    # plot the histogram of MSDs
    ax = fig.add_subplot(numPlots,1,plotCount)
    numBins = max(msdVals)
    numProteins = len(msdVals)
    axTmp = plotUtil.histogramPlot(ax,'Diffusion Coeff (pixels^2/second)',
                                   proteinYStr,
                                   'Histogram of Protein Hiffusion Coeffs',
                                   msdVals,numBins)
    plotCount+=1
    # plot the rSquared values
    RSqVals = goodMsds[:,1]*100
    # RSQ is between 0 and 1, multiply by 100 and fit with 100 bins for 'simple' normalization
    numBinsRsq= 100 
    ax = fig.add_subplot(numPlots,1,plotCount)
    # use 100 bins for each of the RSq values
    plotUtil.histogramPlot(ax,'R Squared Coeff',proteinYStr,
                            'Histogram of Protein RSq',RSqVals,numBinsRsq)
    plotCount += 1
    # next, we plot a comparison of the 'raw', 'valid' (D with uncertainty),
    # and 'processed'
    # (D fit with RSQ > cutoffRsq)
    cutoffRsq = 0.8
    plt.tight_layout()
    plotUtil.saveFigure(fig,"MSD")
    
    titleStr = proteinYStr
    xStr = 'Frames Appearing'
    xLimit = [1,max(numTimes)]
    bestIndices = np.where(rawRsqVals > cutoffRsq)[0]
    # make labels for each of the indices ('Raw' is assumed...)
    compLabel = ["All Proteins","Valid Diffusion Coeffs",
                        ("RSQ > {:.3f}".format(cutoffRsq))]
    comparisonIndices = [goodIndices,bestIndices]
    plotUtil.comparisonPlot(xStr,proteinYStr,titleStr,xLimit,numTimes,
                            comparisonIndices,compLabel)
    # XXX TODO: compare other options (e.g. x velocity, y velcocity, etc)
    # XXX TODO: try for all files, need a better way to store
    # return all the diffusion coeffs, as well as the 'best' indices we found
    return msdMatrix[:,0],bestIndices
Пример #29
0
 lengths = np.array([2,4,8,16,32,64,128,256,512])
 # save the K array: minimum k to have at most one k-mer
 # initialize to -1, so that we know when we have the minimum
 outDir = "./out/"
 pGenUtil.ensureDirExists(outDir)
 forceRun = False
 test = False
 # use checkpointing to save data, since it takes forever
 kArr = pCheckUtil.getCheckpoint('./tmp/check.pkl',getKSequence,forceRun,
                                 lengths,numOligos,weights,chars)
 meanVals,std = pCheckUtil.getCheckpoint('./tmp/meanStd.pkl',plotAll,
                                         forceRun,kArr,outDir)
 if (test):
     testDnaGeneration(chars,lengths,numOligos,weights)
 # plot the mean k vs dna length, l (in theory, k is approx log_1/q(l+1))
 fig = pPlotUtil.figure()
 ax = plt.subplot(1,3,1)
 plt.errorbar(x=lengths,y=meanVals,yerr=std,fmt='ro-',label='Mean K')
 tKVals = getTheoryK(lengths,q)
 plt.plot(lengths,tKVals,'b--',label='Log_[1/q](l+1)')
 xLab = 'DNA Length (l)'
 plt.xlabel(xLab)
 plt.ylabel('Mean K value')
 plt.title('Mean K vs length')
 ax.set_xscale('log')
 plt.legend(loc='best')
 ax = plt.subplot(1,3,2)
 plotError(meanVals,tKVals,lengths,xLab,'Absolute Error in Mean K ',
           'Absolute error in Mean K',ax,relative=False)
 ax = plt.subplot(1,3,3)
 plotError(meanVals,tKVals,lengths,xLab,'Relative Error in Mean K [0-->1]',
Пример #30
0
import PlotUtilities as pPlotUtil
import CheckpointUtilities as pCheckUtil

from scipy.stats import norm
outDir = "./out/"
pGenUtil.ensureDirExists(outDir)

mean = 0
stdev = 1
epsilon = stdev / 100
nPoints = 1000
normDist = norm(loc=mean, scale=stdev)
offsets = np.linspace(mean - 3 * stdev, mean + 3 * stdev, nPoints)
probability = 2 * (normDist.cdf(
    (offsets + epsilon - mean) / stdev) - normDist.cdf(
        (offsets - epsilon - mean) / stdev))

fig = pPlotUtil.figure()
plt.plot(offsets,probability,'r-',
         label="mu = {:.1f}, sigma = {:.1f}, epsilon = {:.2f}".\
         format(mean,stdev,epsilon))
plt.xlabel("offset for CDF, c0")
plt.ylabel("Probability (arbitrary units) to land within epsilon of c0")
plt.axvline(0,
            color='k',
            linestyle='--',
            label="Maximum probability when centered near mu")
plt.legend(loc='best')
plt.title("Probability of landing within epsilon of c0 maximized near mu")
pPlotUtil.savefig(fig, outDir + "q1_1")
def GetPhysicsMain(goodTimes,goodFRET,goodDiff):
    source = 'Step2::GetPhysics'
    util.ReportMessage("Starting",source)
    colors = ['r','g','b','k','m','c','y','0.33','0.66']
    colorCycle = cycle(colors)
    count = 0
    fig = plotUtil.pFigure()
    # XXXfill all these in! based on video size
    frameRate = 0.1
    maxNumTimes = 30*10
    distances,times,definedDistancesIdx,nodeIdx =getDistances(goodFRET,goodTimes)
    # get just the 'nodes' with valid valued.
    # flatten the distances to get a notion of the 'all time'
    # distance information. We can use this and kmeans to find a 'folded
    # and unfolded sttae
    flattenDistances = np.concatenate(distances)
    # use two clusters; folded and unfolded
    numClusters = 2
    # lots of iterations (this number seems to work well; the 'smooth'
    # running time / convergence (?) of kmeans is polynomial
    # http://en.wikipedia.org/wiki/K-means_clustering
    numIters = int(1e3)
    clusters,ignore = cluster.kmeans(flattenDistances,numClusters,iter=numIters)
    # the clusters give us the 'folded' and 'unfolded' groups. between those, we have
    # a fairly undefined state.
    folded = min(clusters)
    unfolded = max(clusters)
    clusters = [unfolded,folded]
    
    folded = getMinimumTime(distances,times,folded,False)
    unfolded = getMinimumTime(distances,times,unfolded,True)
    diffTime, definedUnfoldingIdx = getDifferentialTime(folded,unfolded)

    goodDiff = util.takeSubset(goodDiff,
                                [nodeIdx,definedUnfoldingIdx])

    plt.xscale('log', nonposy='clip')
    plt.xlabel('Time since protein (seconds)')
    plt.ylabel('FRET d distance (arb)')
    fig = plotUtil.pFigure()
    numPlots = 2
    plotCount = 1
    fretLabel = 'FRET d Distance (arb)'
    ax = plt.subplot(numPlots,1,plotCount)
    plotUtil.histogramPlot(ax,fretLabel,'# Proteins',
                           'FRET Distance histogram',flattenDistances,
                           len(flattenDistances)/100,True,True)
    # plot guiding lines for the two clusters we found
    normalClusters = plotUtil.normalizeTo(flattenDistances,clusters)
    plt.axvline(normalClusters[0])
    plt.axvline(normalClusters[1])
    
    plotCount += 1
    ax = plt.subplot(numPlots,1,plotCount)
    plotUtil.histogramPlot(ax,'Unfolding time distribution','# Proteins',
                           'Unfolding time (seconds) ',diffTime,
                           len(diffTime)/100,True,True)


    plotUtil.saveFigure(fig,'tmp2')
    # return the good unfolding times and differential coefficients
    return diffTime,goodDiff
Пример #32
0
    def __init__(self, dialog, parent):

        Ui_LocationSetup.__init__(self)
        zp = pu.ZoomPan()
        self.setupUi(dialog)
        self.dialog = dialog
        self.parent = parent

        self.lsAspectRatio_verticalSlider.setValue(1)
        self.lsAspectRatio_verticalSlider.valueChanged.connect(
            self.redraw_with_aspectratio)

        self.lsAccept_pushButton.clicked.connect(self.makeResults_and_done)
        self.lsCentralization_fields = mdl.get_lsCentralization_fields()
        self.__init__lsCentralizerLocations_tableWidget()

        self.MD = self.parent.v3WorkWellboreMD
        self.ID = self.parent.v3WorkWellboreID
        self.max_MD = mu.np.max(self.MD)
        self.min_MD = mu.np.min(self.MD)
        self.lim_ID = mu.np.max(self.ID) * 1.2

        self.numofStages = mdl.cat_locations(self)
        self.centralizerCount = len(self.lsCentralization_fields.MD)
        self.update_calculations()

        #-------------------------------------------------

        self.lsCaliperMap_graphicsView.axes.set_position([0.3, 0.15, 0.6, 0.8])
        self.lsCaliperMap_graphicsView_ylimits = [None, None]
        self.lsCaliperMap_graphicsView_yselection = []

        self.lsSOVisualization_graphicsView.axes.set_position(
            [0.2, 0.15, 0.7, 0.8])
        self.lsSOVisualization_graphicsView_ylimits = [None, None]
        self.lsSOVisualization_graphicsView_yselection = []

        self.lsSideForces_graphicsView.axes.set_position([0.2, 0.15, 0.7, 0.8])
        #self.lsSideForces_graphicsView_ylimits    = [None,None]
        #self.lsSideForces_graphicsView_yselection = []

        zp.zoomYD_factory((self.lsCaliperMap_graphicsView.axes,
                           self.lsSOVisualization_graphicsView.axes),
                          (self.lsCaliperMap_graphicsView_ylimits,
                           self.lsSOVisualization_graphicsView_ylimits))
        zp.panYD_factory((self.lsCaliperMap_graphicsView.axes,
                          self.lsSOVisualization_graphicsView.axes),
                         (self.lsCaliperMap_graphicsView_ylimits,
                          self.lsSOVisualization_graphicsView_ylimits),
                         (self.lsCaliperMap_graphicsView_yselection,
                          self.lsSOVisualization_graphicsView_yselection),
                         ypressfunction1=self.highlight_MDlocation,
                         ypressfunction3=self.choose_MDlocation)
        zp.zoom2D_factory(self.lsSideForces_graphicsView.axes)
        zp.pan2D_factory(self.lsSideForces_graphicsView.axes)

        self.lsCaliperMap_graphicsView.axes.clear()
        self.lsSOVisualization_graphicsView.axes.clear()
        self.lsSideForces_graphicsView.axes.clear()

        #-------------------------------------------------

        self.lsCaliperMap_graphicsView.axes.fill_betweenx(self.MD,
                                                          -self.ID,
                                                          +self.ID,
                                                          alpha=0.5,
                                                          color='C0')
        factors = mu.np.linspace(1.2, 1.6, 8)

        for stage in self.parent.v3WellboreInnerStageData.values():

            MDstage, IDstage = mdl.get_LASMDandCALID_intoStage(self, stage)
            IPODstage = stage['PipeProps'].OD[0]
            """
			for factor in factors[1:]:
				IPOD = IPODstage*factor
				self.lsCaliperMap_graphicsView.axes.fill_betweenx( MDstage, +IPOD, +IDstage, where=IPOD<IDstage, alpha=0.15, color='C3')
				self.lsCaliperMap_graphicsView.axes.fill_betweenx( MDstage, -IPOD, -IDstage, where=IPOD<IDstage, alpha=0.15, color='C3')
			"""

            if stage['Centralization']['Mode'] == False:
                self.lsCaliperMap_graphicsView.axes.fill_betweenx(
                    MDstage, -IDstage, +IDstage, alpha=0.5, color='white')

            self.lsCaliperMap_graphicsView.axes.plot(
                [-self.lim_ID, self.lim_ID], [stage['MDbot'], stage['MDbot']],
                'k-',
                lw=0.5,
                alpha=0.5)
            self.lsCaliperMap_graphicsView.axes.plot([-IPODstage, -IPODstage],
                                                     [MDstage[0], MDstage[-1]],
                                                     'C1',
                                                     lw=2)
            self.lsCaliperMap_graphicsView.axes.plot([+IPODstage, +IPODstage],
                                                     [MDstage[0], MDstage[-1]],
                                                     'C1',
                                                     lw=2)

        MDHeaderName = self.lsCentralization_fields.MD.headerName
        IDHeaderName = self.lsCentralization_fields.ID.headerName

        self.lsCaliperMap_graphicsView.axes.set_xlabel(IDHeaderName)
        self.lsCaliperMap_graphicsView.axes.set_ylabel(MDHeaderName)
        self.lsCaliperMap_graphicsView.axes.set_xlim(-self.lim_ID, self.lim_ID)
        self.lsCaliperMap_graphicsView.axes.set_ylim(self.max_MD, self.min_MD)
        #self.lsCaliperMap_graphicsView.draw()

        #-------------------------------------------------

        max_VD = max(self.parent.v3Forces_fields.TVD)
        min_VD = min(self.parent.v3Forces_fields.TVD)
        max_SF = max(self.parent.v3Forces_fields.SideF)

        self.lsSideForces_graphicsView.axes.axis('equal')
        self.lsSideForces_graphicsView.axes.set_ylim(max_VD, min_VD)
        self.lsSideForces_graphicsView.axes.set_xlabel(
            self.parent.v3Forces_fields.HD.headerName)
        self.lsSideForces_graphicsView.axes.set_ylabel(
            self.parent.v3Forces_fields.TVD.headerName)

        self.lsSideForces_graphicsView.axes.plot(
            self.parent.v3Forces_fields.HD,
            self.parent.v3Forces_fields.TVD,
            'C0',
            lw=3)
        factor = max(self.parent.v3Forces_fields.HD) / max(
            self.parent.v3Forces_fields.SideF) * 0.5
        for i, MDi in enumerate(self.parent.v3Forces_fields.MD):
            HDi = self.parent.v3Forces_fields.HD[i]
            VDi = self.parent.v3Forces_fields.TVD[i]
            DFi = self.parent.v3Forces_fields.DLplaneF[i]
            SFi = self.parent.v3Forces_fields.SideF[i]

            T = mdl.mdl.get_ASCT_from_MD(self.parent, MDi, MDi.unit)
            t = mu.np.array([T[3], T[2], 0])
            t = t.reshape(1, -1)
            normt = mu.np.linalg.norm(t)
            if normt != 0.0:
                t /= normt
            u = mu.np.array([0, 0, -DFi])
            u = u.reshape(1, -1)
            normu = mu.np.linalg.norm(u)
            if normu != 0.0:
                u /= normu

            if normt == 0 or normu == 0:
                n = mu.np.array([0, 0, 0])
                n = n.reshape(1, -1)
            else:
                n = mu.np_cross(t, u)
                n *= SFi * factor

            self.lsSideForces_graphicsView.axes.arrow(HDi,
                                                      VDi,
                                                      n[0][0],
                                                      n[0][1],
                                                      head_width=factor * 0.1,
                                                      head_length=factor * 0.2,
                                                      fc='C1',
                                                      ec='C1')
            #self.lsSideForces_graphicsView.axes.arrow(HDi, VDi, t[0][0], t[0][1], head_width=factor*0.1, head_length=factor*0.2, fc='C1', ec='C1')

        for stage in self.parent.v3WellboreInnerStageData.values():
            MDbot = stage['MDbot']
            EW, NS, VD, HD, i = mdl.mdl.get_ASCCoordinates_from_MD(
                self.parent, MDbot)

            T = mdl.mdl.get_ASCT_from_MD(self.parent, MDbot, MDbot.unit)
            t = mu.np.array([T[3], T[2], 0])
            t = t.reshape(1, -1)
            normt = mu.np.linalg.norm(t)
            if normt != 0.0:
                t /= normt
            u = mu.np.array([0, 0, 1])
            u = u.reshape(1, -1)
            nu = mu.np_cross(t, u)
            nu *= 1.2 * max_SF * factor

            d = mu.np.array([0, 0, -1])
            d = d.reshape(1, -1)
            nd = mu.np_cross(t, d)
            nd *= 1.2 * max_SF * factor

            self.lsSideForces_graphicsView.axes.arrow(HD,
                                                      VD,
                                                      nu[0][0],
                                                      nu[0][1],
                                                      head_width=0,
                                                      head_length=0,
                                                      fc='k',
                                                      ec='k',
                                                      lw=0.5,
                                                      alpha=0.5)
            self.lsSideForces_graphicsView.axes.arrow(HD,
                                                      VD,
                                                      nd[0][0],
                                                      nd[0][1],
                                                      head_width=0,
                                                      head_length=0,
                                                      fc='k',
                                                      ec='k',
                                                      lw=0.5,
                                                      alpha=0.5)

        #-------------------------------------------------

        SOHeaderName = self.lsCentralization_fields.SOatC.headerName + '  &  ' + self.lsCentralization_fields.SOatM.headerName
        if self.lsCentralization_fields.SOatC.unit == '%':
            self.max_SO = 100
            self.min_SO = 67
            self.ΔSO = 10
        elif self.lsCentralization_fields.SOatC.unit == '1':
            self.max_SO = 1
            self.min_SO = 0.67
            self.ΔSO = 0.1

        self.lsSOVisualization_graphicsView.axes.set_xlabel(SOHeaderName)
        self.lsSOVisualization_graphicsView.axes.set_ylabel(MDHeaderName)
        self.lsSOVisualization_graphicsView.axes.set_xlim(
            -self.ΔSO, self.max_SO + self.ΔSO)
        self.lsSOVisualization_graphicsView.axes.set_ylim(
            self.max_MD, self.min_MD)
        #self.lsSOVisualization_graphicsView.axes.grid()
        self.lsSOVisualization_graphicsView.axes.plot(
            [self.min_SO, self.min_SO], [self.max_MD, self.min_MD],
            'C3--',
            lw=2)
        self.lsSOVisualization_graphicsView.axes.plot(
            [0, 0], [self.max_MD, self.min_MD], 'k-', lw=1, alpha=0.3)
        self.lsSOVisualization_graphicsView.axes.plot(
            [self.max_SO, self.max_SO], [self.max_MD, self.min_MD],
            'k-',
            lw=1,
            alpha=0.3)
        for stage in self.parent.v3WellboreInnerStageData.values():
            self.lsSOVisualization_graphicsView.axes.plot(
                [0, self.max_SO], [stage['MDbot'], stage['MDbot']],
                'k-',
                lw=0.5,
                alpha=0.5)

        #self.lsSOVisualization_graphicsView.draw()

        #-------------------------------------------------

        EW = parent.v2ASCComplements_fields.EW
        NS = parent.v2ASCComplements_fields.NS
        VD = parent.v2ASCComplements_fields.TVD

        self.max_VD = max(VD)
        self.min_VD = min(VD)
        self.max_EW = max(EW)
        self.min_EW = min(EW)
        self.max_NS = max(NS)
        self.min_NS = min(NS)

        self.ΔVD = self.max_VD - self.min_VD
        self.ΔEW = self.max_EW - self.min_EW
        self.ΔNS = self.max_NS - self.min_NS

        self.Δ = max([self.ΔVD, self.ΔEW, self.ΔNS])

        ar = self.lsAspectRatio_verticalSlider.sliderPosition()
        self.set_3DGraph_limits(ar)

        curve, = self.lsWellbore3D_graphicsView.axes.plot(EW, NS, VD, lw=3)

        self.lsWellbore3D_graphicsView.axes.plot([0, 0], [0, 0],
                                                 [VD[0], VD[-1]],
                                                 'g--',
                                                 lw=1)
        self.lsWellbore3D_graphicsView.axes.plot([0, EW[-1]], [0, NS[-1]],
                                                 [VD[-1], VD[-1]],
                                                 'g--',
                                                 lw=1)

        self.lsWellbore3D_graphicsView.axes.set_xlabel(EW.headerName)
        self.lsWellbore3D_graphicsView.axes.set_ylabel(NS.headerName)
        self.lsWellbore3D_graphicsView.axes.set_zlabel(VD.headerName)

        self.lsWellbore3D_graphicsView.axes.mouse_init()
        #zp.point3D_factory(self.s2TriDView_graphicsView.axes, dot, curve)
        zp.zoom3D_factory(self.lsWellbore3D_graphicsView.axes, curve)
        #self.lsWellbore3D_graphicsView.draw()

        #-------------------------------------------------

        self.draw_MDlocations(initial=True)
        self.parent.v3CentralizationProcessed_flag = True

        dialog.setAttribute(Qt.WA_DeleteOnClose)
        dialog.exec_()
    return  (-b*t/(t+a))

CRTD = [1.0 , 0.48386793340231393, 0.23356222368544821, 0.14250776032358203, 0.093876399209858019, 0.066973944125670259, 0.05041858715078551, 0.038848650174019395, 0.03235819772363846, 0.028689681121249255, 0.0242686482927289, 0.021917035086069125, 0.018718841125011876, 0.016649421503151296, 0.015050324522622671, 0.012980904900762091, 0.012040259618098181, 0.011381807920233467, 0.010535227165835992, 0.010158969052770472, 0.0092183237701065623, 0.0079014203743771327, 0.0075251622613116131, 0.0071489041482460935, 0.0066785815069141385, 0.0061141943373157481, 0.0056438716959837931, 0.0053616781111845979, 0.0051735490546518381, 0.0050794845263854027, 0.0049854199981189673, 0.0047972909415862075, 0.0044210328285206879, 0.0040447747154551683, 0.0039507101871887329, 0.0038566456589222975, 0.0035744520741231023, 0.0033863230175903425, 0.0032922584893239071, 0.0031981939610574717, 0.0031041294327910363, 0.0030100649045246008, 0.0029160003762581654, 0.00282193584799173, 0.0027278713197252946, 0.0026338067914588592, 0.0025397422631924238, 0.0024456777349259884, 0.0022575486783932286, 0.0021634841501267932, 0.0020694196218603578, 0.001881290565327598, 0.0016931615087948382, 0.0015990969805284028, 0.0015050324522619674, 0.0014109679239955319, 0.0013169033957290965, 0.0011287743391963367, 0.00094064528266357694, 0.00084658075439714153, 0.00075251622613070612, 0.00065845169786427071, 0.0005643871695978353, 0.00047032264133139989, 0.00037625811306496448, 0.00028219358479852907, 0.00018812905653209366]
times  = [0.0, 0.10000000000000001, 0.20000000000000001, 0.30000000000000004, 0.40000000000000002, 0.5, 0.60000000000000009, 0.70000000000000007, 0.80000000000000004, 0.90000000000000002, 1.0, 1.1000000000000001, 1.2000000000000002, 1.3, 1.4000000000000001, 1.5, 1.6000000000000001, 1.7000000000000002, 1.8, 1.9000000000000001, 2.0, 2.1000000000000001, 2.2000000000000002, 2.3000000000000003, 2.4000000000000004, 2.5, 2.6000000000000001, 2.7000000000000002, 2.8000000000000003, 2.9000000000000004, 3.0, 3.1000000000000001, 3.2000000000000002, 3.4000000000000004, 3.5, 3.6000000000000001, 4.0, 4.1000000000000005, 4.2000000000000002, 4.2999999999999998, 4.4000000000000004, 4.5, 4.7000000000000002, 4.8000000000000007, 4.9000000000000004, 5.0, 5.3000000000000007, 5.4000000000000004, 5.5, 5.7000000000000002, 6.1000000000000005, 6.2000000000000002, 6.7000000000000002, 6.9000000000000004, 7.8000000000000007, 9.0, 9.4000000000000004, 9.6000000000000014, 9.9000000000000004, 11.0, 11.4, 11.700000000000001, 12.0, 12.100000000000001, 12.700000000000001, 16.400000000000002, 21.700000000000003]

times = np.array(times)
CRTD = np.array(CRTD)
logP = np.log(CRTD)
# fit to the normal CRTD
popt, pcov = curve_fit(hyperfit,times,CRTD)
paramsStd = np.sqrt(np.diag(pcov))
# get the predicted values
predict = hyperfit(times,*popt)
# get the string for the model label
modelStr,modelParams = fitStr(popt,paramsStd,predict,CRTD,True)
fig = pltUtil.pFigure()
numPlots = 3
plotCount = 1
xLabelStr = 'Time to unfold, t (seconds)'
# plot it all
timeConstant = popt[0]
timeLabel = modelParams[0]
ax = plt.subplot(numPlots,1,plotCount)
ax.axvline(timeConstant,color='k',label=timeLabel)
ax.plot(times,CRTD,'ro',label="Data")
ax.plot(times,predict,'b-',label=modelStr)
ax.set_ylim([min(CRTD),max(CRTD)])
ax.set_yscale('log')
plt.grid(b=True, which='major', color='b', linestyle='-')
plt.grid(b=True, which='minor', color='r', linestyle='--')
plt.legend(loc='best')
Пример #34
0
def calculateAndDraw_torque_drag_sideforce(self):

    for field in self.v4TorqueDragForces_fields:
        print(field.headerName, len(field), field)

    calculate_TorqueAndDrag(self)

    for field in self.v4TorqueDragForces_fields:
        print(field.headerName, len(field), field)

    TDS_fields = self.v4TorqueDragForces_fields

    for field in self.v4TorqueDragForces_fields[:7]:
        for row, value in enumerate(field):
            item = self.s4TorqueDragSideforce_tableWidget.item(row, field.pos)
            item.set_text(value, value.unit)

    max_MD = max(TDS_fields.MD)

    self.s4Drag_graphicsView.axes.clear()
    self.s4Drag_graphicsView.axes.set_xlabel(TDS_fields.Drag_s.headerName)
    self.s4Drag_graphicsView.axes.set_ylabel(TDS_fields.MD.headerName)
    #self.s4Drag_graphicsView.axes.set_xlim( 0, self.max_SO )
    self.s4Drag_graphicsView.axes.set_ylim(max_MD * 1.2, 0)
    self.s4Drag_graphicsView.axes.grid()
    self.s4Drag_graphicsView.axes.plot(TDS_fields.Drag_u,
                                       TDS_fields.MD,
                                       'C0',
                                       lw=2)
    self.s4Drag_graphicsView.axes.plot(TDS_fields.Drag_s,
                                       TDS_fields.MD,
                                       'C1',
                                       lw=2)
    self.s4Drag_graphicsView.axes.plot(TDS_fields.Drag_d,
                                       TDS_fields.MD,
                                       'C2',
                                       lw=2)
    self.s4Drag_graphicsView.axes.plot(TDS_fields.uncDrag_u,
                                       TDS_fields.MD,
                                       'C0--',
                                       lw=2)
    self.s4Drag_graphicsView.axes.plot(TDS_fields.uncDrag_s,
                                       TDS_fields.MD,
                                       'C1--',
                                       lw=2)
    self.s4Drag_graphicsView.axes.plot(TDS_fields.uncDrag_d,
                                       TDS_fields.MD,
                                       'C2--',
                                       lw=2)
    self.s4Drag_graphicsView.draw()

    #---------------------------------------------
    self.s4Torque_graphicsView.axes.clear()
    self.s4Torque_graphicsView.axes.set_xlabel(TDS_fields.Torque.headerName)
    self.s4Torque_graphicsView.axes.set_ylabel(TDS_fields.MD.headerName)
    #self.s4Torque_graphicsView.axes.set_xlim( 0, self.max_SO )
    self.s4Torque_graphicsView.axes.set_ylim(max_MD * 1.2, 0)
    self.s4Torque_graphicsView.axes.grid()
    self.s4Torque_graphicsView.axes.plot(TDS_fields.Torque,
                                         TDS_fields.MD,
                                         'C0',
                                         lw=2)
    self.s4Torque_graphicsView.axes.plot(TDS_fields.uncTorque,
                                         TDS_fields.MD,
                                         'C0--',
                                         lw=2)
    self.s4Torque_graphicsView.draw()

    #---------------------------------------------

    self.s4Sideforce_graphicsView.axes.set_position([0.2, 0.15, 0.75, 0.8])
    zp = pu.ZoomPan()
    zp.zoom2D_factory(self.s4Sideforce_graphicsView.axes)
    zp.pan2D_factory(self.s4Sideforce_graphicsView.axes)
    self.s4Sideforce_graphicsView.axes.clear()

    max_VD = max(self.v3Forces_fields.TVD)
    min_VD = min(self.v3Forces_fields.TVD)
    max_SF = max(self.v3Forces_fields.SideF)

    self.s4Sideforce_graphicsView.axes.axis('equal')
    self.s4Sideforce_graphicsView.axes.set_ylim(max_VD, min_VD)
    self.s4Sideforce_graphicsView.axes.set_xlabel(
        self.v3Forces_fields.HD.headerName)
    self.s4Sideforce_graphicsView.axes.set_ylabel(
        self.v3Forces_fields.TVD.headerName)

    self.s4Sideforce_graphicsView.axes.plot(self.v3Forces_fields.HD,
                                            self.v3Forces_fields.TVD,
                                            'C0',
                                            lw=3)
    factor = max(self.v3Forces_fields.HD) / max(
        self.v3Forces_fields.SideF) * 0.5
    for i, MDi in enumerate(self.v3Forces_fields.MD):
        HDi = self.v3Forces_fields.HD[i]
        VDi = self.v3Forces_fields.TVD[i]
        DFi = self.v3Forces_fields.DLplaneF[i]
        SFi = self.v3Forces_fields.SideF[i]

        T = mdl.get_ASCT_from_MD(self, MDi, MDi.unit)
        t = mu.np.array([T[3], T[2], 0])
        t = t.reshape(1, -1)
        normt = mu.np.linalg.norm(t)
        if normt != 0.0:
            t /= normt
        u = mu.np.array([0, 0, -DFi])
        u = u.reshape(1, -1)
        normu = mu.np.linalg.norm(u)
        if normu != 0.0:
            u /= normu

        if normt == 0 or normu == 0:
            n = mu.np.array([0, 0, 0])
            n = n.reshape(1, -1)
        else:
            n = mu.np_cross(t, u)
            n *= SFi * factor

        self.s4Sideforce_graphicsView.axes.arrow(HDi,
                                                 VDi,
                                                 n[0][0],
                                                 n[0][1],
                                                 head_width=factor * 0.1,
                                                 head_length=factor * 0.2,
                                                 fc='C1',
                                                 ec='C1')
        #self.s4Sideforce_graphicsView.axes.arrow(HDi, VDi, t[0][0], t[0][1], head_width=factor*0.1, head_length=factor*0.2, fc='C1', ec='C1')

    for stage in self.v3WellboreInnerStageData.values():
        MDbot = stage['MDbot']
        EW, NS, VD, HD, i = mdl.get_ASCCoordinates_from_MD(self, MDbot)

        T = mdl.get_ASCT_from_MD(self, MDbot, MDbot.unit)
        t = mu.np.array([T[3], T[2], 0])
        t = t.reshape(1, -1)
        normt = mu.np.linalg.norm(t)
        if normt != 0.0:
            t /= normt
        u = mu.np.array([0, 0, 1])
        u = u.reshape(1, -1)
        nu = mu.np_cross(t, u)
        nu *= 1.2 * max_SF * factor

        d = mu.np.array([0, 0, -1])
        d = d.reshape(1, -1)
        nd = mu.np_cross(t, d)
        nd *= 1.2 * max_SF * factor

        self.s4Sideforce_graphicsView.axes.arrow(HD,
                                                 VD,
                                                 nu[0][0],
                                                 nu[0][1],
                                                 head_width=0,
                                                 head_length=0,
                                                 fc='k',
                                                 ec='k',
                                                 lw=0.5,
                                                 alpha=0.5)
        self.s4Sideforce_graphicsView.axes.arrow(HD,
                                                 VD,
                                                 nd[0][0],
                                                 nd[0][1],
                                                 head_width=0,
                                                 head_length=0,
                                                 fc='k',
                                                 ec='k',
                                                 lw=0.5,
                                                 alpha=0.5)

    #-------------------------------------------------

    self.s4HookLoad_graphicsView.axes.clear()
    self.s4HookLoad_graphicsView.axes.set_xlabel(TDS_fields.Drag_s.headerName)
    self.s4HookLoad_graphicsView.axes.set_ylabel(TDS_fields.MD.headerName)
    self.s4HookLoad_graphicsView.axes.set_ylim(max_MD * 1.2, 0)
    self.s4HookLoad_graphicsView.axes.grid()
    max_Drag_u = max(TDS_fields.Drag_u)
    max_Drag_s = max(TDS_fields.Drag_s)
    max_Drag_d = max(TDS_fields.Drag_d)
    max_uncDrag_u = max(TDS_fields.uncDrag_u)
    max_uncDrag_s = max(TDS_fields.uncDrag_s)
    max_uncDrag_d = max(TDS_fields.uncDrag_d)
    self.s4HookLoad_graphicsView.axes.plot(max_Drag_u -
                                           mu.array(TDS_fields.Drag_u),
                                           TDS_fields.MD,
                                           'C0',
                                           lw=2)
    self.s4HookLoad_graphicsView.axes.plot(max_Drag_s -
                                           mu.array(TDS_fields.Drag_s),
                                           TDS_fields.MD,
                                           'C1',
                                           lw=2)
    self.s4HookLoad_graphicsView.axes.plot(max_Drag_d -
                                           mu.array(TDS_fields.Drag_d),
                                           TDS_fields.MD,
                                           'C2',
                                           lw=2)
    self.s4HookLoad_graphicsView.axes.plot(max_uncDrag_u -
                                           mu.array(TDS_fields.uncDrag_u),
                                           TDS_fields.MD,
                                           'C0--',
                                           lw=2)
    self.s4HookLoad_graphicsView.axes.plot(max_uncDrag_s -
                                           mu.array(TDS_fields.uncDrag_s),
                                           TDS_fields.MD,
                                           'C1--',
                                           lw=2)
    self.s4HookLoad_graphicsView.axes.plot(max_uncDrag_d -
                                           mu.array(TDS_fields.uncDrag_d),
                                           TDS_fields.MD,
                                           'C2--',
                                           lw=2)
    self.s4HookLoad_graphicsView.draw()