示例#1
0
def Saxton_1986_BC(outputShp, PTFOption):

    log.info("Calculating Brooks-Corey using Saxton et al. (1986)")

    # Arrays to output
    warningArray = []
    WC_resArray = []
    WC_satArray = []
    lambda_BCArray = []
    hb_BCArray = []

    # 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)

    A_Array = []
    B_Array = []

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

        # Calculate values
        # WC_0kPa = WC_sat
        WC_sat = 0.332 - (7.251 * 10**(-4) * sandPerc[x]) + (0.1276 * math.log(clayPerc[x], 10.0))
        WC_residual = 0
        A_Saxton = 100 * math.exp(-4.396 - (0.0715 * clayPerc[x])- (0.000488 * sandPerc[x]**2) - (0.00004285 * sandPerc[x]**2 * clayPerc[x])) 
        B_Saxton = -3.140 - (0.00222 * clayPerc[x]**2) - (0.00003484 * sandPerc[x]**2 * clayPerc[x])
        hb_BC = A_Saxton * (WC_sat** B_Saxton)  
        lambda_BC = -1.0 / float(B_Saxton)

        checks_PTFs.checkNegOutput([WC_sat, WC_residual], x)

        WC_satArray.append(WC_sat)
        WC_resArray.append(WC_residual)
        A_Array.append(A_Saxton)
        B_Array.append(B_Saxton)
        hb_BCArray.append(hb_BC)
        lambda_BCArray.append(lambda_BC)

    return warningArray, WC_resArray, WC_satArray, lambda_BCArray, hb_BCArray
示例#2
0
def RawlsBrakensiek_1985_BC(outputShp, PTFOption):

    log.info("Calculating Brooks-Corey using Rawls and Brakensiek (1985)")

    # Arrays to output
    warningArray = []
    WC_resArray = []
    lambda_BCArray = []
    hb_BCArray = []

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

    reqFields = [OIDField, "Sand", "Clay", "WC_sat"]
    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]
            WCsat = row[3]

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

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

        # Calculate values
        WC_residual = -0.0182482 + (0.00087269 * sandPerc[x]) + (0.00513488 * clayPerc[x]) + (0.02939286 * WC_satArray[x]) - (0.00015395 * clayPerc[x]**2) - (0.0010827 * sandPerc[x] * WC_satArray[x]) - (0.00018233 * clayPerc[x]**2 * WC_satArray[x]**2) + (0.00030703 * clayPerc[x]**2 * WC_satArray[x]) - (0.0023584 * WC_satArray[x]**2 * clayPerc[x])
        
        # Originally in cm
        hb_cm = math.exp(5.3396738 + (0.1845038 * clayPerc[x]) - (2.48394546 * WC_satArray[x]) - (0.00213853 * clayPerc[x]**2) - (0.04356349 * sandPerc[x] * WC_satArray[x]) - (0.61745089 * clayPerc[x] * WC_satArray[x]) + (0.00143598 * sandPerc[x]**2 * WC_satArray[x]**2) - (0.00855375 * clayPerc[x]**2 * WC_satArray[x]**2) - (0.00001282 * sandPerc[x]**2 * clayPerc[x]) + (0.00895359 * clayPerc[x]**2 * WC_satArray[x]) - (0.00072472 * sandPerc[x]**2 * WC_satArray[x]) + (0.0000054 * clayPerc[x]**2 * sandPerc[x]) + (0.50028060 * WC_satArray[x]**2 * clayPerc[x]))
        hb_BC = hb_cm / 10.0 # Convert to kPa

        lambda_BC = math.exp(-0.7842831 + (0.0177544 * sandPerc[x]) - (1.062498 * WC_satArray[x]) - (0.00005304 * sandPerc[x]**2) - (0.00273493 * clayPerc[x]**2) + (1.11134946 * WC_satArray[x]**2) - (0.03088295 * sandPerc[x] * WC_satArray[x])  + (0.00026587 * sandPerc[x]**2 * WC_satArray[x]**2)  - (0.00610522 * clayPerc[x]**2 * WC_satArray[x]**2) - (0.00000235 * sandPerc[x]**2 * clayPerc[x]) + (0.00798746 * clayPerc[x]**2 * WC_satArray[x]) - (0.00674491 * WC_satArray[x]**2 * clayPerc[x]))

        checks_PTFs.checkNegOutput([WC_residual], x)

        WC_resArray.append(WC_residual)
        hb_BCArray.append(hb_BC)
        lambda_BCArray.append(lambda_BC)

    return warningArray, WC_resArray, WC_satArray, lambda_BCArray, hb_BCArray
