def updateMessages(self): """Modify the messages created by internal validation for each tool parameter. This method is called after internal validation.""" import LUCI_PTFs.lib.input_validation as input_validation refresh_modules(input_validation) # Populate converstion factor automatically when either OM or OC is chosen has been chosen CarbParamNo = None ConvFactorParamNo = None for i in range(0, len(self.params)): if self.params[i].name == 'Carbon_content': CarbParamNo = i if self.params[i].name == 'Conversion_factor': ConvFactorParamNo = i CarbPairs = [('Organic carbon', 1.724), ('Organic matter', 0.58)] if CarbParamNo is not None and ConvFactorParamNo is not None: # If this is the most recently changed param ... if not self.params[CarbParamNo].hasBeenValidated: # Update the linking code with the correct value for CarbPair in CarbPairs: if self.params[CarbParamNo].valueAsText == CarbPair[0]: self.params[ConvFactorParamNo].value = CarbPair[1] input_validation.checkFilePaths(self)
def updateMessages(self): """Modify the messages created by internal validation for each tool parameter. This method is called after internal validation.""" import LUCI_PTFs.lib.input_validation as input_validation refresh_modules(input_validation) input_validation.checkFilePaths(self) input_validation.checkThresholdValues(self, "SoilMoisture")
def updateMessages(self): """Modify the messages created by internal validation for each tool parameter. This method is called after internal validation.""" import LUCI_PTFs.lib.input_validation as input_validation refresh_modules(input_validation) # Populate converstion factor automatically when either OM or OC is chosen has been chosen CarbParamNo = None ConvFactorParamNo = None for i in range(0, len(self.params)): if self.params[i].name == 'Carbon_content': CarbParamNo = i if self.params[i].name == 'Conversion_factor': ConvFactorParamNo = i CarbPairs = [('Organic carbon', 1.724), ('Organic matter', 0.58)] if CarbParamNo is not None and ConvFactorParamNo is not None: # If this is the most recently changed param ... if not self.params[CarbParamNo].hasBeenValidated: # Update the linking code with the correct value for CarbPair in CarbPairs: if self.params[CarbParamNo].valueAsText == CarbPair[0]: self.params[ConvFactorParamNo].value = CarbPair[1] # Populate pressures vgChoiceNo = None vgPressuresNo = None for i in range(0, len(self.params)): if self.params[i].name == 'VG_of_choice': vgChoiceNo = i if self.params[i].name == 'Pressure_heads_VG': vgPressuresNo = i vgPairs = [('Wosten et al. (1999) topsoil', '10 30 100 330 1000 2000 10000 15000'), ('Wosten et al. (1999) subsoil', '10 30 100 330 1000 2000 10000 15000'), ('Vereecken et al. (1989)', '10 30 100 330 1000 2000 10000 15000'), ('Zacharias and Wessolek (2007)', '1 3 10 33 100 200 1000 1500')] if vgChoiceNo is not None and vgPressuresNo is not None: # If this is the most recently changed param ... if not self.params[vgChoiceNo].hasBeenValidated: # Update the linking code with the correct value for vgPair in vgPairs: if self.params[vgChoiceNo].valueAsText == vgPair[0]: self.params[vgPressuresNo].value = vgPair[1] input_validation.checkFilePaths(self)
import arcpy import os import sys import LUCI_PTFs.lib.log as log import LUCI_PTFs.lib.common as common import LUCI_PTFs.lib.progress as progress import LUCI_PTFs.solo.calc_ksat as CalcKsat import LUCI_PTFs.lib.PTFdatabase as PTFdatabase from LUCI_PTFs.lib.refresh_modules import refresh_modules refresh_modules([log, common, CalcKsat, PTFdatabase]) def function(params): try: pText = common.paramsAsText(params) # Get inputs runSystemChecks = common.strToBool(pText[1]) outputFolder = pText[2] inputFolder = pText[3] # Get equation of choice Ksat = pText[4] carbonContent = pText[5] carbonConFactor = pText[6] # Create output folder
import sys import os import configuration import numpy as np import arcpy import math import LUCI_PTFs.lib.log as log import LUCI_PTFs.lib.common as common import LUCI_PTFs.lib.point_PTFs as point_PTFs import LUCI_PTFs.lib.checks_PTFs as checks_PTFs import LUCI_PTFs.lib.plots as plots from LUCI_PTFs.lib.external import six # Python 2/3 compatibility module from LUCI_PTFs.lib.refresh_modules import refresh_modules refresh_modules([log, common, point_PTFs, checks_PTFs, plots]) def function(outputFolder, inputShp, PTFOption, fcVal, sicVal, pwpVal, carbContent, carbonConFactor): try: # Set temporary variables prefix = os.path.join(arcpy.env.scratchGDB, "soil_") # Set output filename outputShp = os.path.join(outputFolder, "soil_point_ptf.shp") # Copy the input shapefile to the output folder arcpy.CopyFeatures_management(inputShp, outputShp)
import arcpy import os import sys import time import traceback import xml.etree.cElementTree as ET import LUCI_PTFs.lib.log as log import LUCI_PTFs.lib.common as common from LUCI_PTFs.lib.refresh_modules import refresh_modules refresh_modules([log, common]) ### Global timing variables ### times = [] startTime = time.clock() times.append(startTime) def initProgress(folder, rerun): try: xmlFile = getProgressFilenames(folder).xmlFile if not rerun: removeFile(xmlFile) # Create file if it does not exist if not os.path.exists(xmlFile): root = ET.Element("data")
def execute(self, parameters, messages): import LUCI_PTFs.tools.t_soil_param as t_soil_param refresh_modules(t_soil_param) t_soil_param.function(parameters)
def execute(self, parameters, messages): import LUCI_PTFs.tools.t_brooks_corey as t_brooks_corey refresh_modules(t_brooks_corey) t_brooks_corey.function(parameters)
Functions that help check fields and values for PTFs ''' import sys import os import configuration import numpy as np import arcpy import math import LUCI_PTFs.lib.log as log import LUCI_PTFs.lib.common as common import LUCI_PTFs.lib.PTFdatabase as PTFdatabase from LUCI_PTFs.lib.external import six # Python 2/3 compatibility module from LUCI_PTFs.lib.refresh_modules import refresh_modules refresh_modules([log, common, PTFdatabase]) def checkInputFields(inputFields, inputShp): log.info('Checking if all required input fields are present in ' + str(inputShp)) # Checks if the input fields are present in the shapefile for param in inputFields: fieldPresent = False if common.CheckField(inputShp, param): fieldPresent = True
def execute(self, parameters, messages): import LUCI_PTFs.tools.t_soil_moisture as t_soil_moisture refresh_modules(t_soil_moisture) t_soil_moisture.function(parameters)
def execute(self, parameters, messages): import LUCI_PTFs.tools.t_calc_vg as t_calc_vg refresh_modules(t_calc_vg) t_calc_vg.function(parameters)
import configuration import arcpy import math import os import sys import LUCI_PTFs.lib.log as log import LUCI_PTFs.lib.common as common import LUCI_PTFs.lib.checks_PTFs as checks_PTFs import LUCI_PTFs.lib.PTFdatabase as PTFdatabase import LUCI_PTFs.lib.ksat_PTFs as ksat_PTFs from LUCI_PTFs.lib.external import six # Python 2/3 compatibility module from LUCI_PTFs.lib.refresh_modules import refresh_modules refresh_modules([log, common, checks_PTFs, PTFdatabase, ksat_PTFs]) def function(outputFolder, inputFolder, KsatOption, carbContent, carbonConFactor): try: # Set temporary variables prefix = os.path.join(arcpy.env.scratchGDB, "moist_") # Set output filename outputShp = os.path.join(outputFolder, "Ksat.shp") ## From the input folder, pull the PTFinfo PTFxml = os.path.join(inputFolder, "ptfinfo.xml") if not os.path.exists(PTFxml): log.error(
import arcpy import os import LUCI_PTFs.lib.log as log import LUCI_PTFs.lib.common as common import LUCI_PTFs.lib.progress as progress import LUCI_PTFs.solo.brooks_corey as brooks_corey import LUCI_PTFs.lib.PTFdatabase as PTFdatabase from LUCI_PTFs.lib.refresh_modules import refresh_modules refresh_modules([log, common, brooks_corey, PTFdatabase]) def function(params): try: pText = common.paramsAsText(params) # Get inputs runSystemChecks = common.strToBool(pText[1]) outputFolder = pText[2] inputShapefile = pText[3] PTFChoice = pText[4] BCPressures = pText[5] fcVal = pText[6] sicVal = pText[7] pwpVal = pText[8] carbonContent = pText[9] carbonConFactor = pText[10] unitsPlot = pText[11] axisChoice = pText[12]
import arcpy import os import sys import LUCI_PTFs.lib.log as log import LUCI_PTFs.lib.common as common import LUCI_PTFs.lib.progress as progress import LUCI_PTFs.solo.soil_param as SoilParam from LUCI_PTFs.lib.refresh_modules import refresh_modules refresh_modules([log, common, SoilParam]) def function(params): try: pText = common.paramsAsText(params) # Get inputs runSystemChecks = common.strToBool(pText[1]) outputFolder = pText[2] inputShapefile = pText[3] PTFChoice = common.strToBool(pText[4]) PTF = pText[5] VGChoice = common.strToBool(pText[6]) VG = pText[7] VGPressures = pText[8] MVGChoice = common.strToBool(pText[9]) MVG = pText[10] carbonContent = pText[11] carbonConFactor = pText[12]
import math import os import sys import numpy as np import csv import LUCI_PTFs.lib.log as log import LUCI_PTFs.lib.common as common import LUCI_PTFs.lib.thresholds as thresholds import LUCI_PTFs.lib.PTFdatabase as PTFdatabase import LUCI_PTFs.lib.brooksCorey as brooksCorey import LUCI_PTFs.lib.bc_PTFs as bc_PTFs import LUCI_PTFs.lib.checks_PTFs as checks_PTFs from LUCI_PTFs.lib.external import six # Python 2/3 compatibility module from LUCI_PTFs.lib.refresh_modules import refresh_modules refresh_modules( [log, common, thresholds, PTFdatabase, brooksCorey, bc_PTFs, checks_PTFs]) def function(outputFolder, inputShp, PTFOption, BCPressArray, fcVal, sicVal, pwpVal, carbContent, carbonConFactor): try: # Set temporary variables prefix = os.path.join(arcpy.env.scratchGDB, "bc_") tempSoils = prefix + "tempSoils" # Set output filename outputShp = os.path.join(outputFolder, "BrooksCorey.shp") # Copy the input shapefile to the output folder
''' bc_PTFs: contains all the PTF functions for calculating BC parameters ''' import sys import os import configuration import arcpy import math import LUCI_PTFs.lib.log as log import LUCI_PTFs.lib.common as common import LUCI_PTFs.lib.checks_PTFs as checks_PTFs from LUCI_PTFs.lib.external import six # Python 2/3 compatibility module from LUCI_PTFs.lib.refresh_modules import refresh_modules refresh_modules([log, common, checks_PTFs]) def Cosby_1984_SandC_BC(outputShp, PTFOption): log.info("Calculating Brooks-Corey using Cosby et al. (1984) - Sand and Clay") # Arrays to output warningArray = [] WC_resArray = [] WC_satArray = [] lambda_BCArray = [] hb_BCArray = [] # Get OID field OIDField = common.getOIDField(outputShp)
''' import sys import os import arcpy import csv import numpy as np import LUCI_PTFs.lib.log as log import LUCI_PTFs.lib.common as common import LUCI_PTFs.lib.vanGenuchten as vanGenuchten import LUCI_PTFs.lib.vg_PTFs as vg_PTFs import LUCI_PTFs.lib.checks_PTFs as checks_PTFs from LUCI_PTFs.lib.external import six # Python 2/3 compatibility module from LUCI_PTFs.lib.refresh_modules import refresh_modules refresh_modules([log, common, vanGenuchten, vg_PTFs, checks_PTFs]) def function(outputFolder, inputShp, VGOption, VGPressArray, MVGChoice, fcVal, sicVal, pwpVal, carbContent, carbonConFactor): try: # Set temporary variables prefix = os.path.join(arcpy.env.scratchGDB, "soil_") # Set output filename if MVGChoice == True: outputShp = os.path.join(outputFolder, "soil_mvg.shp") else: outputShp = os.path.join(outputFolder, "soil_vg.shp") # Copy the input shapefile to the output folder arcpy.CopyFeatures_management(inputShp, outputShp)
import arcpy from arcpy.sa import Reclassify, RemapRange import os import sys import shutil import datetime # For writing current date/time to inputs.xml import time # For logging warnings that are very close together import xml.etree.cElementTree as ET from LUCI_PTFs.lib.external import six # Python 2/3 compatibility module import configuration import LUCI_PTFs.lib.log as log from LUCI_PTFs.lib.refresh_modules import refresh_modules refresh_modules([log]) def strToBool(s): ''' Converts a true/false string to an actual Boolean''' if s == "True" or s == "true": return True elif s == "False" or s == "false": return False else: raise ValueError def runSystemChecks(folder=None, rerun=False): import LUCI_PTFs.lib.progress as progress
import sys import os import configuration import numpy as np import arcpy import math import LUCI_PTFs.lib.log as log import LUCI_PTFs.lib.progress as progress import LUCI_PTFs.lib.common as common import LUCI_PTFs.lib.vanGenuchten as vanGenuchten import LUCI_PTFs.lib.thresholds as thresholds import LUCI_PTFs.lib.PTFdatabase as PTFdatabase from LUCI_PTFs.lib.external import six # Python 2/3 compatibility module from LUCI_PTFs.lib.refresh_modules import refresh_modules refresh_modules([log, common, vanGenuchten, thresholds, PTFdatabase]) def plotPTF(outputFolder, outputShp, PTFOption, nameArray, results): # For plotting point PTFs import matplotlib.pyplot as plt import numpy as np PTFInfo = PTFdatabase.checkPTF(PTFOption) PTFPressures = PTFInfo.PTFPressures PTFUnit = PTFInfo.PTFUnit # Remove warning results.pop(0) waterContents = []