예제 #1
0
def Jabro_1992(outputFolder, outputShp):

    # Returns these arrays
    warningArray = []
    K_satArray = []

    log.info('Calculating saturated hydraulic conductivity using Jabro (1992)')

    PTFInfo = PTFdatabase.checkPTF("Jabro_1992")
    PTFType = PTFInfo.PTFType
    PTFPressures = PTFInfo.PTFPressures
    PTFFields = PTFInfo.PTFFields

    # Requirements: sand and clay

    # Get OID field
    OIDField = common.getOIDField(outputShp)

    reqFields = [OIDField, "Silt", "Clay", "BD"]

    checks_PTFs.checkInputFields(reqFields, outputShp)

    # Retrieve info from input
    record = []
    siltPerc = []
    clayPerc = []
    BDg_cm3 = []

    with arcpy.da.SearchCursor(outputShp, reqFields) as searchCursor:
        for row in searchCursor:
            objectID = row[0]
            silt = row[1]
            clay = row[2]
            BD = row[3]

            record.append(objectID)
            siltPerc.append(silt)
            clayPerc.append(clay)
            BDg_cm3.append(BD)

    for x in range(0, len(record)):
        # Data checks
        warningFlag = checks_PTFs.checkValue("Silt", siltPerc[x], record[x])
        warningFlag = checks_PTFs.checkValue("Clay", clayPerc[x], record[x])
        warningFlag = checks_PTFs.checkValue("Bulk density", BDg_cm3[x],
                                             record[x])
        warningArray.append(warningFlag)

        K_sat = 10**(9.56 - (0.81 * math.log(siltPerc[x], 10.0)) -
                     (1.09 * math.log(clayPerc[x], 10.0)) -
                     (4.64 * BDg_cm3[x])) * 10.0

        checks_PTFs.checkValue("Ksat", K_sat, record[x])

        K_satArray.append(K_sat)

    return warningArray, K_satArray
예제 #2
0
def MinasnyMcBratney_2000(outputFolder, outputShp):

    # Returns these arrays
    warningArray = []
    K_satArray = []

    log.info(
        'Calculating saturated hydraulic conductivity using Minasny and McBratney (2000)'
    )

    PTFInfo = PTFdatabase.checkPTF("MinasnyMcBratney_2000")
    PTFType = PTFInfo.PTFType
    PTFPressures = PTFInfo.PTFPressures
    PTFFields = PTFInfo.PTFFields

    # Get OID field
    OIDField = common.getOIDField(outputShp)

    # Requirements: WC @ Sat and WC @ FC
    reqFields = [OIDField, "wc_satCalc", "wc_fcCalc"]

    checks_PTFs.checkInputFields(reqFields, outputShp)

    # Retrieve info from input
    record = []
    WC_satArray = []
    WC_FCArray = []

    with arcpy.da.SearchCursor(outputShp, reqFields) as searchCursor:
        for row in searchCursor:
            objectID = row[0]
            WC_sat = row[1]
            WC_FC = row[2]

            record.append(objectID)
            WC_satArray.append(WC_sat)
            WC_FCArray.append(WC_FC)

    for x in range(0, len(record)):
        # Data checks
        warningFlag = checks_PTFs.checkValue("WC at sat", WC_satArray[x],
                                             record[x])
        warningFlag = checks_PTFs.checkValue("WC at FC", WC_FCArray[x],
                                             record[x])
        warningArray.append(warningFlag)

        Eff_porosity = WC_satArray[x] - WC_FCArray[x]
        K_sat = 23190.55 * Eff_porosity**3.66

        checks_PTFs.checkValue("Ksat", K_sat, record[x])

        K_satArray.append(K_sat)

    return warningArray, K_satArray
