当前位置: 首页>>代码示例>>Python>>正文


Python SSUtilities.compareFloat方法代码示例

本文整理汇总了Python中SSUtilities.compareFloat方法的典型用法代码示例。如果您正苦于以下问题:Python SSUtilities.compareFloat方法的具体用法?Python SSUtilities.compareFloat怎么用?Python SSUtilities.compareFloat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SSUtilities的用法示例。


在下文中一共展示了SSUtilities.compareFloat方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import compareFloat [as 别名]
    def __init__(self, allVarNames, numChoose, ssdo,
                 weightMatrix, weightsType = "SWM",
                 minR2 = .5, maxCoef = .01, maxVIF = 5.0,
                 minJB = .1, minMI = .1, silent = False):

        #### Set Initial Attributes ####
        UTILS.assignClassAttr(self, locals())

        #### Set Label ####
        self.numVars = len(self.allVarNames)

        self.label = ARCPY.GetIDMessage(84283).format(numChoose, self.numVars)
        if numChoose <= 2:
            self.eachAppears = 1
        else:
            self.eachAppears = nChooseK(self.numVars - 2, numChoose - 2)

        #### Set Result Structures ####
        self.varSignDict = {}
        self.signDict = {}
        self.vifDict = {}
        for varName in self.allVarNames:
            self.varSignDict[varName] = [0, 0]
            self.signDict[varName] = [0, 0]
            self.vifDict[varName] = [0, []]

        self.olsResults = {}
        self.bestR2Vals = []
        self.bestR2Res = []
        self.passTable = []
        self.passBools = []
        self.r2Residuals = NUM.empty((self.ssdo.numObs, 3), dtype = float)
        self.allJBPass = UTILS.compareFloat(0.0, self.minJB, rTol = .00000001)
        self.allMIPass = UTILS.compareFloat(0.0, self.minMI, rTol = .00000001)
        self.miVals = []
开发者ID:f-tonini,项目名称:Python-Scripts,代码行数:37,代码来源:ModelSelectionOLS.py

示例2: getMoranStats

# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import compareFloat [as 别名]
    def getMoranStats(self):
        self.sumMoranRuns = 0
        self.sumMoranPass = 0
        miValues = []
        miModels = []
        miSorted = NUM.array([(0.0, 0.0), (0.0, 0.0), (0.0, 0.0)], 
                             dtype = [('mi', float), ('r2', float)])
        for resKey, resHandler in UTILS.iteritems(self.resultDict):
            for olsKey, olsRes in UTILS.iteritems(resHandler.olsResults):
                miValue = olsRes.miPVal
                if miValue is not None:
                    numRes = len(miValues)
                    if numRes < 3:
                        miValues.append(miValue)
                        miModels.append(olsRes)
                    else:
                        if numRes == 3:
                            miSorted['mi'] = miValues
                            miSorted['r2'] = [ ols.r2 for ols in miModels ]

                        minIndex = miSorted.argsort(order = ('mi', 'r2'))[0]
                        minValue = miValues[minIndex]
                        valueSame = UTILS.compareFloat(minValue, miValue)
                        update = False
                        if valueSame:
                            if olsRes.r2 > miModels[minIndex].r2:
                                update = True
                        else:
                            if minValue < miValue:
                                update = True
                        if update:
                            miValues[minIndex] = miValue
                            miModels[minIndex] = olsRes
                            miSorted['mi'][minIndex] = miValue
                            miSorted['r2'][minIndex] = olsRes.r2
                    self.sumMoranRuns += 1
                    if miValue > self.minMI:
                        self.sumMoranPass += 1

        miOrder = list(miSorted.argsort(order = ('mi', 'r2')))
        #miOrder = list(NUM.argsort(miValues))
        miOrder.reverse()
        self.miReportRows = []
        for miIndex in miOrder:
            try:
                miResult = miModels[miIndex]
                self.miReportRows.append(miResult.report(orderType = 2))
            except:
                pass
