Browse Source

修改阈值及存疑表

Kejl 3 tuần trước cách đây
mục cha
commit
0c1d8629ef
1 tập tin đã thay đổi với 14 bổ sung11 xóa
  1. 14 11
      public.py

+ 14 - 11
public.py

@@ -36,12 +36,12 @@ def soil_bulk_density(arr): #arr为计算过的数组
                 tRTypeTarget.append('')
     except Exception as err:
         print('相对极差判断、土壤利用类型判断出错!请检查soil_bulk_density中判断相对极差判断、土壤利用类型内容',err)
-    # (3)加和不在[99.98, 100.02]范围内的,存疑
+    # (3)加和不在[99, 101]范围内的,存疑
     plusShenHeList = [] # 定义一个数组存放加和存疑的数据
     plusShenHeTarget = [] # 保存土壤颗粒加和存疑的指标
     try:
         for i in arr['加和%']:
-            if float(i) > 100.02 or float(i) < 99.98:
+            if float(i) > 101 or float(i) < 99:
                 plusShenHeList.append('土壤颗粒加和:复核数据合理性。')
                 plusShenHeTarget.append('土壤颗粒含量加和。')
             else:
@@ -402,9 +402,9 @@ def cation_value(arr):
                 exchangeableNa.append('')
                 exchangeableNaTar.append('')
             # (8)pH<7.5,阳离子交换量>交换性盐总量>四大离子之和,且盐基饱和度小于100 %;违反则存疑;pH≥7.5,交换性盐总量 = 四大离子之和,盐基饱和度范围在80~120 %;违反则存疑;
-            if ((not pd.isna(row['pH']) and row['pH']<7.5 and (row['阳离子交换量Cmol(+)/kg']>row['交换性盐总量Cmol(+)/kg']) and (row['交换性盐总量Cmol(+)/kg']>row['四大离子之和']) and row['盐基饱和度%']*100 <100 ) or
+            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['盐基饱和度%'] >80))
+                ((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('')
@@ -646,8 +646,11 @@ def nutrient_data(arr):
                 KArr.append('')
                 KArrTar.append('')
             #(6)有效磷在[1, 50]范围之外的;存疑; 耕地 超过80存疑
-            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) or (row['编号'][6:10] == '0101' or row['编号'][6:10] == '0102' or row['编号'][6:10] == '0103') and row['有效磷g/kg'] > 60) :
-                availableP.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('')
@@ -682,10 +685,10 @@ def nutrient_data(arr):
             #     availablePCom.append('有效磷:复核数据合理性。')
             # else:
             #     availablePCom.append('')
-            if row['速效钾mg/kg'] < 50:
-                availableTxt.append('速效钾:复核数据合理性。')
-            else:
-                availableTxt.append('')
+            # if row['速效钾mg/kg'] < 50:
+            #     availableTxt.append('速效钾:复核数据合理性。')
+            # else:
+            #     availableTxt.append('')
             #(13)速效钾>缓效钾,提示异常
             if row['速效钾mg/kg'] > row['缓效钾mg/kg']:
                 availablekCom.append('异常:速效钾大于缓效钾。')
@@ -694,7 +697,7 @@ def nutrient_data(arr):
         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(availablePCom) + pd.Series(availablekCom) + pd.Series(availableTxt) + pd.Series(availablePCom) + pd.Series(sKErr),
+                    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)
         })