示例#3
0
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)

    reqFields = [OIDField, "Sand", "Clay"]
    checks_PTFs.checkInputFields(reqFields, outputShp)

    record = []
    sandPerc = []
    clayPerc = []

    # Required: sand and clay
    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("Clay", clayPerc[x], record[x])
        warningFlag = checks_PTFs.checkValue("Sand", sandPerc[x], record[x])
        warningArray.append(warningFlag)

        # Calculate values
        WC_res = 0
        WC_sat = 0.489 - (0.00126 * sandPerc[x])
        lambda_BC = 1.0 / (2.91 + (0.159 * clayPerc[x]))

        # Originally in cm
        hb_cm = 10.0 ** (1.88 - (0.013 * sandPerc[x]))
        hb_BC = hb_cm / 10.0 # Convert to kPa

        outValues = [WC_res, WC_sat]
        checks_PTFs.checkNegOutput(outValues, x)

        # Append to arrays
        WC_resArray.append(WC_res)
        WC_satArray.append(WC_sat)
        lambda_BCArray.append(lambda_BC)
        hb_BCArray.append(hb_BC)

    return warningArray, WC_resArray, WC_satArray, lambda_BCArray, hb_BCArray
示例#4
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
示例#5
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
示例#6
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
示例#7
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
示例#8
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
示例#9
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
示例#10
0
def HodnettTomasella_2002(outputShp, VGOption, carbonConFactor, carbContent):

    # Arrays to write to shapefile
    warningArray = []
    WC_satArray = []
    WC_residualArray = []
    alpha_VGArray = []
    n_VGArray = []
    m_VGArray = []

    log.info(
        "Calculating van Genuchten parameters using Hodnett and Tomasella (2002)"
    )

    # Requirements: Sand, Silt, Clay, OC, BD, CEC, pH

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

    if carbContent == 'OC':
        reqFields = [
            OIDField, "Sand", "Silt", "Clay", "OC", "BD", "CEC", "pH",
            "LUCIname", "texture"
        ]
        carbonConFactor = 1.0

    elif carbContent == 'OM':
        reqFields = [
            OIDField, "Sand", "Silt", "Clay", "OC", "BD", "CEC", "pH",
            "LUCIname", "texture"
        ]

    checks_PTFs.checkInputFields(reqFields, outputShp)

    # Retrieve info from input
    record = []
    sandPerc = []
    siltPerc = []
    clayPerc = []
    carbPerc = []
    BDg_cm3 = []
    CECcmol_kg = []
    pH = []
    nameArray = []
    textureArray = []

    with arcpy.da.SearchCursor(outputShp, reqFields) as searchCursor:
        for row in searchCursor:
            objectID = row[0]
            sand = row[1]
            silt = row[2]
            clay = row[3]
            carbon = row[4]
            BD = row[5]
            CEC = row[6]
            pHValue = row[7]
            name = row[8]
            texture = row[9]

            record.append(objectID)
            sandPerc.append(sand)
            siltPerc.append(silt)
            clayPerc.append(clay)
            carbPerc.append(carbon)
            BDg_cm3.append(BD)
            CECcmol_kg.append(CEC)
            pH.append(pHValue)
            nameArray.append(name)
            textureArray.append(texture)

    for x in range(0, len(record)):

        # Data checks
        warningFlag = checks_PTFs.checkSSC(sandPerc[x], siltPerc[x],
                                           clayPerc[x], record[x])
        warningFlag = checks_PTFs.checkCarbon(carbPerc[x], carbContent,
                                              record[x])
        warningFlag = checks_PTFs.checkValue("Bulk density", BDg_cm3[x],
                                             record[x])
        warningFlag = checks_PTFs.checkValue("CEC", CECcmol_kg[x], record[x])
        warningFlag = checks_PTFs.checkValue("pH", pH[x], record[x])
        warningArray.append(warningFlag)

        WC_sat = 0.81799 + (9.9 * 10**(-4) * clayPerc[x]) - (
            0.3142 * BDg_cm3[x]) + (1.8 * 10**(-4) * CECcmol_kg[x]) + (
                0.00451 * pH[x]) - (5 * 10**(-6) * sandPerc[x] * clayPerc[x])
        WC_residual = 0.22733 - (0.00164 * sandPerc[x]) + (
            0.00235 * CECcmol_kg[x]) - (0.00831 * pH[x]) + (
                1.8 * 10**(-5) * clayPerc[x]**2) + (2.6 * 10**(-5) *
                                                    sandPerc[x] * clayPerc[x])

        # Original equation had values in kPa-1
        # No internal conversion needed
        alpha_VG = math.exp(-0.02294 - (0.03526 * siltPerc[x]) +
                            (0.024 * carbPerc[x] * float(carbonConFactor)) -
                            (0.00076 * CECcmol_kg[x]) - (0.11331 * pH[x]) +
                            (0.00019 * siltPerc[x]**2))

        n_VG = math.exp(0.62986 - (0.00833 * clayPerc[x]) -
                        (0.00529 * carbPerc[x] * float(carbonConFactor)) +
                        (0.00593 * pH[x]) + (7 * 10**(-5) * clayPerc[x]**2) -
                        (1.4 * 10**(-4) * sandPerc[x] * siltPerc[x]))
        m_VG = 1.0 - (1.0 / float(n_VG))

        WC_satArray.append(WC_sat)
        WC_residualArray.append(WC_residual)
        alpha_VGArray.append(alpha_VG)
        n_VGArray.append(n_VG)
        m_VGArray.append(m_VG)

    common.writeWarning(outputShp, warningArray)

    return WC_residualArray, WC_satArray, alpha_VGArray, n_VGArray, m_VGArray