예제 #3
0
def Cosby_1984(outputFolder, outputShp):

    # Returns these arrays
    warningArray = []
    K_satArray = []

    log.info(
        'Calculating saturated hydraulic conductivity using Cosby et al. (1984)'
    )

    PTFInfo = PTFdatabase.checkPTF("Cosby_1984")
    PTFType = PTFInfo.PTFType
    PTFPressures = PTFInfo.PTFPressures
    PTFFields = PTFInfo.PTFFields

    # Requirements: sand and clay

    # Get OID field
    OIDField = common.getOIDField(outputShp)

    reqFields = [OIDField, "Sand", "Clay"]

    checks_PTFs.checkInputFields(reqFields, outputShp)

    # Retrieve info from input
    record = []
    sandPerc = []
    clayPerc = []

    with arcpy.da.SearchCursor(outputShp, reqFields) as searchCursor:
        for row in searchCursor:
            objectID = row[0]
            sand = row[1]
            clay = row[2]

            record.append(objectID)
            sandPerc.append(sand)
            clayPerc.append(clay)

    for x in range(0, len(record)):
        # Data checks
        warningFlag = checks_PTFs.checkValue("Sand", sandPerc[x], record[x])
        warningFlag = checks_PTFs.checkValue("Clay", clayPerc[x], record[x])
        warningArray.append(warningFlag)

        K_sat = 25.4 * 10**(-0.6 + (0.0126 * sandPerc[x]) -
                            (0.0064 * clayPerc[x]))

        checks_PTFs.checkValue("Ksat", K_sat, record[x])

        K_satArray.append(K_sat)

    return warningArray, K_satArray
예제 #4
0
def CampbellShiozawa_1994(outputFolder, outputShp):

    # Returns these arrays
    warningArray = []
    K_satArray = []

    log.info(
        'Calculating saturated hydraulic conductivity using Campbell and Shiozawa (1994)'
    )

    PTFInfo = PTFdatabase.checkPTF("CampbellShiozawa_1994")
    PTFType = PTFInfo.PTFType
    PTFPressures = PTFInfo.PTFPressures
    PTFFields = PTFInfo.PTFFields

    # Requirements: silt and clay

    # Get OID field
    OIDField = common.getOIDField(outputShp)

    reqFields = [OIDField, "Silt", "Clay"]

    checks_PTFs.checkInputFields(reqFields, outputShp)

    # Retrieve info from input
    record = []
    siltPerc = []
    clayPerc = []

    with arcpy.da.SearchCursor(outputShp, reqFields) as searchCursor:
        for row in searchCursor:
            objectID = row[0]
            silt = row[1]
            clay = row[2]

            record.append(objectID)
            siltPerc.append(silt)
            clayPerc.append(clay)

    for x in range(0, len(record)):
        # Data checks
        warningFlag = checks_PTFs.checkValue("Silt", siltPerc[x], record[x])
        warningFlag = checks_PTFs.checkValue("Clay", clayPerc[x], record[x])
        warningArray.append(warningFlag)

        K_sat = 54.0 * math.exp((-0.07 * siltPerc[x]) - (0.167 * clayPerc[x]))

        checks_PTFs.checkValue("Ksat", K_sat, record[x])

        K_satArray.append(K_sat)

    return warningArray, K_satArray
예제 #5
0
def Puckett_1985(outputFolder, outputShp):

    # Returns these arrays
    warningArray = []
    K_satArray = []

    log.info(
        'Calculating saturated hydraulic conductivity using Puckett et al. (1985)'
    )

    PTFInfo = PTFdatabase.checkPTF("Puckett_1985")
    PTFType = PTFInfo.PTFType
    PTFPressures = PTFInfo.PTFPressures
    PTFFields = PTFInfo.PTFFields

    # Requirements: Clay

    # Get OID field
    OIDField = common.getOIDField(outputShp)

    reqFields = [OIDField, "Clay"]

    checks_PTFs.checkInputFields(reqFields, outputShp)

    # Retrieve info from input
    record = []
    clayPerc = []

    with arcpy.da.SearchCursor(outputShp, reqFields) as searchCursor:
        for row in searchCursor:
            objectID = row[0]
            clay = row[1]

            record.append(objectID)
            clayPerc.append(clay)

    for x in range(0, len(record)):
        # Data checks
        warningFlag = checks_PTFs.checkValue("Clay", clayPerc[x], record[x])
        warningArray.append(warningFlag)

        K_sat = 156.96 * math.exp(-0.1975 * clayPerc[x])

        checks_PTFs.checkValue("Ksat", K_sat, record[x])

        K_satArray.append(K_sat)

    return warningArray, K_satArray
