Xander Bakker I am running into a problem of the mathematical expression in raster calculation. Earlier we had worked for writing the below code. According to existing mathematical function in the script, if raster cell value will be

Earlier we had worked for writing the below code. According to existing mathematical function in the script, if the raster cell value (Mean raster in script ) will be increase or cross the threshold value (23 mentioned in script) , output raster cell should be decreased . But with this code, I am getting reverse output which is not desirable. I have checked the same mathematical equation in Arc GIS raster calculator and Excel also, both results are same. But Output generated from below script is not matching with Excel and Arc GIS raster calculator's result . Kindly provide your guidance to solve the issue .

Below I have attached the link for raster data, which I am working on. Due to size limit here, I just uploaded on dropbox.

I am using Arc GIS 10.3 and script running on PyScripter

In below equation Topt = 23 which is constant value (in our script) and T = Monthly mean raster data which is changed monthly.

Data link : Dropbox - TEST_TSCALAR1.rar

Script copied from Arc GIS raster result :

`arcpy.gp.RasterCalculator_sa("""(1.185 / (1 + Exp(0.2 * (23 - 10 - "Mean_Temp_010.tif"))) / (1 + Exp(0.3 * ( - 23 - 10 + "Mean_Temp_010.tif")))) * 0.99""", "D:/NPP_GUJARAT/WEATHER_DATA/2012/T_SCALAR_2012C/T_SCALAR_010A.tif")`

ArcPy Script,

`import arcpy, os, calendar`

from arcpy.sa import *

from arcpy import env

arcpy.env.overwriteOutput = True

arcpy.CheckOutExtension("Spatial")

topWorkspace = r'D:\TEST_TSCALAR'

ws_out = r'D:\TEST_TSCALAR\T_SCALAR_OUT' ### Output folder!!!

arcpy.env.workspace = topWorkspace

# Get dict of months and month-number (i.e. January = 001, March = 003 etc.)

months = {calendar.month_name[i].upper(): str(i).zfill(3) for i in range(1, 13)}

# Step through list of all folders

for folderPath in arcpy.ListWorkspaces():

baseName = os.path.basename(folderPath).upper()

if baseName in months: # Test that subfolder is a month name

monthNumber = months[baseName] # Get month-number for use in output filename

arcpy.env.workspace = folderPath

# Raster1 take Mean_Temp raster from all month folder(e.g for january: Mean_temp_001.tif) and Raster 2 is constant month of october raster

rasterList1 = arcpy.ListRasters(r'Mean_Temp*.tif')

print rasterList1

for ras_name in rasterList1:

ras_mean = arcpy.Raster(os.path.join(folderPath, ras_name))

# I devided the above equation into two part

# TScalar2 (Exp = exponential)

ras_scal2 = 1.1814 / (1 + Exp(0.2 * (23 - 10 - ras_mean)))

# TScalar3

ras_scal3 = (1 + Exp(0.3 * (- 23 - 10 - ras_mean)))

# Multiply TScalar1 and TScalar2

ras_scal = 0.99 * (ras_scal2 / ras_scal3)

# Save the output

outRasterName = os.path.join(ws_out, "T_SCALAR_{}.tif".format(monthNumber))

#print outRasterName

ras_scal.save(outRasterName)

#print done

print 'done'

In your first code snippet, the last part of your equation is -meantemp, you have +meantemp which disagrees with the equation symbols... Which is it? A minus here, a plus there, will make a difference