Automating parflow preprocessing steps for DEMs John A Koudelka
Topics Background Methods Results Conclusions Photo: John A Koudelka
Background ParFlow Is an integrated watershed model that simulates surface and subsurface flow. Data Processing Soil Moisture – Little Washita Watershed. https://computation.llnl.gov/casc/parflow/simulations.html
Methods Manual Processing Steps Automation Python (Windows) 1. Raster to ASCII 2. ASCII – No Header 3. Dataset Metrics (cell size, # rows, # columns, No Data value, x and y origin) 4. ParFlow Fortran files - Remove Pits - Create Slope Files - Generate Solid File Automation Remove pits Create Slope Files Generate Solid File Python (Windows) Python (OS X)
Methods Manual ASCII No Header ASCII No Pits ARC/INFO GRID ASCII Datasets ASCII No Header ASCII No Pits ARC/INFO GRID ASCII Cell Size # Rows # Cols X origin Y origin ND Value Variables Raster To ASCII Remove Pits Create Slopes CreateSolid File Functions Remove Header X Slopes Y Slopes Solid File ParFlow Input
Methods Automated Raster To ASCII ASCII ARC/INFO GRID 1. X Slopes Y Slopes Solid File ParFlow Input Remove Pits Create Slopes CreateSolid File Cell Size # Rows # Cols X origin Y origin ND Value Remove Header ASCII No Pits ASCII No Header ASCII 2.
Methods Challenges GDAL User Distribution Logos From: Python – http://python.org/ GADL - http://www.gdal.org/ NumPy - http://numpy.scipy.org/
Results Processing Steps: Python Script 1 Python Script 2 import os #import numpy import subprocess ## ****** GRAB DEM PARAMS ***** ## #export raster to ascii path="/Users/johnkoudelka/ParF/Data/LittleBear/preprocess" os.chdir(path) fileName='dem.txt' outFileName='pf_dem.txt' asciiFile=open("dem.txt") rLine=asciiFile.readline().strip().split(" ") ncols=rLine[9] nrows=rLine[9] xllcorner=rLine[5] yllcorner=rLine[5] cellSize=rLine[6] NDval=rLine[2] #create the modified ascii DEM pf_ascii=open(outFileName,'w') i=0 #write it while (i<int(nrows)): rLine=asciiFile.readline() pf_ascii.write(rLine +'\n’) i=i+1 Processing Steps: Python Script 1 Raster to ASCII conversion Python Script 2 Set header information to variables Write DEM without header information Execute modified Fortran codes Script 2 – Code Snieppet
Conclusions Automation Future work Fortran & Python Computing Platform GDAL Photo: John A Koudelka
The End Questions?