예제 #6
0
def FerrerJulia_2004_1(outputFolder, outputShp):

    # Returns these arrays
    warningArray = []
    K_satArray = []

    log.info(
        'Calculating saturated hydraulic conductivity using Ferrer Julia et al. (2004) - Sand'
    )

    PTFInfo = PTFdatabase.checkPTF("FerrerJulia_2004_1")
    PTFType = PTFInfo.PTFType
    PTFPressures = PTFInfo.PTFPressures
    PTFFields = PTFInfo.PTFFields

    # Requirements: sand

    # Get OID field
    OIDField = common.getOIDField(outputShp)

    reqFields = [OIDField, "Sand"]

    checks_PTFs.checkInputFields(reqFields, outputShp)

    # Retrieve info from input
    record = []
    sandPerc = []

    with arcpy.da.SearchCursor(outputShp, reqFields) as searchCursor:
        for row in searchCursor:
            objectID = row[0]
            sand = row[1]

            record.append(objectID)
            sandPerc.append(sand)

    for x in range(0, len(record)):
        # Data checks
        warningFlag = checks_PTFs.checkValue("Sand", sandPerc[x], record[x])
        warningArray.append(warningFlag)

        K_sat = 0.920 * math.exp(0.0491 * sandPerc[x])

        checks_PTFs.checkValue("Ksat", K_sat, record[x])

        K_satArray.append(K_sat)

    return warningArray, K_satArray
