public.py 67 KB

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