示例#11
0
def Dashtaki_2010(outputShp, VGOption, carbonConFactor, carbContent):

    # Arrays to write to shapefile
    warningArray = []
    K_satArray = []
    WC_satArray = []
    WC_residualArray = []
    alpha_VGArray = []
    n_VGArray = []
    m_VGArray = []

    log.info(
        "Calculating van Genuchten parameters using Dashtaki et al. (2010)")

    # Requirements: Sand, clay, and BD

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

    reqFields = [OIDField, "Sand", "Clay", "BD", "LUCIname", "texture"]
    checks_PTFs.checkInputFields(reqFields, outputShp)

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

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

            record.append(objectID)
            sandPerc.append(sand)
            clayPerc.append(clay)
            BDg_cm3.append(BD)
            nameArray.append(name)
            textureArray.append(texture)

    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("Bulk density", BDg_cm3[x],
                                             record[x])
        warningArray.append(warningFlag)

        # Calculate water content using Dashtaki et al. (2010) - Sand, Clay, BD
        WC_residual = 0.034 + (0.0032 * clayPerc[x])
        WC_sat = 0.85 - (0.00061 * sandPerc[x]) - (0.258 * BDg_cm3[x])

        # Alpha in cm-1
        alpha_cm = abs(1 / (-476 - (4.1 * sandPerc[x]) + (499 * BDg_cm3[x])))
        alpha_VG = 10.0 * alpha_cm  # Converted from cm-1 to kPa-1 for internal consistency

        n_VG = 1.56 - (0.00228 * sandPerc[x])
        m_VG = 1.0 - (1.0 / float(n_VG))

        WC_satArray.append(WC_sat)
        WC_residualArray.append(WC_residual)
        alpha_VGArray.append(alpha_VG)
        n_VGArray.append(n_VG)
        m_VGArray.append(m_VG)

    common.writeWarning(outputShp, warningArray)

    return WC_residualArray, WC_satArray, alpha_VGArray, n_VGArray, m_VGArray
示例#12
0
def Weynants_2009(outputShp, VGOption, carbonConFactor, carbContent,
                  MVGChoice):

    # Arrays to write to shapefile
    warningArray = []
    K_satArray = []
    WC_satArray = []
    WC_residualArray = []
    alpha_VGArray = []
    n_VGArray = []
    m_VGArray = []
    l_MvGArray = []

    log.info(
        "Calculating van Genuchten parameters using Weynants et al. (2009)")

    # Requirements: sand, clay, OC, and BD

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

    if carbContent == 'OC':
        reqFields = [
            OIDField, "Sand", "Clay", "OC", "BD", "LUCIname", "texture"
        ]
        carbonConFactor = 1.0

    elif carbContent == 'OM':
        reqFields = [
            OIDField, "Sand", "Clay", "OM", "BD", "LUCIname", "texture"
        ]

    checks_PTFs.checkInputFields(reqFields, outputShp)

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

    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]
            name = row[5]
            texture = row[6]

            record.append(objectID)
            sandPerc.append(sand)
            clayPerc.append(clay)
            carbPerc.append(carbon)
            BDg_cm3.append(BD)
            nameArray.append(name)
            textureArray.append(texture)

    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)

        WC_residual = 0
        WC_sat = 0.6355 + (0.0013 * clayPerc[x]) - (0.1631 * BDg_cm3[x])

        # Alpha in cm-1
        alpha_cm = math.exp(-4.3003 - (0.0097 * clayPerc[x]) +
                            (0.0138 * sandPerc[x]) -
                            (0.0992 * carbPerc[x] * float(carbonConFactor)))
        alpha_VG = 10.0 * alpha_cm  # Convert to kPa-1

        n_VG = math.exp(-1.0846 - (0.0236 * clayPerc[x]) -
                        (0.0085 * sandPerc[x]) + (0.0001 * sandPerc[x]**2)) + 1
        m_VG = 1.0 - (1.0 / float(n_VG))

        l_MvG = -1.8642 - (0.1317 * clayPerc[x]) + (0.0067 * sandPerc[x])

        K_sat = math.exp(1.9582 + (0.0308 * sandPerc[x]) -
                         (0.6142 * BDg_cm3[x]) -
                         (0.1566 *
                          (carbPerc[x] * float(carbonConFactor)))) * (10.0 /
                                                                      24.0)

        WC_satArray.append(WC_sat)
        WC_residualArray.append(WC_residual)
        alpha_VGArray.append(alpha_VG)
        n_VGArray.append(n_VG)
        m_VGArray.append(m_VG)
        l_MvGArray.append(l_MvG)
        K_satArray.append(K_sat)

    common.writeWarning(outputShp, warningArray)

    return WC_residualArray, WC_satArray, alpha_VGArray, n_VGArray, m_VGArray, l_MvGArray, K_satArray
