本文整理汇总了Python中SSUtilities.returnTableName方法的典型用法代码示例。如果您正苦于以下问题:Python SSUtilities.returnTableName方法的具体用法?Python SSUtilities.returnTableName怎么用?Python SSUtilities.returnTableName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SSUtilities
的用法示例。
在下文中一共展示了SSUtilities.returnTableName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: createOutput
# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import returnTableName [as 别名]
def createOutput(self, outputTable):
"""Creates Moran's I Step Output Table.
INPUTS
outputTable (str): path to the output table
"""
#### Allow Overwrite Output ####
ARCPY.env.overwriteOutput = 1
#### Get Output Table Name With Extension if Appropriate ####
outputTable, dbf = UTILS.returnTableName(outputTable)
#### Set Progressor ####
ARCPY.SetProgressor("default", ARCPY.GetIDMessage(84008))
#### Delete Table If Exists ####
UTILS.passiveDelete(outputTable)
#### Create Table ####
outPath, outName = OS.path.split(outputTable)
try:
DM.CreateTable(outPath, outName)
except:
ARCPY.AddIDMessage("ERROR", 541)
raise SystemExit()
#### Add Result Fields ####
self.outputFields = []
for field in iaFieldNames:
fieldOut = ARCPY.ValidateFieldName(field, outPath)
UTILS.addEmptyField(outputTable, fieldOut, "DOUBLE")
self.outputFields.append(fieldOut)
#### Create Insert Cursor ####
try:
insert = DA.InsertCursor(outputTable, self.outputFields)
except:
ARCPY.AddIDMessage("ERROR", 204)
raise SystemExit()
#### Add Rows to Output Table ####
for testIter in xrange(self.nIncrements):
insert.insertRow(self.giResults[testIter])
#### Clean Up ####
del insert
return outputTable, dbf
示例2: runModels
# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import returnTableName [as 别名]
def runModels(self):
"""Performs additional validation and populates the
SSDataObject."""
#### Shorthand Attributes ####
ssdo = self.ssdo
#### Create Dependent Variable ####
self.y = ssdo.fields[self.dependentVar].returnDouble()
self.n = ssdo.numObs
self.y.shape = (self.n, 1)
#### Assure that Variance is Larger than Zero ####
yVar = NUM.var(self.y)
if NUM.isnan(yVar) or yVar <= 0.0:
ARCPY.AddIDMessage("Error", 906)
raise SystemExit()
#### Validate Chosen Number of Combos ####
k = len(ssdo.fields)
if self.maxIndVars > (k - 1):
ARCPY.AddIDMessage("WARNING", 1171, self.maxIndVars)
self.maxIndVars = k - 1
ARCPY.AddIDMessage("WARNING", 1172, self.maxIndVars)
#### Assure Degrees of Freedom ####
withIntercept = self.maxIndVars + 1
dof = self.n - withIntercept
if dof <= 2:
ARCPY.AddIDMessage("WARNING", 1128, 2)
dofLimit = self.n - 4
ARCPY.AddIDMessage("WARNING", 1419, dofLimit)
self.maxIndVars = dofLimit
if self.maxIndVars < 1:
ARCPY.AddIDMessage("WARNING", 1173)
#### Assure Min Vars is less than or equal to Max Vars ####
if self.maxIndVars < self.minIndVars:
ARCPY.AddIDMessage("WARNING", 1174)
ARCPY.AddIDMessage("WARNING", 1175)
self.minIndVars = self.maxIndVars
#### Gen Range Combos ####
rangeVars = range(1, k)
rangeCombos = NUM.arange(self.minIndVars, self.maxIndVars+1)
#### Create Base Design Matrix ####
self.x = NUM.ones((self.n, k), dtype = float)
for column, variable in enumerate(self.independentVars):
self.x[:,column + 1] = ssdo.fields[variable].data
#### Calculate Global VIF ####
self.globalVifVals = COLL.defaultdict(float)
if k > 2:
#### Values Less Than One Were Forced by Psuedo-Inverse ####
self.printVIF = True
else:
self.printVIF = False
#### Create Output Table Info ####
if self.outputTable:
#### List of Results ####
self.tableResults = []
#### Valid Table Name and Type ####
self.outputTable, dbf = UTILS.returnTableName(self.outputTable)
outPath, outName = OS.path.split(self.outputTable)
#### Set Field Names (Base) ####
self.outFieldNames = UTILS.getFieldNames(erFieldNames, outPath)
self.outFieldTypes = ["LONG", "DOUBLE", "DOUBLE", "DOUBLE",
"DOUBLE", "DOUBLE", "DOUBLE", "LONG"]
#### Add Field Names (Independent Vars as X#) ####
maxRange = range(1, self.maxIndVars+1)
self.outFieldNames += [ "X" + str(j) for j in maxRange ]
self.outFieldTypes += ["TEXT"] * self.maxIndVars
#### Calculate Max Text Length for Output Fields ####
fieldLens = [ len(i) for i in self.independentVars ]
self.maxFieldLen = max(fieldLens) + 5
tableReportCount = 0
#### Set NULL Values and Flag to Reset Table Name ####
isNullable = UTILS.isNullable(self.outputTable)
if isNullable:
self.nullValue = NUM.nan
else:
self.nullValue = UTILS.shpFileNull["DOUBLE"]
self.dbf = dbf
#### Create Output Report File ####
if self.outputReportFile:
fo = UTILS.openFile(self.outputReportFile, "w")
#### Hold Results for Every Choose Combo ####
self.resultDict = {}
self.vifVarCount = COLL.defaultdict(int)
#.........这里部分代码省略.........
示例3: setupLogit
# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import returnTableName [as 别名]
def setupLogit():
#### Get User Provided Inputs ####
inputFC = ARCPY.GetParameterAsText(0)
outputFC = ARCPY.GetParameterAsText(1)
depVarName = str(ARCPY.GetParameterAsText(2))
indVarNames = ARCPY.GetParameterAsText(3)
indVarNames = [ str(i) for i in indVarNames.split(";") ]
indVarNames = ";".join(indVarNames)
usePenalty = ARCPY.GetParameterAsText(4)
if usePenalty == 'true':
usePenalty = "1"
else:
usePenalty = "0"
coefTableIn = ARCPY.GetParameterAsText(5)
coefTable, dbf = UTILS.returnTableName(coefTableIn)
diagTableIn = ARCPY.GetParameterAsText(6)
diagTable, dbf = UTILS.returnTableName(diagTableIn)
#### Create R Command ####
pyScript = SYS.argv[0]
toolDir = OS.path.dirname(pyScript)
rScript = OS.path.join(toolDir, "logitWithR.r")
ARCPY.SetProgressor("default", "Executing R Script...")
args = ["R", "--slave", "--vanilla", "--args",
inputFC, outputFC, depVarName, indVarNames,
usePenalty, coefTable, diagTable]
#### Uncomment Next Two Lines to Print/Create Command Line Args ####
#cmd = RARC.createRCommand(args, rScript)
#ARCPY.AddWarning(cmd)
#### Execute Command ####
scriptSource = open(rScript, 'rb')
rCommand = SUB.Popen(args,
stdin = scriptSource,
stdout = SUB.PIPE,
stderr = SUB.PIPE,
shell=True)
#### Print Result ####
resString, errString = rCommand.communicate()
#### Push Output to Message Window ####
if errString and "Calculations Complete..." not in resString:
ARCPY.AddError(errString)
else:
resOutString = RARC.printRMessages(resString)
ARCPY.AddMessage(resOutString)
#### Project the Data ####
DM.DefineProjection(outputFC, inputFC)
#### Create SSDO ####
ssdo = SSDO.SSDataObject(outputFC)
#### Display Symbology ####
params = ARCPY.gp.GetParameterInfo()
try:
renderType = UTILS.renderType[ssdo.shapeType.upper()]
if renderType == 0:
renderLayerFile = "StdResidPoints.lyr"
elif renderType == 1:
renderLayerFile = "StdResidPolylines.lyr"
else:
renderLayerFile = "StdResidPolygons.lyr"
fullRLF = OS.path.join(ARCPY.GetInstallInfo()['InstallDir'],
"ArcToolbox", "Templates", "Layers",
renderLayerFile)
params[1].Symbology = fullRLF
except:
ARCPY.AddIDMessage("WARNING", 973)
#### Print Coef Output Table ####
try:
rows = ARCPY.SearchCursor(coefTable)
except:
ARCPY.AddIDMessage("ERROR", 204)
raise ERROR.ScriptError()
labels = ["Variable", "Coef", "StdError", "Wald", "Prob"]
header = "Logistic Regression Coefficient Table"
res = [ labels ]
for row in rows:
rowRes = []
for i, val in enumerate(labels):
if i == 0:
rowRes.append(row.getValue(val))
else:
rowRes.append(LOCALE.format("%0.6f", row.getValue(val)))
res.append(rowRes)
del rows
coefTextTab = UTILS.outputTextTable(res, header = header)
ARCPY.AddMessage("\n")
ARCPY.AddMessage(coefTextTab)
#### Add to TOC ####
ARCPY.SetParameterAsText(5, coefTable)
#.........这里部分代码省略.........
示例4: createOutput
# 需要导入模块: import SSUtilities [as 别名]
# 或者: from SSUtilities import returnTableName [as 别名]
def createOutput(self, outputTable, displayIt = False):
"""Creates K-Function Output Table.
INPUTS
outputTable (str): path to the output table
displayIt {bool, False}: create output graph?
"""
#### Allow Overwrite Output ####
ARCPY.env.overwriteOutput = 1
#### Get Output Table Name With Extension if Appropriate ####
outputTable, dbf = UTILS.returnTableName(outputTable)
#### Set Progressor ####
ARCPY.SetProgressor("default", ARCPY.GetIDMessage(84008))
#### Delete Table If Exists ####
UTILS.passiveDelete(outputTable)
#### Create Table ####
outPath, outName = OS.path.split(outputTable)
try:
DM.CreateTable(outPath, outName)
except:
ARCPY.AddIDMessage("ERROR", 541)
raise SystemExit()
#### Add Result Fields ####
fn = UTILS.getFieldNames(kOutputFieldNames, outPath)
expectedKName, observedKName, diffKName, lowKName, highKName = fn
outputFields = [expectedKName, observedKName, diffKName]
if self.permutations:
outputFields += [lowKName, highKName]
for field in outputFields:
UTILS.addEmptyField(outputTable, field, "DOUBLE")
#### Create Insert Cursor ####
try:
insert = DA.InsertCursor(outputTable, outputFields)
except:
ARCPY.AddIDMessage("ERROR", 204)
raise SystemExit()
#### Add Rows to Output Table ####
for testIter in xrange(self.nIncrements):
distVal = self.cutoffs[testIter]
ldVal = self.ld[testIter]
diffVal = ldVal - distVal
rowResult = [distVal, ldVal, diffVal]
if self.permutations:
ldMinVal = self.ldMin[testIter]
ldMaxVal = self.ldMax[testIter]
rowResult += [ldMinVal, ldMaxVal]
insert.insertRow(rowResult)
#### Clean Up ####
del insert
#### Make Table Visable in TOC if *.dbf Had To Be Added ####
if dbf:
ARCPY.SetParameterAsText(1, outputTable)
#### Display Results ####
if displayIt:
if "WIN" in SYS.platform.upper():
#### Set Progressor ####
ARCPY.SetProgressor("default", ARCPY.GetIDMessage(84186))
#### Get Image Directory ####
imageDir = UTILS.getImageDir()
#### Make List of Fields and Set Template File ####
yFields = [expectedKName, observedKName]
if self.permutations:
#### Add Confidence Envelopes ####
yFields.append(highKName)
yFields.append(lowKName)
tee = OS.path.join(imageDir, "KFunctionPlotEnv.tee")
else:
tee = OS.path.join(imageDir, "KFunctionPlot.tee")
xFields = [ expectedKName for i in yFields ]
#### Create Data Series String ####
dataStr = UTILS.createSeriesStr(xFields, yFields, outputTable)
#### Make Graph ####
DM.MakeGraph(tee, dataStr, "KFunction")
ARCPY.SetParameterAsText(11, "KFunction")
else:
ARCPY.AddIDMessage("Warning", 942)