예제 #7
0
def pressureFields(outputFolder, inputShp, fieldFC, fieldSIC, fieldPWP):

    # Check PTF information
    PTFxml = os.path.join(outputFolder, "ptfinfo.xml")
    PTFOption = common.readXML(PTFxml, 'VGOption')

    PTFInfo = PTFdatabase.checkPTF(PTFOption)
    PTFType = PTFInfo.PTFType
    PTFPressures = PTFInfo.PTFPressures

    # Get OIDField
    OIDField = arcpy.Describe(inputShp).OIDFieldName

    fcArray = []
    sicArray = []
    pwpArray = []

    # Check the field capacity field
    if common.CheckField(inputShp, fieldFC):

        with arcpy.da.SearchCursor(inputShp,
                                   [fieldFC, OIDField]) as searchCursor:
            for row in searchCursor:
                fc_kPa = row[0]

                if PTFType == 'vgPTF':
                    if fc_kPa < 6 or fc_kPa > 33:
                        log.warning("Field capacity for soil in row " +
                                    str(OIDField) +
                                    " should be between 6 to 33 kPa")

                    fcArray.append(fc_kPa)

                elif PTFType == 'pointPTF':
                    # Check if this pressure point is inside the array

                    if fc_kPa in PTFPressures:
                        fcArray.append(fc_kPa)

                    else:
                        log.error(
                            "Pressure for field capacity NOT present in point-PTF pressures"
                        )
                        log.error(
                            "Cannot calculate water content at this pressure for field capacity"
                        )
                        sys.exit()

                else:
                    log.error("PTF type not recognised: " + str(PTFType))

    else:
        log.error("Field for field capacity not found in input shapefle: " +
                  str(fieldFC))
        sys.exit()

    if fieldSIC is not None:
        if common.CheckField(inputShp, fieldSIC):

            with arcpy.da.SearchCursor(inputShp,
                                       [fieldSIC, OIDField]) as searchCursor:
                for row in searchCursor:
                    sic_kPa = row[0]

                    if PTFType == 'vgPTF':
                        ## TODO: Put in a check for the stoma closure pressure
                        ## TODO: Need to know what is a realistic range for the SIC presusre

                        sicArray.append(sic_kPa)

                    elif PTFType == 'pointPTF':
                        # Check if this pressure point is inside the array

                        if sic_kPa in PTFPressures:
                            sicArray.append(sic_kPa)

                        else:
                            log.error(
                                "Pressure for stoma closure due to water stress NOT present in point-PTF pressures"
                            )
                            log.error(
                                "Cannot calculate water content at this pressure for stoma closure due to water stress"
                            )
                            sys.exit()

                    else:
                        log.error("PTF type not recognised: " + str(PTFType))

        else:
            log.error(
                "Field for water stress-induced stomatal closure not found in input shapefle: "
                + str(fieldFC))

    else:
        log.warning(
            "Field for water stress-induced stomatal closure not specified")
        log.warning("Using default value of 100 kPa")
        defaultSIC = 100.0

        # Populate sicArray
        for i in range(0, len(fcArray)):
            sicArray.append(defaultSIC)

    if fieldPWP is not None:
        if common.CheckField(inputShp, fieldPWP):

            with arcpy.da.SearchCursor(inputShp,
                                       [fieldPWP, OIDField]) as searchCursor:
                for row in searchCursor:
                    pwp_kPa = row[0]

                    if PTFType == 'vgPTF':

                        if pwp_kPa > 1500:
                            log.warning(
                                "Permanent wilting point for soil in row " +
                                str(OIDField) + " exceeds 1500 kPa")

                            ## ASK B: vg not valid for over 1500 kPa?
                            log.warning(
                                "The van Genuchten equation is not valid for pressures greater than 1500 kPa"
                            )

                        pwpArray.append(pwp_kPa)

                    elif PTFType == 'pointPTF':
                        # Check if this pressure point is inside the array

                        if pwp_kPa in pwp_kPa:
                            pwpArray.append(pwp_kPa)

                        else:
                            log.error(
                                "Pressure for permanent wilting point NOT present in point-PTF pressures"
                            )
                            log.error(
                                "Cannot calculate water content at this pressure for permanent wilting point"
                            )
                            sys.exit()

                    else:
                        log.error("PTF type not recognised: " + str(PTFType))

        else:
            log.error(
                "Field for permanent wilting point not found in input shapefle: "
                + str(fieldFC))

    else:
        log.warning("Field for permanent wilting point not specified")
        log.warning("Using default value of 1500 kPa")
        defaultPWP = 1500.0

        # Populate pwpArray
        for i in range(0, len(fcArray)):
            pwpArray.append(defaultPWP)

    # log.info('DEBUG: fcArray: ' + str(fcArray))
    # log.info('DEBUG: sicArray: ' + str(sicArray))
    # log.info('DEBUG: pwpArray: ' + str(pwpArray))

    return fcArray, sicArray, pwpArray
