public.py 68 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147
  1. import pandas as pd
  2. import numpy as np
  3. # 这里写所有表格的判断规则 按顺序每个表格一个函数 方便后续修改
  4. pd.set_option('display.max_columns', 1000)
  5. pd.set_option('display.width', 1000)
  6. pd.set_option('display.max_colwidth', 1000)
  7. # 表1 土壤容重机械组成数据 为了方便做具体修改
  8. def soil_bulk_density(arr): #arr为计算过的数组
  9. # (1)土壤容重不在[0.8, 1.6]范围以内的,存疑
  10. shenHeList=[] # 定义一个数组存放容重存疑的数据
  11. shenHeTarget = [] # 存放每条数据 有问题的指标
  12. try:
  13. for i in arr['土壤容重平均值(g/cm3)(计算)']:
  14. if i > 1.6 or i < 0.8:
  15. shenHeList.append('土壤容重:复核数据合理性。')
  16. shenHeTarget.append('土壤容重平均值。')
  17. else:
  18. shenHeList.append('')
  19. shenHeTarget.append('')
  20. except Exception as err:
  21. print('土壤容重判断出错!请检查soil_bulk_density中判断土壤容重内容',err)
  22. # (2)土壤利用类型→耕地、园地→相对极差>15 %,存疑;土壤利用类型→林地、草地→相对极差>20 %,存疑
  23. tRTypeList = [] # 定义一个数组存放土壤利用类型存疑的数据
  24. tRTypeTarget= [] # 定义一个数组存放土壤利用类型存疑的数据指标名称
  25. try:
  26. for i in arr['相对极差(%)']:
  27. if i > 15 and arr.loc[arr['相对极差(%)'] == i, '土地利用类型'].iloc[0] == '耕地园地':
  28. tRTypeList.append('存疑:耕地园地相对极差>15%。')
  29. tRTypeTarget.append('耕地园地极差。')
  30. elif i > 20 and arr.loc[arr['相对极差(%)'] == i, '土地利用类型'].iloc[0] == '林地草地':
  31. tRTypeList.append('存疑:林地草地相对极差>20%。')
  32. tRTypeTarget.append('林地草地极差。')
  33. else:
  34. tRTypeList.append('')
  35. tRTypeTarget.append('')
  36. except Exception as err:
  37. print('相对极差判断、土壤利用类型判断出错!请检查soil_bulk_density中判断相对极差判断、土壤利用类型内容',err)
  38. # (3)加和不在[99.98, 100.02]范围内的,存疑
  39. plusShenHeList = [] # 定义一个数组存放加和存疑的数据
  40. plusShenHeTarget = [] # 保存土壤颗粒加和存疑的指标
  41. try:
  42. for i in arr['加和%']:
  43. if float(i) > 100.02 or float(i) < 99.98:
  44. plusShenHeList.append('土壤颗粒加和:复核数据合理性。')
  45. plusShenHeTarget.append('土壤颗粒含量加和。')
  46. else:
  47. plusShenHeList.append('')
  48. plusShenHeTarget.append('')
  49. except Exception as err:
  50. print('颗粒含量加和判断出错!请检查soil_bulk_density中判断颗粒含量加和内容',err)
  51. # 根据国际土壤质地类型三角形编程实现对质地的分类→判断质地分类和质地名称是否正确
  52. # 判断土壤类型逻辑:
  53. soilList = [] # 定义一个数组存放土地类型的数据
  54. soilContent = []
  55. soilContentTarget = [] # 存放土壤质地异常的指标名称
  56. xSLErr = [] # 存放ph>7 洗失量为空的异常数据
  57. xSLTarget = [] # 存放异常数据 指标名称
  58. try:
  59. # 按行循环读取所有数据
  60. for index, row in arr.iterrows():
  61. # 1.将0.02-0.2,0.2-2两列加起来
  62. plusSoil = row['0.2-0.02mm颗粒含量%'] + row['2-0.2mm颗粒含量%']
  63. small_002_list = row['0.02-0.002mm颗粒含量%']
  64. small_0002_list = row['0.002mm以下颗粒含量%']
  65. if np.isnan(plusSoil) or np.isnan(small_002_list) or np.isnan(small_0002_list):
  66. soilList.append('')
  67. # 具体判断 这里为了方便看 减少了嵌套逻辑
  68. elif small_0002_list >=65 and small_0002_list <100: # 2. <0.002含量 65-100 ->重黏土
  69. soilList.append('重黏土')
  70. elif small_0002_list >= 45 and small_0002_list <65: # 3.<0.002含量 45-65 ->黏土
  71. soilList.append('黏土')
  72. 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 -> 粉(砂)质黏土
  73. soilList.append('粉(砂)质黏土')
  74. 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-> 壤质黏土
  75. soilList.append('壤质黏土')
  76. 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-> 砂质黏土
  77. soilList.append('砂质黏土')
  78. 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 -> 粉(砂)质黏壤土
  79. soilList.append('粉(砂)质黏壤土')
  80. 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-> 黏壤土
  81. soilList.append('黏壤土')
  82. 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-> 砂质黏壤土
  83. soilList.append('砂质黏壤土')
  84. 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 ->粉(砂)质壤土
  85. soilList.append('粉(砂)质壤土')
  86. 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-> 壤土
  87. soilList.append('壤土')
  88. 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-> 砂质壤土
  89. soilList.append('砂质壤土')
  90. 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-> 砂土及壤质砂土
  91. soilList.append('砂土及壤质砂土')
  92. else:
  93. soilList.append('') # 除所有情况外 还有空值
  94. # 比较和原有数据是否一致
  95. arr['土壤质地(判断)'] = soilList
  96. for index, row in arr.iterrows():
  97. if (row['土壤质地(判断)'] != row['土壤质地']) and (not pd.isna(row['土壤质地'])):
  98. soilContent.append('存疑:土壤质地填报与判断不一致')
  99. soilContentTarget.append('土壤质地。')
  100. else:
  101. soilContent.append('')
  102. soilContentTarget.append('')
  103. # 如果pH>7,则洗失量数据不能为空;
  104. if (not pd.isna(row['pH']) and row['pH'] > 7 and pd.isna(row['洗失量(吸管法需填)%'])):
  105. xSLErr.append('洗失量:ph>7但洗失量未检测。')
  106. xSLTarget.append('洗失量。')
  107. else:
  108. xSLErr.append('')
  109. xSLTarget.append('')
  110. except Exception as err:
  111. print('土壤类型判断出错!请检查soil_bulk_density中判断土壤类型内容', err)
  112. # 把存疑数据组合并返回
  113. # print('shenHeList--',shenHeList,len(shenHeList))
  114. # print('plusShenHeList--', plusShenHeList, len(plusShenHeList))
  115. # print('tRTypeList--', tRTypeList, len(tRTypeList))
  116. # print('soilContent--', soilContent, len(soilContent))
  117. # print('soilList--', soilList, len(soilList))
  118. pdData = pd.DataFrame({
  119. '审核结果': pd.Series(shenHeList) + pd.Series(tRTypeList) + pd.Series(plusShenHeList) + pd.Series(soilContent) + pd.Series(xSLErr),
  120. '土壤质地(判断)': soilList,
  121. '异常指标': pd.Series(shenHeTarget) + pd.Series(tRTypeTarget) + pd.Series(plusShenHeTarget) + pd.Series(soilContentTarget) + pd.Series(xSLTarget),
  122. })
  123. return pdData
  124. # 这是一个判断范围的函数 如果需要修改范围 修改start end值就行
  125. def is_not_in_range(value):
  126. return value <30 or value > 90
  127. def is_than_five(value):
  128. return value < 1 or value > 10
  129. # 表3 水稳性大团聚体规则判断函数
  130. def water_stable(arr):
  131. # (1)不在[30, 90]范围以内的,存疑
  132. shenHeList = [] # 定义一个数组存放团聚体存疑的数据
  133. shenHeTar = [] # 存放水稳异常指标
  134. # (2)总和超过90,存疑;耕地和园地>80,提示关注;林地和草地>90,提示关注
  135. plusList = []
  136. plusTar = [] # 水稳总和异常指标名称
  137. soilType = []
  138. # (3)>5mm指标占比超过10 %,存疑,应回溯
  139. rateList = []
  140. rateTar = [] # >5mm占比异常指标
  141. try:
  142. for index, row in arr.iterrows():
  143. # 规则1判断 先判断值是否存在
  144. # if (not pd.isna(row['>5mm%']) and is_than_five(row['>5mm%'])) or (
  145. # not pd.isna(row['3-5mm%']) and is_not_in_range(row['3-5mm%'])) or (
  146. # not pd.isna(row['2-3mm%']) and is_not_in_range(row['2-3mm%'])) or (
  147. # not pd.isna(row['1-2mm%']) and is_not_in_range(row['1-2mm%'])) or (
  148. # not pd.isna(row['0.5-1mm%']) and is_not_in_range(row['0.5-1mm%'])) or (
  149. # not pd.isna(row['0.25-0.5mm%']) and is_not_in_range(row['0.25-0.5mm%'])):
  150. # shenHeList.append('团聚体百分比:复核数据合理性。')
  151. # shenHeTar.append('水稳分项指标。')
  152. # else:
  153. # shenHeList.append('')
  154. # shenHeTar.append('')
  155. # 规则2判断
  156. if row['总和(%)'] > 70 or row['总和(%)'] < 10:
  157. plusList.append('水稳性大团聚体总和:复核数据合理性。')
  158. plusTar.append('水稳性大团聚体总和。')
  159. else:
  160. plusList.append('')
  161. plusTar.append('')
  162. if (row['土地利用类型'] == '耕地园地' and row['总和(%)'] > 80) or (row['土地利用类型'] == '林地草地' and row['总和(%)'] > 90):
  163. soilType.append('关注:耕地园地团聚体总和大于80或林地草地团聚体总和大于90。')
  164. else:
  165. soilType.append('')
  166. if row['>5mm%'] > 10:
  167. rateList.append('存疑:>5mm占比超过10%应回溯。')
  168. rateTar.append('水稳>5mm。')
  169. else:
  170. rateList.append('')
  171. rateTar.append('')
  172. resData = pd.DataFrame({
  173. '审核结果': pd.Series(plusList) + pd.Series(soilType) + pd.Series(rateList),
  174. '异常指标': pd.Series(plusTar) + pd.Series(rateTar),
  175. })
  176. return resData
  177. except Exception as err:
  178. print('大团聚体判断出错!请检查water_stable中判断大团聚体内容', err)
  179. # 表5 pH、阳离子交换量、交换性盐基基础数据判断
  180. # 判断土壤类型和阳离子交换量 盐基饱和度的范围
  181. def soilTypeValue(row): # 传入一行数据
  182. strValue = row['土壤类型']
  183. soilType = ''
  184. if isinstance(strValue, str):
  185. # print('type---', strValue.split('_'))
  186. # print('strValue',strValue)
  187. if len(strValue.split('_')) > 1:
  188. soilType = strValue.split('_')[1] # 获取到土壤类型
  189. cationChange = row['阳离子交换量Cmol(+)/kg'] # 获取到阳离子交换量
  190. bHValue = (row['交换性盐总量Cmol(+)/kg']/row['阳离子交换量Cmol(+)/kg'] )*100# 计算出的盐基饱和度
  191. # 判断三者范围是否合理
  192. res = ''
  193. if soilType == '黄红壤':
  194. if (not pd.isna(cationChange)) and (cationChange > 10 and cationChange < 24) and (not pd.isna(bHValue)) and (
  195. bHValue > 30 and bHValue < 50):
  196. res = ''
  197. else:
  198. res = '存疑:该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
  199. elif soilType == '棕红壤':
  200. if (not pd.isna(cationChange)) and (cationChange > 6 and cationChange < 15) and (not pd.isna(bHValue)) and (
  201. bHValue > 25 and bHValue < 70):
  202. res = ''
  203. else:
  204. res = '存疑:该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
  205. elif soilType == '红壤性土':
  206. if (not pd.isna(cationChange)) and (cationChange > 5 and cationChange < 15) and (not pd.isna(bHValue)) and (
  207. bHValue > 10 and bHValue < 50):
  208. res = ''
  209. else:
  210. res = '存疑:该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
  211. elif soilType == '典型黄壤':
  212. if (not pd.isna(cationChange)) and (cationChange > 5 and cationChange < 15) and not (pd.isna(bHValue)) and (
  213. bHValue < 30):
  214. res = ''
  215. else:
  216. res = '该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
  217. elif soilType == '黄壤性土':
  218. if (not pd.isna(cationChange)) and (cationChange > 10 and cationChange < 18) and (not pd.isna(bHValue)) and (
  219. bHValue < 45):
  220. res = ''
  221. else:
  222. res = '存疑:该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
  223. elif soilType == '典型黄棕壤' or soilType == '暗黄棕壤' or soilType == '黄棕壤性土':
  224. if (not pd.isna(cationChange)) and (cationChange > 8 and cationChange < 22) and (not pd.isna(bHValue)) and (
  225. bHValue > 30 and bHValue < 60):
  226. res = ''
  227. else:
  228. res = '存疑:该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
  229. elif soilType == '典型黄褐土' or soilType == '黏盘黄褐土' or soilType == '粘盘黄褐土' or soilType == '粘盘黄褐土' or soilType == '白浆化黄褐土' or soilType == '黄褐土性土':
  230. if (not pd.isna(cationChange)) and (cationChange > 15 and cationChange < 25) and (not pd.isna(bHValue)) and (
  231. bHValue > 60 and bHValue < 85):
  232. res = ''
  233. else:
  234. res = '存疑:该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
  235. elif soilType == '粘盘黄褐土':
  236. if (not pd.isna(cationChange)) and (cationChange > 10 and cationChange < 30) and (not pd.isna(bHValue)) and (
  237. bHValue > 75 and bHValue < 95):
  238. res = ''
  239. else:
  240. res = '存疑:该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
  241. elif soilType == '典型棕壤' or soilType == '白浆化棕壤' or soilType == '潮棕壤' or soilType == '棕壤性土' or soilType == '棕壤性土':
  242. if (not pd.isna(cationChange)) and (cationChange > 5 and cationChange < 20) and (not pd.isna(bHValue)) and (
  243. cationChange > 25 and cationChange < 65):
  244. res = ''
  245. else:
  246. res = '存疑:该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
  247. elif soilType == '典型山地草甸土' or soilType == '山地草原草甸土' or soilType == '山地灌丛草甸土':
  248. if (not pd.isna(cationChange)) and (cationChange > 10 and cationChange < 20) and (not pd.isna(bHValue)) and (
  249. bHValue > 15 and bHValue < 30):
  250. res = ''
  251. else:
  252. res = '存疑:该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
  253. elif soilType == '酸性紫色土' or soilType == '中性紫色土' or soilType == '石灰性紫色土':
  254. if (not pd.isna(cationChange)) and (cationChange > 10 and cationChange < 20) and (not pd.isna(bHValue)) and (
  255. bHValue > 50 and bHValue < 70):
  256. res = ''
  257. else:
  258. res = '存疑:该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
  259. elif soilType == '红色石灰土' or soilType == '黑色石灰土' or soilType == '棕色石灰土' or soilType == '黄色石灰土':
  260. if (not pd.isna(cationChange)) and (cationChange > 15 and cationChange < 30) and (not pd.isna(bHValue)) and (
  261. bHValue > 70 and bHValue < 100):
  262. res = ''
  263. else:
  264. res = '存疑:该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
  265. elif soilType == '酸性石质土' or soilType == '中性石质土' or soilType == '钙质石质土' or soilType == '含盐石质土':
  266. if (not pd.isna(cationChange)) and (cationChange > 10 and cationChange < 15) and (not pd.isna(bHValue)) and (
  267. bHValue > 45 and bHValue < 65):
  268. res = ''
  269. else:
  270. res = '存疑:该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
  271. elif soilType == '酸性粗骨土' or soilType == '中性粗骨土' or soilType == '钙质粗骨土' or soilType == '硅质盐粗骨土':
  272. if (not pd.isna(cationChange)) and (cationChange > 5 and cationChange < 15) and (not pd.isna(bHValue)) and (
  273. bHValue > 20 and bHValue < 50):
  274. res = ''
  275. else:
  276. res = '存疑:该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
  277. elif soilType == '典型潮土' or soilType == '灰潮土' or soilType == '脱潮土' or soilType == '湿潮土' or soilType == '盐化潮土' or soilType == '碱化潮土' or soilType == '灌於潮土':
  278. if (not pd.isna(cationChange)) and (cationChange > 10 and cationChange < 30) and (not pd.isna(bHValue)) and (
  279. bHValue > 70 and bHValue < 100):
  280. res = ''
  281. else:
  282. res = '存疑:该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
  283. elif soilType == '典型砂姜黑土' or soilType == '石灰性砂姜黑土' or soilType == '盐化砂姜黑土' or soilType == '碱化砂姜黑土' or soilType == '黑粘土':
  284. if (not pd.isna(cationChange)) and (cationChange > 18 and cationChange < 35) and (not pd.isna(bHValue)) and (
  285. bHValue > 90 and bHValue < 100):
  286. res = ''
  287. else:
  288. res = '存疑:该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
  289. elif soilType == '淹育水稻土':
  290. if (not pd.isna(cationChange)) and (cationChange > 20 and cationChange < 30) and (not pd.isna(bHValue)) and (
  291. bHValue > 85 and bHValue < 90):
  292. res = ''
  293. else:
  294. res = '存疑:该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
  295. elif soilType == '潴育水稻土':
  296. if (not pd.isna(cationChange)) and (cationChange > 12 and cationChange < 20) and (not pd.isna(bHValue)) and (
  297. bHValue > 60 and bHValue < 80):
  298. res = ''
  299. else:
  300. res = '存疑:该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
  301. elif soilType == '潜育水稻土':
  302. if (not pd.isna(cationChange)) and (cationChange > 15 and cationChange < 25) and (not pd.isna(bHValue)) and (
  303. bHValue > 75 and bHValue < 90):
  304. res = ''
  305. else:
  306. res = '存疑:该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
  307. elif soilType == '漂洗水稻土':
  308. if (not pd.isna(cationChange)) and (cationChange > 10 and cationChange < 20) and (not pd.isna(bHValue)) and (
  309. bHValue > 65 and bHValue < 80):
  310. res = ''
  311. else:
  312. res = '存疑:该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
  313. return res
  314. def cation_value(arr):
  315. phList = [] # 保存ph存疑数据
  316. cationList = [] # 保存阳离子存疑数据
  317. exchangeableSalt = [] # 保存交换性盐基总量存疑数据
  318. exchangeableCa = [] # 保存交换性钙总量存疑数据
  319. exchangeableMg = [] # 保存交换性镁总量存疑数据
  320. exchangeableK = [] # 保存交换性钾总量存疑数据
  321. exchangeableNa = [] # 保存交换性钠总量存疑数据
  322. summaryList = [] # 保存ph 离子和 盐基饱和度范围存疑数据
  323. soilTypeList = [] # 保存土壤类型 阳离子交换量cmol(+)/kg 和盐基饱和度范围存疑数据
  324. waterMount = [] # 保存含水量存疑数据 含水量应小于10%
  325. phTar = [] # 保存ph异常指标
  326. cationTar = [] # 保存阳离子异常指标
  327. exchangeableSaltTar = [] # 保存交换性盐基总量异常指标
  328. exchangeableCaTar = [] # 保存交换性钙异常指标
  329. exchangeableMgTar = [] # 保存交换性镁异常指标
  330. exchangeableKTar = [] # 保存交换性钾异常指标
  331. exchangeableNaTar = [] # 保存交换性钠异常指标
  332. summaryListTar = [] # 保存ph 离子和 盐基饱和度异常指标
  333. soilTypeListTar = [] # 保存土壤类型 阳离子交换量cmol(+)/kg 和盐基饱和度异常数据
  334. waterMountTar = [] # 保存含水量异常指标
  335. try:
  336. for index, row in arr.iterrows():
  337. # 风干样含水量 0.5-5,存疑
  338. if pd.isna(row['含水量']) or row['含水量'] > 5 or row['含水量'] < 0.5:
  339. waterMount.append('风干试样含水量(分析基):复核数据合理性。')
  340. waterMountTar.append('风干试样含水量(分析基)。')
  341. else:
  342. waterMount.append('')
  343. waterMountTar.append('')
  344. # (1)pH在[4, 9]范围之外的,存疑;
  345. if pd.isna(row['pH']) or row['pH'] < 4 or row['pH'] > 9:
  346. phList.append('pH:复核数据合理性。')
  347. phTar.append('pH。')
  348. else:
  349. phList.append('')
  350. phTar.append('')
  351. # (2)阳离子交换量在[6, 38]范围之外的,存疑;
  352. if row['阳离子交换量Cmol(+)/kg'] < 6 or row['阳离子交换量Cmol(+)/kg'] > 38:
  353. cationList.append('阳离子交换量:复核数据合理性。')
  354. cationTar.append('阳离子交换量。')
  355. else:
  356. cationList.append('')
  357. cationTar.append('')
  358. # (3)交换性盐基总量在[3, 30]范围之外的,存疑;
  359. if row['交换性盐总量Cmol(+)/kg'] <3 or row['交换性盐总量Cmol(+)/kg'] > 30:
  360. exchangeableSalt.append('交换性盐基总量:复核数据合理性。')
  361. exchangeableSaltTar.append('交换性盐总量。')
  362. else:
  363. exchangeableSalt.append('')
  364. exchangeableSaltTar.append('')
  365. # (4)交换性钙在[1, 25]范围之外的,存疑;
  366. if row['交换性钙Cmol(1/2Ca2+)/kg'] < 1 or row['交换性钙Cmol(1/2Ca2+)/kg'] > 25:
  367. exchangeableCa.append('交换性钙:交换性钙复核数据合理性。')
  368. exchangeableCaTar.append('交换性钙。')
  369. else:
  370. exchangeableCa.append('')
  371. exchangeableCaTar.append('')
  372. # (5)交换性镁在[0.5, 12.5]范围之外的,存疑;
  373. if row['交换性镁cmol(1/2Mg2+)/kg'] < 0.5 or row['交换性镁cmol(1/2Mg2+)/kg'] > 12.5:
  374. exchangeableMg.append('交换性镁:复核数据合理性。')
  375. exchangeableMgTar.append('交换性镁。')
  376. else:
  377. exchangeableMg.append('')
  378. exchangeableMgTar.append('')
  379. # (6)交换性钾在[0.1, 1.5]范围之外的,存疑;
  380. if row['交换性钾Cmol(+)/kg'] < 0.1 or row['交换性钾Cmol(+)/kg'] > 1.5:
  381. exchangeableK.append('交换性钾:复核数据合理性。')
  382. exchangeableKTar.append('交换性钾。')
  383. else:
  384. exchangeableK.append('')
  385. exchangeableKTar.append('')
  386. # (7)交换性钠在[0.1, 2]范围之外的,存疑;
  387. if row['交换性钠cmol(+)/kg'] < 0.1 or row['交换性钠cmol(+)/kg'] > 2:
  388. if row['交换性钠cmol(+)/kg'] > 2:
  389. exchangeableNa.append('交换性钠:复核数据合理性,关联pH审核。')
  390. exchangeableNaTar.append('交换性钠。')
  391. else:
  392. exchangeableNa.append('交换性钠:复核数据合理性。')
  393. exchangeableNaTar.append('交换性钠。')
  394. else:
  395. exchangeableNa.append('')
  396. exchangeableNaTar.append('')
  397. # (8)pH<7.5,阳离子交换量>交换性盐总量>四大离子之和,且盐基饱和度小于100 %;违反则存疑;pH≥7.5,交换性盐总量 = 四大离子之和,盐基饱和度范围在80~120 %;违反则存疑;
  398. if ((not pd.isna(row['pH']) and row['pH'] < 7.5 and ( row['阳离子交换量Cmol(+)/kg'] > row['交换性盐总量Cmol(+)/kg']) and ( row['交换性盐总量Cmol(+)/kg'] > row['四大离子之和']) and row['盐基饱和度%'] * 100 < 100) or
  399. ((not pd.isna(row['pH']) and row['pH'] >= 7.5 and row['交换性盐总量Cmol(+)/kg'] == row['四大离子之和'] and (row['盐基饱和度%'] * 100 < 120 and row['盐基饱和度%'] * 100 > 80))) or
  400. ((not pd.isna(row['pH']) and row['pH'] < 6 and row['盐基饱和度%'] > 80))
  401. ):
  402. summaryList.append('')
  403. summaryListTar.append('')
  404. else:
  405. summaryList.append('存疑:ph值、阳离子交换量、交换性盐总量、离子总和、盐基饱和度之间关系存疑。')
  406. summaryListTar.append('盐基饱和度。')
  407. soilRes = soilTypeValue(row)
  408. soilTypeList.append(soilRes)
  409. # print('pd.Series(phList)',pd.Series(phList) + pd.Series(cationList)+pd.Series(exchangeableSalt))
  410. # print('pd.Series(cationList)', pd.Series(exchangeableSalt))
  411. # print('res---', pd.Series(phList)+pd.Series(cationList)+pd.Series(exchangeableSalt)+pd.Series(exchangeableCa)+pd.Series(exchangeableMg)+pd.Series(exchangeableK)+pd.Series(exchangeableNa)+pd.Series(summaryList))
  412. checkData = pd.DataFrame({
  413. '审核结果': pd.Series(phList)+pd.Series(cationList)+pd.Series(exchangeableSalt)+pd.Series(exchangeableCa)+pd.Series(exchangeableMg)+pd.Series(exchangeableK)+pd.Series(exchangeableNa)+pd.Series(summaryList)+pd.Series(soilTypeList)+pd.Series(waterMount),
  414. '异常指标': pd.Series(phTar)+pd.Series(cationTar)+pd.Series(exchangeableSaltTar)+pd.Series(exchangeableCaTar)+pd.Series(exchangeableMgTar)+pd.Series(exchangeableKTar)+pd.Series(exchangeableNaTar)+pd.Series(summaryListTar)+pd.Series(waterMountTar)
  415. })
  416. return checkData
  417. except Exception as err:
  418. print('阳离子量判断出错!请检查cation_value中判断阳离子量内容', err)
  419. # 表8 8大离子基础数据判断
  420. def eight_ion_coun(arr, summary):
  421. try:
  422. allArr = [] # 存储水溶性盐总量存疑数据
  423. conductivity = [] # 存储电导率存疑数据
  424. naArr = [] # 存储钠离子存疑数据
  425. kArr = [] # 存储钾离子存疑数据
  426. caArr = [] # 存储钙离子存疑数据
  427. mgArr = [] # 存储镁离子存疑数据
  428. coArr = [] # 存储碳酸根离子存疑数据
  429. cohArr = [] # 存储碳酸氢根离子存疑数据
  430. soArr = [] # 存储硫酸根离子存疑数据
  431. clArr = [] # 氯离子存疑数据
  432. totalCom = [] # 全盐量小于八大离子和存疑数据
  433. phCoArr = [] # ph 碳酸根存疑数据
  434. changeComArr = [] #交换性离子高于水溶性离子存疑数据
  435. rateArr = [] # (水溶性全盐量-八大离子加和)/八大离子加和×100 存疑数据
  436. subtractionArr=[] #阳离子-阴离子 不在范围内
  437. # 存放异常指标
  438. allArrTar = [] # 存储水溶性盐总量异常指标
  439. conductivityTar = [] # 存储电导率异常指标
  440. naArrTar = [] # 存储钠离子异常指标
  441. kArrTar = [] # 存储钾离子异常指标
  442. caArrTar = [] # 存储钙离子异常指标
  443. mgArrTar = [] # 存储镁离子异常指标
  444. coArrTar = [] # 存储碳酸根离子异常指标
  445. cohArrTar = [] # 存储碳酸氢根离子异常指标
  446. soArrTar = [] # 存储硫酸根离子异常指标
  447. clArrTar = [] # 氯离子异常指标
  448. totalComTar = [] # 全盐量小于八大离子和异常指标
  449. phCoArrTar = [] # ph 碳酸根异常指标
  450. changeComArrTar = [] # 交换性离子高于水溶性离子异常指标
  451. rateArrTar = [] # (水溶性全盐量-八大离子加和)/八大离子加和×100 异常指标
  452. subtractionArrTar = [] # 阳离子-阴离子 异常指标
  453. #(2)水溶性盐总量在[0.1, 2]范围之外的,存疑;
  454. for index, row in arr.iterrows():
  455. if (not pd.isna(row['水溶性全盐量g/kg']) and row['水溶性全盐量g/kg'] < 0.1) or (not pd.isna(row['水溶性全盐量g/kg']) and row['水溶性全盐量g/kg'] > 2):
  456. allArr.append('全盐量:复核数据合理性。')
  457. allArrTar.append('全盐量。')
  458. else:
  459. allArr.append('')
  460. allArrTar.append('')
  461. #(3)电导率在[0.01, 2]范围之外的,存疑;
  462. if ( not pd.isna(row['电导率ms/cm']) and row['电导率ms/cm'] < 0.01) or (not pd.isna(row['电导率ms/cm']) and row['电导率ms/cm'] > 2):
  463. conductivity.append('电导率:复核数据合理性。')
  464. conductivityTar.append('电导率。')
  465. else:
  466. conductivity.append('')
  467. conductivityTar.append('')
  468. #(4)水溶性钠在[0.05, 0.5]范围之外的,存疑;
  469. if (not pd.isna(row['水溶性钠离子含量Cmol(Na+)/kg']) and row['水溶性钠离子含量Cmol(Na+)/kg'] <0.05) or (pd.isna(row['水溶性钠离子含量Cmol(Na+)/kg']) and row['水溶性钠离子含量Cmol(Na+)/kg'] > 0.5):
  470. naArr.append('水溶性钠离子:水溶性钠离子复核数据合理性。')
  471. naArrTar.append('水溶性钠离子。')
  472. else:
  473. naArr.append('')
  474. naArrTar.append('')
  475. #(5)水溶性钾在[0.01, 0.5]范围之外的,存疑;
  476. if (not pd.isna(row['水溶性钾离子含量Cmol(K+)/kg']) and row['水溶性钾离子含量Cmol(K+)/kg'] <0.01) or ( not pd.isna(row['水溶性钾离子含量Cmol(K+)/kg']) and row['水溶性钾离子含量Cmol(K+)/kg'] > 0.5):
  477. kArr.append('水溶性钾离子:复核数据合理性。')
  478. kArrTar.append('水溶性钾离子。')
  479. else:
  480. kArr.append('')
  481. kArrTar.append('')
  482. #(6)水溶性钙在[0.25, 5]范围之外的,存疑;
  483. if (not pd.isna(row['水溶性钙离子含量cmol(1/2Ca2+)/kg']) and row['水溶性钙离子含量cmol(1/2Ca2+)/kg'] <0.25) or (not pd.isna(row['水溶性钙离子含量cmol(1/2Ca2+)/kg']) and row['水溶性钙离子含量cmol(1/2Ca2+)/kg'] > 0.5):
  484. caArr.append('水溶性钙离子:复核数据合理性。')
  485. caArrTar.append('水溶性钙离子。')
  486. else:
  487. caArr.append('')
  488. caArrTar.append('')
  489. #(7)水溶性镁在[0.125, 2.5]范围之外的,存疑;
  490. if (not pd.isna(row['水溶性镁离子Cmol(1/2Mg2+)/kg']) and row['水溶性镁离子Cmol(1/2Mg2+)/kg'] <0.125) or (not pd.isna(row['水溶性镁离子Cmol(1/2Mg2+)/kg']) and row['水溶性镁离子Cmol(1/2Mg2+)/kg'] > 2.5):
  491. mgArr.append('水溶性镁离子:复核数据合理性。')
  492. mgArrTar.append('水溶性镁离子。')
  493. else:
  494. mgArr.append('')
  495. mgArrTar.append('')
  496. #(8)水溶性碳酸根在[0.01, 2.5]范围之外的,存疑;
  497. if (not pd.isna(row['水溶性碳酸根离子含量cmol(1/2CO32+)/kg']) and row['水溶性碳酸根离子含量cmol(1/2CO32+)/kg'] <0.01) or (not pd.isna(row['水溶性碳酸根离子含量cmol(1/2CO32+)/kg']) and row['水溶性碳酸根离子含量cmol(1/2CO32+)/kg'] > 2.5):
  498. coArr.append('水溶性碳酸根:复核数据合理性。')
  499. coArrTar.append('水溶性碳酸根。')
  500. else:
  501. coArr.append('')
  502. coArrTar.append('')
  503. #(9)水溶性碳酸氢根在[0.05, 5]范围之外的,存疑;
  504. if (not pd.isna(row['水溶性碳酸氢离子含量cmol(1/2HCO3-)/kg']) and row['水溶性碳酸氢离子含量cmol(1/2HCO3-)/kg'] <0.05) or (not pd.isna(row['水溶性碳酸氢离子含量cmol(1/2HCO3-)/kg']) and row['水溶性碳酸氢离子含量cmol(1/2HCO3-)/kg'] > 5):
  505. cohArr.append('水溶性碳酸氢根:复核数据合理性。')
  506. cohArrTar.append('水溶性碳酸氢根。')
  507. else:
  508. cohArr.append('')
  509. cohArrTar.append('')
  510. #(10)水溶性硫酸根在[0.25, 2.5]范围之外的,存疑;
  511. if (not pd.isna(row['水溶性硫酸根离子含量cmol(1/2SO42-)/kg']) and row['水溶性硫酸根离子含量cmol(1/2SO42-)/kg'] <0.25) or (not pd.isna(row['水溶性硫酸根离子含量cmol(1/2SO42-)/kg']) and row['水溶性硫酸根离子含量cmol(1/2SO42-)/kg'] > 2.5):
  512. soArr.append('水溶性硫酸根:复核数据合理性。')
  513. soArrTar.append('水溶性硫酸根。')
  514. else:
  515. soArr.append('')
  516. soArrTar.append('')
  517. #(11)水溶性氯根在[0.5, 5]范围之外的,存疑;
  518. if (not pd.isna(row['水溶性氯离子含量cmol(Cl-)/kg']) and row['水溶性氯离子含量cmol(Cl-)/kg'] <0.5) or (not pd.isna(row['水溶性氯离子含量cmol(Cl-)/kg']) and row['水溶性氯离子含量cmol(Cl-)/kg'] > 5):
  519. clArr.append('水溶性氯根:复核数据合理性。')
  520. clArrTar.append('水溶性氯根。')
  521. else:
  522. clArr.append('')
  523. clArrTar.append('')
  524. #(12)水溶性盐总量大于等于八大离子之和,违背则存疑;土地利用类型为菜地的,可能不符合这个规律;
  525. if (not pd.isna( row['水溶性全盐量g/kg']) and not pd.isna(row['八大离子加和g/kg']) and row['水溶性全盐量g/kg'] < row['八大离子加和g/kg']):
  526. totalCom.append('存疑:水溶性全盐量小于八大离子之和。')
  527. totalComTar.append('水溶性全盐量。')
  528. else:
  529. totalCom.append('')
  530. totalComTar.append('')
  531. #(13)水溶性八大离子换算为g / kg,如水溶性钠离子g / kg = 水溶性钠离子cmol(Na +) / kg×23g / mol×10 - 2; 这里在计算离子和时已转换
  532. #(14)pH<8,碳酸根基本为0
  533. if row['pH'] <8 and not pd.isna(row['水溶性碳酸根离子含量cmol(1/2CO32+)/kg']) and row['水溶性碳酸根离子含量cmol(1/2CO32+)/kg'] != 0:
  534. phCoArr.append('水溶性碳酸根:pH<8水溶性碳酸根不为0。')
  535. phCoArrTar.append('水溶性碳酸根。')
  536. else:
  537. phCoArr.append('')
  538. phCoArrTar.append('')
  539. #(15)交换性四大盐离子均要高于水溶性四大盐离子(钙镁钾钠)
  540. naBool = not pd.isna(row['水溶性钠离子含量Cmol(Na+)/kg'])
  541. kBool = not pd.isna(row['水溶性钾离子含量Cmol(K+)/kg'])
  542. caBool = not pd.isna(row['水溶性钙离子含量cmol(1/2Ca2+)/kg'])
  543. mgBool = not pd.isna(row['水溶性镁离子Cmol(1/2Mg2+)/kg'])
  544. sumNa = not pd.isna(summary.loc[index,'交换性钠'])
  545. sumK = not pd.isna(summary.loc[index, '交换性钾'])
  546. sumCa = not pd.isna(summary.loc[index, '交换性钙'])
  547. sumMg = not pd.isna(summary.loc[index, '交换性镁'])
  548. if (naBool and sumNa and row['水溶性钠离子含量Cmol(Na+)/kg']>summary.loc[index,'交换性钠']) or (
  549. kBool and sumK and row['水溶性钾离子含量Cmol(K+)/kg']>summary.loc[index,'交换性钾']) or (
  550. caBool and sumCa and row['水溶性钙离子含量cmol(1/2Ca2+)/kg']>summary.loc[index,'交换性钙']) or (
  551. mgBool and sumMg and row['水溶性镁离子Cmol(1/2Mg2+)/kg']>summary.loc[index,'交换性镁']):
  552. changeComArr.append('存疑:交换性盐基总量低于于水溶性盐离子。')
  553. else:
  554. changeComArr.append('')
  555. #(16)(水溶性全盐量 - 八大离子加和) / 八大离子加和 * 100,不超过±20 %
  556. if not pd.isna(row['(水溶性全盐量-八大离子加和)/水溶性全盐量×100']) and (row['(水溶性全盐量-八大离子加和)/水溶性全盐量×100'] < -0.2 or row['(水溶性全盐量-八大离子加和)/水溶性全盐量×100'] > 0.2) :
  557. rateArr.append('存疑:(水溶性全盐量-八大离子加和)/水溶性全盐量×100复核数据合理性。')
  558. else:
  559. rateArr.append('')
  560. #(17)阳离子总量 - 阴离子总量应基本相等,超过±0.5则提示异常
  561. if not pd.isna(row['阳离子总量-阴离子总量']) and (row['阳离子总量-阴离子总量'] < -0.5 or row['阳离子总量-阴离子总量'] > 0.5) :
  562. subtractionArr.append('存疑:阳离子总量 - 阴离子总量复核数据合理性。')
  563. else:
  564. subtractionArr.append('')
  565. resData = pd.DataFrame({
  566. '审核结果': pd.Series(allArr) + pd.Series(conductivity) + pd.Series(naArr) +
  567. pd.Series(kArr) + pd.Series(caArr) + pd.Series(mgArr) + pd.Series(coArr) + pd.Series(
  568. cohArr) + pd.Series(soArr) + pd.Series(clArr) + pd.Series(totalCom) + pd.Series(
  569. phCoArr) + pd.Series(changeComArr) + pd.Series(rateArr) + pd.Series(subtractionArr),
  570. '异常指标': pd.Series(allArrTar) + pd.Series(conductivityTar) + pd.Series(naArrTar) +
  571. pd.Series(kArrTar) + pd.Series(caArrTar) + pd.Series(mgArrTar) + pd.Series(coArrTar) + pd.Series(
  572. cohArrTar) + pd.Series(soArrTar) + pd.Series(clArrTar) + pd.Series(totalComTar) + pd.Series(
  573. phCoArrTar)
  574. })
  575. return resData
  576. except Exception as err:
  577. print('八大离子判断出错!请检查eight_ion_coun中判断离子内容', err)
  578. # 表10 有机质、全氮、全磷、全钾数据
  579. def nutrient_data(arr):
  580. try:
  581. organicMatter = [] # 有机质存疑数据
  582. NArr = [] # 全氮存疑数据
  583. PArr = [] # 全磷存疑数据
  584. KArr = [] # 全钾存疑数据
  585. availableP = [] # 有效磷存疑数据
  586. availablek = [] #速效钾存疑数据
  587. slowlyK= [] #缓效钾存疑数据
  588. organicRate = [] #有机质 / 全氮比值存疑数据
  589. availablePCom = [] #有效磷<3和大于60,提示异常;
  590. availableTxt = [] # 速效钾<50提示异常
  591. availablekCom = [] # 速效钾>缓效钾 存疑数据
  592. sKErr = [] # 保存交换性钾不等于速效钾
  593. # 异常指标
  594. organicMatterTar = [] # 有机质异常指标
  595. NArrTar = [] # 全氮异常指标
  596. PArrTar = [] # 全磷异常指标
  597. KArrTar = [] # 全钾异常指标
  598. availablePTar = [] # 有效磷异常指标
  599. availablekTar = [] # 速效钾异常指标
  600. slowlyKTar = [] # 缓效钾异常指标
  601. sKErrTar = [] # 保存交换性钾不等于速效钾
  602. for index, row in arr.iterrows():
  603. # 交换性钾 == 速效钾
  604. if not pd.isna(row['速效钾mg/kg']) and not pd.isna(row['交换性钾']) and (2*(row['速效钾mg/kg'] - row['交换性钾']*391) / (row['速效钾mg/kg'] + row['交换性钾']*391) > 0.2 or 2*(row['速效钾mg/kg'] - row['交换性钾']*391)/ (row['速效钾mg/kg'] + row['交换性钾']*391) < -0.2):
  605. sKErr.append('存疑:交换性钾和速效钾误差超20%。')
  606. sKErrTar.append('交换性钾、速效钾。')
  607. else:
  608. sKErr.append('')
  609. sKErrTar.append('')
  610. #(2)有机质在[2, 50]范围之外的,存疑;有机质<5提示异常;
  611. if row['有机质g/kg'] < 2 or row['有机质g/kg'] >50:
  612. organicMatter.append('有机质:复核数据合理性。')
  613. organicMatterTar.append('有机质。')
  614. else:
  615. organicMatter.append('')
  616. organicMatterTar.append('')
  617. #(3)全氮在[0.1, 2.5]范围之外的;存疑;
  618. if row['全氮g/kg'] < 0.1 or row['全氮g/kg'] > 2.5:
  619. NArr.append('全氮:复核数据合理性。')
  620. NArrTar.append('全氮。')
  621. else:
  622. NArr.append('')
  623. NArrTar.append('')
  624. #(4)全磷在[0.18, 1.5]范围之外的;存疑;
  625. if row['全磷g/kg'] < 0.18 or row['全磷g/kg'] > 1.5:
  626. PArr.append('全磷:复核数据合理性。')
  627. PArrTar.append('全磷。')
  628. else:
  629. PArr.append('')
  630. PArrTar.append('')
  631. #(5)全钾在[10, 29]范围之外的;存疑;
  632. if row['全钾g/kg'] < 10 or row['全钾g/kg'] > 29:
  633. KArr.append('全钾:复核数据合理性。')
  634. KArrTar.append('全钾。')
  635. else:
  636. KArr.append('')
  637. KArrTar.append('')
  638. #(6)有效磷在[1, 80]范围之外的;存疑; 耕地 超过80存疑
  639. if (row['pH'] >= 6.5 and (row['有效磷g/kg'] < 3 or row['有效磷g/kg'] > 60)) or (row['pH'] < 6.5 and (row['有效磷g/kg'] < 1 or row['有效磷g/kg'] > 50) or ( row['编号'][6:10] == '0101' or row['编号'][6:10] == '0102' or row['编号'][6:10] == '0103') and row['有效磷g/kg'] > 60):
  640. availableP.append('有效磷:复核数据合理性。')
  641. availablePTar.append('有效磷。')
  642. else:
  643. availableP.append('')
  644. availablePTar.append('')
  645. # if row['有效磷g/kg'] < 1 or row['有效磷g/kg'] > 60 or ((row['编号'][6:11] == '0101' or row['编号'][6:11] == '0102' or row['编号'][6:11] == '0103') and row['有效磷g/kg'] > 60):
  646. # availableP.append('存疑:有效磷复核数据合理性。')
  647. # else:
  648. # availableP.append('')
  649. #(7)速效钾在[30, 300] 范围之外的;存疑; 耕地超过300存疑
  650. if row['速效钾mg/kg'] < 30 or row['速效钾mg/kg'] > 300 or ((row['编号'][6:10] == '0101' or row['编号'][6:10] == '0102' or row['编号'][6:10] == '0103') and row['速效钾mg/kg'] > 300):
  651. availablek.append('速效钾:复核数据合理性。')
  652. availablekTar.append('速效钾。')
  653. else:
  654. availablek.append('')
  655. availablekTar.append('')
  656. #(8)缓效钾在[100, 2000]范围之外的;存疑;
  657. if row['缓效钾mg/kg'] < 100 or row['缓效钾mg/kg'] > 2000:
  658. slowlyK.append('缓效钾:复核数据合理性。')
  659. slowlyKTar.append('缓效钾。')
  660. else:
  661. slowlyK.append('')
  662. slowlyKTar.append('')
  663. #(9)有机质 / 全氮比值≥20和≤13,提示存疑
  664. if row['有机质g/kg']/row['全氮g/kg'] >=20 or row['有机质g/kg']/row['全氮g/kg'] <=13 :
  665. organicRate.append('存疑:有机质/全氮比值复核数据合理性。')
  666. else:
  667. organicRate.append('')
  668. #(10)有机质、全氮含量异常高,但速效养分特低,提示异常 无法量化不处理
  669. #(11)母岩为片麻岩,但全钾、速效缓效钾含量低,提示异常 无法量化不处理
  670. #(12)有效磷<3和大于60,提示异常;速效钾<50提示异常
  671. # if row['有效磷g/kg'] < 3 or row['有效磷g/kg'] > 60:
  672. # availablePCom.append('有效磷:复核数据合理性。')
  673. # else:
  674. # availablePCom.append('')
  675. if row['速效钾mg/kg'] < 50:
  676. availableTxt.append('速效钾:复核数据合理性。')
  677. else:
  678. availableTxt.append('')
  679. #(13)速效钾>缓效钾,提示异常
  680. if row['速效钾mg/kg'] > row['缓效钾mg/kg']:
  681. availablekCom.append('异常:速效钾大于缓效钾。')
  682. else:
  683. availablekCom.append('')
  684. resData = pd.DataFrame({
  685. '审核结果': pd.Series(organicMatter) + pd.Series(NArr) + pd.Series(PArr) +
  686. pd.Series(KArr) + pd.Series(availableP) + pd.Series(availablek) + pd.Series(slowlyK) + pd.Series(
  687. organicRate) + pd.Series(availablePCom) + pd.Series(availablekCom) + pd.Series(availableTxt) + pd.Series(availablePCom) + pd.Series(sKErr),
  688. '异常指标': pd.Series(organicMatterTar) + pd.Series(NArrTar) + pd.Series(PArrTar) +
  689. pd.Series(KArrTar) + pd.Series(availablePTar) + pd.Series(availablekTar) + pd.Series(slowlyKTar) + pd.Series(sKErrTar)
  690. })
  691. return resData
  692. except Exception as err:
  693. print('有机质、全氮、全磷、全钾数据判断出错!请检查nutrient_data中判断内容', err)
  694. # 表12 土壤指标判断规则
  695. def soil_metal(arr):
  696. try:
  697. effectiveL = [] # 有效硫存疑数据
  698. effectiveG = [] # 有效硅存疑数据
  699. effectiveT = [] # 有效铁存疑数据
  700. effectiveM = [] # 有效锰存疑数据
  701. effectiveCu = [] # 有效铜存疑数据
  702. effectiveX = [] # 有效锌存疑数据
  703. effectiveP = [] # 有效硼存疑数据
  704. effectiveMu = [] # 有效钼存疑数据
  705. # 存疑指标
  706. effectiveLTar = [] # 有效硫
  707. effectiveGTar = [] # 有效硅
  708. effectiveTTar = [] # 有效铁
  709. effectiveMTar = [] # 有效锰
  710. effectiveCuTar = [] # 有效铜
  711. effectiveXTar = [] # 有效锌
  712. effectivePTar = [] # 有效硼
  713. effectiveMutar = [] # 有效钼
  714. for index, row in arr.iterrows():
  715. #(1)有效硫在[2, 60]范围之外的,存疑;
  716. if (not pd.isna(row['有效硫mg/kg']) and row['有效硫mg/kg'] <2) or (not pd.isna(row['有效硫mg/kg']) and row['有效硫mg/kg'] >60):
  717. effectiveL.append('有效硫:复核数据合理性。')
  718. effectiveLTar.append('有效硫。')
  719. else:
  720. effectiveL.append('')
  721. effectiveLTar.append('')
  722. #(2)有效硅在[10, 500]范围之外的,存疑;
  723. if ( not pd.isna(row['有效硅mg/kg']) and row['有效硅mg/kg'] <10) or (not pd.isna(row['有效硅mg/kg']) and row['有效硅mg/kg'] >500):
  724. effectiveG.append('有效硅:复核数据合理性。')
  725. effectiveGTar.append('有效硅。')
  726. else:
  727. effectiveG.append('')
  728. effectiveGTar.append('')
  729. #(3)有效铁在[5, 300]范围之外的,存疑;
  730. if ( not pd.isna(row['有效铁mg/kg']) and row['有效铁mg/kg'] <5) or (not pd.isna(row['有效铁mg/kg']) and row['有效铁mg/kg'] >300):
  731. effectiveT.append('有效铁:复核数据合理性。')
  732. effectiveTTar.append('有效铁。')
  733. else:
  734. effectiveT.append('')
  735. effectiveTTar.append('')
  736. #(4)有效锰在[5, 200]范围之外的,存疑;
  737. if (not pd.isna(row['有效锰mg/kg']) and row['有效锰mg/kg'] <5) or (not pd.isna(row['有效锰mg/kg']) and row['有效锰mg/kg'] >200) :
  738. effectiveM.append('有效锰:复核数据合理性。')
  739. effectiveMTar.append('有效锰。')
  740. else:
  741. effectiveM.append('')
  742. effectiveMTar.append('')
  743. #(5)有效铜在[0.1, 8]范围之外的,存疑;
  744. if ( not pd.isna(row['有效铜mg/kg']) and row['有效铜mg/kg'] <0.1) or (not pd.isna(row['有效铜mg/kg']) and row['有效铜mg/kg'] >8):
  745. effectiveCu.append('有效铜:复核数据合理性。')
  746. effectiveCuTar.append('有效铜。')
  747. else:
  748. effectiveCu.append('')
  749. effectiveCuTar.append('')
  750. #(6)有效锌在[0.1, 10] 范围之外的,存疑;
  751. if (not pd.isna(row['有效锌mg/kg']) and row['有效锌mg/kg'] <0.1) or (not pd.isna(row['有效锌mg/kg']) and row['有效锌mg/kg'] >10):
  752. effectiveX.append('有效锌:复核数据合理性。')
  753. effectiveXTar.append('有效锌。')
  754. else:
  755. effectiveX.append('')
  756. effectiveXTar.append('')
  757. #(7)有效硼在[0.1, 2] 范围之外的,存疑;
  758. if (not pd.isna(row['有效硼mg/kg']) and row['有效硼mg/kg'] <0.1) or (not pd.isna(row['有效硼mg/kg']) and row['有效硼mg/kg'] >2):
  759. effectiveP.append('有效硼:复核数据合理性。')
  760. effectivePTar.append('有效硼。')
  761. else:
  762. effectiveP.append('')
  763. effectivePTar.append('')
  764. #(8)有效钼在[0.03, 1]范围之外的,存疑。
  765. if (not pd.isna(row['有效钼mg/kg']) and row['有效钼mg/kg'] <0.03) or (not pd.isna(row['有效钼mg/kg']) and row['有效钼mg/kg'] >1):
  766. effectiveMu.append('有效钼:复核数据合理性。')
  767. effectiveMutar.append('有效钼。')
  768. else:
  769. effectiveMu.append('')
  770. effectiveMutar.append('')
  771. resData = pd.DataFrame({
  772. '审核结果': pd.Series(effectiveL) + pd.Series(effectiveT) + pd.Series(effectiveG) +
  773. pd.Series(effectiveM) + pd.Series(effectiveCu) + pd.Series(effectiveX) + pd.Series(effectiveP) + pd.Series(
  774. effectiveMu),
  775. '异常指标': pd.Series(effectiveLTar) + pd.Series(effectiveTTar) + pd.Series(effectiveGTar) +
  776. pd.Series(effectiveMTar) + pd.Series(effectiveCuTar) + pd.Series(effectiveXTar) + pd.Series(effectivePTar) + pd.Series(
  777. effectiveMutar)
  778. })
  779. return resData
  780. except Exception as err:
  781. print('土壤重金属指标数据判断出错!请检查soil_metal中判断内容', err)
  782. # 表14 土壤重金属判断
  783. # 这里风险值和管控值判断 单独写两个函数
  784. # 风险值
  785. def risk_value(arr):
  786. unnormalValue = []
  787. for index, row in arr.iterrows():
  788. str = ''
  789. if row['编号'][6:10] == '0101': # 水田
  790. # 镉
  791. if (row['pH'] <= 5.5 and row['镉mg/kg'] > 0.3) or (
  792. row['pH'] > 5.5 and row['pH']<= 6.5 and row['镉mg/kg'] > 0.4) or (
  793. row['pH'] >6.5 and row['pH'] <=7.5 and row['镉mg/kg'] > 0.6) or (
  794. row['pH'] > 7.5 and row['镉mg/kg'] > 0.8):
  795. str += '镉超污染风险值筛选值。'
  796. # 汞
  797. if (row['pH'] <= 5.5 and row['汞mg/kg'] > 0.5) or (
  798. row['pH'] > 5.5 and row['pH'] <= 6.5 and row['汞mg/kg'] > 0.5) or (
  799. row['pH'] > 6.5 and row['pH'] <= 7.5 and row['汞mg/kg'] > 0.6) or (
  800. row['pH'] > 7.5 and row['汞mg/kg'] > 1):
  801. str += '汞超污染风险值筛选值。'
  802. # 砷
  803. if (row['pH'] <= 5.5 and row['砷mg/kg'] >30) or (
  804. row['pH'] > 5.5 and row['pH'] <= 6.5 and row['砷mg/kg'] > 30) or (
  805. row['pH'] > 6.5 and row['pH'] <= 7.5 and row['砷mg/kg'] > 25) or (
  806. row['pH'] > 7.5 and row['砷mg/kg'] > 20):
  807. str += '砷超污染风险值筛选值。'
  808. # 铅
  809. if (row['pH'] <= 5.5 and row['铅mg/kg'] > 80) or (
  810. row['pH'] > 5.5 and row['pH'] <= 6.5 and row['铅mg/kg'] > 100) or (
  811. row['pH'] > 6.5 and row['pH'] <= 7.5 and row['铅mg/kg'] > 140) or (
  812. row['pH'] > 7.5 and row['铅mg/kg'] > 240):
  813. str += '铅超污染风险值筛选值。'
  814. # 铬
  815. if (row['pH'] <= 5.5 and row['铬mg/kg'] > 250) or (
  816. row['pH'] > 5.5 and row['pH'] <= 6.5 and row['铬mg/kg'] > 250) or (
  817. row['pH'] > 6.5 and row['pH'] <= 7.5 and row['铬mg/kg'] > 300) or (
  818. row['pH'] > 7.5 and row['铬mg/kg'] >350):
  819. str += '铬超污染风险值筛选值。'
  820. else:
  821. # 镉
  822. if (row['pH'] <= 5.5 and row['镉mg/kg'] > 0.3) or (
  823. row['pH'] > 5.5 and row['pH']<= 6.5 and row['镉mg/kg'] > 0.3) or (
  824. row['pH'] >6.5 and row['pH'] <=7.5 and row['镉mg/kg'] > 0.3) or (
  825. row['pH'] > 7.5 and row['镉mg/kg'] > 0.6):
  826. str += '镉超污染风险值筛选值。'
  827. # 汞
  828. if (row['pH'] <= 5.5 and row['汞mg/kg'] > 1.3) or (
  829. row['pH'] > 5.5 and row['pH'] <= 6.5 and row['汞mg/kg'] > 1.8) or (
  830. row['pH'] > 6.5 and row['pH'] <= 7.5 and row['汞mg/kg'] > 2.4) or (
  831. row['pH'] > 7.5 and row['汞mg/kg'] > 3.4):
  832. str += '汞超污染风险值筛选值。'
  833. # 砷
  834. if (row['pH'] <= 5.5 and row['砷mg/kg'] > 40) or (
  835. row['pH'] > 5.5 and row['pH'] <= 6.5 and row['砷mg/kg'] > 40) or (
  836. row['pH'] > 6.5 and row['pH'] <= 7.5 and row['砷mg/kg'] > 30) or (
  837. row['pH'] > 7.5 and row['砷mg/kg'] > 25):
  838. str += '砷超污染风险值筛选值。'
  839. # 铅
  840. if (row['pH'] <= 5.5 and row['铅mg/kg'] > 70) or (
  841. row['pH'] > 5.5 and row['pH'] <= 6.5 and row['铅mg/kg'] > 90) or (
  842. row['pH'] > 6.5 and row['pH'] <= 7.5 and row['铅mg/kg'] > 120) or (
  843. row['pH'] > 7.5 and row['铅mg/kg'] > 170):
  844. str += '铅超污染风险值筛选值。'
  845. # 铬
  846. if (row['pH'] <= 5.5 and row['铬mg/kg'] > 150) or (
  847. row['pH'] > 5.5 and row['pH'] <= 6.5 and row['铬mg/kg'] > 150) or (
  848. row['pH'] > 6.5 and row['pH'] <= 7.5 and row['铬mg/kg'] > 200) or (
  849. row['pH'] > 7.5 and row['铬mg/kg'] > 250):
  850. str += '铬超污染风险值筛选值。'
  851. if (row['pH'] <= 5.5 and row['镍mg/kg'] > 60) or (
  852. row['pH'] > 5.5 and row['pH'] <= 6.5 and row['镍mg/kg'] > 70) or (
  853. row['pH'] > 6.5 and row['pH'] <= 7.5 and row['镍mg/kg'] > 100) or (
  854. row['pH'] > 7.5 and row['镍mg/kg'] > 190):
  855. str += '镍超污染风险值筛选值。'
  856. unnormalValue.append(str)
  857. return unnormalValue
  858. # 管制值
  859. def control_value(arr):
  860. unnormalValue = []
  861. for index, row in arr.iterrows():
  862. str = ''
  863. # 镉
  864. if (row['pH'] <= 5.5 and row['镉mg/kg'] > 1.5) or (
  865. row['pH'] > 5.5 and row['pH'] <= 6.5 and row['镉mg/kg'] > 2) or (
  866. row['pH'] > 6.5 and row['pH'] <= 7.5 and row['镉mg/kg'] > 3) or (
  867. row['pH'] > 7.5 and row['镉mg/kg'] > 4):
  868. str += '镉超污染风险值管制值。'
  869. # 汞
  870. if (row['pH'] <= 5.5 and row['汞mg/kg'] > 2) or (
  871. row['pH'] > 5.5 and row['pH'] <= 6.5 and row['汞mg/kg'] > 2.5) or (
  872. row['pH'] > 6.5 and row['pH'] <= 7.5 and row['汞mg/kg'] > 4) or (
  873. row['pH'] > 7.5 and row['汞mg/kg'] > 6):
  874. str += '汞超污染风险值管制值。'
  875. # 砷
  876. if (row['pH'] <= 5.5 and row['砷mg/kg'] > 200) or (
  877. row['pH'] > 5.5 and row['pH'] <= 6.5 and row['砷mg/kg'] > 150) or (
  878. row['pH'] > 6.5 and row['pH'] <= 7.5 and row['砷mg/kg'] > 120) or (
  879. row['pH'] > 7.5 and row['砷mg/kg'] > 100):
  880. str += '砷超污染风险值管制值。'
  881. # 铅
  882. if (row['pH'] <= 5.5 and row['铅mg/kg'] >400) or (
  883. row['pH'] > 5.5 and row['pH'] <= 6.5 and row['铅mg/kg'] > 500) or (
  884. row['pH'] > 6.5 and row['pH'] <= 7.5 and row['铅mg/kg'] > 700) or (
  885. row['pH'] > 7.5 and row['铅mg/kg'] > 1000):
  886. str += '铅超污染风险值管制值。'
  887. # 铬
  888. if (row['pH'] <= 5.5 and row['铬mg/kg'] > 800) or (
  889. row['pH'] > 5.5 and row['pH'] <= 6.5 and row['铬mg/kg'] > 850) or (
  890. row['pH'] > 6.5 and row['pH'] <= 7.5 and row['铬mg/kg'] > 1000) or (
  891. row['pH'] > 7.5 and row['铬mg/kg'] > 1300):
  892. str += '铬超污染风险值管制值。'
  893. unnormalValue.append(str)
  894. return unnormalValue
  895. def last_metal(arr):
  896. try:
  897. totalGe = [] # 总镉在范围之外
  898. totalGo = [] # 总汞在范围之外
  899. totalShen = [] # 总砷在范围之外
  900. totalPb = [] # 总铅在范围之外
  901. totalG = [] # 总铬在范围之外
  902. totalN = [] # 总镍在范围之外
  903. # 异常指标
  904. totalGeTar = [] # 总镉
  905. totalGoTar = [] # 总汞
  906. totalShenTar = [] # 总砷
  907. totalPbTar = [] # 总铅
  908. totalGTar = [] # 总铬
  909. totalNTar = [] # 总镍
  910. # (1)超过风险筛选值,提示关注
  911. overValue = risk_value(arr) # 超过风险筛选值
  912. # (2)超过风险管控值,提示重点关注
  913. overLimit = control_value(arr) # 超过风险管控值
  914. for index, row in arr.iterrows():
  915. # (3)总镉在[0.03, 0.3]范围之外的,存疑
  916. if (row['镉mg/kg'] < 0.03 or row['镉mg/kg'] > 0.3):
  917. totalGe.append('总镉:复核数据合理性。')
  918. totalGeTar.append('总镉。')
  919. else:
  920. totalGe.append('')
  921. totalGeTar.append('')
  922. # (4)总汞在[0.01, 0.3]范围之外的,存疑
  923. if (row['汞mg/kg'] < 0.01 or row['汞mg/kg'] > 0.3):
  924. totalGo.append('总汞:复核数据合理性。')
  925. totalGoTar.append('总汞。')
  926. else:
  927. totalGo.append('')
  928. totalGoTar.append('')
  929. # (5)总砷在[0.5, 30]范围之外的,存疑
  930. if (row['砷mg/kg'] < 0.5 or row['砷mg/kg'] > 30):
  931. totalShen.append('总砷:复核数据合理性。')
  932. totalShenTar.append('总砷。')
  933. else:
  934. totalShen.append('')
  935. totalShenTar.append('')
  936. # (6)总铅在[2, 100]范围之外的,存疑
  937. if (row['铅mg/kg'] < 2 or row['铅mg/kg'] > 100):
  938. totalPb.append('总铅:复核数据合理性。')
  939. totalPbTar.append('总铅。')
  940. else:
  941. totalPb.append('')
  942. totalPbTar.append('')
  943. # (7)总铬在[0.4, 200]范围之外的,存疑
  944. if row['铬mg/kg'] < 0.4 or row['铬mg/kg'] > 200:
  945. totalG.append('总铬:复核数据合理性。')
  946. totalGTar.append('总铬。')
  947. else:
  948. totalG.append('')
  949. totalGTar.append('')
  950. # (8)总镍在[0.3, 100]范围之外的,存疑
  951. if (row['镍mg/kg'] < 0.3 or row['镍mg/kg'] > 100):
  952. totalN.append('总镍:复核数据合理性。')
  953. totalNTar.append('总镍。')
  954. else:
  955. totalN.append('')
  956. totalNTar.append('')
  957. resData = pd.DataFrame({
  958. '审核结果': pd.Series(overValue) + pd.Series(overLimit) + pd.Series(totalGe) +
  959. pd.Series(totalGo) + pd.Series(totalShen) + pd.Series(totalPb) + pd.Series(
  960. totalG) + pd.Series(totalN),
  961. '异常指标': pd.Series(totalGeTar) + pd.Series(totalGoTar) + pd.Series(totalShenTar) + pd.Series(totalPbTar) + pd.Series(
  962. totalGTar) + pd.Series(totalNTar)
  963. })
  964. return resData
  965. except Exception as err:
  966. print('土壤重金属指标数据判断出错!请检查last_metal中判断内容', err)
  967. # 增加剖面数据审核规则
  968. def sectionData(arr):
  969. errArr_LIU = []
  970. errArr_GUI = []
  971. errArr_GAI = []
  972. errArr_MEI = []
  973. errArr_LV = []
  974. errArr_FE = []
  975. errArr_MENG = []
  976. errArr_CU = []
  977. errArr_ZN = []
  978. errArr_PENG = []
  979. errArr_MU = []
  980. errArr_CACO3 = []
  981. errArr_YFE = []
  982. changeS = [] # 可交换酸度
  983. waterS = [] # 水解性酸度
  984. changeH = [] # 水解性氢离子
  985. changeAl = [] # 水解性铝离子
  986. caco3_empty = []
  987. # 存储异常指标
  988. errArr_LIU_Tar = []
  989. errArr_GUI_Tar = []
  990. errArr_GAI_Tar = []
  991. errArr_MEI_Tar = []
  992. errArr_LV_Tar = []
  993. errArr_FE_Tar = []
  994. errArr_MENG_Tar = []
  995. errArr_CU_Tar = []
  996. errArr_ZN_Tar = []
  997. errArr_PENG_Tar = []
  998. errArr_MU_Tar = []
  999. errArr_CACO3_Tar = []
  1000. errArr_YFE_Tar = []
  1001. changeS_Tar = [] # 可交换酸度
  1002. waterS_Tar = [] # 水解性酸度
  1003. changeH_Tar = [] # 水解性氢离子
  1004. changeAl_Tar = [] # 水解性铝离子
  1005. caco3_empty_Tar = []
  1006. for index, row in arr.iterrows():
  1007. if row['全硫'] < 0.1 or row['全硫'] > 5:
  1008. errArr_LIU.append('全硫:复核数据合理性。')
  1009. errArr_LIU_Tar.append('全硫。')
  1010. else:
  1011. errArr_LIU.append('')
  1012. errArr_LIU_Tar.append('')
  1013. if (row['全硅'] < 18 or row['全硅'] > 30):
  1014. errArr_GUI.append('全硅:复核数据合理性。')
  1015. errArr_GUI_Tar.append('全硅。')
  1016. else:
  1017. errArr_GUI.append('')
  1018. errArr_GUI_Tar.append('')
  1019. if (row['全钙'] <0.05 or row['全钙']>5):
  1020. errArr_GAI.append('全钙:复核数据合理性。')
  1021. errArr_GAI_Tar.append('全钙。')
  1022. else:
  1023. errArr_GAI.append('')
  1024. errArr_GAI_Tar.append('')
  1025. if (row['全镁'] <0.3 or row['全镁'] > 4):
  1026. errArr_MEI.append('全镁:复核数据合理性。')
  1027. errArr_MEI_Tar.append('全镁。')
  1028. else:
  1029. errArr_MEI.append('')
  1030. errArr_MEI_Tar.append('')
  1031. if (row['全铝'] < 4 or row['全铝'] > 12):
  1032. errArr_LV.append('全铝:复核数据合理性。')
  1033. errArr_LV_Tar.append('全铝。')
  1034. else:
  1035. errArr_LV.append('')
  1036. errArr_LV_Tar.append('')
  1037. if row['全铁'] < 2 or row['全铁'] > 6:
  1038. errArr_FE.append('全铁:复核数据合理性。')
  1039. errArr_FE_Tar.append('全铁。')
  1040. else:
  1041. errArr_FE.append('')
  1042. errArr_FE_Tar.append('')
  1043. if (row['全锰'] < 100 or row['全锰'] > 2500):
  1044. errArr_MENG.append('全锰:复核数据合理性。')
  1045. errArr_MENG_Tar.append('全锰。')
  1046. else:
  1047. errArr_MENG.append('')
  1048. errArr_MENG_Tar.append('')
  1049. if (row['全铜'] < 6 or row['全铜'] > 150):
  1050. errArr_CU.append('全铜:复核数据合理性。')
  1051. errArr_CU_Tar.append('全铜。')
  1052. else:
  1053. errArr_CU.append('')
  1054. errArr_CU_Tar.append('')
  1055. if (row['全锌'] < 15 or row['全锌'] > 300):
  1056. errArr_ZN.append('全锌:复核数据合理性。')
  1057. errArr_ZN_Tar.append('全锌。')
  1058. else:
  1059. errArr_ZN.append('')
  1060. errArr_ZN_Tar.append('')
  1061. if (row['全硼'] < 12 or row['全硼'] > 75):
  1062. errArr_PENG.append('全硼:复核数据合理性。')
  1063. errArr_PENG_Tar.append('全硼。')
  1064. else:
  1065. errArr_PENG.append('')
  1066. errArr_PENG_Tar.append('')
  1067. if row['全钼'] < 0.1 or row['全钼'] > 7:
  1068. errArr_MU.append('全钼:复核数据合理性。')
  1069. errArr_MU_Tar.append('全钼。')
  1070. else:
  1071. errArr_MU.append('')
  1072. errArr_MU_Tar.append('')
  1073. if (row['碳酸钙'] < 5 or row['碳酸钙'] > 100):
  1074. errArr_CACO3.append('碳酸钙:复核数据合理性。')
  1075. errArr_CACO3_Tar.append('碳酸钙。')
  1076. else:
  1077. errArr_CACO3.append('')
  1078. errArr_CACO3_Tar.append('')
  1079. if row['游离铁'] < 25 or row['游离铁'] > 40:
  1080. errArr_YFE.append('游离铁:复核数据合理性。')
  1081. errArr_YFE_Tar.append('游离铁。')
  1082. else:
  1083. errArr_YFE.append('')
  1084. errArr_YFE_Tar.append('')
  1085. if row['交换性酸总量'] < 0.1 or row['交换性酸总量'] > 10:
  1086. changeS.append('交换性酸总量:复核数据合理性。')
  1087. changeS_Tar.append('交换性酸总量。')
  1088. else:
  1089. changeS.append('')
  1090. changeS_Tar.append('')
  1091. if row['水解性总酸度'] < 0.1 or row['水解性总酸度'] > 15:
  1092. waterS.append('水解性总酸度:复核数据合理性。')
  1093. waterS_Tar.append('水解性总酸度。')
  1094. else:
  1095. waterS.append('')
  1096. waterS_Tar.append('')
  1097. if row['交换性H⁺'] < 0.05 or row['交换性H⁺'] > 5:
  1098. changeH.append('交换性H⁺:复核数据合理性。')
  1099. changeH_Tar.append('交换性H⁺。')
  1100. else:
  1101. changeH.append('')
  1102. changeH_Tar.append('')
  1103. if row['交换性Al³⁺'] < 0.05 or row['交换性Al³⁺'] > 6:
  1104. changeAl.append('交换性Al³⁺:复核数据合理性。')
  1105. changeAl_Tar.append('交换性Al³⁺。')
  1106. else:
  1107. changeAl.append('')
  1108. changeAl_Tar.append('')
  1109. if row['pH'] > 7 and pd.isna(row['碳酸钙']):
  1110. caco3_empty.append('碳酸钙:ph大于7碳酸钙未检测。')
  1111. caco3_empty_Tar.append('碳酸钙。')
  1112. else:
  1113. caco3_empty.append('')
  1114. caco3_empty_Tar.append('')
  1115. resData = pd.DataFrame({
  1116. '审核结果': pd.Series(errArr_LIU) + pd.Series(errArr_GUI) + pd.Series(errArr_GAI) +
  1117. pd.Series(errArr_MEI) + pd.Series(errArr_LV) + pd.Series(errArr_FE) + pd.Series(
  1118. errArr_MENG) + pd.Series(errArr_CU) + pd.Series(errArr_ZN) + pd.Series(errArr_PENG)+ pd.Series(errArr_MU)
  1119. + pd.Series(errArr_CACO3) + pd.Series(errArr_YFE) + pd.Series(changeS) + pd.Series(waterS) + pd.Series(caco3_empty),
  1120. '异常指标': pd.Series(errArr_LIU_Tar) + pd.Series(errArr_GUI_Tar) + pd.Series(errArr_GAI_Tar) +
  1121. pd.Series(errArr_MEI_Tar) + pd.Series(errArr_LV_Tar) + pd.Series(errArr_FE_Tar) + pd.Series(
  1122. errArr_MENG_Tar) + pd.Series(errArr_CU_Tar) + pd.Series(errArr_ZN_Tar) + pd.Series(errArr_PENG_Tar)+ pd.Series(errArr_MU_Tar)
  1123. + pd.Series(errArr_CACO3_Tar) + pd.Series(errArr_YFE_Tar) + pd.Series(changeS_Tar) + pd.Series(waterS_Tar) + pd.Series(caco3_empty_Tar)
  1124. })
  1125. return resData