I am trying to figure out a way to have my model perform its functions on the rasters contained inside the sub-folders of the root folder. I can't use the default iteration function in model builder because it only looks for rasters in the root folder. This is what my model looks like currently.
# Import arcpy module
import arcpy
# Load required toolboxes
arcpy.ImportToolbox("Model Functions")
# Script arguments
Basins = arcpy.GetParameterAsText(0)
if Basins == '#' or not Basins:
Basins = "Basins" # provide a default value if unspecified
# Local variables:
Basins_Project2 = "C:\\Users\\straussk\\Documents\\ArcGIS\\Default.gdb\\Basins_Project2"
UnmaskedData = "U:\\SWEModelConstruction\\UnmaskedData"
Raster = "U:\\SWEModelConstruction\\UnmaskedData\\Raster"
SetNull_Rast2 = "C:\\Users\\straussk\\Documents\\ArcGIS\\Default.gdb\\SetNull_Rast2"
Output_Name = "C:\\Users\\straussk\\Documents\\ArcGIS\\Default.gdb\\ZonalSt_Basins_3"
ZonalSt_Basins_3 = Output_Name
ZonalSt_Basins_3__6_ = ZonalSt_Basins_3
Raster_Output = ZonalSt_Basins_3__6_
Basin_Raster_Output = "U:\\SWEModelConstruction\\UnmaskedData\\%Name%.xls"
Name = "Raster"
# Process: Project
arcpy.Project_management(Basins, Basins_Project2, "GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]]", "", "PROJCS['WGS_1984_Web_Mercator_Auxiliary_Sphere',GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Mercator_Auxiliary_Sphere'],PARAMETER['False_Easting',0.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',0.0],PARAMETER['Standard_Parallel_1',0.0],PARAMETER['Auxiliary_Sphere_Type',0.0],UNIT['Meter',1.0]]", "NO_PRESERVE_SHAPE", "")
# Process: Iterate Rasters
arcpy.IterateRasters_mb(UnmaskedData, "", "", "NOT_RECURSIVE")
# Process: Set Null
arcpy.gp.SetNull_sa(Raster, Raster, SetNull_Rast2, "\"Value\" = 55537")
# Process: Zonal Statistics as Table
arcpy.gp.ZonalStatisticsAsTable_sa(Basins_Project2, "Drainage_A", SetNull_Rast2, Output_Name, "DATA", "ALL")
# Process: Calculate Field (7)
arcpy.CalculateField_management(Output_Name, "Mean", "[Mean] /1000", "VB", "")
# Process: Calculate Field (8)
arcpy.CalculateField_management(ZonalSt_Basins_3, "Std", "[Std] /1000", "VB", "")
# Process: Calculate Field (9)
arcpy.CalculateField_management(ZonalSt_Basins_3__6_, "Sum", "[Sum] /1000", "VB", "")
# Process: Table To Excel
arcpy.TableToExcel_conversion(Raster_Output, Basin_Raster_Output, "ALIAS", "CODE")
My rasters are placed in folders categorized by their year and date so simply inputting them into one root file is not possible. Is there a way to perform this function on a file system like the following U:\SWEModelConstruction\UnmaskedData\2010\February\15 where the raster files are located on the 15, not the year or month they are just sub-folders to categorize data.