JustDreamer7 2 gadi atpakaļ
vecāks
revīzija
48efbe8e63
6 mainītis faili ar 337 papildinājumiem un 366 dzēšanām
  1. 20 15
      report_prisma_32.py
  2. 13 6
      drawing_graphs.py
  3. 290 0
      make_report_prisma.py
  4. 12 36
      processing_for_report.py
  5. 0 307
      testing.py
  6. 2 2
      word_addition.py

+ 20 - 15
report_prisma_32.py

@@ -1,14 +1,14 @@
-import os
 import datetime
-from PyQt6 import QtCore, QtWidgets
+import os
 
+from PyQt6 import QtCore, QtWidgets
 
 from interfaces.clientui import Ui_MainWindow
 from interfaces.drctryChoice import Ui_drctryChoice
 from interfaces.takeFiles import Ui_takeFiles
+from make_report_prisma import make_report_prisma
 
-
-class ReportPrisma32(QtWidgets.QMainWindow, Ui_MainWindow):
+class UIReportPrisma32(QtWidgets.QMainWindow, Ui_MainWindow):
     def __init__(self):
         super().__init__()
         self.widget = QtWidgets.QWidget()
@@ -21,7 +21,7 @@ class ReportPrisma32(QtWidgets.QMainWindow, Ui_MainWindow):
                                              int(str(datetime.datetime.today()).split(' ')[0].split('-')[1]),
                                              int(str(datetime.datetime.today()).split(' ')[0].split('-')[2])))
         self.dateEdit_2.setDisplayFormat("dd.MM.yyyy")
-        self.dateEdit.setDate(QtCore.QDate(2020, 1, 1))
+        self.dateEdit.setDate(QtCore.QDate(int(str(datetime.datetime.today()).split(' ')[0].split('-')[0]), 1, 1))
         self.dateEdit.setDisplayFormat("dd.MM.yyyy")
 
     def open_file_directory(self):
@@ -62,16 +62,16 @@ class ReportPrisma32(QtWidgets.QMainWindow, Ui_MainWindow):
 
     def report_on_click(self):
         """Метод, описывающий получение паспорта с помощью данных UI"""
-        start_date = self.dateEdit.dateTime()
-        end_date = self.dateEdit_2.dateTime()
+        start_date = self.dateEdit.date().toPyDate()
+        end_date = self.dateEdit_2.date().toPyDate()
         print(f'start_date - {start_date}, \n end_date - {end_date}')
         with open('path_prisma_report.txt', 'r') as f:
             report_path = f.read()
-        picture_path = report_path + '/Pics'
+        picture_path = report_path + '/Pics' + f'/{start_date.year}'
         with open('path_prisma_1cl_files.txt', 'r') as f:
-            file1cl = f.read()
+            path_to_files_1 = f.read()
         with open('path_prisma_2cl_files.txt', 'r') as f:
-            file2cl = f.read()
+            path_to_files_2 = f.read()
         if ~os.path.exists(picture_path):
             try:
                 os.mkdir(picture_path)
@@ -80,15 +80,20 @@ class ReportPrisma32(QtWidgets.QMainWindow, Ui_MainWindow):
             else:
                 print(f"Успешно создана директория {picture_path}")
 
-        # проверяем нормальные даты или нет, если да, то графики и word файл строятся
         try:
-            pass
-        except ZeroDivisionError:
-            pass
+            make_report_prisma(start_date=start_date, end_date=end_date, report_path=report_path, picture_path=picture_path,
+                               path_to_files_1=path_to_files_1, path_to_files_2 = path_to_files_2)
+        except PermissionError:
+            print("Закройте предыдущую версию файла!")
+        # проверяем нормальные даты или нет, если да, то графики и word файл строятся
+        # try:
+        #     pass
+        # except ZeroDivisionError:
+        #     pass
 
 
 # запуск основного окна
 app = QtWidgets.QApplication([])
-window = ReportPrisma32()
+window = UIReportPrisma32()
 window.show()
 app.exec()

+ 13 - 6
drawing_graphs.py

@@ -11,6 +11,10 @@ class GraphsDrawing:
                     'edgecolor': 'red',  # цвет крайней линии
                     'boxstyle': 'round'}
 