예제 #8
0
def function(params):

    try:
        pText = common.paramsAsText(params)

        # Get inputs
        runSystemChecks = common.strToBool(pText[1])
        outputFolder = pText[2]
        inputShapefile = pText[3]
        VGChoice = pText[4]
        VGPressures = pText[5]
        fcVal = pText[6]
        sicVal = pText[7]
        pwpVal = pText[8]
        carbonContent = pText[9]
        carbonConFactor = pText[10]
        unitsPlot = pText[11]
        plotAxis = pText[12]
        MVGChoice =  common.strToBool(pText[13])

        # Create output folder
        if not os.path.exists(outputFolder):
            os.mkdir(outputFolder)

        common.runSystemChecks(outputFolder)

        # Set up logging output to file
        log.setupLogging(outputFolder)

        # Write input params to XML
        common.writeParamsToXML(params, outputFolder)

        # Simplify VGOption
        if VGChoice == "Wosten et al. (1999) topsoil":
            VGOption = "Wosten_1999_top"

        elif VGChoice == "Wosten et al. (1999) subsoil":
            VGOption = "Wosten_1999_sub"

        elif VGChoice == "Vereecken et al. (1989)":
            VGOption = "Vereecken_1989"

        elif VGChoice == "Zacharias and Wessolek (2007)":
            VGOption = "ZachariasWessolek_2007"

        elif VGChoice == "Weynants et al. (2009)":
            VGOption = "Weynants_2009"

        elif VGChoice == "Dashtaki et al. (2010)":
            VGOption = 'Dashtaki_2010_vg'

        elif VGChoice == "Hodnett and Tomasella (2002)":
            VGOption = 'HodnettTomasella_2002'

        else:
            log.error('Invalid PTF option')
            sys.exit()

        # Set carbon content choice
        if carbonContent == 'Organic carbon':
            carbContent = 'OC'

        elif carbonContent == 'Organic matter':
            carbContent = 'OM'

        else:
            log.error('Invalid carbon content option')
            sys.exit()

        # Unpack 'VG pressure heads' parameter
        if VGPressures is None:
            VGPressArray = []
        else:
            VGPressArray = VGPressures.split(' ')

        # Pull out PTFinfo
        PTFInfo = PTFdatabase.checkPTF(VGOption)
        PTFType = PTFInfo.PTFType
        PTFUnit = PTFInfo.PTFUnit

        PTFOut = [("VGOption", VGOption),
                  ("PTFType", PTFType),
                  ("UserUnitPlot", unitsPlot),
                  ("carbContent", carbContent)]

        # Write to XML file
        PTFXML = os.path.join(outputFolder, "ptfinfo.xml")
        common.writeXML(PTFXML, PTFOut)

        # Call van Genuchten function
        calc_vg.function(outputFolder, inputShapefile, VGOption, VGPressArray,
                         MVGChoice, fcVal, sicVal, pwpVal,
                         carbContent, carbonConFactor)

        # Loading shapefile automatically
        if MVGChoice == True:
            soilParamOut = os.path.join(outputFolder, "soil_mvg.shp")
        else:
            soilParamOut = os.path.join(outputFolder, "soil_vg.shp")
        

        arcpy.SetParameter(14, soilParamOut)

        log.info("van Genuchten operations completed successfully")

    except Exception:
        log.exception("van Genuchten tool failed")
        raise
예제 #9
0
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
        if not os.path.exists(outputFolder):
            os.mkdir(outputFolder)

        # System checks and setup
        if runSystemChecks:
            common.runSystemChecks(outputFolder)

        # Set up logging output to file
        log.setupLogging(outputFolder)

        # Write input params to XML
        common.writeParamsToXML(params, outputFolder)

        # Set saturated hydraulic conductivity option
        if Ksat == 'Cosby et al. (1984)':
            KsatOption = 'Cosby_1984'

        elif Ksat == 'Puckett et al. (1985)':
            KsatOption = 'Puckett_1985'

        elif Ksat == 'Jabro (1992)':
            KsatOption = 'Jabro_1992'

        elif Ksat == 'Campbell and Shiozawa (1994)':
            KsatOption = 'CampbellShiozawa_1994'

        elif Ksat == 'Ferrer Julia et al. (2004) - Sand':
            KsatOption = 'FerrerJulia_2004_1'

        elif Ksat == 'Ferrer Julia et al. (2004) - Sand, clay, OM':
            KsatOption = 'FerrerJulia_2004_2'

        elif Ksat == 'Ahuja et al. (1989)':
            KsatOption = 'Ahuja_1989'

        elif Ksat == 'Minasny and McBratney (2000)':
            KsatOption = 'MinasnyMcBratney_2000'

        elif Ksat == 'Brakensiek et al. (1984)':
            KsatOption = 'Brakensiek_1984'

        elif Ksat == 'Wosten et al. (1999)':
            KsatOption = 'Wosten_1999'
            log.info(
                '==========================================================================='
            )
            log.info(
                'Wosten et al. (1999) already calculated Ksat in the previous step'
            )
            log.info(
                'Please check the output shapefile of the previous step for the K_sat field'
            )
            log.info(
                '==========================================================================='
            )
            sys.exit()

        else:
            log.error('Invalid Ksat option')
            sys.exit()

        # Set carbon content choice
        if carbonContent == 'Organic carbon':
            carbContent = 'OC'

        elif carbonContent == 'Organic matter':
            carbContent = 'OM'

        else:
            log.error('Invalid carbon content option')
            sys.exit()

        # Pull out PTFinfo
        PTFInfo = PTFdatabase.checkPTF(KsatOption)
        PTFType = PTFInfo.PTFType
        PTFUnit = PTFInfo.PTFUnit

        PTFOut = [("KsatOption", KsatOption), ("PTFType", PTFType),
                  ("carbContent", carbContent)]

        # Write to XML file
        PTFXML = os.path.join(outputFolder, "ksat_ptfinfo.xml")
        common.writeXML(PTFXML, PTFOut)

        CalcKsat.function(outputFolder, inputFolder, KsatOption, carbContent,
                          carbonConFactor)

        # Set output filename for display
        KsatOut = os.path.join(outputFolder, "Ksat.shp")
        arcpy.SetParameter(7, KsatOut)

        log.info(
            "Saturated hydraulic conductivity operations completed successfully"
        )

    except Exception:
        log.exception("Saturated hydraulic conductivity tool failed")
        raise
