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