Power plant electric quantity intelligent statistical method and device based on Python technology

Through the dynamic time division algorithm and generator expression of Python technology, the problems of low efficiency and high error rate of power plant electricity statistics are solved, and efficient and accurate electricity statistics and analysis are achieved to meet complex time period rules and real-time requirements.

CN120596549APending Publication Date: 2025-09-05CHINA HUADIAN ENG CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510761524.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-09
Publication Date
2025-09-05

AI Technical Summary

Technical Problem

Existing power plant electricity statistics rely on manual Excel operations, which are inefficient, have high error rates, lack intelligence, and are unable to automatically identify abnormal data or dynamically adjust holiday rules. They are unable to meet complex time period rules and real-time requirements.

Method used

An intelligent power plant electricity statistics method based on Python technology is adopted to calculate electricity through dynamic time period division algorithm and generator expression, combined with visual display to achieve fully automated electricity statistics and analysis.

Benefits of technology

It achieves efficient and accurate power statistics, reduces memory usage by 60%, improves processing efficiency, reduces the error rate to 0, and meets complex time period rules and real-time requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120596549A_ABST
    Figure CN120596549A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a power plant electric quantity intelligent statistical method and device based on a Python technology, and the method comprises the steps: obtaining electric quantity data, obtaining date and time rule configuration information, and carrying out the holiday and festival and execution time division of the electric quantity data through employing a dynamic time division algorithm according to the date and time rule configuration information; performing electric quantity calculation on the electric quantity data according to hours and days by adopting a generator expression, and performing electric quantity calculation according to a holiday and execution period division result and an execution period; and carrying out visual display on an electric quantity calculation result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This document relates to the field of power system automation technology, and in particular to a method and device for intelligent power plant electricity statistics based on Python technology. Background Art

[0002] In the existing technology, power plant electricity statistics rely on manual Excel data processing, which has the following defects: 1. Inefficiency: Processing 60,000+ data points per month takes 4 hours, and formula chain references cause memory usage to reach 1.2GB.

[0003] 2. High error rate: Manually dividing peak, valley, and normal time periods is prone to errors (especially when there are special rules for crossing days, holidays, and Saturdays).

[0004] 3. Lack of intelligence: Unable to automatically identify abnormal data or dynamically adjust holiday rules, unable to meet complex time period rules and real-time requirements. Summary of the Invention

[0005] The purpose of the present invention is to provide a method and device for intelligent statistical analysis of power plant electricity based on Python technology, aiming to solve the above-mentioned problems in the prior art.

[0006] The present invention provides a Python-based intelligent statistical method for power plant electricity consumption, comprising: Acquire power data and date and time rule configuration information, and divide the power data into holidays and execution periods using a dynamic time period division algorithm according to the date and time rule configuration information; The generator expression is used to calculate the power data by hour and day, and the power is calculated according to the execution period based on the results of the holidays and execution period; Visualize the power calculation results.

[0007] The present invention provides a Python-based intelligent statistical device for power plant electricity consumption, comprising: An acquisition and division module is used to acquire power data and date and time rule configuration information, and divide the power data into holidays and execution periods using a dynamic time period division algorithm according to the date and time rule configuration information; An electricity calculation module, configured to calculate the electricity data by hour and day using a generator expression, and to calculate the electricity by execution period based on the result of the division between holidays and execution periods; The visualization display module is used to visualize the power calculation results.

[0008] An embodiment of the present invention also provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, the steps of the above-mentioned method for intelligent statistical analysis of power plant electricity consumption based on Python technology are implemented.

[0009] An embodiment of the present invention also provides a computer-readable storage medium, on which a program for implementing information transmission is stored. When the program is executed by a processor, the steps of the above-mentioned method for intelligent statistical analysis of power plant electricity based on Python technology are implemented.

[0010] The embodiments of the present invention solve the technical problems of low manual processing efficiency and high error rate. By building a dynamic time period engine and an intelligent data aggregation model, cross-national rule adaptation is achieved, and fully automated electricity statistics and analysis are realized. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] In order to more clearly illustrate one or more embodiments of this specification or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments recorded in this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0012] Figure 1 This is a flow chart of a method for intelligent statistical analysis of power plant electricity consumption based on Python technology according to an embodiment of the present invention; Figure 2 This is a flow chart of an intelligent statistical method for power plant electricity consumption based on Python technology according to an embodiment of the present invention; Figure 3 Schematic diagram of the system architecture of the Python-based power plant electricity intelligent statistics method according to an embodiment of the present invention; Figure 4 Schematic diagram of the processing flow of the dynamic time period division algorithm according to an embodiment of the present invention; Figure 5 is a schematic diagram of data aggregation according to an embodiment of the present invention; Figure 6 Schematic diagram of a Python-based intelligent statistical device for power plant electricity consumption according to an embodiment of the present invention; Figure 7 is a schematic diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0013] In order to enable those skilled in the art to better understand the technical solutions in one or more embodiments of this specification, the technical solutions in one or more embodiments of this specification will be clearly and completely described below in conjunction with the drawings in one or more embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on one or more embodiments of this specification, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of this document.