+    def __del__(self):
+        """Деструктор, закрывающий все объекты Figure, созданные в процессе работы класса."""
+        plt.close('all')
+
     @staticmethod
     def change_design():
         """Метод, который должен применяться вначале, для изменения размера и веса шрифта. А также для изменения,
@@ -49,7 +53,7 @@ class GraphsDrawing:
         plt.plot(worktime_frame['Date'], worktime_frame['Worktime'], marker='s', markersize=15, color='darkblue',
                  linewidth='6')
         plt.title(f"{cluster}-кластер", bbox=self.box, fontsize=20, loc='center')
-        path_pic = f'{self.path_to_pic}\\{self.start_date.year}\\{cluster}worktime{self.start_date.day}-{self.start_date.month}-{self.end_date.day}-{self.end_date.month}.png'
+        path_pic = f'{self.path_to_pic}\\{cluster}worktime{self.start_date.day}-{self.start_date.month}-{self.end_date.day}-{self.end_date.month}.png'
         plt.savefig(path_pic, bbox_inches='tight')
         return path_pic
 
@@ -64,7 +68,7 @@ class GraphsDrawing:
         plt.plot(amp_5_fr_4_frame_2['Date'], amp_5_fr_4_frame_2['Events'] / worktime_frame_2['Worktime'], label='2 Кл.',
                  marker='s', markersize=15, color='crimson', linewidth='6')
         plt.legend(bbox_to_anchor=(1.04, 1), loc="upper left")
-        path_pic = f'{self.path_to_pic}\\{self.start_date.year}\\amp_5_fr_4{self.start_date.day}-{self.start_date.month}-{self.end_date.day}-{self.end_date.month}.png'
+        path_pic = f'{self.path_to_pic}\\amp_5_fr_4{self.start_date.day}-{self.start_date.month}-{self.end_date.day}-{self.end_date.month}.png'
         plt.savefig(path_pic, bbox_inches='tight')
         return path_pic
 
@@ -79,7 +83,7 @@ class GraphsDrawing:
         for i in range(1, 17):
             plt.plot(neutron_num_0_tr_frame['Date'], neutron_num_0_tr_frame[f'n{i}'], label=f'{i}', linewidth=5)
         plt.legend(bbox_to_anchor=(1.04, 1), loc="upper left")
-        path_pic = f'{self.path_to_pic}\\{self.start_date.year}\\{cluster}n_to_0_tr{self.start_date.day}-{self.start_date.month}-{self.end_date.day}-{self.end_date.month}.png'
+        path_pic = f'{self.path_to_pic}\\{cluster}n_to_0_tr{self.start_date.day}-{self.start_date.month}-{self.end_date.day}-{self.end_date.month}.png'
         plt.savefig(path_pic, bbox_inches='tight')
         return path_pic
 
@@ -103,7 +107,7 @@ class GraphsDrawing:
                      amp_distribution_frame[amp_distribution_frame[f'amp{i}'] >= a_crit][
                          f'amp{i}'].value_counts().sort_index(), label=f'{i}', linewidth=5)
         plt.legend(bbox_to_anchor=(1.04, 1), loc="upper left")
-        path_pic = f'{self.path_to_pic}\\{self.start_date.year}\\{cluster}amp_distr_{a_crit}_fr_{freq}{self.start_date.day}-{self.start_date.month}-{self.end_date.day}-{self.end_date.month}.png'
+        path_pic = f'{self.path_to_pic}\\{cluster}amp_distr_{a_crit}_fr_{freq}{self.start_date.day}-{self.start_date.month}-{self.end_date.day}-{self.end_date.month}.png'
         plt.savefig(path_pic, bbox_inches='tight')
         return path_pic
 
@@ -115,9 +119,12 @@ class GraphsDrawing:
         for i in range(1, 17):
             plt.xticks([i.date() for i in list(count_rate_frame['Date'])[::4]],
                        [i.date() for i in list(count_rate_frame['Date'])[::4]])
-            plt.plot(count_rate_frame['Date'], count_rate_frame[f'amp{i}'] / working_frame['Worktime'], label=f'{i}',
+            plt.plot(count_rate_frame['Date'], count_rate_frame[f'amp{i}'], label=f'{i}',
                      linewidth=6)
         plt.legend(bbox_to_anchor=(1.04, 1), loc="upper left")
-        path_pic = f'{self.path_to_pic}\\{self.start_date.year}\\{cluster}count_rate_{a_crit}_fr_{freq}{self.start_date.day}-{self.start_date.month}-{self.end_date.day}-{self.end_date.month}.png'
+        path_pic = f'{self.path_to_pic}\\{cluster}count_rate_{a_crit}_fr_{freq}{self.start_date.day}-{self.start_date.month}-{self.end_date.day}-{self.end_date.month}.png'
         plt.savefig(path_pic, bbox_inches='tight')
         return path_pic
+
+
+

+ 290 - 0
make_report_prisma.py

@@ -0,0 +1,290 @@
+import time
+import warnings
+import pandas as pd
+from docx import Document
+from docx.enum.text import WD_BREAK
+
+from drawing_graphs import GraphsDrawing
+from processing_data_prisma import ProccessingPrismaCl
+from word_addition import *
+
+def make_report_prisma(start_date, end_date, path_to_files_1, path_to_files_2, report_path, picture_path):
+    t1 = time.time()
+
+    warnings.filterwarnings(action='ignore')
+
+    days_amount = len(pd.date_range(start_date, end_date))
+
+    process_1 = ProccessingPrismaCl(1, start_date=start_date, end_date=end_date,
+                                    path_to_files=path_to_files_1)
+    process_2 = ProccessingPrismaCl(2, start_date=start_date, end_date=end_date,
+                                    path_to_files=path_to_files_2)
+    graphs = GraphsDrawing(start_date=start_date, end_date=end_date,
+                           path_to_pic=f'{picture_path}')
+
+    worktime_frame_1, breaks_frame_1, n_vs_zero_tr_frame_1, event_counter_fr_4_1, amp_5_fr_2_frame_1, amp_10_fr_1_frame_1, count_rate_amp_5_fr_2_1, count_rate_amp_10_fr_1_1 = process_1.day_proccessing()
+
+
+    worktime_frame_2, breaks_frame_2, n_vs_zero_tr_frame_2, event_counter_fr_4_2, amp_5_fr_2_frame_2, amp_10_fr_1_frame_2, count_rate_amp_5_fr_2_2, count_rate_amp_10_fr_1_2 = process_2.day_proccessing()
+
+    brake_both_cl_time = 0
+    for i in range(len(breaks_frame_1.index)):
+        for j in range(len(breaks_frame_2.index)):
+            if breaks_frame_1['Date'][i] == breaks_frame_2['Date'][j]:
+                if breaks_frame_1['StartMinutes'][i] <= breaks_frame_2['StartMinutes'][j] < breaks_frame_1['EndMinutes'][i]:
+                    brake_both_cl_time += min(breaks_frame_2['EndMinutes'][j], breaks_frame_1['EndMinutes'][i]) - max(
+                        breaks_frame_2['StartMinutes'][j], breaks_frame_1['StartMinutes'][i])
+                elif breaks_frame_2['StartMinutes'][j] <= breaks_frame_1['StartMinutes'][i] < breaks_frame_2['EndMinutes'][
+                    j]:
+                    brake_both_cl_time += min(breaks_frame_2['EndMinutes'][j], breaks_frame_1['EndMinutes'][i]) - max(
+                        breaks_frame_2['StartMinutes'][j], breaks_frame_1['StartMinutes'][i])
+
+    real_worktime = worktime_frame_2['Worktime'].sum() - 24 * days_amount + worktime_frame_1[
+        'Worktime'].sum() + brake_both_cl_time / 60
+    print(brake_both_cl_time)
+
+    graphs.change_design()
+
+    worktime_pic_path_1 = graphs.worktime_graph(cluster=1, worktime_frame=worktime_frame_1)
+    worktime_pic_path_2 = graphs.worktime_graph(cluster=2, worktime_frame=worktime_frame_2)
+
+    n_vs_zero_tr_pic_path_1 = graphs.neutron_to_0_tr_graph(cluster=1, neutron_num_0_tr_frame=n_vs_zero_tr_frame_1)
+    n_vs_zero_tr_pic_path_2 = graphs.neutron_to_0_tr_graph(cluster=2, neutron_num_0_tr_frame=n_vs_zero_tr_frame_2)
+
+    event_counter_fr_4_pic_path = graphs.amp_5_fr_4_graph(amp_5_fr_4_frame=event_counter_fr_4_1,
+                                                          amp_5_fr_4_frame_2=event_counter_fr_4_2,
+                                                          worktime_frame=worktime_frame_1,
+                                                          worktime_frame_2=worktime_frame_2)
+
+    amp_distribution_pic_path_1 = graphs.amp_distribution_graph(cluster=1, amp_distribution_frame=amp_5_fr_2_frame_1,
+                                                                a_crit=6, freq=2)
+    amp_distribution_pic_path_2 = graphs.amp_distribution_graph(cluster=2, amp_distribution_frame=amp_5_fr_2_frame_2,
+                                                                a_crit=6, freq=2)
+
+    count_rate_amp_5_fr_2_pic_path_1 = graphs.count_rate_graph(cluster=1, count_rate_frame=count_rate_amp_5_fr_2_1,
+                                                      working_frame=worktime_frame_1,
+                                                      a_crit=5, freq=2)
+    count_rate_amp_5_fr_2_pic_path_2 = graphs.count_rate_graph(cluster=2, count_rate_frame=count_rate_amp_5_fr_2_2,
+                                                      working_frame=worktime_frame_2,
+                                                      a_crit=5, freq=2)
+
+    count_rate_amp_10_fr_1_pic_path_1 = graphs.count_rate_graph(cluster=1, count_rate_frame=count_rate_amp_10_fr_1_1,
+                                                       working_frame=worktime_frame_1,
+                                                       a_crit=10, freq=1)
+    count_rate_amp_10_fr_1_pic_path_2 = graphs.count_rate_graph(cluster=2, count_rate_frame=count_rate_amp_10_fr_1_2,
+                                                       working_frame=worktime_frame_2,
+                                                       a_crit=10, freq=1)
+
+    del graphs
+
+    doc = Document()
+    section_choice(doc)
+    add_new_styles(doc)
+
+    head = doc.add_paragraph(
+        f'Справка о работе установки ПРИЗМА-32 в период с {start_date} по {end_date} ', style='Head-style')
+    head.alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
+
+    table_title = doc.add_paragraph('Таблица 1: Время работы установки ПРИЗМА-32.', style='PItalic')
+    table_title.alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
+    worktime_table = doc.add_table(4, 4, doc.styles['Table Grid'])
+    worktime_table.cell(0, 0).text = '№ кластера'
+    worktime_table.cell(0, 1).text = 'Экспозиции, ч.'
+    worktime_table.cell(0, 2).text = 'Календарное время, ч.'
+    worktime_table.cell(0, 3).text = 'Экспозиция, %'
+    worktime_table.cell(1, 0).text = '1'
+    worktime_table.cell(1, 1).text = str(round(worktime_frame_1['Worktime'].sum(), 2))
+    worktime_table.cell(1, 2).text = str(24 * days_amount)
+    worktime_table.cell(1, 3).text = str(
+        round(worktime_frame_1['Worktime'].sum() / (24 * days_amount) * 100, 3)) + '%'
+
+    worktime_table.cell(2, 0).text = '2'
+    worktime_table.cell(2, 1).text = str(round(worktime_frame_2['Worktime'].sum(), 2))
+    worktime_table.cell(2, 2).text = str(24 * days_amount)
+    worktime_table.cell(2, 3).text = str(
+        round(worktime_frame_2['Worktime'].sum() / (24 * days_amount) * 100, 3)) + '%'
+
+    worktime_table.cell(3, 0).text = '1&2'
+    worktime_table.cell(3, 1).text = str(round(real_worktime, 2))
+    worktime_table.cell(3, 2).text = str(24 * days_amount)
+    worktime_table.cell(3, 3).text = str(round(real_worktime / (24 * days_amount) * 100, 3)) + '%'
+
+    make_table_bold(worktime_table, cols=4, rows=4)
+
+    doc.add_paragraph()
+
+    fail_str_begin_1, fail_str_end_1, lost_minutes_1, break_1 = time_breaks_counter(brake_frame=breaks_frame_1)
+    fail_str_begin_2, fail_str_end_2, lost_minutes_2, break_2 = time_breaks_counter(brake_frame=breaks_frame_2)
+    brake_table_title = doc.add_paragraph('Таблица 2: Сводная таблица остановок и работ установки ПРИЗМА-32.', style='PItalic')
+    brake_table_title.alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
+    brake_table = doc.add_table(len(fail_str_begin_1) + len(fail_str_begin_2) + 2, 5, doc.styles['Table Grid'])
+    brake_table.alignment = WD_TABLE_ALIGNMENT.CENTER
+    brake_table.cell(0, 0).text = '№ кластера'
+    brake_table.cell(0, 0).merge(brake_table.cell(1, 0))
+    brake_table.cell(0, 1).text = 'Время простоя'
+    brake_table.cell(1, 1).text = 'c'
+    brake_table.cell(1, 2).text = 'по'
+    brake_table.cell(0, 1).merge(brake_table.cell(0, 2))
+    brake_table.cell(0, 3).text = 'Кол-во потерянных минут (период)'
+    brake_table.cell(0, 3).merge(brake_table.cell(1, 3))
+    brake_table.cell(0, 4).text = 'Примечание'
+    brake_table.cell(0, 4).merge(brake_table.cell(1, 4))
+
+    for i in range(2, len(fail_str_begin_1) + 2):
+        brake_table.cell(i, 0).text = '1'
+        brake_table.cell(i, 1).text = str(fail_str_begin_1[i - 2])
+        brake_table.cell(i, 2).text = str(fail_str_end_1[i - 2])
+        brake_table.cell(i, 3).text = str(lost_minutes_1[i - 2])
+        brake_table.cell(i, 4).text = ' '
+
+    for i in range(2 + len(fail_str_begin_1), len(fail_str_begin_2) + 2 + len(fail_str_begin_1)):
+        brake_table.cell(i, 0).text = '2'
+        brake_table.cell(i, 1).text = str(fail_str_begin_2[i - 2 - len(fail_str_begin_1)])
+        brake_table.cell(i, 2).text = str(fail_str_end_2[i - 2 - len(fail_str_begin_1)])
+        brake_table.cell(i, 3).text = str(lost_minutes_2[i - 2 - len(fail_str_begin_1)])
+        brake_table.cell(i, 4).text = ' '
+
+    make_table_bold(brake_table, cols=5, rows=len(fail_str_begin_1) + len(fail_str_begin_2)+2)
+    doc.add_paragraph()
+
+    table_title = doc.add_paragraph(
+        'Таблица 3: Сводная таблица темпов счета событий и сигналов, отобранных как нейтрон кластеров установки ПРИЗМА-32.',
+        style='PItalic')
+    table_title.alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
+
+    neut_stat_info_1, neut_stat_info_2 = statistical_table(n_vs_zero_tr_frame_1, n_vs_zero_tr_frame_2, dimension='100/соб')
+
+    neutron_table = doc.add_table(3, 3, doc.styles['Table Grid'])
+    neutron_table.cell(0, 0).text = 'Счет/кластер'
+    neutron_table.cell(0, 1).text = 'Кл1'
+    neutron_table.cell(0, 2).text = 'Кл2'
+    neutron_table.cell(1, 0).text = 'События (Fr ≥ 4, A ≥ 5), N соб./ч.'
+    neutron_table.cell(1, 1).text = str(round((event_counter_fr_4_1['Events'] / worktime_frame_1['Worktime']).mean(), 2))
+    neutron_table.cell(1, 2).text = str(round((event_counter_fr_4_2['Events'] / worktime_frame_2['Worktime']).mean(), 2))
+    neutron_table.cell(2, 0).text = 'Нейтроны, (Nn)/соб.'
+    neutron_table.cell(2, 1).text = str(round(neut_stat_info_1.iloc[0].sum(), 2))
+    neutron_table.cell(2, 2).text = str(round(neut_stat_info_2.iloc[0].sum(), 2))
+
+    make_table_bold(neutron_table, cols=3, rows=3)
+    change_cell_size(neutron_table, column_num=3, size_arr=[2.5, 0.5, 0.5])
+
+    doc.add_paragraph()
+
+    notes = doc.add_paragraph('')
+    notes.add_run('Примечание:').bold = True
+    doc.add_paragraph(
+        '        В таблице 4 представлена сводная информация о неисправностях в работе детекторов кластера.')
+    table_title = doc.add_paragraph('Таблица 4: Неисправности.', style='PItalic')
+    table_title.alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
+
+    notes_table = doc.add_table(3, 5, doc.styles['Table Grid'])
+    notes_table.cell(0, 0).text = '№'
+    notes_table.cell(0, 1).text = 'Кластер'
+    notes_table.cell(0, 2).text = '№ Детектора'
+    notes_table.cell(0, 3).text = 'Период'
+    notes_table.cell(0, 4).text = 'Примечание'
+    notes_table.cell(1, 0).text = '1'
+    notes_table.cell(2, 0).text = '2'
+
+    change_cell_size(notes_table, column_num=5, size_arr=[0.3, 0.8, 1.2, 1, 4.2])
+
+    run = doc.add_paragraph().add_run()
+    run.add_break(WD_BREAK.PAGE)
+
+    graphic_header = doc.add_paragraph('Продолжительность работы кластеров установки ПРИЗМА-32.', style='Head-graphic')
+    graphic_header.alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
+    adding_graphic(doc, title='Рис. 1 - Продолжительность работы 1-го кластера в сутки', width=6,
+                   picture_path=worktime_pic_path_1)
+    adding_graphic(doc, title='Рис. 2 - Продолжительность работы 2-го кластера в сутки', width=6,
+                   picture_path=worktime_pic_path_2)
+
+    run = doc.add_paragraph().add_run()
+    run.add_break(WD_BREAK.PAGE)
+
+    graphic_header = doc.add_paragraph('Скорость счета событий установки ПРИЗМА-32.', style='Head-graphic')
+    graphic_header.alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
+    adding_graphic(doc, title='Рис. 3 - Скорость счета событий Fr ≥ 4, A ≥ 5', width=7,
+                   picture_path=event_counter_fr_4_pic_path)
+
+    run = doc.add_paragraph().add_run()
+    run.add_break(WD_BREAK.PAGE)
+
+    adding_graphic(doc, title='Рис. 4 - Число импульсов в событии, отобранных как нейтрон, при самозапуске кластер 1',
+                   width=6, picture_path=n_vs_zero_tr_pic_path_1)
+    adding_graphic(doc, title='Рис. 5 - Число импульсов в событии, отобранных как нейтрон, при самозапуске кластер 2',
+                   width=6, picture_path=n_vs_zero_tr_pic_path_2)
+
+    table_title = doc.add_paragraph(
+        'Таблица 5: Среднее число нейтронов (Nn) для детекторов установки ПРИЗМА-32 за месяц работы, нормированное на количество событий (Ns).(при самозапуске), ',
+        style='PItalic')
+    table_title.add_run('(100/соб)').bold = True
+    table_title.alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
+
+
+    neutron_stat_table = doc.add_table(neut_stat_info_1.shape[0] + neut_stat_info_2.shape[0] + 2,
+                                       neut_stat_info_1.shape[1] + 2,
+                                       doc.styles['Table Grid'])
+
+    draw_stat_table(neutron_stat_table, neut_stat_info_1, neut_stat_info_2)
+    make_stat_table_bold(neutron_stat_table, cols=18, rows=6)
+
+    run = doc.add_paragraph().add_run()
+    run.add_break(WD_BREAK.PAGE)
+
+    # Переделать, чтобы амплитуда и кратность были переменными.
+    adding_graphic(doc, title='Рис. 6 - Скорость счета  детекторов в 1-м кластере Fr ≥ 2, A > 5',
+                   width=6, picture_path=count_rate_amp_5_fr_2_pic_path_1)
+    adding_graphic(doc, title='Рис. 7 - Скорость счета  детекторов в 2-м кластере Fr ≥ 2, A > 5',
+                   width=6, picture_path=count_rate_amp_5_fr_2_pic_path_2)
+
+    table_title = doc.add_paragraph(
+        'Таблица 6: Среднемесячные число срабатываний детекторов установки ПРИЗМА-32, cоб./час.',
+        style='PItalic')
+    table_title.alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
+
+    count_rate_stat_info_1, count_rate_stat_info_2 = statistical_table(count_rate_amp_5_fr_2_1, count_rate_amp_5_fr_2_2,
+                                                                       dimension='cоб./ч.')
+
+    count_stat_table = doc.add_table(count_rate_stat_info_1.shape[0] + count_rate_stat_info_2.shape[0] + 2,
+                                     count_rate_stat_info_1.shape[1] + 2, doc.styles['Table Grid'])
+
+    draw_stat_table(count_stat_table, count_rate_stat_info_1, count_rate_stat_info_2)
+    make_stat_table_bold(count_stat_table, cols=18, rows=6)
+
+    run = doc.add_paragraph().add_run()
+    run.add_break(WD_BREAK.PAGE)
+
+    adding_graphic(doc, title='Рис. 8 - Скорость счета  детекторов в 1-м кластере Fr ≥ 1, A > 10',
+                   width=6, picture_path=count_rate_amp_10_fr_1_pic_path_1)
+    adding_graphic(doc, title='Рис. 9 - Скорость счета  детекторов в 2-м кластере Fr ≥ 1, A > 10',
+                   width=6, picture_path=count_rate_amp_10_fr_1_pic_path_2)
+
+    table_title = doc.add_paragraph(
+        'Таблица 7: Среднемесячные число срабатываний детекторов установки ПРИЗМА-32, cоб./час.',
+        style='PItalic')
+    table_title.alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
+
+    count_rate_stat_info_1, count_rate_stat_info_2 = statistical_table(count_rate_amp_10_fr_1_1, count_rate_amp_10_fr_1_2,
+                                                                       dimension='cоб./ч.')
+    count_stat_table_2 = doc.add_table(count_rate_stat_info_1.shape[0] + count_rate_stat_info_2.shape[0] + 2,
+                                       count_rate_stat_info_1.shape[1] + 2, doc.styles['Table Grid'])
+
+    draw_stat_table(count_stat_table_2, count_rate_stat_info_1, count_rate_stat_info_2)
+    make_stat_table_bold(count_stat_table_2, cols=18, rows=6)
+
+    run = doc.add_paragraph().add_run()
+    run.add_break(WD_BREAK.PAGE)
+
+    graphic_header = doc.add_paragraph('На рисунке 8, 9 представлено число сигналов с А>5 кодов АЦП в час для 16 детекторов.',
+                             style='Head-graphic')
+    graphic_header.alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
+
+    adding_graphic(doc, title='Рис. 10 - Амплитудное распределение сигналов от детекторов, кластер 1 (Fr ≥ 2 и А > 5)',
+                   width=6, picture_path=amp_distribution_pic_path_1)
+    adding_graphic(doc, title='Рис. 11 - Амплитудное распределение сигналов от детекторов, кластер 2 (Fr ≥ 2 и А > 5)',
+                   width=6, picture_path=amp_distribution_pic_path_2)
+    add_page_number(doc.sections[0].footer.paragraphs[0])
+
+    doc.save(f'{report_path}\\{start_date.day:02}.{start_date.month:02}.{start_date.year}-{end_date.day:02}.{end_date.month:02}.{end_date.year}.docx')
+
+    print(time.time() - t1)

+ 12 - 36
processing_for_report.py

@@ -113,15 +113,19 @@ class ProccessingPrismaCl:
                     count_rate_amp_10_fr_1[f'amp{i + 1}'].append(0.00)
                 event_counter_fr_4['Events'].append(0.00)
 
-        return worktime_dict, breaks_dict, n_vs_zero_tr_dict, event_counter_fr_4, amp_5_fr_2_frame, amp_10_fr_1_frame, count_rate_amp_5_fr_2, count_rate_amp_10_fr_1
+        worktime_frame = pd.DataFrame(worktime_dict)
+        n_vs_zero_tr_frame = pd.DataFrame(n_vs_zero_tr_dict)
+        breaks_frame = pd.DataFrame(breaks_dict)
+        event_counter_fr_4 = pd.DataFrame(event_counter_fr_4)
+        count_rate_amp_5_fr_2 = pd.DataFrame(count_rate_amp_5_fr_2)
+        count_rate_amp_10_fr_1 = pd.DataFrame(count_rate_amp_10_fr_1)
+
+        for column in [f'amp{i}' for i in range(1,17)]:
+            count_rate_amp_5_fr_2[column] = count_rate_amp_5_fr_2[column]/worktime_frame['Worktime']
+            count_rate_amp_10_fr_1[column] = count_rate_amp_10_fr_1[column]/worktime_frame['Worktime']
+
+        return worktime_frame, breaks_frame, n_vs_zero_tr_frame, event_counter_fr_4, amp_5_fr_2_frame, amp_10_fr_1_frame, count_rate_amp_5_fr_2, count_rate_amp_10_fr_1
 
-    # worktime_df = pd.DataFrame(worktime_dict, columns=['Date', 'Worktime'])
-    # worktime_df['Date'] = pd.to_datetime(worktime_df["Date"])
-    # # df.loc[16, 'WORKTIME'] = 24 # для января 2013-го, там хуйня с файлом, а именно разное количество колонок
-    # return worktime_df
-    # n_vs_zero_tr_df = pd.DataFrame(n_vs_zero_tr_dict, columns=['Date'] + [f'n{i}' for i in range(1, 17)])
-    # n_vs_zero_tr_df['Date'] = pd.to_datetime(n_vs_zero_tr_df["Date"])
-    # return n_vs_zero_tr_df
 
     @staticmethod
     def correcting_p_file(p_file):
@@ -209,31 +213,3 @@ class ProccessingPrismaCl:
                 'count_rate': cluster_count_rate}
 
 
-        # if max(index) < 287:
-        #     start_hour = math.floor(max(index) * 5 / 60)
-        #     start_minutes = max(index) * 5 - start_hour * 60
-        #     end_hour = 23
-        #     end_minutes = 55
-        #     daily_breaks_dict['StartHour'].append(start_hour)
-        #     daily_breaks_dict['StartMinutes'].append(start_minutes)
-        #     daily_breaks_dict['EndHour'].append(end_hour)
-        #     daily_breaks_dict['EndMinutes'].append(end_minutes)
-        # if min(index) != 0:
-        #     start_hour = 0
-        #     start_minutes = 0
-        #     end_hour = math.floor(min(index) * 5 / 60)
-        #     end_minutes = min(index) * 5 - end_hour * 60
-        #     daily_breaks_dict['StartHour'].append(start_hour)
-        #     daily_breaks_dict['StartMinutes'].append(start_minutes)
-        #     daily_breaks_dict['EndHour'].append(end_hour)
-        #     daily_breaks_dict['EndMinutes'].append(end_minutes)
-        # for i in range(1, len(index)):
-        #     if index[i] - index[i - 1] > 1:
-        #         start_hour = math.floor(index[i - 1] * 5 / 60)
-        #         start_minutes = index[i - 1] * 5 - start_hour * 60
-        #         end_hour = math.floor(index[i] * 5 / 60)
-        #         end_minutes = index[i] * 5 - end_hour * 60
-        #         daily_breaks_dict['StartHour'].append(start_hour)
-        #         daily_breaks_dict['StartMinutes'].append(start_minutes)
-        #         daily_breaks_dict['EndHour'].append(end_hour)
-                # daily_breaks_dict['EndMinutes'].append(end_minutes)

+ 0 - 307
testing.py

@@ -1,307 +0,0 @@
-import datetime
-import time
-import warnings
-from matplotlib import pyplot as plt
-import pandas as pd
-from docx import Document
-from docx.enum.text import WD_BREAK
-
-from drawing_graphs import GraphsDrawing
-from processing_for_report import ProccessingPrismaCl
-from word_addition import *
-
-t1 = time.time()
-
-warnings.filterwarnings(action='ignore')
-
-# Следующее должно быть передающимися переменными
-start_date = datetime.date(2021, 1, 1)
-end_date = datetime.date(2021, 1, 31)
-days_amount = len(pd.date_range(start_date, end_date))
-
-process_1 = ProccessingPrismaCl(1, start_date=start_date, end_date=end_date,
-                                path_to_files='D:\\PRISMA20\\P1')
-process_2 = ProccessingPrismaCl(2, start_date=start_date, end_date=end_date,
-                                path_to_files='D:\\PRISMA20\\P2')
-graphs = GraphsDrawing(start_date=start_date, end_date=end_date,
-                       path_to_pic='C:\\Users\\pad_z\\OneDrive\\Рабочий стол\\PrismaPassport')
-
-worktime_1, breaks_1, n_vs_zero_tr_1, event_counter_fr_4_1, amp_5_fr_2_frame_1, amp_10_fr_1_frame_1, count_rate_amp_5_fr_2_1, count_rate_amp_10_fr_1_1 = process_1.day_proccessing()
-worktime_frame_1 = pd.DataFrame(worktime_1)
-n_vs_zero_tr_frame_1 = pd.DataFrame(n_vs_zero_tr_1)
-breaks_frame_1 = pd.DataFrame(breaks_1)
-event_counter_fr_4_1 = pd.DataFrame(event_counter_fr_4_1)
-count_rate_amp_5_fr_2_1 = pd.DataFrame(count_rate_amp_5_fr_2_1)
-count_rate_amp_10_fr_1_1 = pd.DataFrame(count_rate_amp_10_fr_1_1)
-
-worktime_2, breaks_2, n_vs_zero_tr_2, event_counter_fr_4_2, amp_5_fr_2_frame_2, amp_10_fr_1_frame_2, count_rate_amp_5_fr_2_2, count_rate_amp_10_fr_1_2 = process_2.day_proccessing()
-worktime_frame_2 = pd.DataFrame(worktime_2)
-n_vs_zero_tr_frame_2 = pd.DataFrame(n_vs_zero_tr_2)
-breaks_frame_2 = pd.DataFrame(breaks_2)
-event_counter_fr_4_2 = pd.DataFrame(event_counter_fr_4_2)
-count_rate_amp_5_fr_2_2 = pd.DataFrame(count_rate_amp_5_fr_2_2)
-count_rate_amp_10_fr_1_2 = pd.DataFrame(count_rate_amp_10_fr_1_2)
-
-brake_both_cl_time = 0
-for i in range(len(breaks_frame_1.index)):
-    for j in range(len(breaks_frame_2.index)):
-        if breaks_frame_1['Date'][i] == breaks_frame_2['Date'][j]:
-            if breaks_frame_1['StartMinutes'][i] <= breaks_frame_2['StartMinutes'][j] < breaks_frame_1['EndMinutes'][i]:
-                brake_both_cl_time += min(breaks_frame_2['EndMinutes'][j], breaks_frame_1['EndMinutes'][i]) - max(
-                    breaks_frame_2['StartMinutes'][j], breaks_frame_1['StartMinutes'][i])
-            elif breaks_frame_2['StartMinutes'][j] <= breaks_frame_1['StartMinutes'][i] < breaks_frame_2['EndMinutes'][
-                j]:
-                brake_both_cl_time += min(breaks_frame_2['EndMinutes'][j], breaks_frame_1['EndMinutes'][i]) - max(
-                    breaks_frame_2['StartMinutes'][j], breaks_frame_1['StartMinutes'][i])
-
-real_worktime = worktime_frame_2['Worktime'].sum() - 24 * days_amount + worktime_frame_1[
-    'Worktime'].sum() + brake_both_cl_time / 60
-print(brake_both_cl_time)
-
-graphs.change_design()
-
-worktime_pic_path_1 = graphs.worktime_graph(cluster=1, worktime_frame=worktime_frame_1)
-worktime_pic_path_2 = graphs.worktime_graph(cluster=2, worktime_frame=worktime_frame_2)
-
-n_vs_zero_tr_pic_path_1 = graphs.neutron_to_0_tr_graph(cluster=1, neutron_num_0_tr_frame=n_vs_zero_tr_frame_1)
-n_vs_zero_tr_pic_path_2 = graphs.neutron_to_0_tr_graph(cluster=2, neutron_num_0_tr_frame=n_vs_zero_tr_frame_2)
-
-event_counter_fr_4_pic_path = graphs.amp_5_fr_4_graph(amp_5_fr_4_frame=event_counter_fr_4_1,
-                                                      amp_5_fr_4_frame_2=event_counter_fr_4_2,
-                                                      worktime_frame=worktime_frame_1,
-                                                      worktime_frame_2=worktime_frame_2)
-
-amp_distribution_pic_path_1 = graphs.amp_distribution_graph(cluster=1, amp_distribution_frame=amp_5_fr_2_frame_1,
-                                                            a_crit=6, freq=2)
-amp_distribution_pic_path_2 = graphs.amp_distribution_graph(cluster=2, amp_distribution_frame=amp_5_fr_2_frame_2,
-                                                            a_crit=6, freq=2)
-
-count_rate_amp_5_fr_2_pic_path_1 = graphs.count_rate_graph(cluster=1, count_rate_frame=count_rate_amp_5_fr_2_1,
-                                                  working_frame=worktime_frame_1,
-                                                  a_crit=5, freq=2)
-count_rate_amp_5_fr_2_pic_path_2 = graphs.count_rate_graph(cluster=2, count_rate_frame=count_rate_amp_5_fr_2_2,
-                                                  working_frame=worktime_frame_2,
-                                                  a_crit=5, freq=2)
-
-count_rate_amp_10_fr_1_pic_path_1 = graphs.count_rate_graph(cluster=1, count_rate_frame=count_rate_amp_10_fr_1_1,
-                                                   working_frame=worktime_frame_1,
-                                                   a_crit=10, freq=1)
-count_rate_amp_10_fr_1_pic_path_2 = graphs.count_rate_graph(cluster=2, count_rate_frame=count_rate_amp_10_fr_1_2,
-                                                   working_frame=worktime_frame_2,
-                                                   a_crit=10, freq=1)
-
-doc = Document()
-section_choice(doc)
-add_new_styles(doc)
-
-head = doc.add_paragraph(
-    f'Справка о работе установки ПРИЗМА-32 в период с {start_date} по {end_date} ', style='Head-style')
-head.alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
-
-table_title = doc.add_paragraph('Таблица 1: Время работы установки ПРИЗМА-32.', style='PItalic')
-table_title.alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
-worktime_table = doc.add_table(4, 4, doc.styles['Table Grid'])
-worktime_table.cell(0, 0).text = '№ кластера'
-worktime_table.cell(0, 1).text = 'Экспозиции, ч.'
-worktime_table.cell(0, 2).text = 'Календарное время, ч.'
-worktime_table.cell(0, 3).text = 'Экспозиция, %'
-worktime_table.cell(1, 0).text = '1'
-worktime_table.cell(1, 1).text = str(round(worktime_frame_1['Worktime'].sum(), 2))
-worktime_table.cell(1, 2).text = str(24 * days_amount)
-worktime_table.cell(1, 3).text = str(
-    round(worktime_frame_1['Worktime'].sum() / (24 * days_amount) * 100, 3)) + '%'
-
-worktime_table.cell(2, 0).text = '2'
-worktime_table.cell(2, 1).text = str(round(worktime_frame_2['Worktime'].sum(), 2))
-worktime_table.cell(2, 2).text = str(24 * days_amount)
-worktime_table.cell(2, 3).text = str(
-    round(worktime_frame_2['Worktime'].sum() / (24 * days_amount) * 100, 3)) + '%'
-
-worktime_table.cell(3, 0).text = '1&2'
-worktime_table.cell(3, 1).text = str(round(real_worktime, 2))
-worktime_table.cell(3, 2).text = str(24 * days_amount)
-worktime_table.cell(3, 3).text = str(round(real_worktime / (24 * days_amount) * 100, 3)) + '%'
-
-make_table_bold(worktime_table, cols=4, rows=4)
-
-doc.add_paragraph()
-
-# В РАЗРАБОТКЕ
-fail_str_begin_1, fail_str_end_1, lost_minutes_1, break_1 = time_breaks_counter(brake_frame=breaks_frame_1)
-fail_str_begin_2, fail_str_end_2, lost_minutes_2, break_2 = time_breaks_counter(brake_frame=breaks_frame_2)
-brake_table_title = doc.add_paragraph('Таблица 2: Сводная таблица остановок и работ установки ПРИЗМА-32.', style='PItalic')
-brake_table_title.alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
-brake_table = doc.add_table(len(fail_str_begin_1) + len(fail_str_begin_2) + 2, 5, doc.styles['Table Grid'])
-brake_table.alignment = WD_TABLE_ALIGNMENT.CENTER
-brake_table.cell(0, 0).text = '№ кластера'
-brake_table.cell(0, 0).merge(brake_table.cell(1, 0))
-brake_table.cell(0, 1).text = 'Время простоя'
-brake_table.cell(1, 1).text = 'c'
-brake_table.cell(1, 2).text = 'по'
-brake_table.cell(0, 1).merge(brake_table.cell(0, 2))
-brake_table.cell(0, 3).text = 'Кол-во потерянных минут (период)'
-brake_table.cell(0, 3).merge(brake_table.cell(1, 3))
-brake_table.cell(0, 4).text = 'Примечание'
-brake_table.cell(0, 4).merge(brake_table.cell(1, 4))
-
-for i in range(2, len(fail_str_begin_1) + 2):
-    brake_table.cell(i, 0).text = '1'
-    brake_table.cell(i, 1).text = str(fail_str_begin_1[i - 2])
-    brake_table.cell(i, 2).text = str(fail_str_end_1[i - 2])
-    brake_table.cell(i, 3).text = str(lost_minutes_1[i - 2])
-    brake_table.cell(i, 4).text = ' '
-
-for i in range(2 + len(fail_str_begin_1), len(fail_str_begin_2) + 2 + len(fail_str_begin_1)):
-    brake_table.cell(i, 0).text = '2'
-    brake_table.cell(i, 1).text = str(fail_str_begin_2[i - 2 - len(fail_str_begin_1)])
-    brake_table.cell(i, 2).text = str(fail_str_end_2[i - 2 - len(fail_str_begin_1)])
-    brake_table.cell(i, 3).text = str(lost_minutes_2[i - 2 - len(fail_str_begin_1)])
-    brake_table.cell(i, 4).text = ' '
-
-make_table_bold(brake_table, cols=5, rows=len(fail_str_begin_1) + len(fail_str_begin_2)+2)
-doc.add_paragraph()
-
-table_title = doc.add_paragraph(
-    'Таблица 3: Сводная таблица темпов счета событий и сигналов, отобранных как нейтрон кластеров установки ПРИЗМА-32.',
-    style='PItalic')
-table_title.alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
-
-neut_stat_info_1, neut_stat_info_2 = statistical_table(n_vs_zero_tr_frame_1, n_vs_zero_tr_frame_2, dimension='100/соб')
-
-neutron_table = doc.add_table(3, 3, doc.styles['Table Grid'])
-neutron_table.cell(0, 0).text = 'Счет/кластер'
-neutron_table.cell(0, 1).text = 'Кл1'
-neutron_table.cell(0, 2).text = 'Кл2'
-neutron_table.cell(1, 0).text = 'События (Fr ≥ 4, A ≥ 5), N соб./ч.'
-neutron_table.cell(1, 1).text = str(round((event_counter_fr_4_1['Events'] / worktime_frame_1['Worktime']).mean(), 2))
-neutron_table.cell(1, 2).text = str(round((event_counter_fr_4_2['Events'] / worktime_frame_2['Worktime']).mean(), 2))
-neutron_table.cell(2, 0).text = 'Нейтроны, (Nn)/соб.'
-neutron_table.cell(2, 1).text = str(round(neut_stat_info_1.iloc[0].sum(), 2))
-neutron_table.cell(2, 2).text = str(round(neut_stat_info_2.iloc[0].sum(), 2))
-
-make_table_bold(neutron_table, cols=3, rows=3)
-change_cell_size(neutron_table, column_num=3, size_arr=[2.5, 0.5, 0.5])
-
-doc.add_paragraph()
-
-notes = doc.add_paragraph('')
-notes.add_run('Примечание:').bold = True
-notes_description = doc.add_paragraph(
-    '        В таблице 4 представлена сводная информация о неисправностях в работе детекторов кластера.')
-table_title = doc.add_paragraph('Таблица 4: Неисправности.', style='PItalic')
-table_title.alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
-
-notes_table = doc.add_table(3, 5, doc.styles['Table Grid'])
-notes_table.cell(0, 0).text = '№'
-notes_table.cell(0, 1).text = 'Кластер'
-notes_table.cell(0, 2).text = '№ Детектора'
-notes_table.cell(0, 3).text = 'Период'
-notes_table.cell(0, 4).text = 'Примечание'
-notes_table.cell(1, 0).text = '1'
-notes_table.cell(2, 0).text = '2'
-
-change_cell_size(notes_table, column_num=5, size_arr=[0.3, 0.8, 1.2, 1, 4.2])
-
-run = doc.add_paragraph().add_run()
-run.add_break(WD_BREAK.PAGE)
-
-graphic_header = doc.add_paragraph('Продолжительность работы кластеров установки ПРИЗМА-32.', style='Head-graphic')
-graphic_header.alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
-adding_graphic(doc, title='Рис. 1 - Продолжительность работы 1-го кластера в сутки', width=6,
-               picture_path=worktime_pic_path_1)
-adding_graphic(doc, title='Рис. 2 - Продолжительность работы 2-го кластера в сутки', width=6,
-               picture_path=worktime_pic_path_2)
-
-run = doc.add_paragraph().add_run()
-run.add_break(WD_BREAK.PAGE)
-
-graphic_header = doc.add_paragraph('Скорость счета событий установки ПРИЗМА-32.', style='Head-graphic')
-graphic_header.alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
-adding_graphic(doc, title='Рис. 3 - Скорость счета событий Fr ≥ 4, A ≥ 5', width=7,
-               picture_path=event_counter_fr_4_pic_path)
-
-run = doc.add_paragraph().add_run()
-run.add_break(WD_BREAK.PAGE)
-
-adding_graphic(doc, title='Рис. 4 - Число импульсов в событии, отобранных как нейтрон, при самозапуске кластер 1',
-               width=6, picture_path=n_vs_zero_tr_pic_path_1)
-adding_graphic(doc, title='Рис. 5 - Число импульсов в событии, отобранных как нейтрон, при самозапуске кластер 2',
-               width=6, picture_path=n_vs_zero_tr_pic_path_2)
-
-table_title = doc.add_paragraph(
-    'Таблица 5: Среднее число нейтронов (Nn) для детекторов установки ПРИЗМА-32 за месяц работы, нормированное на количество событий (Ns).(при самозапуске), ',
-    style='PItalic')
-table_title.add_run('(100/соб)').bold = True
-table_title.alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
-
-
-neutron_stat_table = doc.add_table(neut_stat_info_1.shape[0] + neut_stat_info_2.shape[0] + 2,
-                                   neut_stat_info_1.shape[1] + 2,
-                                   doc.styles['Table Grid'])
-
-draw_stat_table(neutron_stat_table, neut_stat_info_1, neut_stat_info_2)
-make_stat_table_bold(neutron_stat_table, cols=18, rows=6)
-
-run = doc.add_paragraph().add_run()
-run.add_break(WD_BREAK.PAGE)
-
-# Переделать, чтобы амплитуда и кратность были переменными.
-adding_graphic(doc, title='Рис. 6 - Скорость счета  детекторов в 1-м кластере Fr ≥ 2, A > 5',
-               width=6, picture_path=count_rate_amp_5_fr_2_pic_path_1)
-adding_graphic(doc, title='Рис. 7 - Скорость счета  детекторов в 2-м кластере Fr ≥ 2, A > 5',
-               width=6, picture_path=count_rate_amp_5_fr_2_pic_path_2)
-
-table_title = doc.add_paragraph(
-    'Таблица 6: Среднемесячные число срабатываний детекторов установки ПРИЗМА-32, cоб./час.',
-    style='PItalic')
-table_title.alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
-
-# print(f'{count_rate_amp_5_fr_2_1=}')
-# print(f'{count_rate_amp_5_fr_2_2=}')
-count_rate_stat_info_1, count_rate_stat_info_2 = statistical_table(count_rate_amp_5_fr_2_1, count_rate_amp_5_fr_2_2,
-                                                                   dimension='cоб./ч.')
-
-count_stat_table = doc.add_table(count_rate_stat_info_1.shape[0] + count_rate_stat_info_2.shape[0] + 2,
-                                 count_rate_stat_info_1.shape[1] + 2, doc.styles['Table Grid'])
-
-draw_stat_table(count_stat_table, count_rate_stat_info_1, count_rate_stat_info_2)
-make_stat_table_bold(count_stat_table, cols=18, rows=6)
-
-run = doc.add_paragraph().add_run()
-run.add_break(WD_BREAK.PAGE)
-
-adding_graphic(doc, title='Рис. 8 - Скорость счета  детекторов в 1-м кластере Fr ≥ 1, A > 10',
-               width=6, picture_path=count_rate_amp_10_fr_1_pic_path_1)
-adding_graphic(doc, title='Рис. 9 - Скорость счета  детекторов в 2-м кластере Fr ≥ 1, A > 10',
-               width=6, picture_path=count_rate_amp_10_fr_1_pic_path_2)
-
-table_title = doc.add_paragraph(
-    'Таблица 7: Среднемесячные число срабатываний детекторов установки ПРИЗМА-32, cоб./час.',
-    style='PItalic')
-table_title.alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
-
-count_rate_stat_info_1, count_rate_stat_info_2 = statistical_table(count_rate_amp_10_fr_1_1, count_rate_amp_10_fr_1_2,
-                                                                   dimension='cоб./ч.')
-count_stat_table_2 = doc.add_table(count_rate_stat_info_1.shape[0] + count_rate_stat_info_2.shape[0] + 2,
-                                   count_rate_stat_info_1.shape[1] + 2, doc.styles['Table Grid'])
-
-draw_stat_table(count_stat_table_2, count_rate_stat_info_1, count_rate_stat_info_2)
-make_stat_table_bold(count_stat_table_2, cols=18, rows=6)
-
-run = doc.add_paragraph().add_run()
-run.add_break(WD_BREAK.PAGE)
-
-graphic_header = doc.add_paragraph('На рисунке 8, 9 представлено число сигналов с А>5 кодов АЦП в час для 16 детекторов.',
-                         style='Head-graphic')
-graphic_header.alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
-
-adding_graphic(doc, title='Рис. 10 - Амплитудное распределение сигналов от детекторов, кластер 1 (Fr ≥ 2 и А > 5)',
-               width=6, picture_path=amp_distribution_pic_path_1)
-adding_graphic(doc, title='Рис. 11 - Амплитудное распределение сигналов от детекторов, кластер 2 (Fr ≥ 2 и А > 5)',
-               width=6, picture_path=amp_distribution_pic_path_2)
-add_page_number(doc.sections[0].footer.paragraphs[0])
-
-doc.save(f'C:\\Users\\pad_z\\OneDrive\\Рабочий стол\\PrismaPassport\\2021\\{start_date}-{end_date}.docx')
-
-plt.close('all')
-print(time.time() - t1)

+ 2 - 2
word_addition.py

@@ -132,8 +132,8 @@ def draw_stat_table(stat_table, stat_info_1, stat_info_2):
     stat_table.cell(0, 2).merge(stat_table.cell(0, 17))
     stat_table.cell(0, 0).merge(stat_table.cell(1, 0))
     stat_table.cell(0, 1).merge(stat_table.cell(1, 1))
-    for j in range(stat_info_1.shape[-1]):
-        stat_table.cell(1, j + 2).text = stat_info_1.columns[j]
+    for j in range(16):
+        stat_table.cell(1, j + 2).text = str(j+1)
     stat_table.cell(2, 0).text = '1'
     stat_table.cell(2, 0).merge(stat_table.cell(3, 0))
     stat_table.cell(4, 0).text = '2'