示例#13
0
def ZachariasWessolek_2007(outputShp, VGOption, carbonConFactor, carbContent):

    # Arrays to write to shapefile
    warningArray = []
    WC_satArray = []
    WC_residualArray = []
    alpha_VGArray = []
    n_VGArray = []
    m_VGArray = []

    log.info(
        "Calculating van Genuchten parameters using Zacharias and Wessolek (2007)"
    )

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

    # Requirements: Sand, clay, and BD
    reqFields = [OIDField, "Sand", "Clay", "BD", "LUCIname", "texture"]
    checks_PTFs.checkInputFields(reqFields, outputShp)

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

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

            record.append(objectID)
            sandPerc.append(sand)
            clayPerc.append(clay)
            BDg_cm3.append(BD)
            nameArray.append(name)
            textureArray.append(texture)

    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("Bulk density", BDg_cm3[x],
                                             record[x])
        warningArray.append(warningFlag)

        if sandPerc[x] < 66.5:
            WC_residual = 0
            WC_sat = 0.788 + (0.001 * clayPerc[x]) - (0.263 * BDg_cm3[x])

            # Alpha in kPa-1
            alpha_VG = math.exp(-0.648 + (0.023 * sandPerc[x]) +
                                (0.044 * clayPerc[x]) - (3.168 * BDg_cm3[x]))

            n_VG = 1.392 - (0.418 * sandPerc[x]**
                            (-0.024)) + (1.212 * clayPerc[x]**(-0.704))
            m_VG = 1.0 - (1.0 / float(n_VG))

        else:
            WC_residual = 0
            WC_sat = 0.89 - (0.001 * clayPerc[x]) - (0.322 * BDg_cm3[x])

            # Alpha in kPa-1
            alpha_VG = math.exp(-4.197 + (0.013 * sandPerc[x]) +
                                (0.076 * clayPerc[x]) - (0.276 * BDg_cm3[x]))

            n_VG = -2.562 + (7 * 10**(-9) * sandPerc[x]**4.004) + (
                3.75 * clayPerc[x]**(-0.016))
            m_VG = 1.0 - (1.0 / float(n_VG))

        WC_satArray.append(WC_sat)
        WC_residualArray.append(WC_residual)
        alpha_VGArray.append(alpha_VG)
        n_VGArray.append(n_VG)
        m_VGArray.append(m_VG)

    common.writeWarning(outputShp, warningArray)

    return WC_residualArray, WC_satArray, alpha_VGArray, n_VGArray, m_VGArray
示例#14
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
示例#15
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
示例#16
0
def CampbellShiozawa_1992_BC(outputShp, PTFOption):

    log.info("Calculating Brooks-Corey using Campbell and Shiozawa (1992)")

    # Arrays to output
    warningArray = []
    WC_resArray = []
    lambda_BCArray = []
    hb_BCArray = []

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

    reqFields = [OIDField, "Silt", "Clay", "BD", "WC_sat"]
    checks_PTFs.checkInputFields(reqFields, outputShp)

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

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

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

    dg_CSArray = []
    Sg_CSArray = []
    hes_CSArray = []
    b_CSArray = []

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

        # Calculate values
        WC_residual = 0
        dg_CS = math.exp(-0.8 - (0.0317 * siltPerc[x]) - (0.0761 * clayPerc[x]))
        Sg_CS = (math.exp((0.133 * siltPerc[x]) + (0.477 * clayPerc[x]) - ((math.log(dg_CS))**2)))**0.5
        hes_CS = 0.05/float((math.sqrt(dg_CS)))
        b_CS = (-20.0 * (-hes_CS)) + (0.2 * Sg_CS)
        
        # Originally in cm
        hb_cm = 100.0 * (hes_CS * ((BDg_cm3[x] / 1.3) ** (0.67* b_CS)))
        hb_BC = hb_cm / 10.0 # Convert to kPa

        lambda_BC = 1.0 /float(b_CS)

        checks_PTFs.checkNegOutput([WC_residual], x)

        WC_resArray.append(WC_residual)
        dg_CSArray.append(dg_CS)
        Sg_CSArray.append(Sg_CS)
        hes_CSArray.append(hes_CS)
        b_CSArray.append(b_CS)
        hb_BCArray.append(hb_BC)
        lambda_BCArray.append(lambda_BC)

    return warningArray, WC_resArray, WC_satArray, lambda_BCArray, hb_BCArray