[0014] Method Example According to an embodiment of the present invention, a method for intelligent statistical analysis of power plant electricity consumption based on Python technology is provided. Figure 1 This is a flow chart of the intelligent statistical method for power plant electricity based on Python technology according to an embodiment of the present invention. Figure 1 As shown, the intelligent statistical method for power plant electricity consumption based on Python technology according to an embodiment of the present invention specifically includes: Step S101: acquiring power data and date and time rule configuration information, and dividing the power data into holidays and execution periods using a dynamic time period division algorithm according to the date and time rule configuration information; wherein acquiring power data specifically includes: Automatically traverses the CSV files in the specified path, reads the first row of each CSV file, extracts the electricity data for N predetermined time periods in columns C-AX, fills missing values ​​in the electricity data with 0, converts non-numeric data and logs it, extracts the date information from the CSV file name, and generates a complete timestamp for the extracted electricity data based on the globally configured year and month parameters, where N is a positive integer. In one embodiment of the present invention, N = 48, and the predetermined time period is half an hour. Acquiring date and time rule configuration information, and dividing the electricity data into holidays and execution periods using a dynamic time period division algorithm according to the date and time rule configuration information specifically includes: Obtain date and time rule configuration information, and according to the date and time rule configuration information, use a dynamic time period division algorithm to classify the electricity data into time periods and mark time period types, and generate a time period type list for the electricity data, wherein the dynamic time period division algorithm specifically includes: distinguishing between working days and rest days, and dividing the working days and rest days into peak time periods, valley time periods, and normal time periods based on the time period division rules. The time period division rules specifically include: 9:30-11:00 and 17:00-20:00 on working days as peak time periods, 22:00-4:00 the next day as valley time periods on working days, and the rest of the working days as normal time periods; only 22:00-4:00 on Saturdays is designated as valley time periods, and the rest of the time is normal time periods; 22:00-4:00 on Sundays as valley time periods, and the rest of the time on Sundays as normal time periods.

[0015] In the embodiment of the present invention, the date and time rule configuration information can be dynamically configured according to different requirements.

[0016] Step S102, using a generator expression to calculate the power data by hour and day, and calculating the power by execution period based on the result of the holiday and execution period division; Step S103: Visualize the power calculation results. This includes: Create an electricity report based on the electricity calculation results, mark the peak period, valley period, and normal period in the electricity report with different colors, add a SUM function to the electricity report to calculate the total value of rows and columns, and record the source file path of the electricity data.

[0017] The above technical solutions of the embodiments of the present invention are described in detail below with reference to the accompanying drawings.

[0018] like Figure 2 and Figure 3 As shown, the intelligent statistical method for power plant electricity consumption based on Python technology in an embodiment of the present invention specifically includes the following processing: The processing flow of the data access layer: File scanning: Automatically traverses the CSV files in the specified path (`BASE_FOLDER / YEARMONTH / 01, 02`).

[0019] Data parsing: Read the first row of each CSV file and extract 48 half-hour power consumption data in columns C-AX.

[0020] Exception handling: Missing values ​​are filled with 0, and non-numeric data are forcibly converted and logged.

[0021] Metadata binding: Extract the date from the file name and combine it with the globally configured year and month parameters to generate a complete timestamp.

[0022] The dynamic time period engine processing of the core processing layer: Load the basic configuration (fixed year, month, and holiday rules), calculate the day of the week based on the date, distinguish between workday and holiday modes, and perform time division. The calculation method for performing time division includes: 1. Input parameter: the day of the week of the current date (0-6 corresponds to Monday to Sunday) 2. Time period rules: Working days (Monday to Friday): Peak hours: 9:30-11:00 and 17:00-20:00; Valley period: 22:00-4:00 the next day; Normal period: rest of the time; Saturday: The entire day will be treated as normal hours, with only 22:00-4:00 designated as off-peak hours; Sunday: All-day valley period (22:00-4:00) + regular period; 3. Execution logic: The 48 half-hour data points per day (00:00-23:30) are classified according to the above rules, with special treatment given to the 30-minute period (e.g., 9:30-10:00 is a peak period).