开发者ID:f-tonini,项目名称:Python-Scripts,代码行数:51,代码来源:ModelSelectionOLS.py

示例3: __init__

# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import compareFloat [as 别名]
    def __init__(self, ssdo, dependentVar, independentVars, weightsFile,
                 outputReportFile = None, outputTable = None,
                 maxIndVars = 5, minIndVars = 1, minR2 = .5,
                 maxCoef = .01, maxVIF = 5.0, minJB = .1, minMI = .1):

        ARCPY.env.overwriteOutput = True

        #### Set Initial Attributes ####
        UTILS.assignClassAttr(self, locals())
        self.masterField = self.ssdo.masterField
        self.warnedTProb = False

        #### Set Boolean For Passing All Moran's I ####
        self.allMIPass = UTILS.compareFloat(0.0, self.minMI, rTol = .00000001)

        #### Assess Whether SWM File Being Used ####
        if weightsFile:
            weightSuffix = weightsFile.split(".")[-1].lower()
            if weightSuffix == "swm":
                self.weightsType = "SWM"
                self.weightsMatrix = self.weightsFile
            else:
                self.weightsType = "GWT"
                self.weightsMatrix = WU.buildTextWeightDict(weightsFile,
                                                 self.ssdo.master2Order)
        else:
            #### If No Weightsfile Provided, Use 8 Nearest Neighbors ####
            if ssdo.numObs <= 9:
                nn = ssdo.numObs - 2
                ARCPY.AddIDMessage("WARNING", 1500, 8, nn)
            else:
                nn = 8
            self.weightsType = "GA"
            gaSearch = GAPY.ga_nsearch(self.ssdo.gaTable)
            gaSearch.init_nearest(0.0, nn, "euclidean")
            self.weightsMatrix = gaSearch

        #### Initialize Data ####
        self.runModels()
开发者ID:rvinc66,项目名称:ArcGISRuntimeBook,代码行数:41,代码来源:ExploratoryRegression.py

示例4: checkBoundary

# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import compareFloat [as 别名]
    def checkBoundary(self):
        printOHSSubject(84486, addNewLine = False)

        #### Assure That There Is Only a Single Polygon ####
        cnt = UTILS.getCount(self.boundaryFC)
        if cnt > 1:
            #### Dissolve Polys into Boundary ####
            dissolveFC = UTILS.returnScratchName("Dissolve_TempFC")
            DM.Dissolve(self.boundaryFC, dissolveFC, "#", "#", "SINGLE_PART",
                        "DISSOLVE_LINES")
            self.boundaryFC = dissolveFC
            self.cleanUpList.append(dissolveFC)

        #### Read Boundary FC ####
        ssdoBound = SSDO.SSDataObject(self.boundaryFC,
                                 explicitSpatialRef = self.ssdo.spatialRef,
                                 silentWarnings = True,
                                 useChordal = True)

        polyDict, polyAreas = UTILS.readPolygonFC(self.boundaryFC,
                                spatialRef = self.ssdo.spatialRef,
                                useGeodesic = self.ssdo.useChordal)
        self.boundArea = sum(polyAreas.values())
        self.boundExtent = getPolyExtent(polyDict)

        del ssdoBound

        if UTILS.compareFloat(0.0, self.boundArea):
            #### Invalid Study Area ####
            ARCPY.AddIDMessage("ERROR", 932)
            self.cleanUp()
            raise SystemExit()
        else:
            areaStr = self.ssdo.distanceInfo.printDistance(self.boundArea)
            msg = ARCPY.GetIDMessage(84492).format(areaStr)
            printOHSAnswer(msg)
开发者ID:rvinc66,项目名称:ArcGISRuntimeBook,代码行数:38,代码来源:OptimizedHotSpotAnalysis.py

示例5: createOutput

# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import compareFloat [as 别名]
    def createOutput(self, outputFC):
        """Creates an Output Feature Class with the Standard Distances.

        INPUTS:
        outputFC (str): path to the output feature class
        """

        #### Validate Output Workspace ####
        ERROR.checkOutputPath(outputFC)

        #### Shorthand Attributes ####
        ssdo = self.ssdo
        caseField = self.caseField

        #### Increase Extent if not Projected ####
        if ssdo.spatialRefType != "Projected":
            sdValues = self.sd.values()
            if len(sdValues):
                maxRadius = max(sdValues)
                largerExtent = UTILS.increaseExtentByConstant(ssdo.extent, 
                                                    constant = maxRadius)
                largerExtent = [ LOCALE.str(i) for i in largerExtent ]
                ARCPY.env.XYDomain = " ".join(largerExtent)

        #### Create Output Feature Class ####
        ARCPY.SetProgressor("default", ARCPY.GetIDMessage(84003))
        outPath, outName = OS.path.split(outputFC)

        try:
            DM.CreateFeatureclass(outPath, outName, "POLYGON", 
                                  "", ssdo.mFlag, ssdo.zFlag, 
                                  ssdo.spatialRefString)
        except:
            ARCPY.AddIDMessage("ERROR", 210, outputFC)
            raise SystemExit()

        #### Add Fields to Output FC ####
        dataFieldNames = UTILS.getFieldNames(sdFieldNames, outPath)
        shapeFieldNames = ["[email protected]"]
        for fieldName in dataFieldNames:
            UTILS.addEmptyField(outputFC, fieldName, "DOUBLE")

        caseIsDate = False
        if caseField:
            fcCaseField = ssdo.allFields[caseField]
            validCaseName = UTILS.validQFieldName(fcCaseField, outPath)
            caseType = UTILS.convertType[fcCaseField.type]
            UTILS.addEmptyField(outputFC, validCaseName, caseType)
            dataFieldNames.append(validCaseName)
            if caseType.upper() == "DATE":
                caseIsDate = True

        #### Write Output ####
        badCaseRadians = []
        allFieldNames = shapeFieldNames + dataFieldNames
        rows = DA.InsertCursor(outputFC, allFieldNames)
        for case in self.caseKeys:

            #### Get Results ####
            xVal, yVal = self.meanCenter[case]
            radius = self.sd[case]

            #### Create Empty Polygon Geomretry ####
            poly = ARCPY.Array()

            #### Check for Valid Radius ####
            radiusZero = UTILS.compareFloat(0.0, radius, rTol = .0000001)
            radiusNan = NUM.isnan(radius)
            radiusBool = radiusZero + radiusNan
            if radiusBool:
                badRadian = 6
                badCase = UTILS.caseValue2Print(case, self.caseIsString)
                badCaseRadians.append(badCase)
            else:
                badRadian = 0

                #### Calculate a Point For Each ####
                #### Degree in Circle Polygon ####
                for degree in NUM.arange(0, 360):  
                    try:
                        radians = NUM.pi / 180.0 * degree
                        pntX = xVal + (radius * NUM.cos(radians))
                        pntY = yVal + (radius * NUM.sin(radians))
                        pnt = ARCPY.Point(pntX, pntY, ssdo.defaultZ)
                        poly.add(pnt)
                    except:
                        badRadian += 1
                        if badRadian == 6:
                            badCase = UTILS.caseValue2Print(case, 
                                               self.caseIsString)
                            badCaseRadians.append(badCase)
                            break

            if badRadian < 6:
                #### Create and Populate New Feature ####
                poly = ARCPY.Polygon(poly, None, True)
                rowResult = [poly, xVal, yVal, radius]

                if caseField:
                    caseValue = case.item()
#.........这里部分代码省略.........
开发者ID:rvinc66,项目名称:ArcGISRuntimeBook,代码行数:103,代码来源:StandardDistance.py

示例6: calculate

# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import compareFloat [as 别名]
    def calculate(self, comboX):
        """Performs OLS and related diagnostics."""

        #### Shorthand Attributes ####
        ssdo = self.ssdo
        x = comboX
        n, k = NUM.shape(comboX)
        y = self.y

        #### General Information ####
        fn = n * 1.0
        dof = n - k
        fdof = dof * 1.0
        xt = x.T
        yt = y.T
        xx = NUM.dot(xt, x)

        #### Check for Perfect Multicollinearity ####
        U, s, V = LA.svd(xx)
        if UTILS.compareFloat(0.0, s[-1]):
            return False

        #### Attempt to Invert Design Matrix ####
        try:
            xxi = LA.inv(xx)
        except:
            #### Perfect multicollinearity, cannot proceed ####
            return False

        #### Bad Probabilities - Near Multicollinearity ####
        badProbs = False

        #### Compute Coefficients ####
        xy = NUM.dot(xt, y)
        coef = NUM.dot(xxi, xy)

        #### Residuals, Sum Of Squares, R2, Etc. ####
        yHat = NUM.dot(x, coef)
        yBar = (y.sum())/fn
        e = y - yHat
        ess = ( NUM.dot(e.T, e) )[0][0]
        s2 = (ess / fdof)
        s2mle = (ess / fn)
        seResiduals = NUM.sqrt(s2)
        ss = y - yBar
        tss = ( NUM.dot(ss.T, ss) )[0][0]
        r2 = 1.0 - (ess/tss)
        r2Adj =  1.0 - ( (ess / (fdof)) / (tss / (fn-1)) )
        u2 = e * e

        #### Variance-Covariance for Coefficients ####
        varBeta = xxi * s2

        #### Standard Errors / t-Statistics ####
        seBeta = NUM.sqrt(varBeta.diagonal())
        tStat = (coef.T / seBeta).flatten()

        #### White's Robust Standard Errors ####
        dofScale =  (int( n / (n - k) )) * 1.0
        sHat = NUM.dot((u2 * x).T, x) * dofScale
        varBetaRob = NUM.dot(NUM.dot(xxi, sHat), xxi)
        seBetaRob =  NUM.sqrt(varBetaRob.diagonal())
        tStatRob = (coef.T / seBetaRob).flatten()

        #### DOF Warning Once for t-Stats ####
        silentVector = [ True for i in range(k) ]
        if (2 <= dof <= 4) and not self.warnedTProb:
            silentVector[0] = False
            self.warnedTProb = True

        #### Coefficient t-Tests ####
        pVals = []
        pValsRob = []
        for varInd in UTILS.ssRange(k):
            #### General ####
            try:
                p = STATS.tProb(tStat[varInd], dof, type = 2,
                                silent = silentVector[varInd])
            except:
                p =  NUM.nan
                badProbs = True
            pVals.append(p)

            #### Robust ####
            try:
                p = STATS.tProb(tStatRob[varInd], dof, type = 2,
                                silent = True)
            except:
                p =  NUM.nan
                badProbs = True
            pValsRob.append(p)

        #### Jarque-Bera Test For Normality of the Residuals ####
        muE = (e.sum()) / fn
        devE = e - muE
        u3 = (devE**3.0).sum() / fn
        u4 = (devE**4.0).sum() / fn
        denomS = s2mle**1.5
        denomK = s2mle**2.0
        skew = u3 / denomS
#.........这里部分代码省略.........
开发者ID:f-tonini,项目名称:Python-Scripts,代码行数:103,代码来源:ModelSelectionOLS.py

示例7: initialize

# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import compareFloat [as 别名]

