本文整理汇总了Python中SSUtilities.convert2Radians方法的典型用法代码示例。如果您正苦于以下问题:Python SSUtilities.convert2Radians方法的具体用法?Python SSUtilities.convert2Radians怎么用?Python SSUtilities.convert2Radians使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SSUtilities
的用法示例。
在下文中一共展示了SSUtilities.convert2Radians方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import convert2Radians [as 别名]
#.........这里部分代码省略.........
self.caseVals = NUM.ones((self.ssdo.numObs, ), int)
self.uniqueCases = [1]
#### Set Result Dict ####
meanCenter = COLL.defaultdict(NUM.array)
se = COLL.defaultdict(float)
#### Keep Track of Bad Cases ####
badCases = []
#### Calculate Mean Center and Standard Distance ####
for case in self.uniqueCases:
indices = NUM.where(self.caseVals == case)
numFeatures = len(indices[0])
xy = self.xyCoords[indices]
w = self.weights[indices]
w.shape = numFeatures, 1
weightSum = w.sum()
if (weightSum != 0.0) and (numFeatures > 2):
xyWeighted = w * xy
#### Mean Center ####
centers = xyWeighted.sum(0) / weightSum
meanX, meanY = centers
meanCenter[case] = centers
#### Standard Ellipse ####
devXY = xy - centers
flatW = w.flatten()
sigX = (flatW * devXY[:,0]**2.0).sum()
sigY = (flatW * devXY[:,1]**2.0).sum()
sigXY = (flatW * devXY[:,0] * devXY[:,1]).sum()
denom = 2.0 * sigXY
diffXY = sigX - sigY
sum1 = diffXY**2.0 + 4.0 * sigXY**2.0
if not abs(denom) > 0:
arctanVal = 0.0
else:
tempVal = (diffXY + NUM.sqrt(sum1)) / denom
arctanVal = NUM.arctan(tempVal)
if arctanVal < 0.0:
arctanVal += (NUM.pi / 2.0)
sinVal = NUM.sin(arctanVal)
cosVal = NUM.cos(arctanVal)
sqrt2 = NUM.sqrt(2.0)
sigXYSinCos = 2.0 * sigXY * sinVal * cosVal
seX = (sqrt2 *
NUM.sqrt(((sigX * cosVal**2.0) - sigXYSinCos +
(sigY * sinVal**2.0)) /
weightSum) * stdDeviations)
seY = (sqrt2 *
NUM.sqrt(((sigX * sinVal**2.0) + sigXYSinCos +
(sigY * cosVal**2.0)) /
weightSum) * stdDeviations)
#### Counter Clockwise from Noon ####
degreeRotation = 360.0 - (arctanVal * 57.2957795)
#### Convert to Radians ####
radianRotation1 = UTILS.convert2Radians(degreeRotation)
#### Add Rotation ####
radianRotation2 = 360.0 - degreeRotation
if seX > seY:
radianRotation2 += 90.0
if radianRotation2 > 360.0:
radianRotation2 = radianRotation2 - 180.0
se[case] = (seX, seY, degreeRotation,
radianRotation1, radianRotation2)
else:
badCases.append(case)
#### Report Bad Cases ####
nCases = len(self.uniqueCases)
nBadCases = len(badCases)
badCases.sort()
if nBadCases:
cBool = self.caseIsString
if not self.caseIsString:
badCases = [UTILS.caseValue2Print(i, cBool) for i in badCases]
ERROR.reportBadCases(nCases, nBadCases, badCases,
label = caseField)
#### Sorted Case List ####
caseKeys = se.keys()
caseKeys.sort()
self.caseKeys = caseKeys
#### Set Attributes ####
self.meanCenter = meanCenter
self.se = se
self.badCases = badCases
self.caseField = caseField
self.stdDeviations = stdDeviations
self.weightField = weightField
示例2: createOutput
# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import convert2Radians [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
#.........这里部分代码省略.........