|
@@ -51,66 +51,66 @@ def soil_bulk_density(arr): #arr为计算过的数组
|
|
print('颗粒含量加和判断出错!请检查soil_bulk_density中判断颗粒含量加和内容',err)
|
|
print('颗粒含量加和判断出错!请检查soil_bulk_density中判断颗粒含量加和内容',err)
|
|
# 根据国际土壤质地类型三角形编程实现对质地的分类→判断质地分类和质地名称是否正确
|
|
# 根据国际土壤质地类型三角形编程实现对质地的分类→判断质地分类和质地名称是否正确
|
|
# 判断土壤类型逻辑:
|
|
# 判断土壤类型逻辑:
|
|
- soilList = [] # 定义一个数组存放土地类型的数据
|
|
|
|
- soilContent = []
|
|
|
|
- soilContentTarget = [] # 存放土壤质地异常的指标名称
|
|
|
|
- xSLErr = [] # 存放ph>7 洗失量为空的异常数据
|
|
|
|
- xSLTarget = [] # 存放异常数据 指标名称
|
|
|
|
- try:
|
|
|
|
- # 按行循环读取所有数据
|
|
|
|
- for index, row in arr.iterrows():
|
|
|
|
- # 1.将0.02-0.2,0.2-2两列加起来
|
|
|
|
- plusSoil = row['0.2-0.02mm颗粒含量%'] + row['2-0.2mm颗粒含量%']
|
|
|
|
- small_002_list = row['0.02-0.002mm颗粒含量%']
|
|
|
|
- small_0002_list = row['0.002mm以下颗粒含量%']
|
|
|
|
- if np.isnan(plusSoil) or np.isnan(small_002_list) or np.isnan(small_0002_list):
|
|
|
|
- soilList.append('')
|
|
|
|
- # 具体判断 这里为了方便看 减少了嵌套逻辑
|
|
|
|
- elif small_0002_list >=65 and small_0002_list <100: # 2. <0.002含量 65-100 ->重黏土
|
|
|
|
- soilList.append('重黏土')
|
|
|
|
- elif small_0002_list >= 45 and small_0002_list <65: # 3.<0.002含量 45-65 ->黏土
|
|
|
|
- soilList.append('黏土')
|
|
|
|
- elif small_0002_list >= 25 and small_0002_list <45 and small_002_list >= 45 and small_002_list <75: # 4. <0.002含量 25-45 and 0.002-0.02含量 45-75 -> 粉(砂)质黏土
|
|
|
|
- soilList.append('粉(砂)质黏土')
|
|
|
|
- elif small_0002_list >= 25 and small_0002_list<45 and small_002_list>=0 and small_002_list<45 and plusSoil>=10 and plusSoil <55: # 5. <0.002含量 25-45 and 0.002-0.02含量 0-45 and 0.02-2含量 10-55-> 壤质黏土
|
|
|
|
- soilList.append('壤质黏土')
|
|
|
|
- elif small_0002_list >= 25 and small_0002_list<45 and small_002_list>=0 and small_002_list<20 and plusSoil>=55 and plusSoil <75:# 6. <0.002含量 25-45 and 0.002-0.02含量 0-20 and 0.02-2含量 55-75-> 砂质黏土
|
|
|
|
- soilList.append('砂质黏土')
|
|
|
|
- elif small_0002_list >= 15 and small_0002_list<25 and small_002_list>=45 and small_002_list<85: # 7.<0.002含量 15-25 and 0.002-0.02含量 45-85 -> 粉(砂)质黏壤土
|
|
|
|
- soilList.append('粉(砂)质黏壤土')
|
|
|
|
- elif small_0002_list >= 15 and small_0002_list<25 and small_002_list>=20 and small_002_list<45 and plusSoil>=30 and plusSoil <55:# 8.<0.002含量 15-25 and 0.002-0.02含量 20-45 and 0.02-2含量 30-55-> 黏壤土
|
|
|
|
- soilList.append('黏壤土')
|
|
|
|
- elif small_0002_list >= 15 and small_0002_list<25 and small_002_list>=0 and small_002_list<30 and plusSoil>=55 and plusSoil <85:# 9.<0.002含量 15-25 and 0.002-0.02含量 0-30 and 0.02-2含量 55-85-> 砂质黏壤土
|
|
|
|
- soilList.append('砂质黏壤土')
|
|
|
|
- elif small_0002_list >= 0 and small_0002_list<15 and small_002_list>=45 and small_002_list<100:#10.<0.002含量 0-15 and 0.002-0.02含量 45-100 ->粉(砂)质壤土
|
|
|
|
- soilList.append('粉(砂)质壤土')
|
|
|
|
- elif small_0002_list >= 0 and small_0002_list<15 and small_002_list>=30 and small_002_list<45 and plusSoil>=40 and plusSoil <55: # 11.<0.002含量 0-15 and 0.002-0.02含量 30-45 and 0.02-2含量 40-55-> 壤土
|
|
|
|
- soilList.append('壤土')
|
|
|
|
- elif small_0002_list >= 0 and small_0002_list<15 and small_002_list>=0 and small_002_list<45 and plusSoil>=55 and plusSoil <85: # 12.<0.002含量 0-15 and 0.002-0.02含量 0-45 and 0.02-2含量 55-85-> 砂质壤土
|
|
|
|
- soilList.append('砂质壤土')
|
|
|
|
- elif small_0002_list >= 0 and small_0002_list<15 and small_002_list>=0 and small_002_list<15 and plusSoil>=85 and plusSoil <100: # 13.<0.002含量 0-15 and 0.002-0.02含量 0-15 and 0.02-2含量 85-100-> 砂土及壤质砂土
|
|
|
|
- soilList.append('砂土及壤质砂土')
|
|
|
|
- else:
|
|
|
|
- soilList.append('') # 除所有情况外 还有空值
|
|
|
|
-
|
|
|
|
- # 比较和原有数据是否一致
|
|
|
|
- arr['土壤质地(判断)'] = soilList
|
|
|
|
- for index, row in arr.iterrows():
|
|
|
|
- if (row['土壤质地(判断)'] != row['土壤质地']) and (not pd.isna(row['土壤质地'])):
|
|
|
|
- soilContent.append('存疑:土壤质地填报与判断不一致')
|
|
|
|
- soilContentTarget.append('土壤质地。')
|
|
|
|
- else:
|
|
|
|
- soilContent.append('')
|
|
|
|
- soilContentTarget.append('')
|
|
|
|
- # 如果pH>7,则洗失量数据不能为空;
|
|
|
|
- if (not pd.isna(row['pH']) and row['pH'] > 7 and pd.isna(row['洗失量(吸管法需填)%'])):
|
|
|
|
- xSLErr.append('洗失量:ph>7但洗失量未检测。')
|
|
|
|
- xSLTarget.append('洗失量。')
|
|
|
|
- else:
|
|
|
|
- xSLErr.append('')
|
|
|
|
- xSLTarget.append('')
|
|
|
|
- except Exception as err:
|
|
|
|
- print('土壤类型判断出错!请检查soil_bulk_density中判断土壤类型内容', err)
|
|
|
|
|
|
+ # soilList = [] # 定义一个数组存放土地类型的数据
|
|
|
|
+ # soilContent = []
|
|
|
|
+ # soilContentTarget = [] # 存放土壤质地异常的指标名称
|
|
|
|
+ # xSLErr = [] # 存放ph>7 洗失量为空的异常数据
|
|
|
|
+ # xSLTarget = [] # 存放异常数据 指标名称
|
|
|
|
+ # try:
|
|
|
|
+ # # 按行循环读取所有数据
|
|
|
|
+ # for index, row in arr.iterrows():
|
|
|
|
+ # # 1.将0.02-0.2,0.2-2两列加起来
|
|
|
|
+ # plusSoil = row['0.2-0.02mm颗粒含量%'] + row['2-0.2mm颗粒含量%']
|
|
|
|
+ # small_002_list = row['0.02-0.002mm颗粒含量%']
|
|
|
|
+ # small_0002_list = row['0.002mm以下颗粒含量%']
|
|
|
|
+ # if np.isnan(plusSoil) or np.isnan(small_002_list) or np.isnan(small_0002_list):
|
|
|
|
+ # soilList.append('')
|
|
|
|
+ # # 具体判断 这里为了方便看 减少了嵌套逻辑
|
|
|
|
+ # elif small_0002_list >=65 and small_0002_list <100: # 2. <0.002含量 65-100 ->重黏土
|
|
|
|
+ # soilList.append('重黏土')
|
|
|
|
+ # elif small_0002_list >= 45 and small_0002_list <65: # 3.<0.002含量 45-65 ->黏土
|
|
|
|
+ # soilList.append('黏土')
|
|
|
|
+ # elif small_0002_list >= 25 and small_0002_list <45 and small_002_list >= 45 and small_002_list <75: # 4. <0.002含量 25-45 and 0.002-0.02含量 45-75 -> 粉(砂)质黏土
|
|
|
|
+ # soilList.append('粉(砂)质黏土')
|
|
|
|
+ # elif small_0002_list >= 25 and small_0002_list<45 and small_002_list>=0 and small_002_list<45 and plusSoil>=10 and plusSoil <55: # 5. <0.002含量 25-45 and 0.002-0.02含量 0-45 and 0.02-2含量 10-55-> 壤质黏土
|
|
|
|
+ # soilList.append('壤质黏土')
|
|
|
|
+ # elif small_0002_list >= 25 and small_0002_list<45 and small_002_list>=0 and small_002_list<20 and plusSoil>=55 and plusSoil <75:# 6. <0.002含量 25-45 and 0.002-0.02含量 0-20 and 0.02-2含量 55-75-> 砂质黏土
|
|
|
|
+ # soilList.append('砂质黏土')
|
|
|
|
+ # elif small_0002_list >= 15 and small_0002_list<25 and small_002_list>=45 and small_002_list<85: # 7.<0.002含量 15-25 and 0.002-0.02含量 45-85 -> 粉(砂)质黏壤土
|
|
|
|
+ # soilList.append('粉(砂)质黏壤土')
|
|
|
|
+ # elif small_0002_list >= 15 and small_0002_list<25 and small_002_list>=20 and small_002_list<45 and plusSoil>=30 and plusSoil <55:# 8.<0.002含量 15-25 and 0.002-0.02含量 20-45 and 0.02-2含量 30-55-> 黏壤土
|
|
|
|
+ # soilList.append('黏壤土')
|
|
|
|
+ # elif small_0002_list >= 15 and small_0002_list<25 and small_002_list>=0 and small_002_list<30 and plusSoil>=55 and plusSoil <85:# 9.<0.002含量 15-25 and 0.002-0.02含量 0-30 and 0.02-2含量 55-85-> 砂质黏壤土
|
|
|
|
+ # soilList.append('砂质黏壤土')
|
|
|
|
+ # elif small_0002_list >= 0 and small_0002_list<15 and small_002_list>=45 and small_002_list<100:#10.<0.002含量 0-15 and 0.002-0.02含量 45-100 ->粉(砂)质壤土
|
|
|
|
+ # soilList.append('粉(砂)质壤土')
|
|
|
|
+ # elif small_0002_list >= 0 and small_0002_list<15 and small_002_list>=30 and small_002_list<45 and plusSoil>=40 and plusSoil <55: # 11.<0.002含量 0-15 and 0.002-0.02含量 30-45 and 0.02-2含量 40-55-> 壤土
|
|
|
|
+ # soilList.append('壤土')
|
|
|
|
+ # elif small_0002_list >= 0 and small_0002_list<15 and small_002_list>=0 and small_002_list<45 and plusSoil>=55 and plusSoil <85: # 12.<0.002含量 0-15 and 0.002-0.02含量 0-45 and 0.02-2含量 55-85-> 砂质壤土
|
|
|
|
+ # soilList.append('砂质壤土')
|
|
|
|
+ # elif small_0002_list >= 0 and small_0002_list<15 and small_002_list>=0 and small_002_list<15 and plusSoil>=85 and plusSoil <100: # 13.<0.002含量 0-15 and 0.002-0.02含量 0-15 and 0.02-2含量 85-100-> 砂土及壤质砂土
|
|
|
|
+ # soilList.append('砂土及壤质砂土')
|
|
|
|
+ # else:
|
|
|
|
+ # soilList.append('') # 除所有情况外 还有空值
|
|
|
|
+ #
|
|
|
|
+ # # 比较和原有数据是否一致
|
|
|
|
+ # arr['土壤质地(判断)'] = soilList
|
|
|
|
+ # for index, row in arr.iterrows():
|
|
|
|
+ # if (row['土壤质地(判断)'] != row['土壤质地']) and (not pd.isna(row['土壤质地'])):
|
|
|
|
+ # soilContent.append('存疑:土壤质地填报与判断不一致')
|
|
|
|
+ # soilContentTarget.append('土壤质地。')
|
|
|
|
+ # else:
|
|
|
|
+ # soilContent.append('')
|
|
|
|
+ # soilContentTarget.append('')
|
|
|
|
+ # # 如果pH>7,则洗失量数据不能为空;
|
|
|
|
+ # if (not pd.isna(row['pH']) and row['pH'] > 7 and pd.isna(row['洗失量(吸管法需填)%'])):
|
|
|
|
+ # xSLErr.append('洗失量:ph>7但洗失量未检测。')
|
|
|
|
+ # xSLTarget.append('洗失量。')
|
|
|
|
+ # else:
|
|
|
|
+ # xSLErr.append('')
|
|
|
|
+ # xSLTarget.append('')
|
|
|
|
+ # except Exception as err:
|
|
|
|
+ # print('土壤类型判断出错!请检查soil_bulk_density中判断土壤类型内容', err)
|
|
# 把存疑数据组合并返回
|
|
# 把存疑数据组合并返回
|
|
# print('shenHeList--',shenHeList,len(shenHeList))
|
|
# print('shenHeList--',shenHeList,len(shenHeList))
|
|
# print('plusShenHeList--', plusShenHeList, len(plusShenHeList))
|
|
# print('plusShenHeList--', plusShenHeList, len(plusShenHeList))
|
|
@@ -118,15 +118,15 @@ def soil_bulk_density(arr): #arr为计算过的数组
|
|
# print('soilContent--', soilContent, len(soilContent))
|
|
# print('soilContent--', soilContent, len(soilContent))
|
|
# print('soilList--', soilList, len(soilList))
|
|
# print('soilList--', soilList, len(soilList))
|
|
pdData = pd.DataFrame({
|
|
pdData = pd.DataFrame({
|
|
- '审核结果': pd.Series(shenHeList) + pd.Series(tRTypeList) + pd.Series(plusShenHeList) + pd.Series(soilContent) + pd.Series(xSLErr),
|
|
|
|
- '土壤质地(判断)': soilList,
|
|
|
|
- '异常指标': pd.Series(shenHeTarget) + pd.Series(tRTypeTarget) + pd.Series(plusShenHeTarget) + pd.Series(soilContentTarget) + pd.Series(xSLTarget),
|
|
|
|
|
|
+ '审核结果': pd.Series(shenHeList) + pd.Series(tRTypeList) + pd.Series(plusShenHeList),
|
|
|
|
+ #'土壤质地(判断)': soilList,
|
|
|
|
+ '异常指标': pd.Series(shenHeTarget) + pd.Series(tRTypeTarget) + pd.Series(plusShenHeTarget),
|
|
})
|
|
})
|
|
return pdData
|
|
return pdData
|
|
# 这是一个判断范围的函数 如果需要修改范围 修改start end值就行
|
|
# 这是一个判断范围的函数 如果需要修改范围 修改start end值就行
|
|
|
|
|
|
-def is_not_in_range(value):
|
|
|
|
- return value <30 or value > 90
|
|
|
|
|
|
+# def is_not_in_range(value):
|
|
|
|
+# return value <30 or value > 90
|
|
|
|
|
|
|
|
|
|
# 表3 水稳性大团聚体规则判断函数
|
|
# 表3 水稳性大团聚体规则判断函数
|
|
@@ -409,7 +409,7 @@ def cation_value(arr):
|
|
summaryList.append('')
|
|
summaryList.append('')
|
|
summaryListTar.append('')
|
|
summaryListTar.append('')
|
|
else:
|
|
else:
|
|
- summaryList.append('存疑:PH值、阳离子交换量、交换性盐总量、离子总和、盐基饱和度之间关系存疑。')
|
|
|
|
|
|
+ summaryList.append('存疑:pH值、阳离子交换量、交换性盐总量、离子总和、盐基饱和度之间关系存疑。')
|
|
summaryListTar.append('盐基饱和度。')
|
|
summaryListTar.append('盐基饱和度。')
|
|
soilRes = soilTypeValue(row)
|
|
soilRes = soilTypeValue(row)
|
|
soilTypeList.append(soilRes)
|
|
soilTypeList.append(soilRes)
|
|
@@ -561,8 +561,8 @@ def eight_ion_coun(arr, summary):
|
|
changeComArr.append('存疑:交换性盐基总量低于于水溶性盐离子。')
|
|
changeComArr.append('存疑:交换性盐基总量低于于水溶性盐离子。')
|
|
else:
|
|
else:
|
|
changeComArr.append('')
|
|
changeComArr.append('')
|
|
- #(16)(水溶性全盐量 - 八大离子加和) / 八大离子加和 * 100,不超过±20 %
|
|
|
|
- if not pd.isna(row['(水溶性全盐量-八大离子加和)/水溶性全盐量×100']) and (row['(水溶性全盐量-八大离子加和)/水溶性全盐量×100'] < -0.2 or row['(水溶性全盐量-八大离子加和)/水溶性全盐量×100'] > 0.2) :
|
|
|
|
|
|
+ #(16)(全盐量-水溶性八大离子加和)x2/(全盐量+水溶性八大离子加和)*100,不超过±20 %
|
|
|
|
+ if not pd.isna(row['(全盐量-水溶性八大离子加和)x2/(全盐量+水溶性八大离子加和)*100']) and (row['(全盐量-水溶性八大离子加和)x2/(全盐量+水溶性八大离子加和)*100'] < -0.2 or row['(全盐量-水溶性八大离子加和)x2/(全盐量+水溶性八大离子加和)*100'] > 0.2) :
|
|
rateArr.append('存疑:全盐量与水溶性八大离子加和的相对相差超过±20%,复核合理性。')
|
|
rateArr.append('存疑:全盐量与水溶性八大离子加和的相对相差超过±20%,复核合理性。')
|
|
else:
|
|
else:
|
|
rateArr.append('')
|
|
rateArr.append('')
|