public.py 66 KB

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