"""
    Spatial Data Modeller for ESRI* ArcGIS 9.2
    Copyright 2007
    Gary L Raines, Reno, NV, USA: production and certification
    Don L Sawatzky, Spokane, WA, USA: Python software development
    
#1 - ((1-FMSmall) * (1-FMLarge2))
"""
import sys, string, os

#GP = win32com.client.Dispatch("esriGeoprocessing.GpDispatch.1")
import arcgisscripting
GP = arcgisscripting.create()

try:
    Evidence_Rasters = string.split(GP.GetParameterAsText(0),";")   
    #GP.AddMessage(str(Evidence_Rasters))
    Output_Raster = GP.GetParameterAsText(1)
    if Output_Raster == "":
        outp_name = ""
        for inp_name in Evidence_Rasters:
            outp_name = outp_name + inp_name[0:3]
        Output_Raster = outp_name + "_Sum"
        GP.SetParameterAsText(1,Output_Raster)
    GP.AddMessage("Output_Raster: "+ Output_Raster)
    
# Check out ArcGIS Spatial Analyst extension license
    GP.CheckOutExtension("Spatial")

# Process
    GP.OverwriteOutput = 1
    #1.0 - (1-arg1)*...*(1-argn)
    InExpression = "1.0 - ((1.0 - " + Evidence_Rasters[0] + ")" # + string.replace(Evidence_Rasters,';',',') + ")"
    for Evidence_Raster in Evidence_Rasters[1:]:
        InExpression = InExpression + " * (1.0 - " + Evidence_Raster + ")"
    InExpression = InExpression + ")"
    GP.AddMessage(InExpression)
# Process: MapAlgebraStatement
    GP.SingleOutputMapAlgebra_sa(InExpression,Output_Raster,"#")
except:
    GP.AddError("Error in Execution" + GP.GetMessages())
GP.AddMessage("Exit Fuzzy Sum.")