예제 #10
0
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]

        # Create output folder
        if not os.path.exists(outputFolder):
            os.mkdir(outputFolder)

        # System checks and setup
        if runSystemChecks:
            common.runSystemChecks(outputFolder)

        # Set up logging output to file
        log.setupLogging(outputFolder)

        # Write input params to XML
        common.writeParamsToXML(params, outputFolder)

        if PTFChoice == 'Cosby et al. (1984) - Sand and Clay':
            PTFOption = 'Cosby_1984_SandC_BC'

        elif PTFChoice == 'Cosby et al. (1984) - Sand, Silt and Clay':
            PTFOption = 'Cosby_1984_SSC_BC'

        elif PTFChoice == 'Rawls and Brakensiek (1985)':
            PTFOption = 'RawlsBrakensiek_1985_BC'
            log.warning("Rawls and Brakensiek (1985) requires water content at saturation")
            log.warning("Please ensure the WC_sat field is present in the shapefile")

        elif PTFChoice == 'Campbell and Shiozawa (1992)':
            PTFOption = 'CampbellShiozawa_1992_BC'
            log.warning("Campbell and Shiozava (1992) requires water content at saturation")
            log.warning("Please ensure the WC_sat field is present in the shapefile")

        elif PTFChoice == 'Saxton et al. (1986)':
            PTFOption = 'Saxton_1986_BC'
            
        elif PTFChoice == 'Saxton and Rawls (2006)':
            PTFOption = 'SaxtonRawls_2006_BC'

        else:
            log.error('Choice for Brooks-Corey calculation not recognised')
            sys.exit()

        # Set carbon content choice
        if carbonContent == 'Organic carbon':
            carbContent = 'OC'

        elif carbonContent == 'Organic matter':
            carbContent = 'OM'

        else:
            log.error('Invalid carbon content option')
            sys.exit()

        # Unpack 'BC pressure heads' parameter
        if BCPressures is None:
            BCPressArray = []
        else:
            BCPressArray = BCPressures.split(' ')

        # Pull out PTFinfo
        PTFInfo = PTFdatabase.checkPTF(PTFOption)
        PTFType = PTFInfo.PTFType
        PTFUnit = PTFInfo.PTFUnit

        PTFOut = [("BCOption", PTFOption),
                  ("PTFType", PTFType),
                  ("UserUnitPlot", unitsPlot),
                  ("carbContent", carbContent)]

        # Write to XML file
        PTFXML = os.path.join(outputFolder, "ptfinfo.xml")
        common.writeXML(PTFXML, PTFOut)

        # Call Brooks-Corey function
        brooks_corey.function(outputFolder, inputShapefile, PTFOption,
                              BCPressArray, fcVal, sicVal, pwpVal,
                              carbContent, carbonConFactor)

        # Set output filename for display
        BCOut = os.path.join(outputFolder, "BrooksCorey.shp")
        arcpy.SetParameter(13, BCOut)

        log.info("Brooks-Corey operations completed successfully")

    except Exception:
        log.exception("Brooks-Corey tool failed")
        raise
