# -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------
# relelev_l.py
# Created on: 2016-06-05 21:56:45.00000
#   (generated by ArcGIS/ModelBuilder)
# Description: 
# ---------------------------------------------------------------------------

# Import arcpy module
import arcpy


# Local variables:
distridgeclip = "C:\\Users\\hmpou\\Documents\\TXDEM051915\\smoothed060216\\distridgeclip"
distvallyclip = "C:\\Users\\hmpou\\Documents\\TXDEM051915\\smoothed060216\\distvallyclip"
relelevnad83 = "C:\\Users\\hmpou\\Documents\\TXDEM051915\\smoothed060216\\relelevnad83"
relelevwgs = "C:\\Users\\hmpou\\Documents\\TXDEM051915\\smoothed060216\\relelevwgs"
cm_elev = "C:\\Users\\hmpou\\Documents\\TXDEM051915\\final_zipped_grids\\CM\\elev.asc"
masked_cm = "C:\\Users\\hmpou\\Documents\\ArcGIS\\Default.gdb\\Extract_rele1"
relev_l_asc = "C:\\Users\\hmpou\\Documents\\TXDEM051915\\final_zipped_grids\\CM\\relev_l.asc"
gm_elev = "C:\\Users\\hmpou\\Documents\\TXDEM051915\\final_zipped_grids\\GM\\elev.asc"
masked_gm = "C:\\Users\\hmpou\\Documents\\ArcGIS\\Default.gdb\\Extract_rele2"
relev_l_asc__2_ = "C:\\Users\\hmpou\\Documents\\TXDEM051915\\final_zipped_grids\\GM\\relev_l.asc"
dm_elev = "C:\\Users\\hmpou\\Documents\\TXDEM051915\\final_zipped_grids\\DM\\DM\\elev.asc"
masked_dm = "C:\\Users\\hmpou\\Documents\\ArcGIS\\Default.gdb\\Extract_rele3"
relev_l_asc__3_ = "C:\\Users\\hmpou\\Documents\\TXDEM051915\\final_zipped_grids\\DM\\DM\\relev_l.asc"
distridge = ""
distvalley = ""

# Process: Raster Calculator
arcpy.gp.RasterCalculator_sa("\"%distridgeclip%\"- \"%distvallyclip%\"", relelevnad83)

# Process: Project Raster
arcpy.ProjectRaster_management(relelevnad83, relelevwgs, "GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]]", "NEAREST", "28.921983022337 28.921983022337", "WGS_1984_(ITRF00)_To_NAD_1983", "", "")

# Process: extract mask CM
tempEnvironment0 = arcpy.env.snapRaster
arcpy.env.snapRaster = "C:\\Users\\hmpou\\Documents\\TXDEM051915\\final_zipped_grids\\CM\\elev.asc"
tempEnvironment1 = arcpy.env.extent
arcpy.env.extent = "-103.6698019919 29.032009197477 -102.942579769096 29.529231420097"
tempEnvironment2 = arcpy.env.cellSize
arcpy.env.cellSize = "2.77777778000001E-04"
tempEnvironment3 = arcpy.env.mask
arcpy.env.mask = "C:\\Users\\hmpou\\Documents\\TXDEM051915\\final_zipped_grids\\CM\\elev.asc"
arcpy.gp.ExtractByMask_sa(relelevwgs, cm_elev, masked_cm)
arcpy.env.snapRaster = tempEnvironment0
arcpy.env.extent = tempEnvironment1
arcpy.env.cellSize = tempEnvironment2
arcpy.env.mask = tempEnvironment3

# Process: Raster to ASCII CM
arcpy.RasterToASCII_conversion(masked_cm, relev_l_asc)

# Process: extract mask GM
tempEnvironment0 = arcpy.env.snapRaster
arcpy.env.snapRaster = "C:\\Users\\hmpou\\Documents\\TXDEM051915\\final_zipped_grids\\GM\\elev.asc"
tempEnvironment1 = arcpy.env.extent
arcpy.env.extent = "-105.1699300894 31.718225977625 -104.48520786663 32.186559311333"
tempEnvironment2 = arcpy.env.cellSize
arcpy.env.cellSize = "2.77777778000002E-04"
tempEnvironment3 = arcpy.env.mask
arcpy.env.mask = "C:\\Users\\hmpou\\Documents\\TXDEM051915\\final_zipped_grids\\GM\\elev.asc"
arcpy.gp.ExtractByMask_sa(relelevwgs, gm_elev, masked_gm)
arcpy.env.snapRaster = tempEnvironment0
arcpy.env.extent = tempEnvironment1
arcpy.env.cellSize = tempEnvironment2
arcpy.env.mask = tempEnvironment3

# Process: Raster to ASCII GM
arcpy.RasterToASCII_conversion(masked_gm, relev_l_asc__2_)

# Process: extract mask DM
tempEnvironment0 = arcpy.env.snapRaster
arcpy.env.snapRaster = "C:\\Users\\hmpou\\Documents\\TXDEM051915\\final_zipped_grids\\DM\\DM\\elev.asc"
tempEnvironment1 = arcpy.env.extent
arcpy.env.extent = "-104.57461785062 30.448603245144 -103.671562294342 31.073047690088"
tempEnvironment2 = arcpy.env.cellSize
arcpy.env.cellSize = "2.77777778000002E-04"
tempEnvironment3 = arcpy.env.mask
arcpy.env.mask = "C:\\Users\\hmpou\\Documents\\TXDEM051915\\final_zipped_grids\\DM\\DM\\elev.asc"
arcpy.gp.ExtractByMask_sa(relelevwgs, dm_elev, masked_dm)
arcpy.env.snapRaster = tempEnvironment0
arcpy.env.extent = tempEnvironment1
arcpy.env.cellSize = tempEnvironment2
arcpy.env.mask = tempEnvironment3

# Process: Raster to ASCII DM
arcpy.RasterToASCII_conversion(masked_dm, relev_l_asc__3_)