示例#17
0
def Wosten_1999(outputShp, VGOption, carbonConFactor, carbContent, MVGChoice):

    # Arrays to write to shapefile
    warningArray = []
    K_satArray = []
    WC_satArray = []
    WC_residualArray = []
    alpha_VGArray = []
    n_VGArray = []
    m_VGArray = []
    l_MvGArray = []

    log.info("Calculating van Genuchten parameters using Wosten et al. (1999)")

    # Requirements: sand, silt, clay, OM, and BD

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

    if carbContent == 'OC':
        reqFields = [
            OIDField, "Sand", "Silt", "Clay", "OC", "BD", "LUCIname", "texture"
        ]

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

    checks_PTFs.checkInputFields(reqFields, outputShp)

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

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

            record.append(objectID)
            sandPerc.append(sand)
            siltPerc.append(silt)
            clayPerc.append(clay)
            carbPerc.append(carbon)
            BDg_cm3.append(BD)
            nameArray.append(name)
            textureArray.append(texture)

    for x in range(0, len(record)):

        # Data checks
        warningFlag = checks_PTFs.checkSSC(sandPerc[x], siltPerc[x],
                                           clayPerc[x], record[x])
        warningFlag = checks_PTFs.checkCarbon(carbPerc[x], carbContent,
                                              record[x])
        warningFlag = checks_PTFs.checkValue("Bulk density", BDg_cm3[x],
                                             record[x])
        warningArray.append(warningFlag)

        # Calculate VG parameters
        if clayPerc[x] < 18.0 and sandPerc[x] > 65.0:
            WC_residual = 0.025
        else:
            WC_residual = 0.01

        if VGOption == 'Wosten_1999_top':

            K_sat = (10.0 / 24.0) * math.exp(
                7.755 + (0.0352 * siltPerc[x]) + (0.93 * 1) -
                (0.976 * BDg_cm3[x]**2) - (0.000484 * clayPerc[x]**2) -
                (0.000322 * siltPerc[x]**2) + (0.001 * siltPerc[x]**(-1)) -
                (0.0748 * (carbPerc[x] * float(carbonConFactor))**(-1)) -
                (0.643 * math.log(siltPerc[x])) -
                (0.0139 * BDg_cm3[x] * clayPerc[x]) -
                (0.167 * BDg_cm3[x] * carbPerc[x] * float(carbonConFactor)) +
                (0.0298 * 1 * clayPerc[x]) - (0.03305 * 1 * siltPerc[x]))

            WC_sat = 0.7919 + (0.001691 * clayPerc[x]) - (
                0.29619 * BDg_cm3[x]) - (0.000001491 * siltPerc[x]**2) + (
                    0.0000821 *
                    ((carbPerc[x] * float(carbonConFactor)))**2) + (
                        0.02427 * clayPerc[x]**(-1.0) +
                        (0.01113 * siltPerc[x]**(-1.0)) +
                        (0.01472 * math.log(siltPerc[x])) - 0.0000733 *
                        ((carbPerc[x] * float(carbonConFactor))) * clayPerc[x]
                    ) - (0.000619 * BDg_cm3[x] *
                         clayPerc[x]) - (0.001183 * BDg_cm3[x] *
                                         (carbPerc[x] * float(carbonConFactor))
                                         ) - (0.0001664 * 1.0 * siltPerc[x])

            # Alpha with 10.0 multiplier (convert alpha in cm-1 to kPa-1)
            alpha_cm = math.exp(
                -14.96 + (0.03135 * clayPerc[x]) + (0.0351 * siltPerc[x]) +
                (0.646 * (carbPerc[x] * float(carbonConFactor))) +
                (15.29 * BDg_cm3[x]) - (0.192 * 1.0) -
                (4.671 * BDg_cm3[x]**2.0) - (0.000781 * clayPerc[x]**2) -
                (0.00687 * (carbPerc[x] * float(carbonConFactor))**2.0) +
                (0.0449 * ((carbPerc[x] * float(carbonConFactor)))**(-1.0)) +
                (0.0663 * math.log(siltPerc[x])) +
                (0.1482 * math.log((carbPerc[x] * float(carbonConFactor)))) -
                (0.04546 * BDg_cm3[x] * siltPerc[x]) -
                (0.4852 * BDg_cm3[x] *
                 (carbPerc[x] * float(carbonConFactor))) +
                (0.00673 * 1.0 * clayPerc[x]))
            alpha_VG = 10.0 * alpha_cm  # Converted from cm-1 to kPa-1 for internal consistency

            n_VG = 1.0 + math.exp(
                -25.23 - (0.02195 * clayPerc[x]) + (0.0074 * siltPerc[x]) -
                (0.1940 * (carbPerc[x] * float(carbonConFactor))) +
                (45.5 * BDg_cm3[x]) - (7.24 * BDg_cm3[x]**2.0) +
                (0.0003658 * clayPerc[x]**2.0) +
                (0.002885 * ((carbPerc[x] * float(carbonConFactor)))**2.0) -
                (12.81 * (BDg_cm3[x])**(-1.0)) - (0.1524 *
                                                  (siltPerc[x])**(-1.0)) -
                (0.01958 * ((carbPerc[x] * float(carbonConFactor)))**(-1.0)) -
                (0.2876 * math.log(siltPerc[x])) -
                (0.0709 * math.log((carbPerc[x] * float(carbonConFactor)))) -
                (44.6 * math.log(BDg_cm3[x])) -
                (0.02264 * BDg_cm3[x] * clayPerc[x]) +
                (0.0896 * BDg_cm3[x] *
                 (carbPerc[x] * float(carbonConFactor))) +
                (0.00718 * 1.0 * clayPerc[x]))
            m_VG = 1.0 - (1.0 / float(n_VG))

            l_MvG_norm = 0.0202 + (0.0006193 * clayPerc[x]**2) - (
                0.001136 * (carbPerc[x] * float(carbonConFactor))**2) - (
                    0.2316 * math.log(carbPerc[x] * float(carbonConFactor))
                ) - (0.03544 * BDg_cm3[x] *
                     clayPerc[x]) + (0.00283 * BDg_cm3[x] * siltPerc[x]) + (
                         0.0488 * BDg_cm3[x] *
                         (carbPerc[x] * float(carbonConFactor)))
            l_MvG = 10 * (math.exp(l_MvG_norm) - 1) / (math.exp(l_MvG_norm) +
                                                       1)

        elif VGOption == 'Wosten_1999_sub':

            K_sat = (10.0 / 24.0) * math.exp(
                7.755 + (0.0352 * siltPerc[x]) + (0.93 * 0) -
                (0.976 * BDg_cm3[x]**2) - (0.000484 * clayPerc[x]**2) -
                (0.000322 * siltPerc[x]**2) + (0.001 * siltPerc[x]**(-1)) -
                (0.0748 * (carbPerc[x] * float(carbonConFactor))**(-1)) -
                (0.643 * math.log(siltPerc[x])) -
                (0.0139 * BDg_cm3[x] * clayPerc[x]) -
                (0.167 * BDg_cm3[x] * carbPerc[x] * float(carbonConFactor)) +
                (0.0298 * 0 * clayPerc[x]) - (0.03305 * 0 * siltPerc[x]))

            WC_sat = 0.7919 + (0.001691 * clayPerc[x]) - (
                0.29619 * BDg_cm3[x]) - (0.000001491 * siltPerc[x]**2) + (
                    0.0000821 *
                    ((carbPerc[x] * float(carbonConFactor)))**2) + (
                        0.02427 * clayPerc[x]**(-1.0) +
                        (0.01113 * siltPerc[x]**(-1.0)) +
                        (0.01472 * math.log(siltPerc[x])) - 0.0000733 *
                        ((carbPerc[x] * float(carbonConFactor))) * clayPerc[x]
                    ) - (0.000619 * BDg_cm3[x] *
                         clayPerc[x]) - (0.001183 * BDg_cm3[x] *
                                         (carbPerc[x] * float(carbonConFactor))
                                         ) - (0.0001664 * 0.0 * siltPerc[x])

            # Wosten originally has alpha in cm-1
            alpha_cm = math.exp(
                -14.96 + (0.03135 * clayPerc[x]) + (0.0351 * siltPerc[x]) +
                (0.646 * (carbPerc[x] * float(carbonConFactor))) +
                (15.29 * BDg_cm3[x]) - (0.192 * 0.0) -
                (4.671 * BDg_cm3[x]**2.0) - (0.000781 * clayPerc[x]**2) -
                (0.00687 * (carbPerc[x] * float(carbonConFactor))**2.0) +
                (0.0449 * ((carbPerc[x] * float(carbonConFactor)))**(-1.0)) +
                (0.0663 * math.log(siltPerc[x])) +
                (0.1482 * math.log((carbPerc[x] * float(carbonConFactor)))) -
                (0.04546 * BDg_cm3[x] * siltPerc[x]) -
                (0.4852 * BDg_cm3[x] *
                 (carbPerc[x] * float(carbonConFactor))) +
                (0.00673 * 0.0 * clayPerc[x]))
            alpha_VG = 10.0 * alpha_cm  # Converted from cm-1 to kPa-1 for internal consistency

            n_VG = 1.0 + math.exp(
                -25.23 - (0.02195 * clayPerc[x]) + (0.0074 * siltPerc[x]) -
                (0.1940 * (carbPerc[x] * float(carbonConFactor))) +
                (45.5 * BDg_cm3[x]) - (7.24 * BDg_cm3[x]**2.0) +
                (0.0003658 * clayPerc[x]**2.0) +
                (0.002885 * ((carbPerc[x] * float(carbonConFactor)))**2.0) -
                (12.81 * (BDg_cm3[x])**(-1.0)) - (0.1524 *
                                                  (siltPerc[x])**(-1.0)) -
                (0.01958 * ((carbPerc[x] * float(carbonConFactor)))**(-1.0)) -
                (0.2876 * math.log(siltPerc[x])) -
                (0.0709 * math.log((carbPerc[x] * float(carbonConFactor)))) -
                (44.6 * math.log(BDg_cm3[x])) -
                (0.02264 * BDg_cm3[x] * clayPerc[x]) +
                (0.0896 * BDg_cm3[x] *
                 (carbPerc[x] * float(carbonConFactor))) +
                (0.00718 * 0.0 * clayPerc[x]))
            m_VG = 1.0 - (1.0 / float(n_VG))

            l_MvG_norm = 0.0202 + (0.0006193 * clayPerc[x]**2) - (
                0.001136 * (carbPerc[x] * float(carbonConFactor))**2) - (
                    0.2316 * math.log(carbPerc[x] * float(carbonConFactor))
                ) - (0.03544 * BDg_cm3[x] *
                     clayPerc[x]) + (0.00283 * BDg_cm3[x] * siltPerc[x]) + (
                         0.0488 * BDg_cm3[x] *
                         (carbPerc[x] * float(carbonConFactor)))
            l_MvG = 10 * (math.exp(l_MvG_norm) - 1) / (math.exp(l_MvG_norm) +
                                                       1)

        WC_satArray.append(WC_sat)
        WC_residualArray.append(WC_residual)
        alpha_VGArray.append(alpha_VG)
        n_VGArray.append(n_VG)
        m_VGArray.append(m_VG)
        l_MvGArray.append(l_MvG)

        K_satArray.append(K_sat)

    # Write K_sat and warning results to output shapefile
    arcpy.AddField_management(outputShp, "warning", "TEXT")
    arcpy.AddField_management(outputShp, "K_sat", "DOUBLE", 10, 6)

    outputFields = ["warning", "K_sat"]

    recordNum = 0
    with arcpy.da.UpdateCursor(outputShp, outputFields) as cursor:
        for row in cursor:
            row[0] = warningArray[recordNum]
            row[1] = K_satArray[recordNum]

            cursor.updateRow(row)
            recordNum += 1

    return WC_residualArray, WC_satArray, alpha_VGArray, n_VGArray, m_VGArray, l_MvGArray, K_satArray