#.........这里部分代码省略.........
            self.minRect = UTILS.MinRect(tempMBG_FC)
            UTILS.passiveDelete(tempMBG_FC)

        else:
            #### Create Min. Enc. Rectangle ####
            self.studyAreaFC = UTILS.returnScratchName("regularBound_FC")
            self.tempStudyArea = True
            clearedMinBoundGeom(ssdo.xyCoords, self.studyAreaFC, 
                                geomType = "RECTANGLE_BY_AREA",
                                spatialRef = ssdo.spatialRef)
            polyInfo = UTILS.returnPolygon(self.studyAreaFC, 
                                           spatialRef = ssdo.spatialRefString)
            self.studyAreaPoly, self.studyArea = polyInfo

            #### Create Min. Enc. Rectangle Class ####
            self.minRect = UTILS.MinRect(self.studyAreaFC)

            if self.reduce:
                #### Only Need To Create FC if Reduce Buffer ####
                UTILS.createPolygonFC(self.studyAreaFC, self.studyAreaPoly, 
                                      spatialRef = ssdo.spatialRefString)


        #### Set Extent and Envelope and Min Rect ####
        self.envelope = UTILS.Envelope(ssdo.extent)
        self.maxDistance = self.minRect.maxLength * 0.25
        if self.maxDistance > (self.minRect.minLength * .5):
            #### 25% of Max Extent is Larger Than Half Min Extent ####
            #### Results in Reduced Study Area Failure ####
            if self.reduce:
                self.maxDistance = self.minRect.minLength * 0.25

        #### Determine Distance Increment ####
        if not self.dIncrement:
            if self.begDist: 
                distRange = self.maxDistance - self.begDist
            else: 
                distRange = self.maxDistance
            self.dIncrement = float(distRange / self.nIncrements)

        #### Determine Starting Distance ####
        if not self.begDist:
            self.begDist = self.dIncrement
        
        #### Determine All Distance Cutoffs ####
        rangeInc = xrange(self.nIncrements)
        cutoffs = []
        for inc in rangeInc:
            val = (inc * self.dIncrement) + self.begDist
            cutoffs.append(val)
        stepMax = cutoffs[-1]

        #### Check Cutoff Values ###
        if self.begDist > (self.minRect.maxLength * 0.51):
            ARCPY.AddIDMessage("WARNING", 934)
        elif stepMax > self.minRect.maxLength:
            ARCPY.AddIDMessage("WARNING", 935)

        #### Set Step Attributes ####
        self.stepMax = stepMax
        self.cutoffs = NUM.array(cutoffs)
        self.reverseOrder = range(self.nIncrements - 1, -1, -1)
        self.cutoffOrder = range(self.nIncrements)
        self.largestDistBand = self.cutoffs[-1]
        self.tolerance = self.minRect.tolerance
        self.xyTolerance = ssdo.spatialRef.XYTolerance

        #### Get Linear Unit for Reduce, Simulate and Ripley ####
        floatMax = self.stepMax * 1.0
        self.simulateUnitStr = ssdo.distanceInfo.linearUnitString(floatMax, 
                                                            convert = True) 
        self.reduceUnitStr = "-" + self.simulateUnitStr

        #### Create Smaller Poly FC for Reduce ####
        if self.reduce:
            self.reducedFC = UTILS.returnScratchName("reducedBound_FC")
            if UTILS.compareFloat(floatMax, 0):
                ARCPY.AddIDMessage("ERROR", 1170)
                raise SystemExit()
            ANA.Buffer(self.studyAreaFC, self.reducedFC, self.reduceUnitStr)
            reduceInfo = UTILS.returnPolygon(self.reducedFC, 
                                spatialRef = ssdo.spatialRefString)
            self.reducePoly, self.reduceArea = reduceInfo
            self.reducePath = PATH.Path(self.reducePoly)
            if self.reducePoly == None:
                ARCPY.AddIDMessage("ERROR", 1170)
                raise SystemExit()
            descRed = ARCPY.Describe(self.reducedFC)
            redExtent = descRed.extent
            self.redEnvelope = UTILS.Envelope(redExtent)
            self.redTolerance = self.redEnvelope.tolerance
            UTILS.passiveDelete(self.reducedFC)

        #### Create Study Area Envelope ####
        descSA = ARCPY.Describe(self.studyAreaFC)
        self.extentSA = descSA.extent
        self.envelopeSA = UTILS.Envelope(self.extentSA)
        envCoordsSA = self.envelopeSA.envelope
        self.minX, self.minY, self.maxX, self.maxY = envCoordsSA
        self.studyAreaPath = PATH.Path(self.studyAreaPoly)
开发者ID:rvinc66,项目名称:ArcGISRuntimeBook,代码行数:104,代码来源:KFunction.py