예제 #11
0
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 = []

    # Rearrange arrays
    for j in range(0, len(nameArray)):
        WC = []
        for i in range(0, len(PTFPressures)):
            water = results[i][j]
            WC.append(water)

        waterContents.append(WC)

    # log.info('DEBUG: waterContents: ')
    # log.info(waterContents)

    PTFInfo = PTFdatabase.checkPTF(PTFOption)
    WCheadings = PTFInfo.PTFFields
    WCheadings.pop(0) # remove warning

    for j in range(0, len(waterContents)):
        WC = waterContents[j]

        firstWCName = WCheadings[0]
        firstWCVal = WC[0]

        for i in range(1, len(WC)):
            if WC[i] > firstWCVal:
                log.warning('Water content in field ' + str(WCheadings[i]) + ' is higher than pressure at lowest water content (' + str(firstWCName) + ')')
                log.warning('Check this soil: ' + str(nameArray[j]))

    # Get units for plot
    unitPlots = common.getInputValue(outputFolder, "Pressure_units_plot")
    
    # Get critical thresholds
    fcValue = common.getInputValue(outputFolder, "FieldCapacity")
    sicValue = common.getInputValue(outputFolder, "SIC")
    pwpValue = common.getInputValue(outputFolder, "PWP")

    # Set up pressure vector
    psiArray = np.array(PTFPressures)
    psi_kPa = psiArray.astype(np.float)

    if unitPlots == 'kPa':
        psi_plot = psi_kPa
        fc_plot = float(fcValue) * -1.0
        sic_plot = float(sicValue) * -1.0
        pwp_plot = float(pwpValue) * -1.0
        xLimits = [-1600.0, 0.1]

    elif unitPlots == 'cm':
        psi_plot = 10.0 * psi_kPa
        fc_plot = float(fcValue) * -10.0
        sic_plot = float(sicValue) * -10.0
        pwp_plot = float(pwpValue) * -10.0
        xLimits = [-16000.0, 0.1]

    elif unitPlots == 'm':
        psi_plot = 0.1 * psi_kPa
        fc_plot = float(fcValue) * -0.1
        sic_plot = float(sicValue) * -0.1
        pwp_plot = float(pwpValue) * -0.1
        xLimits = [-160.0, 0.1]

    # Convert psi_plot to negative for plotting purposes
    psi_neg = -1.0 * psi_plot
 
    for i in range(0, len(nameArray)):
        outName = 'pointPTF_'  + str(nameArray[i]) + '.png'
        outPath = os.path.join(outputFolder, outName)
        title = 'Point-PTF plot for ' + str(nameArray[i])

        plt.scatter(psi_neg, waterContents[i], label=str(nameArray[i]), c='b')
        plt.xscale('symlog')
        plt.title(title)
        plt.xlabel('log Pressure (' + str(unitPlots) + ')')
        plt.ylabel('Volumetric water content')
        plt.xlim(xLimits)
        plt.axvline(x=fc_plot, color='g', linestyle='dashed', label='FC')
        plt.axvline(x=sic_plot, color='m', linestyle='dashed', label='SIC')
        plt.axvline(x=pwp_plot, color='r', linestyle='dashed', label='PWP')
        plt.legend(loc="upper left")
        plt.savefig(outPath, transparent=False)
        plt.close()
        log.info('Plot created for soil ' + str(nameArray[i]))