示例#18
0
def SaxtonRawls_2006_BC(outputShp, PTFOption, carbonConFactor, carbContent):

    log.info("Calculating Brooks-Corey using Saxton and Rawls (2006)")

    # Arrays to output
    warningArray = []
    WC_resArray = []
    WC_satArray = []
    lambda_BCArray = []
    hb_BCArray = []
    K_satArray = []

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

    # Requirements: sand, clay, and OM
    if carbContent == 'OC':
        reqFields = [OIDField, "Sand", "Clay", "OC", "LUCIname"]

    elif carbContent == 'OM':
        reqFields = [OIDField, "Sand", "Clay", "OM", "LUCIname"]
        carbonConFactor = 1.0
    
    checks_PTFs.checkInputFields(reqFields, outputShp)

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

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

            record.append(objectID)
            sandPerc.append(sand)
            clayPerc.append(clay)
            carbPerc.append(carbon)
            name.append(recName)

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

        # Calculate values
        WC_residual = 0

        WC_33tkPa = (-0.00251 * sandPerc[x]) + (0.00195 * clayPerc[x]) + (0.00011 * carbPerc[x]*float(carbonConFactor)) + (0.0000006 * sandPerc[x] * carbPerc[x]*float(carbonConFactor)) - (0.0000027 * clayPerc[x] * carbPerc[x]*float(carbonConFactor)) + (0.0000452 * sandPerc[x] * clayPerc[x]) + 0.299
        WC_33kPa = (1.283 * (WC_33tkPa)**(2)) + (0.626 * (WC_33tkPa)) - 0.015
        WC_sat_33tkPa = (0.00278 * sandPerc[x]) + (0.00034 * clayPerc[x]) + (0.00022 * carbPerc[x]*float(carbonConFactor)) - (0.0000018 * sandPerc[x] * carbPerc[x]*float(carbonConFactor)) - (0.0000027 * clayPerc[x] * carbPerc[x]*float(carbonConFactor)) - (0.0000584 * sandPerc[x] * clayPerc[x]) + 0.078
        WC_sat_33kPa = 1.636 * WC_sat_33tkPa - 0.107
        
        ## WC_0kPa is now WC_sat
        WC_sat = WC_33kPa + WC_sat_33kPa - (0.00097 * sandPerc[x]) + 0.043                    
        
        WC_1500tkPa = (-0.00024 * sandPerc[x]) + (0.00487 * clayPerc[x]) + (0.00006 * carbPerc[x]*float(carbonConFactor)) + (0.0000005 * sandPerc[x] * carbPerc[x]*float(carbonConFactor)) - (0.0000013 * clayPerc[x] * carbPerc[x]*float(carbonConFactor)) + (0.0000068 * sandPerc[x] * clayPerc[x]) + 0.031
        WC_1500kPa = 1.14 * WC_1500tkPa - 0.02

        # Need checks on WC_33kPa and WC_1500kPa

        wcError = False

        if WC_33kPa < 0.0:
            log.warning('WARNING: water content at 33kPa is negative for ' + str(name[x]))
            log.warning('WARNING: Cannot calculate lambda, setting it to -9999 for error catching')
            wcError = True

        if WC_1500kPa < 0.0:
            log.warning('WARNING: Water content at 1500kPa is negative for ' + str(name[x]))
            log.warning('WARNING: Cannot calculate lambda, setting it to -9999 for error catching')
            wcError = True

        if wcError == True:
            lambda_BC = -9999
            hb_BC = -9999

        else:

            B_SR = (math.log(1500.0) - math.log(33.0)) / (math.log(WC_33kPa) - math.log(WC_1500kPa))
            lambda_BC = 1.0 / float(B_SR)
            hbt_BC = - (0.2167 * sandPerc[x]) - (0.2793 * clayPerc[x])  -  (81.97 * WC_sat_33kPa) + (0.7112 * sandPerc[x] * WC_sat_33kPa)  + (0.0829 * clayPerc[x]  * WC_sat_33kPa) + (0.001405 * sandPerc[x] * clayPerc[x])   + 27.16
            hb_BC = hbt_BC + (0.02 * hbt_BC  ** 2)  - (0.113 * hbt_BC) - 0.7

        # If there is a valid lambda value
        if lambda_BC != -9999:
            K_sat = 1930.0 * ((WC_sat - WC_33kPa)**(3 - lambda_BC)) 
        else:
            # If not valid, set K_sat to -9999
            K_sat = -9999

        WC_resArray.append(WC_residual)
        WC_satArray.append(WC_sat)
        lambda_BCArray.append(lambda_BC)
        hb_BCArray.append(hb_BC)
        K_satArray.append(K_sat)

    # Write K_sat to the output shapefile
    arcpy.AddField_management(outputShp, "K_sat", "DOUBLE", 10, 6)

    recordNum = 0
    with arcpy.da.UpdateCursor(outputShp, "K_sat") as cursor:
        for row in cursor:
            row[0] = K_satArray[recordNum]

            cursor.updateRow(row)
            recordNum += 1

    return warningArray, WC_resArray, WC_satArray, lambda_BCArray, hb_BCArray