示例8: createOutput

# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import compareFloat [as 别名]
    def createOutput(self, outputFC):
        """Creates an Output Feature Class with the Standard Distances.

        INPUTS:
        outputFC (str): path to the output feature class
        """

        #### Validate Output Workspace ####
        ERROR.checkOutputPath(outputFC)

        #### Shorthand Attributes ####
        ssdo = self.ssdo
        caseField = self.caseField

        #### Increase Extent if not Projected ####
        if ssdo.spatialRefType != "Projected":
            seValues = self.se.values()
            if len(seValues):
                maxSE = NUM.array([ i[0:2] for i in seValues ]).max()
                largerExtent = UTILS.increaseExtentByConstant(ssdo.extent,
                                                        constant = maxSE)
                largerExtent = [ LOCALE.str(i) for i in largerExtent ]
                ARCPY.env.XYDomain = " ".join(largerExtent)

        #### Create Output Feature Class ####
        ARCPY.SetProgressor("default", ARCPY.GetIDMessage(84003))
        outPath, outName = OS.path.split(outputFC)

        try:
            DM.CreateFeatureclass(outPath, outName, "POLYGON", 
                                  "", ssdo.mFlag, ssdo.zFlag, 
                                  ssdo.spatialRefString)
        except:
            ARCPY.AddIDMessage("ERROR", 210, outputFC)
            raise SystemExit()

        #### Add Fields to Output FC ####
        dataFieldNames = UTILS.getFieldNames(seFieldNames, outPath)
        shapeFieldNames = ["[email protected]"]
        for fieldName in dataFieldNames:
            UTILS.addEmptyField(outputFC, fieldName, "DOUBLE")

        caseIsDate = False
        if caseField:
            fcCaseField = ssdo.allFields[caseField]
            validCaseName = UTILS.validQFieldName(fcCaseField, outPath)
            caseType = UTILS.convertType[fcCaseField.type]
            UTILS.addEmptyField(outputFC, validCaseName, caseType)
            dataFieldNames.append(validCaseName)
            if caseType.upper() == "DATE":
                caseIsDate = True

        #### Write Output ####
        badCaseRadians = []
        allFieldNames = shapeFieldNames + dataFieldNames
        rows = DA.InsertCursor(outputFC, allFieldNames)
        for case in self.caseKeys:

            #### Get Results ####
            xVal, yVal = self.meanCenter[case]
            seX, seY, degreeRotation, radianR1, radianR2 = self.se[case]
            seX2 = seX**2.0
            seY2 = seY**2.0

            #### Create Empty Polygon Geomretry ####
            poly = ARCPY.Array()

            #### Check for Valid Radius ####
            seXZero = UTILS.compareFloat(0.0, seX, rTol = .0000001)
            seXNan = NUM.isnan(seX)
            seXBool = seXZero + seXNan
            seYZero = UTILS.compareFloat(0.0, seY, rTol = .0000001)
            seYNan = NUM.isnan(seY)
            seYBool = seYZero + seYNan
            if seXBool or seYBool:
                badRadian = 6
                badCase = UTILS.caseValue2Print(case, self.caseIsString)
                badCaseRadians.append(badCase)
            else:
                badRadian = 0
                cosRadian = NUM.cos(radianR1)
                sinRadian = NUM.sin(radianR1)

                #### Calculate a Point For Each ####
                #### Degree in Ellipse Polygon ####                
                for degree in NUM.arange(0, 360): 
                    try:
                        radians = UTILS.convert2Radians(degree)
                        tanVal2 = NUM.tan(radians)**2.0
                        dX = MATH.sqrt((seX2 * seY2) /
                                      (seY2 + (seX2 * tanVal2)))
                        dY = MATH.sqrt((seY2 * (seX2 - dX**2.0)) /
                                       seX2)

                        #### Adjust for Quadrant ####
                        if 90 <= degree < 180:
                            dX = -dX
                        elif 180 <= degree < 270:
                            dX = -dX
                            dY = -dY
