shZhang_HuaWeiMatebookD il y a 1 mois
Parent
commit
2082a8bd9b
4 fichiers modifiés avec 81 ajouts et 81 suppressions
  1. 5 5
      partReport.py
  2. 68 68
      public.py
  3. 1 1
      report.py
  4. 7 7
      rongzhong.py

+ 5 - 5
partReport.py

@@ -1116,10 +1116,10 @@ def getConventionalNutrientIndicators(originData,data,type, changeFileUrl, saveF
     paragraph_t_2.add_run(f'图2:有机质与全氮相关关系').bold = True
     paragraph_t_2.alignment = WD_ALIGN_PARAGRAPH.CENTER
 
-    # 插入氮比异常数据
+    # 插入有机质全氮比异常数据
     if not table_10_data.empty:
         paragraph_10 = doc.add_paragraph()
-        paragraph_10.add_run('表9:氮比异常数据统计表').bold = True
+        paragraph_10.add_run('表9:有机质全氮比异常数据统计表').bold = True
         table_10 = doc.add_table(rows=len(table_10_data) + 1, cols=8, style='Light Shading Accent 1')
         paragraph_10.alignment = WD_ALIGN_PARAGRAPH.CENTER
         table_10.alignment = WD_TABLE_ALIGNMENT.CENTER
@@ -1741,10 +1741,10 @@ def getChemicalIndicators(originData,data,type, changeFileUrl, saveFileUrl, chec
     paragraph_t_12.add_run(f'图12:全盐量与电导率相关性散点图').bold = True
     paragraph_t_12.alignment = WD_ALIGN_PARAGRAPH.CENTER
 
-    if os.path.isfile(f'{mkdir_path}/离子总量与水溶性盐总量关系图.png'):
-        doc.add_picture(f'{mkdir_path}/离子总量与水溶性盐总量关系图.png', width=Inches(6.0))
+    if os.path.isfile(f'{mkdir_path}/全盐量与离子总量相关性散点图.png'):
+        doc.add_picture(f'{mkdir_path}/全盐量与离子总量相关性散点图.png', width=Inches(6.0))
     paragraph_t_13 = doc.add_paragraph()
-    paragraph_t_13.add_run(f'图13:水溶性盐总量与离子总量关系分析图').bold = True
+    paragraph_t_13.add_run(f'图13:全盐量与离子总量相关性散点图').bold = True
     paragraph_t_13.alignment = WD_ALIGN_PARAGRAPH.CENTER
 
     doc.add_heading('四、审核存疑数据', level=1)

+ 68 - 68
public.py

@@ -51,66 +51,66 @@ def soil_bulk_density(arr): #arr为计算过的数组
         print('颗粒含量加和判断出错!请检查soil_bulk_density中判断颗粒含量加和内容',err)
     # 根据国际土壤质地类型三角形编程实现对质地的分类→判断质地分类和质地名称是否正确
     # 判断土壤类型逻辑:
-    soilList = []  # 定义一个数组存放土地类型的数据
-    soilContent = []
-    soilContentTarget = [] # 存放土壤质地异常的指标名称
-    xSLErr = []  # 存放ph>7 洗失量为空的异常数据
-    xSLTarget = []  # 存放异常数据 指标名称
-    try:
-        # 按行循环读取所有数据
-        for index, row in arr.iterrows():
-            # 1.将0.02-0.2,0.2-2两列加起来
-            plusSoil = row['0.2-0.02mm颗粒含量%'] + row['2-0.2mm颗粒含量%']
-            small_002_list = row['0.02-0.002mm颗粒含量%']
-            small_0002_list = row['0.002mm以下颗粒含量%']
-            if np.isnan(plusSoil) or np.isnan(small_002_list) or np.isnan(small_0002_list):
-                soilList.append('')
-            # 具体判断 这里为了方便看 减少了嵌套逻辑
-            elif small_0002_list >=65 and  small_0002_list <100: # 2. <0.002含量 65-100 ->重黏土
-                soilList.append('重黏土')
-            elif small_0002_list >= 45 and small_0002_list <65: # 3.<0.002含量 45-65 ->黏土
-                soilList.append('黏土')
-            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 -> 粉(砂)质黏土
-                soilList.append('粉(砂)质黏土')
-            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-> 壤质黏土
-                soilList.append('壤质黏土')
-            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-> 砂质黏土
-                soilList.append('砂质黏土')
-            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 -> 粉(砂)质黏壤土
-                soilList.append('粉(砂)质黏壤土')
-            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-> 黏壤土
-                soilList.append('黏壤土')
-            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-> 砂质黏壤土
-                soilList.append('砂质黏壤土')
-            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 ->粉(砂)质壤土
-                soilList.append('粉(砂)质壤土')
-            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-> 壤土
-                soilList.append('壤土')
-            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-> 砂质壤土
-                soilList.append('砂质壤土')
-            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-> 砂土及壤质砂土
-                soilList.append('砂土及壤质砂土')
-            else:
-                soilList.append('') # 除所有情况外 还有空值
-
-        # 比较和原有数据是否一致
-        arr['土壤质地(判断)'] = soilList
-        for index, row in arr.iterrows():
-            if (row['土壤质地(判断)'] != row['土壤质地']) and (not pd.isna(row['土壤质地'])):
-                soilContent.append('存疑:土壤质地填报与判断不一致')
-                soilContentTarget.append('土壤质地。')
-            else:
-                soilContent.append('')
-                soilContentTarget.append('')
-            # 如果pH>7,则洗失量数据不能为空;
-            if (not pd.isna(row['pH']) and row['pH'] > 7 and pd.isna(row['洗失量(吸管法需填)%'])):
-                xSLErr.append('洗失量:ph>7但洗失量未检测。')
-                xSLTarget.append('洗失量。')
-            else:
-                xSLErr.append('')
-                xSLTarget.append('')
-    except Exception as err:
-        print('土壤类型判断出错!请检查soil_bulk_density中判断土壤类型内容', err)
+    # soilList = []  # 定义一个数组存放土地类型的数据
+    # soilContent = []
+    # soilContentTarget = [] # 存放土壤质地异常的指标名称
+    # xSLErr = []  # 存放ph>7 洗失量为空的异常数据
+    # xSLTarget = []  # 存放异常数据 指标名称
+    # try:
+    #     # 按行循环读取所有数据
+    #     for index, row in arr.iterrows():
+    #         # 1.将0.02-0.2,0.2-2两列加起来
+    #         plusSoil = row['0.2-0.02mm颗粒含量%'] + row['2-0.2mm颗粒含量%']
+    #         small_002_list = row['0.02-0.002mm颗粒含量%']
+    #         small_0002_list = row['0.002mm以下颗粒含量%']
+    #         if np.isnan(plusSoil) or np.isnan(small_002_list) or np.isnan(small_0002_list):
+    #             soilList.append('')
+    #         # 具体判断 这里为了方便看 减少了嵌套逻辑
+    #         elif small_0002_list >=65 and  small_0002_list <100: # 2. <0.002含量 65-100 ->重黏土
+    #             soilList.append('重黏土')
+    #         elif small_0002_list >= 45 and small_0002_list <65: # 3.<0.002含量 45-65 ->黏土
+    #             soilList.append('黏土')
+    #         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 -> 粉(砂)质黏土
+    #             soilList.append('粉(砂)质黏土')
+    #         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-> 壤质黏土
+    #             soilList.append('壤质黏土')
+    #         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-> 砂质黏土
+    #             soilList.append('砂质黏土')
+    #         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 -> 粉(砂)质黏壤土
+    #             soilList.append('粉(砂)质黏壤土')
+    #         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-> 黏壤土
+    #             soilList.append('黏壤土')
+    #         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-> 砂质黏壤土
+    #             soilList.append('砂质黏壤土')
+    #         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 ->粉(砂)质壤土
+    #             soilList.append('粉(砂)质壤土')
+    #         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-> 壤土
+    #             soilList.append('壤土')
+    #         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-> 砂质壤土
+    #             soilList.append('砂质壤土')
+    #         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-> 砂土及壤质砂土
+    #             soilList.append('砂土及壤质砂土')
+    #         else:
+    #             soilList.append('') # 除所有情况外 还有空值
+    #
+    #     # 比较和原有数据是否一致
+    #     arr['土壤质地(判断)'] = soilList
+    #     for index, row in arr.iterrows():
+    #         if (row['土壤质地(判断)'] != row['土壤质地']) and (not pd.isna(row['土壤质地'])):
+    #             soilContent.append('存疑:土壤质地填报与判断不一致')
+    #             soilContentTarget.append('土壤质地。')
+    #         else:
+    #             soilContent.append('')
+    #             soilContentTarget.append('')
+    #         # 如果pH>7,则洗失量数据不能为空;
+    #         if (not pd.isna(row['pH']) and row['pH'] > 7 and pd.isna(row['洗失量(吸管法需填)%'])):
+    #             xSLErr.append('洗失量:ph>7但洗失量未检测。')
+    #             xSLTarget.append('洗失量。')
+    #         else:
+    #             xSLErr.append('')
+    #             xSLTarget.append('')
+    # except Exception as err:
+    #     print('土壤类型判断出错!请检查soil_bulk_density中判断土壤类型内容', err)
     # 把存疑数据组合并返回
     # print('shenHeList--',shenHeList,len(shenHeList))
     # print('plusShenHeList--', plusShenHeList, len(plusShenHeList))
@@ -118,15 +118,15 @@ def soil_bulk_density(arr): #arr为计算过的数组
     # print('soilContent--', soilContent, len(soilContent))
     # print('soilList--', soilList, len(soilList))
     pdData = pd.DataFrame({
-        '审核结果': pd.Series(shenHeList) + pd.Series(tRTypeList) + pd.Series(plusShenHeList) + pd.Series(soilContent) + pd.Series(xSLErr),
-        '土壤质地(判断)': soilList,
-        '异常指标': pd.Series(shenHeTarget) + pd.Series(tRTypeTarget) + pd.Series(plusShenHeTarget) + pd.Series(soilContentTarget) + pd.Series(xSLTarget),
+        '审核结果': pd.Series(shenHeList) + pd.Series(tRTypeList) + pd.Series(plusShenHeList),
+        #'土壤质地(判断)': soilList,
+        '异常指标': pd.Series(shenHeTarget) + pd.Series(tRTypeTarget) + pd.Series(plusShenHeTarget),
     })
     return pdData
 # 这是一个判断范围的函数 如果需要修改范围 修改start end值就行
 
-def is_not_in_range(value):
-    return value <30 or value > 90
+# def is_not_in_range(value):
+#     return value <30 or value > 90
 
 
 # 表3 水稳性大团聚体规则判断函数
@@ -409,7 +409,7 @@ def cation_value(arr):
                 summaryList.append('')
                 summaryListTar.append('')
             else:
-                summaryList.append('存疑:PH值、阳离子交换量、交换性盐总量、离子总和、盐基饱和度之间关系存疑。')
+                summaryList.append('存疑:pH值、阳离子交换量、交换性盐总量、离子总和、盐基饱和度之间关系存疑。')
                 summaryListTar.append('盐基饱和度。')
             soilRes = soilTypeValue(row)
             soilTypeList.append(soilRes)
@@ -561,8 +561,8 @@ def eight_ion_coun(arr, summary):
                 changeComArr.append('存疑:交换性盐基总量低于于水溶性盐离子。')
             else:
                 changeComArr.append('')
-            #(16)(水溶性全盐量 - 八大离子加和) / 八大离子加和 * 100,不超过±20 %
-            if not pd.isna(row['(水溶性全盐量-八大离子加和)/水溶性全盐量×100']) and (row['(水溶性全盐量-八大离子加和)/水溶性全盐量×100'] < -0.2 or row['(水溶性全盐量-八大离子加和)/水溶性全盐量×100'] > 0.2) :
+            #(16)(全盐量-水溶性八大离子加和)x2/(全盐量+水溶性八大离子加和)*100,不超过±20 %
+            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('')

+ 1 - 1
report.py

@@ -1031,7 +1031,7 @@ def manyTypes(data,url):
         #要增加对指标值是否缺失进行判断,都不缺失绘图
         getInteractiveImg(x2, y2, '离子总量', x2, y3, '水溶性盐总量', x2, y4,
                       '离子总量与水溶性盐总量之差', url,
-                      '水溶性盐总量与离子总量相关性散点图', '样品数量', '离子总量/水溶性盐总量(g/kg)', data['原样品编号'])
+                      '全盐量与离子总量相关性散点图', '样品数量', '离子总量/水溶性盐总量(g/kg)', data['原样品编号'])
 
 
 

+ 7 - 7
rongzhong.py

@@ -352,7 +352,7 @@ def checkData(fileUrl):
                 resData = resData.reset_index(drop=True)
                 resData['审核结果'] = table_1_res['审核结果']
                 global table_1_data
-                table_1_data_res = resData[resData['土壤质地'] != resData['土壤质地(判断)']]
+                #table_1_data_res = resData[resData['土壤质地'] != resData['土壤质地(判断)']]
                 table_1_data = resData
                 # 提取异常指标数据
                 global table_1_index
@@ -369,8 +369,8 @@ def checkData(fileUrl):
                 table_1_index['指标'] = table_1_res['异常指标']
                 table_1_index['原因'] = table_1_res['审核结果']
                 # 这里数据直接使用即可(土壤质地填报)todo
-                del resData['土壤质地(判断)']
-                resData.insert(loc=6, column='土壤质地(判断)', value=table_1_res['土壤质地(判断)'])
+                #del resData['土壤质地(判断)']
+                #resData.insert(loc=6, column='土壤质地(判断)', value=table_1_res['土壤质地(判断)'])
                 global resData_1_Style
                 resData_1_Style = resData.style.apply(highlight_condition,axis=1)
                 # 表2--------------------------表2 土壤容重与机械组成总体数据频度分析----------------------------------------
@@ -509,7 +509,7 @@ def checkData(fileUrl):
                     '水溶性碳酸氢离子含量cmol(1/2HCO3-)/kg': hcoArr,
                     '水溶性硫酸根离子含量cmol(1/2SO42-)/kg': soArr,
                     '八大离子加和g/kg': eightPlusArr,
-                    '(水溶性全盐量-八大离子加和)/水溶性全盐量×100': 2*(allArr - eightPlusArr) / (allArr + eightPlusArr) * 100, #/已改:分母水溶性全盐量二者均值
+                    '(全盐量-水溶性八大离子加和)x2/(全盐量+水溶性八大离子加和)*100': 2*(allArr - eightPlusArr) / (allArr + eightPlusArr) * 100, #/已改:分母水溶性全盐量二者均值
                     '离子总量g/kg': filter_number(simpleData['离子总量']),
                     '阳离子总量-阴离子总量': totalCations - totalAnions,
                     '土地利用类型': simpleData['土地利用类型']
@@ -1179,10 +1179,10 @@ def getReport(originData,data,changeFileUrl, saveFileUrl, check_1_data,
     paragraph_t_12.add_run(f'图12:全盐量与电导率相关性散点图').bold = True
     paragraph_t_12.alignment = WD_ALIGN_PARAGRAPH.CENTER
 
-    if os.path.isfile(f'{mkdir_path}/水溶性盐总量与离子总量相关性散点图.png'):
-        doc.add_picture(f'{mkdir_path}/水溶性盐总量与离子总量相关性散点图.png', width=Inches(6.0))
+    if os.path.isfile(f'{mkdir_path}/全盐量与离子总量相关性散点图.png'):
+        doc.add_picture(f'{mkdir_path}/全盐量与离子总量相关性散点图.png', width=Inches(6.0))
     paragraph_t_13 = doc.add_paragraph()
-    paragraph_t_13.add_run(f'图13:水溶性盐总量与离子总量相关性散点图').bold = True
+    paragraph_t_13.add_run(f'图13:全盐量与离子总量相关性散点图').bold = True
     paragraph_t_13.alignment = WD_ALIGN_PARAGRAPH.CENTER
 
     doc.add_heading('四、审核存疑数据', level=1)