示例#19
0
def Vereecken_1989(outputShp, VGOption, carbonConFactor, carbContent):

    # Arrays to write to shapefile
    warningArray = []
    WC_satArray = []
    WC_residualArray = []
    alpha_VGArray = []
    n_VGArray = []
    m_VGArray = []

    log.info(
        "Calculating van Genuchten parameters using Vereecken et al. (1989)")

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

    if carbContent == 'OC':
        reqFields = [
            OIDField, "Sand", "Clay", "OC", "BD", "LUCIname", "texture"
        ]
        carbonConFactor = 1.0

    elif carbContent == 'OM':
        reqFields = [
            OIDField, "Sand", "Clay", "OM", "BD", "LUCIname", "texture"
        ]

    checks_PTFs.checkInputFields(reqFields, outputShp)

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

    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]
            name = row[5]
            texture = row[6]

            record.append(objectID)
            sandPerc.append(sand)
            clayPerc.append(clay)
            carbPerc.append(carbon)
            BDg_cm3.append(BD)
            nameArray.append(name)
            textureArray.append(texture)

    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)

        WC_sat = 0.81 - (0.283 * BDg_cm3[x]) + (0.001 * clayPerc[x])
        WC_residual = 0.015 + (0.005 * clayPerc[x]) + (0.014 * carbPerc[x] *
                                                       float(carbonConFactor))

        # Vereecken et al. (1989) calculates alpha in cm-1
        alpha_cm = math.exp(-2.486 + (0.025 * sandPerc[x]) -
                            (0.351 * carbPerc[x] * float(carbonConFactor)) -
                            (2.617 * BDg_cm3[x]) - (0.023 * clayPerc[x]))
        alpha_VG = 10.0 * alpha_cm  # Converted from cm-1 to kPa-1

        n_VG = math.exp(0.053 - (0.009 * sandPerc[x]) - (0.013 * clayPerc[x]) +
                        (0.00015 * sandPerc[x]**2))
        m_VG = 1.0

        WC_satArray.append(WC_sat)
        WC_residualArray.append(WC_residual)
        alpha_VGArray.append(alpha_VG)
        n_VGArray.append(n_VG)
        m_VGArray.append(m_VG)

    common.writeWarning(outputShp, warningArray)

    return WC_residualArray, WC_satArray, alpha_VGArray, n_VGArray, m_VGArray