예제 #12
0
def Brakensiek_1984(outputFolder, outputShp):

    # Returns these arrays
    warningArray = []
    K_satArray = []

    log.info(
        'Calculating saturated hydraulic conductivity using Brakensiek et al. (1984)'
    )

    PTFInfo = PTFdatabase.checkPTF("Brakensiek_1984")
    PTFType = PTFInfo.PTFType
    PTFPressures = PTFInfo.PTFPressures
    PTFFields = PTFInfo.PTFFields

    # Get OID field
    OIDField = common.getOIDField(outputShp)

    # Requirements: Clay, sand, WC @ Sat
    reqFields = [OIDField, "Sand", "Clay", "wc_satCalc"]

    checks_PTFs.checkInputFields(reqFields, outputShp)

    # Retrieve info from input
    record = []
    sandPerc = []
    clayPerc = []
    WC_satArray = []

    with arcpy.da.SearchCursor(outputShp, reqFields) as searchCursor:
        for row in searchCursor:
            objectID = row[0]
            sand = row[1]
            clay = row[2]
            WC_sat = row[3]

            record.append(objectID)
            sandPerc.append(sand)
            clayPerc.append(clay)
            WC_satArray.append(WC_sat)

    for x in range(0, len(record)):
        # Data checks
        warningFlag = checks_PTFs.checkValue("Sand", sandPerc[x], record[x])
        warningFlag = checks_PTFs.checkValue("Clay", clayPerc[x], record[x])
        warningFlag = checks_PTFs.checkValue("WC at sat", WC_satArray[x],
                                             record[x])
        warningArray.append(warningFlag)

        K_sat = 10 * math.exp((19.52348 * WC_satArray[x]) - 8.96847 -
                              (0.028212 * clayPerc[x]) +
                              (0.00018107 * sandPerc[x]**2) -
                              (0.0094125 * clayPerc[x]**2) -
                              (8.395215 * WC_satArray[x]**2) +
                              (0.077718 * sandPerc[x] * WC_satArray[x]) -
                              (0.00298 * sandPerc[x]**2 * WC_satArray[x]**2) -
                              (0.019492 * clayPerc[x]**2 * WC_satArray[x]**2) +
                              (0.0000173 * sandPerc[x]**2 * clayPerc[x]) +
                              (0.02733 * clayPerc[x]**2 * WC_satArray[x]) +
                              (0.001434 * sandPerc[x]**2 * WC_satArray[x]) -
                              (0.0000035 * clayPerc[x]**2 * sandPerc[x]))

        checks_PTFs.checkValue("Ksat", K_sat, record[x])

        K_satArray.append(K_sat)

    return warningArray, K_satArray
예제 #13
0
def FerrerJulia_2004_2(outputFolder, outputShp, carbonConFactor, carbContent):

    # Returns these arrays
    warningArray = []
    K_satArray = []

    log.info(
        'Calculating saturated hydraulic conductivity using Ferrer Julia et al. (2004) - Sand, clay, OM'
    )

    PTFInfo = PTFdatabase.checkPTF("FerrerJulia_2004_2")
    PTFType = PTFInfo.PTFType
    PTFPressures = PTFInfo.PTFPressures
    PTFFields = PTFInfo.PTFFields

    # Get OID field
    OIDField = common.getOIDField(outputShp)

    # Requirements: sand, clay, OM, BD
    if carbContent == 'OC':
        reqFields = [OIDField, "Sand", "Clay", "OC", "BD"]
        carbonConFactor = 1.724

    elif carbContent == 'OM':
        reqFields = [OIDField, "Sand", "Clay", "OM", "BD"]
        carbonConFactor = 1.0

    checks_PTFs.checkInputFields(reqFields, outputShp)

    # Retrieve info from input
    record = []
    sandPerc = []
    clayPerc = []
    carbPerc = []
    BDg_cm3 = []

    with arcpy.da.SearchCursor(outputShp, reqFields) as searchCursor:
        for row in searchCursor:
            objectID = row[0]
            sand = row[1]
            clay = row[2]
            carbon = row[3]
            BD = row[4]

            record.append(objectID)
            sandPerc.append(sand)
            clayPerc.append(clay)
            carbPerc.append(carbon)
            BDg_cm3.append(BD)

    for x in range(0, len(record)):
        # Data checks
        warningFlag = checks_PTFs.checkCarbon(carbPerc[x], carbContent,
                                              record[x])
        warningFlag = checks_PTFs.checkValue("Sand", sandPerc[x], record[x])
        warningFlag = checks_PTFs.checkValue("Clay", clayPerc[x], record[x])
        warningFlag = checks_PTFs.checkValue("Bulk density", BDg_cm3[x],
                                             record[x])
        warningArray.append(warningFlag)

        K_sat = -4.994 + (0.56728 * sandPerc[x]) - (0.131 * clayPerc[x]) - (
            0.0127 * carbPerc[x] * float(carbonConFactor))

        checks_PTFs.checkValue("Ksat", K_sat, record[x])

        K_satArray.append(K_sat)

    return warningArray, K_satArray