123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155 |
- import pandas as pd
- import numpy as np
- pd.set_option('display.max_columns', 1000)
- pd.set_option('display.width', 1000)
- pd.set_option('display.max_colwidth', 1000)
- def soil_bulk_density(arr):
-
- shenHeList=[]
- shenHeTarget = []
- try:
- for i in arr['土壤容重平均值(g/cm3)(计算)']:
- if i > 1.6 or i < 0.8:
- shenHeList.append('土壤容重:复核数据合理性。')
- shenHeTarget.append('土壤容重平均值。')
- else:
- shenHeList.append('')
- shenHeTarget.append('')
- except Exception as err:
- print('土壤容重判断出错!请检查soil_bulk_density中判断土壤容重内容',err)
-
- tRTypeList = []
- tRTypeTarget= []
- try:
- for i in arr['相对极差(%)']:
- if i > 15 and arr.loc[arr['相对极差(%)'] == i, '土地利用类型'].iloc[0] == '耕地园地':
- tRTypeList.append('存疑:耕地园地相对极差>15%。')
- tRTypeTarget.append('耕地园地极差。')
- elif i > 20 and arr.loc[arr['相对极差(%)'] == i, '土地利用类型'].iloc[0] == '林地草地':
- tRTypeList.append('存疑:林地草地相对极差>20%。')
- tRTypeTarget.append('林地草地极差。')
- else:
- tRTypeList.append('')
- tRTypeTarget.append('')
- except Exception as err:
- print('相对极差判断、土壤利用类型判断出错!请检查soil_bulk_density中判断相对极差判断、土壤利用类型内容',err)
-
- plusShenHeList = []
- plusShenHeTarget = []
- try:
- for i in arr['加和%']:
- if float(i) > 101 or float(i) < 99:
- plusShenHeList.append('土壤颗粒加和:复核数据合理性。')
- plusShenHeTarget.append('土壤颗粒含量加和。')
- else:
- plusShenHeList.append('')
- plusShenHeTarget.append('')
- except Exception as err:
- print('颗粒含量加和判断出错!请检查soil_bulk_density中判断颗粒含量加和内容',err)
-
-
-
-
-
- xSLErr = []
- xSLTarget = []
- try:
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- for index, row in arr.iterrows():
-
-
-
-
-
-
-
- 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颗粒含量%']))):
- xSLErr.append('洗失量:机械组成不为空,ph>7但洗失量未检测。')
- xSLTarget.append('洗失量。')
- else:
- xSLErr.append('')
- xSLTarget.append('')
- except Exception as err:
- print('土壤洗失量判断出错!请检查soil_bulk_density中判断洗失量内容', err)
-
-
-
-
-
-
- pdData = pd.DataFrame({
- '审核结果': pd.Series(shenHeList) + pd.Series(tRTypeList) + pd.Series(plusShenHeList),
-
- '异常指标': pd.Series(shenHeTarget) + pd.Series(tRTypeTarget) + pd.Series(plusShenHeTarget),
- })
- return pdData
- def is_than_five(value):
- return value < 1 or value > 10
- def water_stable(arr):
-
- shenHeList = []
- shenHeTar = []
-
- plusList = []
- plusTar = []
- soilType = []
-
- rateList = []
- rateTar = []
- try:
- for index, row in arr.iterrows():
-
-
-
-
-
-
-
-
-
-
-
-
-
- if (not pd.isna(row['总和(%)'])) and (row['总和(%)'] > 90 or row['总和(%)'] < 30):
- plusList.append('水稳性大团聚体总和:复核数据合理性。')
- plusTar.append('水稳性大团聚体总和。')
- else:
- plusList.append('')
- plusTar.append('')
-
-
-
-
- if row['>5mm%'] > 10:
- rateList.append('存疑:>5mm占比超过10%应回溯。')
- rateTar.append('水稳>5mm。')
- else:
- rateList.append('')
- rateTar.append('')
- resData = pd.DataFrame({
- '审核结果': pd.Series(plusList) + pd.Series(rateList),
- '异常指标': pd.Series(plusTar) + pd.Series(rateTar),
- })
- return resData
- except Exception as err:
- print('大团聚体判断出错!请检查water_stable中判断大团聚体内容', err)
- def soilTypeValue(row):
- strValue = row['土壤类型']
- soilType = ''
- if isinstance(strValue, str):
-
-
- if len(strValue.split('_')) > 1:
- soilType = strValue.split('_')[1]
- cationChange = row['阳离子交换量Cmol(+)/kg']
- bHValue = (row['交换性盐总量Cmol(+)/kg']/row['阳离子交换量Cmol(+)/kg'] )*100
-
- res = ''
- if soilType == '黄红壤':
- if (not pd.isna(cationChange)) and (cationChange > 10 and cationChange < 24) and (not pd.isna(bHValue)) and (
- bHValue > 30 and bHValue < 50):
- res = ''
- else:
- res = '存疑:该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
- elif soilType == '棕红壤':
- if (not pd.isna(cationChange)) and (cationChange > 6 and cationChange < 15) and (not pd.isna(bHValue)) and (
- bHValue > 25 and bHValue < 70):
- res = ''
- else:
- res = '存疑:该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
- elif soilType == '红壤性土':
- if (not pd.isna(cationChange)) and (cationChange > 5 and cationChange < 15) and (not pd.isna(bHValue)) and (
- bHValue > 10 and bHValue < 50):
- res = ''
- else:
- res = '存疑:该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
- elif soilType == '典型黄壤':
- if (not pd.isna(cationChange)) and (cationChange > 5 and cationChange < 15) and not (pd.isna(bHValue)) and (
- bHValue < 30):
- res = ''
- else:
- res = '该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
- elif soilType == '黄壤性土':
- if (not pd.isna(cationChange)) and (cationChange > 10 and cationChange < 18) and (not pd.isna(bHValue)) and (
- bHValue < 45):
- res = ''
- else:
- res = '存疑:该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
- elif soilType == '典型黄棕壤' or soilType == '暗黄棕壤' or soilType == '黄棕壤性土':
- if (not pd.isna(cationChange)) and (cationChange > 8 and cationChange < 22) and (not pd.isna(bHValue)) and (
- bHValue > 30 and bHValue < 60):
- res = ''
- else:
- res = '存疑:该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
- elif soilType == '典型黄褐土' or soilType == '黏盘黄褐土' or soilType == '粘盘黄褐土' or soilType == '粘盘黄褐土' or soilType == '白浆化黄褐土' or soilType == '黄褐土性土':
- if (not pd.isna(cationChange)) and (cationChange > 15 and cationChange < 25) and (not pd.isna(bHValue)) and (
- bHValue > 60 and bHValue < 85):
- res = ''
- else:
- res = '存疑:该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
- elif soilType == '粘盘黄褐土':
- if (not pd.isna(cationChange)) and (cationChange > 10 and cationChange < 30) and (not pd.isna(bHValue)) and (
- bHValue > 75 and bHValue < 95):
- res = ''
- else:
- res = '存疑:该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
- elif soilType == '典型棕壤' or soilType == '白浆化棕壤' or soilType == '潮棕壤' or soilType == '棕壤性土' or soilType == '棕壤性土':
- if (not pd.isna(cationChange)) and (cationChange > 5 and cationChange < 20) and (not pd.isna(bHValue)) and (
- cationChange > 25 and cationChange < 65):
- res = ''
- else:
- res = '存疑:该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
- elif soilType == '典型山地草甸土' or soilType == '山地草原草甸土' or soilType == '山地灌丛草甸土':
- if (not pd.isna(cationChange)) and (cationChange > 10 and cationChange < 20) and (not pd.isna(bHValue)) and (
- bHValue > 15 and bHValue < 30):
- res = ''
- else:
- res = '存疑:该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
- elif soilType == '酸性紫色土' or soilType == '中性紫色土' or soilType == '石灰性紫色土':
- if (not pd.isna(cationChange)) and (cationChange > 10 and cationChange < 20) and (not pd.isna(bHValue)) and (
- bHValue > 50 and bHValue < 70):
- res = ''
- else:
- res = '存疑:该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
- elif soilType == '红色石灰土' or soilType == '黑色石灰土' or soilType == '棕色石灰土' or soilType == '黄色石灰土':
- if (not pd.isna(cationChange)) and (cationChange > 15 and cationChange < 30) and (not pd.isna(bHValue)) and (
- bHValue > 70 and bHValue < 100):
- res = ''
- else:
- res = '存疑:该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
- elif soilType == '酸性石质土' or soilType == '中性石质土' or soilType == '钙质石质土' or soilType == '含盐石质土':
- if (not pd.isna(cationChange)) and (cationChange > 10 and cationChange < 15) and (not pd.isna(bHValue)) and (
- bHValue > 45 and bHValue < 65):
- res = ''
- else:
- res = '存疑:该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
- elif soilType == '酸性粗骨土' or soilType == '中性粗骨土' or soilType == '钙质粗骨土' or soilType == '硅质盐粗骨土':
- if (not pd.isna(cationChange)) and (cationChange > 5 and cationChange < 15) and (not pd.isna(bHValue)) and (
- bHValue > 20 and bHValue < 50):
- res = ''
- else:
- res = '存疑:该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
- elif soilType == '典型潮土' or soilType == '灰潮土' or soilType == '脱潮土' or soilType == '湿潮土' or soilType == '盐化潮土' or soilType == '碱化潮土' or soilType == '灌於潮土':
- if (not pd.isna(cationChange)) and (cationChange > 10 and cationChange < 30) and (not pd.isna(bHValue)) and (
- bHValue > 70 and bHValue < 100):
- res = ''
- else:
- res = '存疑:该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
- elif soilType == '典型砂姜黑土' or soilType == '石灰性砂姜黑土' or soilType == '盐化砂姜黑土' or soilType == '碱化砂姜黑土' or soilType == '黑粘土':
- if (not pd.isna(cationChange)) and (cationChange > 18 and cationChange < 35) and (not pd.isna(bHValue)) and (
- bHValue > 90 and bHValue < 100):
- res = ''
- else:
- res = '存疑:该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
- elif soilType == '淹育水稻土':
- if (not pd.isna(cationChange)) and (cationChange > 20 and cationChange < 30) and (not pd.isna(bHValue)) and (
- bHValue > 85 and bHValue < 90):
- res = ''
- else:
- res = '存疑:该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
- elif soilType == '潴育水稻土':
- if (not pd.isna(cationChange)) and (cationChange > 12 and cationChange < 20) and (not pd.isna(bHValue)) and (
- bHValue > 60 and bHValue < 80):
- res = ''
- else:
- res = '存疑:该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
- elif soilType == '潜育水稻土':
- if (not pd.isna(cationChange)) and (cationChange > 15 and cationChange < 25) and (not pd.isna(bHValue)) and (
- bHValue > 75 and bHValue < 90):
- res = ''
- else:
- res = '存疑:该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
- elif soilType == '漂洗水稻土':
- if (not pd.isna(cationChange)) and (cationChange > 10 and cationChange < 20) and (not pd.isna(bHValue)) and (
- bHValue > 65 and bHValue < 80):
- res = ''
- else:
- res = '存疑:该土壤类型的阳离子交换量或盐基饱和度范围存疑。'
- return res
- def cation_value(arr):
- phList = []
- cationList = []
- exchangeableSalt = []
- exchangeableCa = []
- exchangeableMg = []
- exchangeableK = []
- exchangeableNa = []
- summaryList = []
- soilTypeList = []
- waterMount = []
- phTar = []
- cationTar = []
- exchangeableSaltTar = []
- exchangeableCaTar = []
- exchangeableMgTar = []
- exchangeableKTar = []
- exchangeableNaTar = []
- summaryListTar = []
- soilTypeListTar = []
- waterMountTar = []
- try:
- for index, row in arr.iterrows():
-
- if pd.isna(row['含水量']) or row['含水量'] > 5 or row['含水量'] < 0.5:
- waterMount.append('风干试样含水量(分析基):复核数据合理性。')
- waterMountTar.append('风干试样含水量(分析基)。')
- else:
- waterMount.append('')
- waterMountTar.append('')
-
- if pd.isna(row['pH']) or row['pH'] < 4 or row['pH'] > 9:
- phList.append('pH:复核数据合理性。')
- phTar.append('pH。')
- else:
- phList.append('')
- phTar.append('')
-
- if row['阳离子交换量Cmol(+)/kg'] < 6 or row['阳离子交换量Cmol(+)/kg'] > 38:
- cationList.append('阳离子交换量:复核数据合理性。')
- cationTar.append('阳离子交换量。')
- else:
- cationList.append('')
- cationTar.append('')
-
- if row['交换性盐总量Cmol(+)/kg'] <3 or row['交换性盐总量Cmol(+)/kg'] > 30:
- exchangeableSalt.append('交换性盐基总量:复核数据合理性。')
- exchangeableSaltTar.append('交换性盐总量。')
- else:
- exchangeableSalt.append('')
- exchangeableSaltTar.append('')
-
- if row['交换性钙Cmol(1/2Ca2+)/kg'] < 1 or row['交换性钙Cmol(1/2Ca2+)/kg'] > 25:
- exchangeableCa.append('交换性钙:交换性钙复核数据合理性。')
- exchangeableCaTar.append('交换性钙。')
- else:
- exchangeableCa.append('')
- exchangeableCaTar.append('')
-
- if row['交换性镁cmol(1/2Mg2+)/kg'] < 0.5 or row['交换性镁cmol(1/2Mg2+)/kg'] > 12.5:
- exchangeableMg.append('交换性镁:复核数据合理性。')
- exchangeableMgTar.append('交换性镁。')
- else:
- exchangeableMg.append('')
- exchangeableMgTar.append('')
-
- if row['交换性钾Cmol(+)/kg'] < 0.1 or row['交换性钾Cmol(+)/kg'] > 1.5:
- exchangeableK.append('交换性钾:复核数据合理性。')
- exchangeableKTar.append('交换性钾。')
- else:
- exchangeableK.append('')
- exchangeableKTar.append('')
-
- if row['交换性钠cmol(+)/kg'] < 0.1 or row['交换性钠cmol(+)/kg'] > 2:
- if row['交换性钠cmol(+)/kg'] > 2:
- exchangeableNa.append('交换性钠:复核数据合理性,关联pH审核。')
- exchangeableNaTar.append('交换性钠。')
- else:
- exchangeableNa.append('交换性钠:复核数据合理性。')
- exchangeableNaTar.append('交换性钠。')
- else:
- exchangeableNa.append('')
- exchangeableNaTar.append('')
-
- if ((not pd.isna(row['pH']) and row['pH'] < 6 and (
- row['阳离子交换量Cmol(+)/kg'] > row['交换性盐总量Cmol(+)/kg']) and (
- row['交换性盐总量Cmol(+)/kg'] > row['四大离子之和']) and row['盐基饱和度%'] * 100 < 60) or
- ((not pd.isna(row['pH']) and row['pH'] >= 7.5 and row['交换性盐总量Cmol(+)/kg'] == row[
- '四大离子之和'] and (row['盐基饱和度%'] * 100 < 120 and row['盐基饱和度%'] * 100 > 80))) or
- ((not pd.isna(row['pH']) and row['pH'] >= 6 and row['pH'] < 7.5 and (
- row['阳离子交换量Cmol(+)/kg'] > row['交换性盐总量Cmol(+)/kg']) and (
- row['交换性盐总量Cmol(+)/kg'] > row['四大离子之和']) and row['盐基饱和度%'] * 100 < 85))
- ):
- summaryList.append('')
- summaryListTar.append('')
- else:
- summaryList.append('存疑:pH值、阳离子交换量、交换性盐总量、离子总和、盐基饱和度之间关系存疑。')
- summaryListTar.append('盐基饱和度。')
- soilRes = soilTypeValue(row)
- soilTypeList.append(soilRes)
-
-
-
- checkData = pd.DataFrame({
- '审核结果': 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),
- '异常指标': 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)
- })
- return checkData
- except Exception as err:
- print('阳离子量判断出错!请检查cation_value中判断阳离子量内容', err)
- def eight_ion_coun(arr, summary):
- try:
- allArr = []
- conductivity = []
- naArr = []
- kArr = []
- caArr = []
- mgArr = []
- coArr = []
- cohArr = []
- soArr = []
- clArr = []
- totalCom = []
- phCoArr = []
- changeComArr = []
- rateArr = []
- subtractionArr=[]
-
- allArrTar = []
- conductivityTar = []
- naArrTar = []
- kArrTar = []
- caArrTar = []
- mgArrTar = []
- coArrTar = []
- cohArrTar = []
- soArrTar = []
- clArrTar = []
- totalComTar = []
- phCoArrTar = []
- changeComArrTar = []
- rateArrTar = []
- subtractionArrTar = []
-
- for index, row in arr.iterrows():
- 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):
- allArr.append('全盐量:复核数据合理性。')
- allArrTar.append('全盐量。')
- else:
- allArr.append('')
- allArrTar.append('')
-
- 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):
- conductivity.append('电导率:复核数据合理性。')
- conductivityTar.append('电导率。')
- else:
- conductivity.append('')
- conductivityTar.append('')
-
- 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):
- naArr.append('水溶性钠离子:水溶性钠离子复核数据合理性。')
- naArrTar.append('水溶性钠离子。')
- else:
- naArr.append('')
- naArrTar.append('')
-
- 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):
- kArr.append('水溶性钾离子:复核数据合理性。')
- kArrTar.append('水溶性钾离子。')
- else:
- kArr.append('')
- kArrTar.append('')
-
- 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):
- caArr.append('水溶性钙离子:复核数据合理性。')
- caArrTar.append('水溶性钙离子。')
- else:
- caArr.append('')
- caArrTar.append('')
-
- 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):
- mgArr.append('水溶性镁离子:复核数据合理性。')
- mgArrTar.append('水溶性镁离子。')
- else:
- mgArr.append('')
- mgArrTar.append('')
-
- 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):
- coArr.append('水溶性碳酸根:复核数据合理性。')
- coArrTar.append('水溶性碳酸根。')
- else:
- coArr.append('')
- coArrTar.append('')
-
- 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):
- cohArr.append('水溶性碳酸氢根:复核数据合理性。')
- cohArrTar.append('水溶性碳酸氢根。')
- else:
- cohArr.append('')
- cohArrTar.append('')
-
- 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):
- soArr.append('水溶性硫酸根:复核数据合理性。')
- soArrTar.append('水溶性硫酸根。')
- else:
- soArr.append('')
- soArrTar.append('')
-
- 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):
- clArr.append('水溶性氯根:复核数据合理性。')
- clArrTar.append('水溶性氯根。')
- else:
- clArr.append('')
- clArrTar.append('')
-
- if (not pd.isna( row['水溶性全盐量g/kg']) and not pd.isna(row['八大离子加和g/kg']) and row['水溶性全盐量g/kg'] < row['八大离子加和g/kg']):
- totalCom.append('存疑:水溶性全盐量小于八大离子之和。')
- totalComTar.append('水溶性全盐量。')
- else:
- totalCom.append('')
- totalComTar.append('')
-
-
- if row['pH'] <8 and not pd.isna(row['水溶性碳酸根离子含量cmol(1/2CO32+)/kg']) and row['水溶性碳酸根离子含量cmol(1/2CO32+)/kg'] != 0:
- phCoArr.append('水溶性碳酸根:pH<8水溶性碳酸根不为0。')
- phCoArrTar.append('水溶性碳酸根。')
- else:
- phCoArr.append('')
- phCoArrTar.append('')
-
- naBool = not pd.isna(row['水溶性钠离子含量Cmol(Na+)/kg'])
- kBool = not pd.isna(row['水溶性钾离子含量Cmol(K+)/kg'])
- caBool = not pd.isna(row['水溶性钙离子含量cmol(1/2Ca2+)/kg'])
- mgBool = not pd.isna(row['水溶性镁离子Cmol(1/2Mg2+)/kg'])
- sumNa = not pd.isna(summary.loc[index,'交换性钠'])
- sumK = not pd.isna(summary.loc[index, '交换性钾'])
- sumCa = not pd.isna(summary.loc[index, '交换性钙'])
- sumMg = not pd.isna(summary.loc[index, '交换性镁'])
- if (naBool and sumNa and row['水溶性钠离子含量Cmol(Na+)/kg']>summary.loc[index,'交换性钠']) or (
- kBool and sumK and row['水溶性钾离子含量Cmol(K+)/kg']>summary.loc[index,'交换性钾']) or (
- caBool and sumCa and row['水溶性钙离子含量cmol(1/2Ca2+)/kg']>summary.loc[index,'交换性钙']) or (
- mgBool and sumMg and row['水溶性镁离子Cmol(1/2Mg2+)/kg']>summary.loc[index,'交换性镁']):
- changeComArr.append('存疑:交换性盐基总量低于于水溶性盐离子。')
- else:
- changeComArr.append('')
-
- if not pd.isna(row['(全盐量-水溶性八大离子加和)x2/(全盐量+水溶性八大离子加和)*100']) and (row['(全盐量-水溶性八大离子加和)x2/(全盐量+水溶性八大离子加和)*100'] < -0.2 or row['(全盐量-水溶性八大离子加和)x2/(全盐量+水溶性八大离子加和)*100'] > 0.2) :
- rateArr.append('存疑:全盐量与水溶性八大离子加和的相对相差超过±20%,复核合理性。')
- else:
- rateArr.append('')
-
- if not pd.isna(row['阳离子总量-阴离子总量']) and (row['阳离子总量-阴离子总量'] < -0.5 or row['阳离子总量-阴离子总量'] > 0.5) :
- subtractionArr.append('存疑:阳离子总量 - 阴离子总量复核数据合理性。')
- else:
- subtractionArr.append('')
- resData = pd.DataFrame({
- '审核结果': pd.Series(allArr) + pd.Series(conductivity) + pd.Series(naArr) +
- pd.Series(kArr) + pd.Series(caArr) + pd.Series(mgArr) + pd.Series(coArr) + pd.Series(
- cohArr) + pd.Series(soArr) + pd.Series(clArr) + pd.Series(totalCom) + pd.Series(
- phCoArr) + pd.Series(changeComArr) + pd.Series(rateArr) + pd.Series(subtractionArr),
- '异常指标': pd.Series(allArrTar) + pd.Series(conductivityTar) + pd.Series(naArrTar) +
- pd.Series(kArrTar) + pd.Series(caArrTar) + pd.Series(mgArrTar) + pd.Series(coArrTar) + pd.Series(
- cohArrTar) + pd.Series(soArrTar) + pd.Series(clArrTar) + pd.Series(totalComTar) + pd.Series(
- phCoArrTar)
- })
- return resData
- except Exception as err:
- print('八大离子判断出错!请检查eight_ion_coun中判断离子内容', err)
- def nutrient_data(arr):
- try:
- organicMatter = []
- NArr = []
- PArr = []
- KArr = []
- availableP = []
- availablek = []
- slowlyK= []
- organicRate = []
- availablePCom = []
- availableTxt = []
- availablekCom = []
- sKErr = []
-
- organicMatterTar = []
- NArrTar = []
- PArrTar = []
- KArrTar = []
- availablePTar = []
- availablekTar = []
- slowlyKTar = []
- sKErrTar = []
- for index, row in arr.iterrows():
-
- 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):
- sKErr.append('存疑:交换性钾和速效钾相对相差超过±20%,复核合理性。')
- sKErrTar.append('交换性钾、速效钾。')
- else:
- sKErr.append('')
- sKErrTar.append('')
-
- if row['有机质g/kg'] < 2 or row['有机质g/kg'] >50:
- organicMatter.append('有机质:复核数据合理性。')
- organicMatterTar.append('有机质。')
- else:
- organicMatter.append('')
- organicMatterTar.append('')
-
- if row['全氮g/kg'] < 0.1 or row['全氮g/kg'] > 2.5:
- NArr.append('全氮:复核数据合理性。')
- NArrTar.append('全氮。')
- else:
- NArr.append('')
- NArrTar.append('')
-
- if row['全磷g/kg'] < 0.18 or row['全磷g/kg'] > 1.5:
- PArr.append('全磷:复核数据合理性。')
- PArrTar.append('全磷。')
- else:
- PArr.append('')
- PArrTar.append('')
-
- if row['全钾g/kg'] < 10 or row['全钾g/kg'] > 29:
- KArr.append('全钾:复核数据合理性。')
- KArrTar.append('全钾。')
- else:
- KArr.append('')
- KArrTar.append('')
-
- 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)):
- if (row['pH'] >= 6.5 and row['有效磷g/kg'] > 60) or (row['pH'] < 6.5 and row['有效磷g/kg'] > 50):
- availableP.append('有效磷:复核数据合理性。回溯土地利用类型是否为设施农业。')
- else:
- availableP.append('有效磷:复核数据合理性。')
- availablePTar.append('有效磷。')
- else:
- availableP.append('')
- availablePTar.append('')
-
-
-
-
-
- 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):
- availablek.append('速效钾:复核数据合理性。')
- availablekTar.append('速效钾。')
- else:
- availablek.append('')
- availablekTar.append('')
-
- if row['缓效钾mg/kg'] < 100 or row['缓效钾mg/kg'] > 2000:
- slowlyK.append('缓效钾:复核数据合理性。')
- slowlyKTar.append('缓效钾。')
- else:
- slowlyK.append('')
- slowlyKTar.append('')
-
- if row['有机质g/kg']/row['全氮g/kg'] >=20 or row['有机质g/kg']/row['全氮g/kg'] <=13 :
- organicRate.append('存疑:有机质/全氮比值复核数据合理性。')
- else:
- organicRate.append('')
-
-
-
-
-
-
-
-
-
-
-
-
- if row['速效钾mg/kg'] > row['缓效钾mg/kg']:
- availablekCom.append('异常:速效钾大于缓效钾。')
- else:
- availablekCom.append('')
- resData = pd.DataFrame({
- '审核结果': pd.Series(organicMatter) + pd.Series(NArr) + pd.Series(PArr) +
- pd.Series(KArr) + pd.Series(availableP) + pd.Series(availablek) + pd.Series(slowlyK) + pd.Series(
- organicRate) + pd.Series(availablekCom) + pd.Series(sKErr),
- '异常指标': pd.Series(organicMatterTar) + pd.Series(NArrTar) + pd.Series(PArrTar) +
- pd.Series(KArrTar) + pd.Series(availablePTar) + pd.Series(availablekTar) + pd.Series(slowlyKTar) + pd.Series(sKErrTar)
- })
- return resData
- except Exception as err:
- print('有机质、全氮、全磷、全钾数据判断出错!请检查nutrient_data中判断内容', err)
- def soil_metal(arr):
- try:
- effectiveL = []
- effectiveG = []
- effectiveT = []
- effectiveM = []
- effectiveCu = []
- effectiveX = []
- effectiveP = []
- effectiveMu = []
-
- effectiveLTar = []
- effectiveGTar = []
- effectiveTTar = []
- effectiveMTar = []
- effectiveCuTar = []
- effectiveXTar = []
- effectivePTar = []
- effectiveMutar = []
- for index, row in arr.iterrows():
-
- if (not pd.isna(row['有效硫mg/kg']) and row['有效硫mg/kg'] <2) or (not pd.isna(row['有效硫mg/kg']) and row['有效硫mg/kg'] >60):
- effectiveL.append('有效硫:复核数据合理性。')
- effectiveLTar.append('有效硫。')
- else:
- effectiveL.append('')
- effectiveLTar.append('')
-
- if ( not pd.isna(row['有效硅mg/kg']) and row['有效硅mg/kg'] <10) or (not pd.isna(row['有效硅mg/kg']) and row['有效硅mg/kg'] >500):
- effectiveG.append('有效硅:复核数据合理性。')
- effectiveGTar.append('有效硅。')
- else:
- effectiveG.append('')
- effectiveGTar.append('')
-
- if ( not pd.isna(row['有效铁mg/kg']) and row['有效铁mg/kg'] <5) or (not pd.isna(row['有效铁mg/kg']) and row['有效铁mg/kg'] >300):
- effectiveT.append('有效铁:复核数据合理性。')
- effectiveTTar.append('有效铁。')
- else:
- effectiveT.append('')
- effectiveTTar.append('')
-
- if (not pd.isna(row['有效锰mg/kg']) and row['有效锰mg/kg'] <5) or (not pd.isna(row['有效锰mg/kg']) and row['有效锰mg/kg'] >200) :
- effectiveM.append('有效锰:复核数据合理性。')
- effectiveMTar.append('有效锰。')
- else:
- effectiveM.append('')
- effectiveMTar.append('')
-
- 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):
- effectiveCu.append('有效铜:复核数据合理性。')
- effectiveCuTar.append('有效铜。')
- else:
- effectiveCu.append('')
- effectiveCuTar.append('')
-
- 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):
- effectiveX.append('有效锌:复核数据合理性。')
- effectiveXTar.append('有效锌。')
- else:
- effectiveX.append('')
- effectiveXTar.append('')
-
- 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):
- effectiveP.append('有效硼:复核数据合理性。')
- effectivePTar.append('有效硼。')
- else:
- effectiveP.append('')
- effectivePTar.append('')
-
- 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):
- effectiveMu.append('有效钼:复核数据合理性。')
- effectiveMutar.append('有效钼。')
- else:
- effectiveMu.append('')
- effectiveMutar.append('')
- resData = pd.DataFrame({
- '审核结果': pd.Series(effectiveL) + pd.Series(effectiveT) + pd.Series(effectiveG) +
- pd.Series(effectiveM) + pd.Series(effectiveCu) + pd.Series(effectiveX) + pd.Series(effectiveP) + pd.Series(
- effectiveMu),
- '异常指标': pd.Series(effectiveLTar) + pd.Series(effectiveTTar) + pd.Series(effectiveGTar) +
- pd.Series(effectiveMTar) + pd.Series(effectiveCuTar) + pd.Series(effectiveXTar) + pd.Series(effectivePTar) + pd.Series(
- effectiveMutar)
- })
- return resData
- except Exception as err:
- print('土壤重金属指标数据判断出错!请检查soil_metal中判断内容', err)
- def risk_value(arr):
- unnormalValue = []
- for index, row in arr.iterrows():
- str = ''
- if row['编号'][6:10] == '0101':
-
- if (row['pH'] <= 5.5 and row['镉mg/kg'] > 0.3) or (
- row['pH'] > 5.5 and row['pH']<= 6.5 and row['镉mg/kg'] > 0.4) or (
- row['pH'] >6.5 and row['pH'] <=7.5 and row['镉mg/kg'] > 0.6) or (
- row['pH'] > 7.5 and row['镉mg/kg'] > 0.8):
- str += '镉超污染风险值筛选值。'
-
- if (row['pH'] <= 5.5 and row['汞mg/kg'] > 0.5) or (
- row['pH'] > 5.5 and row['pH'] <= 6.5 and row['汞mg/kg'] > 0.5) or (
- row['pH'] > 6.5 and row['pH'] <= 7.5 and row['汞mg/kg'] > 0.6) or (
- row['pH'] > 7.5 and row['汞mg/kg'] > 1):
- str += '汞超污染风险值筛选值。'
-
- if (row['pH'] <= 5.5 and row['砷mg/kg'] >30) or (
- row['pH'] > 5.5 and row['pH'] <= 6.5 and row['砷mg/kg'] > 30) or (
- row['pH'] > 6.5 and row['pH'] <= 7.5 and row['砷mg/kg'] > 25) or (
- row['pH'] > 7.5 and row['砷mg/kg'] > 20):
- str += '砷超污染风险值筛选值。'
-
- if (row['pH'] <= 5.5 and row['铅mg/kg'] > 80) or (
- row['pH'] > 5.5 and row['pH'] <= 6.5 and row['铅mg/kg'] > 100) or (
- row['pH'] > 6.5 and row['pH'] <= 7.5 and row['铅mg/kg'] > 140) or (
- row['pH'] > 7.5 and row['铅mg/kg'] > 240):
- str += '铅超污染风险值筛选值。'
-
- if (row['pH'] <= 5.5 and row['铬mg/kg'] > 250) or (
- row['pH'] > 5.5 and row['pH'] <= 6.5 and row['铬mg/kg'] > 250) or (
- row['pH'] > 6.5 and row['pH'] <= 7.5 and row['铬mg/kg'] > 300) or (
- row['pH'] > 7.5 and row['铬mg/kg'] >350):
- str += '铬超污染风险值筛选值。'
- else:
-
- if (row['pH'] <= 5.5 and row['镉mg/kg'] > 0.3) or (
- row['pH'] > 5.5 and row['pH']<= 6.5 and row['镉mg/kg'] > 0.3) or (
- row['pH'] >6.5 and row['pH'] <=7.5 and row['镉mg/kg'] > 0.3) or (
- row['pH'] > 7.5 and row['镉mg/kg'] > 0.6):
- str += '镉超污染风险值筛选值。'
-
- if (row['pH'] <= 5.5 and row['汞mg/kg'] > 1.3) or (
- row['pH'] > 5.5 and row['pH'] <= 6.5 and row['汞mg/kg'] > 1.8) or (
- row['pH'] > 6.5 and row['pH'] <= 7.5 and row['汞mg/kg'] > 2.4) or (
- row['pH'] > 7.5 and row['汞mg/kg'] > 3.4):
- str += '汞超污染风险值筛选值。'
-
- if (row['pH'] <= 5.5 and row['砷mg/kg'] > 40) or (
- row['pH'] > 5.5 and row['pH'] <= 6.5 and row['砷mg/kg'] > 40) or (
- row['pH'] > 6.5 and row['pH'] <= 7.5 and row['砷mg/kg'] > 30) or (
- row['pH'] > 7.5 and row['砷mg/kg'] > 25):
- str += '砷超污染风险值筛选值。'
-
- if (row['pH'] <= 5.5 and row['铅mg/kg'] > 70) or (
- row['pH'] > 5.5 and row['pH'] <= 6.5 and row['铅mg/kg'] > 90) or (
- row['pH'] > 6.5 and row['pH'] <= 7.5 and row['铅mg/kg'] > 120) or (
- row['pH'] > 7.5 and row['铅mg/kg'] > 170):
- str += '铅超污染风险值筛选值。'
-
- if (row['pH'] <= 5.5 and row['铬mg/kg'] > 150) or (
- row['pH'] > 5.5 and row['pH'] <= 6.5 and row['铬mg/kg'] > 150) or (
- row['pH'] > 6.5 and row['pH'] <= 7.5 and row['铬mg/kg'] > 200) or (
- row['pH'] > 7.5 and row['铬mg/kg'] > 250):
- str += '铬超污染风险值筛选值。'
- if (row['pH'] <= 5.5 and row['镍mg/kg'] > 60) or (
- row['pH'] > 5.5 and row['pH'] <= 6.5 and row['镍mg/kg'] > 70) or (
- row['pH'] > 6.5 and row['pH'] <= 7.5 and row['镍mg/kg'] > 100) or (
- row['pH'] > 7.5 and row['镍mg/kg'] > 190):
- str += '镍超污染风险值筛选值。'
- unnormalValue.append(str)
- return unnormalValue
- def control_value(arr):
- unnormalValue = []
- for index, row in arr.iterrows():
- str = ''
-
- if (row['pH'] <= 5.5 and row['镉mg/kg'] > 1.5) or (
- row['pH'] > 5.5 and row['pH'] <= 6.5 and row['镉mg/kg'] > 2) or (
- row['pH'] > 6.5 and row['pH'] <= 7.5 and row['镉mg/kg'] > 3) or (
- row['pH'] > 7.5 and row['镉mg/kg'] > 4):
- str += '镉超污染风险值管制值。'
-
- if (row['pH'] <= 5.5 and row['汞mg/kg'] > 2) or (
- row['pH'] > 5.5 and row['pH'] <= 6.5 and row['汞mg/kg'] > 2.5) or (
- row['pH'] > 6.5 and row['pH'] <= 7.5 and row['汞mg/kg'] > 4) or (
- row['pH'] > 7.5 and row['汞mg/kg'] > 6):
- str += '汞超污染风险值管制值。'
-
- if (row['pH'] <= 5.5 and row['砷mg/kg'] > 200) or (
- row['pH'] > 5.5 and row['pH'] <= 6.5 and row['砷mg/kg'] > 150) or (
- row['pH'] > 6.5 and row['pH'] <= 7.5 and row['砷mg/kg'] > 120) or (
- row['pH'] > 7.5 and row['砷mg/kg'] > 100):
- str += '砷超污染风险值管制值。'
-
- if (row['pH'] <= 5.5 and row['铅mg/kg'] >400) or (
- row['pH'] > 5.5 and row['pH'] <= 6.5 and row['铅mg/kg'] > 500) or (
- row['pH'] > 6.5 and row['pH'] <= 7.5 and row['铅mg/kg'] > 700) or (
- row['pH'] > 7.5 and row['铅mg/kg'] > 1000):
- str += '铅超污染风险值管制值。'
-
- if (row['pH'] <= 5.5 and row['铬mg/kg'] > 800) or (
- row['pH'] > 5.5 and row['pH'] <= 6.5 and row['铬mg/kg'] > 850) or (
- row['pH'] > 6.5 and row['pH'] <= 7.5 and row['铬mg/kg'] > 1000) or (
- row['pH'] > 7.5 and row['铬mg/kg'] > 1300):
- str += '铬超污染风险值管制值。'
- unnormalValue.append(str)
- return unnormalValue
- def last_metal(arr):
- try:
- totalGe = []
- totalGo = []
- totalShen = []
- totalPb = []
- totalG = []
- totalN = []
-
- totalGeTar = []
- totalGoTar = []
- totalShenTar = []
- totalPbTar = []
- totalGTar = []
- totalNTar = []
-
- overValue = risk_value(arr)
-
- overLimit = control_value(arr)
- for index, row in arr.iterrows():
-
- if (row['镉mg/kg'] < 0.03 or row['镉mg/kg'] > 0.3):
- totalGe.append('总镉:复核数据合理性。')
- totalGeTar.append('总镉。')
- else:
- totalGe.append('')
- totalGeTar.append('')
-
- if (row['汞mg/kg'] < 0.01 or row['汞mg/kg'] > 0.3):
- totalGo.append('总汞:复核数据合理性。')
- totalGoTar.append('总汞。')
- else:
- totalGo.append('')
- totalGoTar.append('')
-
- if (row['砷mg/kg'] < 0.5 or row['砷mg/kg'] > 30):
- totalShen.append('总砷:复核数据合理性。')
- totalShenTar.append('总砷。')
- else:
- totalShen.append('')
- totalShenTar.append('')
-
- if (row['铅mg/kg'] < 2 or row['铅mg/kg'] > 100):
- totalPb.append('总铅:复核数据合理性。')
- totalPbTar.append('总铅。')
- else:
- totalPb.append('')
- totalPbTar.append('')
-
- if row['铬mg/kg'] < 0.4 or row['铬mg/kg'] > 200:
- totalG.append('总铬:复核数据合理性。')
- totalGTar.append('总铬。')
- else:
- totalG.append('')
- totalGTar.append('')
-
- if (row['镍mg/kg'] < 0.3 or row['镍mg/kg'] > 100):
- totalN.append('总镍:复核数据合理性。')
- totalNTar.append('总镍。')
- else:
- totalN.append('')
- totalNTar.append('')
- resData = pd.DataFrame({
- '审核结果': pd.Series(overValue) + pd.Series(overLimit) + pd.Series(totalGe) +
- pd.Series(totalGo) + pd.Series(totalShen) + pd.Series(totalPb) + pd.Series(
- totalG) + pd.Series(totalN),
- '异常指标': pd.Series(totalGeTar) + pd.Series(totalGoTar) + pd.Series(totalShenTar) + pd.Series(totalPbTar) + pd.Series(
- totalGTar) + pd.Series(totalNTar)
- })
- return resData
- except Exception as err:
- print('土壤重金属指标数据判断出错!请检查last_metal中判断内容', err)
- def sectionData(arr):
- errArr_LIU = []
- errArr_GUI = []
- errArr_GAI = []
- errArr_MEI = []
- errArr_LV = []
- errArr_FE = []
- errArr_MENG = []
- errArr_CU = []
- errArr_ZN = []
- errArr_PENG = []
- errArr_MU = []
- errArr_CACO3 = []
- errArr_YFE = []
- changeS = []
- waterS = []
- changeH = []
- changeAl = []
- caco3_empty = []
-
- errArr_LIU_Tar = []
- errArr_GUI_Tar = []
- errArr_GAI_Tar = []
- errArr_MEI_Tar = []
- errArr_LV_Tar = []
- errArr_FE_Tar = []
- errArr_MENG_Tar = []
- errArr_CU_Tar = []
- errArr_ZN_Tar = []
- errArr_PENG_Tar = []
- errArr_MU_Tar = []
- errArr_CACO3_Tar = []
- errArr_YFE_Tar = []
- changeS_Tar = []
- waterS_Tar = []
- changeH_Tar = []
- changeAl_Tar = []
- caco3_empty_Tar = []
- for index, row in arr.iterrows():
- if row['全硫'] < 0.1 or row['全硫'] > 5:
- errArr_LIU.append('全硫:复核数据合理性。')
- errArr_LIU_Tar.append('全硫。')
- else:
- errArr_LIU.append('')
- errArr_LIU_Tar.append('')
- if (row['全硅'] < 18 or row['全硅'] > 30):
- errArr_GUI.append('全硅:复核数据合理性。')
- errArr_GUI_Tar.append('全硅。')
- else:
- errArr_GUI.append('')
- errArr_GUI_Tar.append('')
- if (row['全钙'] <0.05 or row['全钙']>5):
- errArr_GAI.append('全钙:复核数据合理性。')
- errArr_GAI_Tar.append('全钙。')
- else:
- errArr_GAI.append('')
- errArr_GAI_Tar.append('')
- if (row['全镁'] <0.3 or row['全镁'] > 4):
- errArr_MEI.append('全镁:复核数据合理性。')
- errArr_MEI_Tar.append('全镁。')
- else:
- errArr_MEI.append('')
- errArr_MEI_Tar.append('')
- if (row['全铝'] < 4 or row['全铝'] > 12):
- errArr_LV.append('全铝:复核数据合理性。')
- errArr_LV_Tar.append('全铝。')
- else:
- errArr_LV.append('')
- errArr_LV_Tar.append('')
- if row['全铁'] < 2 or row['全铁'] > 6:
- errArr_FE.append('全铁:复核数据合理性。')
- errArr_FE_Tar.append('全铁。')
- else:
- errArr_FE.append('')
- errArr_FE_Tar.append('')
- if (row['全锰'] < 100 or row['全锰'] > 2500):
- errArr_MENG.append('全锰:复核数据合理性。')
- errArr_MENG_Tar.append('全锰。')
- else:
- errArr_MENG.append('')
- errArr_MENG_Tar.append('')
- if (row['全铜'] < 6 or row['全铜'] > 150):
- errArr_CU.append('全铜:复核数据合理性。')
- errArr_CU_Tar.append('全铜。')
- else:
- errArr_CU.append('')
- errArr_CU_Tar.append('')
- if (row['全锌'] < 15 or row['全锌'] > 300):
- errArr_ZN.append('全锌:复核数据合理性。')
- errArr_ZN_Tar.append('全锌。')
- else:
- errArr_ZN.append('')
- errArr_ZN_Tar.append('')
- if (row['全硼'] < 12 or row['全硼'] > 75):
- errArr_PENG.append('全硼:复核数据合理性。')
- errArr_PENG_Tar.append('全硼。')
- else:
- errArr_PENG.append('')
- errArr_PENG_Tar.append('')
- if row['全钼'] < 0.1 or row['全钼'] > 7:
- errArr_MU.append('全钼:复核数据合理性。')
- errArr_MU_Tar.append('全钼。')
- else:
- errArr_MU.append('')
- errArr_MU_Tar.append('')
- if (row['碳酸钙'] < 5 or row['碳酸钙'] > 100):
- errArr_CACO3.append('碳酸钙:复核数据合理性。')
- errArr_CACO3_Tar.append('碳酸钙。')
- else:
- errArr_CACO3.append('')
- errArr_CACO3_Tar.append('')
- if row['游离铁'] < 25 or row['游离铁'] > 40:
- errArr_YFE.append('游离铁:复核数据合理性。')
- errArr_YFE_Tar.append('游离铁。')
- else:
- errArr_YFE.append('')
- errArr_YFE_Tar.append('')
- if row['交换性酸总量'] < 0.1 or row['交换性酸总量'] > 10:
- changeS.append('交换性酸总量:复核数据合理性。')
- changeS_Tar.append('交换性酸总量。')
- else:
- changeS.append('')
- changeS_Tar.append('')
- if row['水解性总酸度'] < 0.1 or row['水解性总酸度'] > 15:
- waterS.append('水解性总酸度:复核数据合理性。')
- waterS_Tar.append('水解性总酸度。')
- else:
- waterS.append('')
- waterS_Tar.append('')
- if row['交换性H⁺'] < 0.05 or row['交换性H⁺'] > 5:
- changeH.append('交换性H⁺:复核数据合理性。')
- changeH_Tar.append('交换性H⁺。')
- else:
- changeH.append('')
- changeH_Tar.append('')
- if row['交换性Al³⁺'] < 0.05 or row['交换性Al³⁺'] > 6:
- changeAl.append('交换性Al³⁺:复核数据合理性。')
- changeAl_Tar.append('交换性Al³⁺。')
- else:
- changeAl.append('')
- changeAl_Tar.append('')
- if row['pH'] > 7 and pd.isna(row['碳酸钙']):
- caco3_empty.append('碳酸钙:ph大于7碳酸钙未检测。')
- caco3_empty_Tar.append('碳酸钙。')
- else:
- caco3_empty.append('')
- caco3_empty_Tar.append('')
- resData = pd.DataFrame({
- '审核结果': pd.Series(errArr_LIU) + pd.Series(errArr_GUI) + pd.Series(errArr_GAI) +
- pd.Series(errArr_MEI) + pd.Series(errArr_LV) + pd.Series(errArr_FE) + pd.Series(
- errArr_MENG) + pd.Series(errArr_CU) + pd.Series(errArr_ZN) + pd.Series(errArr_PENG)+ pd.Series(errArr_MU)
- + pd.Series(errArr_CACO3) + pd.Series(errArr_YFE) + pd.Series(changeS) + pd.Series(waterS) + pd.Series(caco3_empty),
- '异常指标': pd.Series(errArr_LIU_Tar) + pd.Series(errArr_GUI_Tar) + pd.Series(errArr_GAI_Tar) +
- pd.Series(errArr_MEI_Tar) + pd.Series(errArr_LV_Tar) + pd.Series(errArr_FE_Tar) + pd.Series(
- errArr_MENG_Tar) + pd.Series(errArr_CU_Tar) + pd.Series(errArr_ZN_Tar) + pd.Series(errArr_PENG_Tar)+ pd.Series(errArr_MU_Tar)
- + pd.Series(errArr_CACO3_Tar) + pd.Series(errArr_YFE_Tar) + pd.Series(changeS_Tar) + pd.Series(waterS_Tar) + pd.Series(caco3_empty_Tar)
- })
- return resData
|