[0023] 4. Output: Generate a list of 48 elements, marking the time period type of each time point.

[0024] like Figure 4 As shown, the processing logic example of the dynamic time period division algorithm is as follows: - **Input**: Date, time, holiday mark (e.g. Saturday is treated as a working day, Sunday has special rules).

[0025] - **Processing logic**: ```Python def calculate_periods(date, hour): if is_holiday(date): return apply_holiday_rules(hour)# Holiday special period elif date.weekday() == 6: # Sunday return 'Valley' if (hour>= 22 or hour<4) else 'Ping' else:# Working days (including Saturday) is_peak = (9.5<= hour<11.5) or (17<= hour<20) is_valley = (hour>= 22) or (hour<4) return 'peak' if is_peak else 'valley' if is_valley else 'flat' ``` like Figure 5 As shown, the data aggregator includes the following processing: 1. Time dimension aggregation: Aggregate the 48 half-hour data by hour (sum of two data points) and day (24-hour accumulation).

[0026] 2. Electricity price statistics: Accumulate electricity consumption by peak / flat / valley classification, retaining 2 decimal places of precision.

[0027] 3. Memory optimization: Use generator expression streaming processing to avoid storing all data in memory.

[0028] Report generation at the visualization layer: Create an Excel file containing four worksheets (a half-hourly breakdown, a summary, and an hourly report). Intelligent coloring is available for peaks (light green #FFCCFFCC), valleys (khaki #FFCC9900), and missing data (gray #FFC0C0C0). Formula injection automatically adds the SUM function to calculate row and column totals. Interactive features include: cell double-click traceback: recording the data source file path; and adaptive column width: setting a uniform 10-character width.

[0029] Provide automated scheduling at the service layer: 1. Directory self-check: automatically create missing output directories (`os.makedirs`); 2. Error retry mechanism: when file reading fails, it is skipped and recorded without affecting the overall process; 3. Execution log: Outputs status information with timestamps for key steps.

[0030] The following is an example of the processing flow of the embodiment of the present invention.

[0031] Initialization phase: load the global configuration (year, month, base path), and verify whether the input directory structure meets the expectations (the existence of subfolders 01 and 02).

[0032] Data collection and cleaning: Multi-threaded parallel reading of data from two units (folders 01 and 02). For each CSV file: verify the file naming convention (DD.csv format), extract the first row of data and clean outliers, and generate a data dictionary with date labels.

[0033] Core calculations: Time period division: call `calculate_periods` to generate 48 daily time period markers; multi-dimensional statistics: single-machine statistics: calculate the daily peak / average / valley power consumption of each unit, dual-machine summary: generate cross-unit comparison data, aggregate calculation: summarize power consumption by hourly and daily granularity.

[0034] Visual output: Create an Excel workbook and generate a three-table linkage structure: a half-hour detailed table (raw data + time period coloring), a daily summary table (cross-time period statistics with the SUM formula), and an hourly report (24-hour aggregate view). Apply a unified style (font, alignment, number format).

[0035] Exception handling and services: File-level errors: skip damaged files and mark them in the log; Data-level errors: automatically fill in 0 values ​​and highlight them in gray; Resource release: ensure that file handles are closed correctly.

[0036] 1. Deployment environment configuration: Install Python 3.11 runtime environment (using Anaconda3 and Jupyter) 2. Data access example: ```Python def read_plant_data(folder_path): for filename in sorted(os.listdir(folder_path)): if filename.endswith('.csv'): Extract file date tags (ddmm format) Verify file integrity (size verification + first line verification) Perform CRC32 data check ``` 3. Report generation process: Create a basic workbook and generate unit data tables (EO1, EO2) in parallel Build a three-dimensional summary table (time × unit × time period) and generate interactive hourly reports.

[0037] The technical solutions implemented in this embodiment fully cover the entire process from data collection to visualization output. Data linkage is achieved through a unified time series processing engine. A dynamic time period engine automatically divides time periods for holidays and special dates by configuring program parameters. A memory-optimized model uses generator expressions for streaming data processing, reducing memory usage by 60%. An intelligent traceability mechanism establishes a bidirectional data index table to locate abnormal data within seconds. Processing efficiency: 30 days of data (approximately 1,440 data points) can be processed in less than 15 seconds. Accuracy: The data verification mechanism ensures 100% statistical accuracy. Resource consumption: Peak memory usage is less than 150MB (based on a measured data set).

[0038] Device Example 1 According to an embodiment of the present invention, a Python-based intelligent statistical device for power plant electricity consumption is provided. Figure 6 Schematic diagram of the intelligent statistical device for power plant electricity based on Python technology according to an embodiment of the present invention. Figure 6 As shown, the intelligent statistical device for power plant electricity consumption based on Python technology according to an embodiment of the present invention specifically includes: An acquisition and division module 60 is configured to acquire power data and date and time rule configuration information, and divide the power data into holidays and execution periods using a dynamic time period division algorithm according to the date and time rule configuration information; The power calculation module 62 is used to calculate the power data by hour and day using a generator expression, and calculate the power by execution period based on the result of the holiday and execution period division; The visualization display module 64 is used to visualize the power calculation results.

[0039] The embodiment of the present invention is an apparatus embodiment corresponding to the above-mentioned method embodiment. The specific operations of each module can be understood by referring to the description of the method embodiment, which will not be repeated here.

[0040] Device Example 2 An embodiment of the present invention provides an electronic device, such as Figure 7 As shown, it includes: a memory 70, a processor 72 and a computer program stored in the memory 70 and executable on the processor 72. When the computer program is executed by the processor 72, the steps described in the method embodiment are implemented.

[0041] Device Example 3 An embodiment of the present invention provides a computer-readable storage medium, on which a program for implementing information transmission is stored. When the program is executed by the processor 72, the steps described in the method embodiment are implemented.

[0042] The computer-readable storage medium in this embodiment includes but is not limited to: ROM, RAM, magnetic disk or optical disk, etc.

[0043] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A Python-based intelligent statistical method for power plant electricity consumption, characterized in that: include: Acquire power data and date and time rule configuration information, and divide the power data into holidays and execution periods using a dynamic time period division algorithm according to the date and time rule configuration information; The generator expression is used to calculate the power data by hour and day, and the power is calculated according to the execution period based on the results of the holidays and execution period; Visualize the power calculation results.

2. The method according to claim 1, characterized in that The obtaining of power data specifically includes: Automatically traverses the CSV files in the specified path, reads the first row of each CSV file, extracts electricity data for N predetermined time periods in columns C-AX, fills missing values ​​in the electricity data with 0, converts non-numeric data and logs it, extracts the date information from the CSV file name, and generates a complete timestamp for the extracted electricity data based on the globally configured year and month parameters, where N is a positive integer.

3. The method according to claim 2, characterized in that The N=48, and the predetermined time period is half an hour.

4. The method according to claim 1, wherein Acquiring date and time rule configuration information, and dividing the electricity data into holidays and execution periods using a dynamic time period division algorithm according to the date and time rule configuration information specifically includes: Obtain date and time rule configuration information, and according to the date and time rule configuration information, adopt a dynamic time period division algorithm to classify the electricity data into time periods and mark the time period types, and generate a time period type list for the electricity data, wherein the dynamic time period division algorithm specifically includes: distinguishing between working days and rest days, and dividing the working days and rest days into peak periods, valley periods, and normal periods based on the time period division rules.

5. The method according to claim 4, characterized in that The time period division rules specifically include: 9:30-11:00 and 17:00-20:00 on weekdays are peak periods, 22:00-4:00 the next day on weekdays are off-peak periods, and the rest of the weekdays are normal periods. Only 22:00-4:00 on Saturdays are off-peak periods, and the rest of the time is normal periods. 22:00-4:00 on Sundays is off-peak period, and the rest of the time on Sundays is normal periods.

6. The method according to claim 1, characterized in that The visualization of power calculation results includes: Create an electricity report based on the electricity calculation results, mark the peak period, valley period, and normal period in the electricity report with different colors, add a SUM function to the electricity report to calculate the total value of rows and columns, and record the source file path of the electricity data.

7. The method according to claim 1, characterized in that The method further comprises: The date and time rule configuration information is dynamically configured.

8. A Python-based intelligent statistical device for power plant electricity consumption, characterized in that: include: An acquisition and division module is used to acquire power data and date and time rule configuration information, and divide the power data into holidays and execution periods using a dynamic time period division algorithm according to the date and time rule configuration information; An electricity calculation module, configured to calculate the electricity data by hour and day using a generator expression, and to calculate the electricity by execution period based on the result of the division between holidays and execution periods; The visualization display module is used to visualize the power calculation results.

9. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the intelligent statistical method for power plant electricity based on Python technology as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores an implementation program for information transmission, and when the program is executed by the processor, the steps of the power plant electricity intelligent statistics method based on Python technology as described in any one of claims 1 to 7 are implemented.