public.py 68 KB

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