#.........这里部分代码省略.........
开发者ID:rvinc66,项目名称:ArcGISRuntimeBook,代码行数:103,代码来源:StandardEllipse.py

示例9: initialize

# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import compareFloat [as 别名]
    def initialize(self):
        #### Get Quick Output Info ####
        self.numFeatures = self.ssdoBase.numObs + self.ssdoCand.numObs

        #### Start With Target Features ####
        baseVals = NUM.empty((self.ssdoBase.numObs, self.k), float)
        for ind, fieldName in enumerate(self.fieldNames):
            baseVals[:,ind] = self.ssdoBase.fields[fieldName].returnDouble()   

        #### Store Report Info ####
        self.baseMin = baseVals.min(0)
        self.baseMax = baseVals.max(0)
        self.baseStd = baseVals.std(0)
        self.baseMean = baseVals.mean(0)

        #### Use Average Value if More Than One Input ####
        if self.ssdoBase.numObs > 1:
            baseVals = self.baseMean

        #### Get Candidate Variables ####
        dataVals = NUM.empty((self.ssdoCand.numObs + 1, self.k), float)
        dataVals[0] = baseVals
        for ind, fieldName in enumerate(self.fieldNames):
            dataVals[1:,ind] = self.ssdoCand.fields[fieldName].returnDouble()

        #### More Report Info ####
        self.attMin = dataVals.min(0)
        self.attMax = dataVals.max(0)
        self.attStd = dataVals.std(0)
        self.attMean = dataVals.mean(0)

        #### Zero Variance Fields ####
        zeroVarFields = []
        takeList = []
        for ind in xrange(self.k):
            stdValue = self.attStd[ind]
            if UTILS.compareFloat(0.0, stdValue):
                fieldName = self.fieldNames[ind]
                zeroVarFields.append(fieldName)
                self.k = self.k - 1
            else:
                takeList.append(ind)

        #### Toss Out Fields w/ No Variation ####
        nVarFields = len(zeroVarFields)
        if nVarFields:
            zeroNames = ", ".join(zeroVarFields)
            ARCPY.AddIDMessage("WARNING", 1588, zeroNames)
            for fieldName in zeroVarFields:
                self.fieldNames.remove(fieldName)

        #### Cosign Sim Must Have At Least Two Analysis Fields ####
        if self.k == 1 and self.matchMethod == 'ATTRIBUTE_PROFILES':
            ARCPY.AddIDMessage("ERROR", 1598)
            raise SystemExit()

        #### No Fields Left ####
        if not self.k:
            ARCPY.AddIDMessage("ERROR", 1585)
            raise SystemExit()

        #### Use Only Valid Fields ####
        if nVarFields:
            self.baseMin = NUM.take(self.baseMin, takeList)
            self.baseMax = NUM.take(self.baseMax, takeList)
            self.baseStd = NUM.take(self.baseStd, takeList)
            self.baseMean = NUM.take(self.baseMean, takeList)
            self.attMin = NUM.take(self.attMin, takeList)
            self.attMax = NUM.take(self.attMax, takeList)
            self.attStd = NUM.take(self.attStd, takeList)
            self.attMean = NUM.take(self.attMean, takeList)
            dataVals = NUM.take(dataVals, takeList, axis = 1)

        #### Get Tranformed Variables
        if self.matchMethod == 'RANKED_ATTRIBUTE_VALUES':
            #### Use Ranks ####
            dataVals = ARC._ss.rank_array(dataVals)
        else:
            #### Use Z Transformed ####
            dataVals = STATS.zTransform(dataVals)

        if self.matchMethod == 'ATTRIBUTE_PROFILES':
            self.baseVals = abs(dataVals[0])
            self.candVals = abs(dataVals[1:])
        else:
            self.baseVals = dataVals[0]
            self.candVals = dataVals[1:]
开发者ID:rvinc66,项目名称:ArcGISRuntimeBook,代码行数:89,代码来源:Similarity.py


注:本文中的SSUtilities.compareFloat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。