#NEWLINE# def CalculateDerivative( tool , toolboxPath , params , wksp ) : #NEWLINE# #INDENT# arcpy . AddMessage ( ( ( ( ( ( ( ( ( 'CalculateDerivative(' + tool ) + ', ' ) + toolboxPath ) + ', ' ) + str ( params ) ) + ', ' ) + wksp ) + ')' ) ) #NEWLINE# arcpy . ImportToolbox ( toolboxPath ) #NEWLINE# try : #NEWLINE# #INDENT# toolToCall = getattr ( arcpy , tool ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# arcpy . AddWarning ( ( ( ( "An error occurred trying to find tool '" + tool ) + "'\n" ) + str ( sys . exc_info ( ) ) ) ) #NEWLINE# return #NEWLINE# #UNINDENT# paramBandNumbers = [ ] #NEWLINE# lastIndex = ( len ( params ) - 1 ) #NEWLINE# for ( index , param ) in enumerate ( params ) : #NEWLINE# #INDENT# if ( index != lastIndex ) : #NEWLINE# #INDENT# paramBandNumbers . append ( ( 'Band_' + str ( ( list ( weatherTerms . values ( ) ) . index ( param ) + 1 ) ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# arcpy . AddMessage ( ( ( ( ( ( ( "Calculating derivative: calling '" + tool ) + "' with params '" ) + str ( params ) ) + "' which are represented by bands '" ) + str ( paramBandNumbers ) ) + "'" ) ) #NEWLINE# try : #NEWLINE# #INDENT# result = arcpy . ListRasters_maow ( wksp , ( weatherName + '*' ) ) #NEWLINE# out = str ( result . getOutput ( 0 ) ) #NEWLINE# datasetList = out . split ( ';' ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# arcpy . AddWarning ( ( ( ( "An error occurred listing the rasters in '" + wksp ) + "'\n" ) + str ( sys . exc_info ( ) ) ) ) #NEWLINE# datasetList = [ ] #NEWLINE# #UNINDENT# if datasetList : #NEWLINE# #INDENT# for dataset in datasetList : #NEWLINE# #INDENT# if ( dataset . startswith ( "'" ) and dataset . endswith ( "'" ) ) : #NEWLINE# #INDENT# dataset = dataset [ 1 : ( - 1 ) ] #NEWLINE# #UNINDENT# newparams = [ ] #NEWLINE# del newparams [ : ] #NEWLINE# for band in paramBandNumbers : #NEWLINE# #INDENT# newparams . append ( ( ( dataset + '\\' ) + band ) ) #NEWLINE# #UNINDENT# outParam = dataset . replace ( weatherName , ( params [ ( - 1 ) ] . replace ( ' ' , '_' ) + '__' ) ) #NEWLINE# newparams . append ( outParam ) #NEWLINE# arcpy . AddMessage ( ( ( ( ( 'Running tool : ' + tool ) + '(' ) + str ( newparams ) ) + ')' ) ) #NEWLINE# arcpy . ImportToolbox ( toolboxPath ) #NEWLINE# try : #NEWLINE# #INDENT# toolToCall ( * newparams ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# arcpy . AddWarning ( ( ( ( ( ( "An error occured trying to call tool '" + tool ) + "' with parameters\n" ) + str ( outParam ) ) + '\n' ) + str ( sys . exc_info ( ) ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# arcpy . AddMessage ( ( ( "No datasets found in '" + wksp ) + "'" ) )