anweiguo 5 meses atrás
pai
commit
99642f30b0
41 arquivos alterados com 1242 adições e 15 exclusões
  1. 7 0
      .gitignore
  2. 56 0
      .ipynb_checkpoints/Untitled-checkpoint.ipynb
  3. 4 0
      .ipynb_checkpoints/main-checkpoint.py
  4. 81 0
      Untitled.ipynb
  5. 1 1
      data_processing/processing_limit_power/processing_limit_power_by_agcavc/.ipynb_checkpoints/Dockerfile-checkpoint
  6. 1 1
      data_processing/processing_limit_power/processing_limit_power_by_agcavc/Dockerfile
  7. 1 1
      data_processing/processing_limit_power/processing_limit_power_by_machines/.ipynb_checkpoints/Dockerfile-checkpoint
  8. 6 0
      data_processing/processing_limit_power/processing_limit_power_by_machines/.ipynb_checkpoints/Untitled-checkpoint.ipynb
  9. 1 0
      data_processing/processing_limit_power/processing_limit_power_by_machines/.ipynb_checkpoints/processing_limit_power_by_machines-checkpoint.py
  10. 1 1
      data_processing/processing_limit_power/processing_limit_power_by_machines/Dockerfile
  11. 89 0
      data_processing/processing_limit_power/processing_limit_power_by_machines/Untitled.ipynb
  12. 1 0
      data_processing/processing_limit_power/processing_limit_power_by_machines/processing_limit_power_by_machines.py
  13. 34 1
      data_processing/processing_limit_power/processing_limit_power_by_machines/test.ipynb
  14. 1 1
      data_processing/processing_limit_power/processing_limit_power_by_records/.ipynb_checkpoints/Dockerfile-checkpoint
  15. 1 1
      data_processing/processing_limit_power/processing_limit_power_by_records/Dockerfile
  16. 16 0
      data_processing/processing_limit_power/processing_limit_power_by_statistics/.ipynb_checkpoints/Dockerfile-checkpoint
  17. 128 0
      data_processing/processing_limit_power/processing_limit_power_by_statistics/.ipynb_checkpoints/processing_limit_power_by_statistics_light-checkpoint.py
  18. 8 0
      data_processing/processing_limit_power/processing_limit_power_by_statistics/.ipynb_checkpoints/requirements-checkpoint.txt
  19. 298 0
      data_processing/processing_limit_power/processing_limit_power_by_statistics/.ipynb_checkpoints/test-checkpoint.ipynb
  20. 16 0
      data_processing/processing_limit_power/processing_limit_power_by_statistics/Dockerfile
  21. 128 0
      data_processing/processing_limit_power/processing_limit_power_by_statistics/processing_limit_power_by_statistics_light.py
  22. 8 0
      data_processing/processing_limit_power/processing_limit_power_by_statistics/requirements.txt
  23. 298 0
      data_processing/processing_limit_power/processing_limit_power_by_statistics/test.ipynb
  24. 0 0
      docker_bulid/.ipynb_checkpoints/__init__-checkpoint.py
  25. 0 0
      docker_bulid/.ipynb_checkpoints/main-checkpoint.py
  26. 5 0
      docker_bulid/.ipynb_checkpoints/method_a-checkpoint.py
  27. 5 0
      docker_bulid/.ipynb_checkpoints/method_b-checkpoint.py
  28. 0 0
      docker_bulid/__init__.py
  29. BIN
      docker_bulid/__pycache__/method_a.cpython-39.pyc
  30. 4 0
      docker_bulid/main.py
  31. 5 0
      docker_bulid/method_a.py
  32. 5 0
      docker_bulid/method_b.py
  33. 1 1
      evaluation_processing/evaluation_accuracy/.ipynb_checkpoints/Dockerfile-checkpoint
  34. 1 1
      evaluation_processing/evaluation_accuracy/Dockerfile
  35. 19 0
      evaluation_processing/evaluation_accuracy/test.ipynb
  36. 5 0
      main.py
  37. 1 1
      models_processing/model_prediction_lightgbm/.ipynb_checkpoints/Dockerfile-checkpoint
  38. 1 1
      models_processing/model_prediction_lightgbm/Dockerfile
  39. 1 1
      models_processing/model_training_lighgbm/.ipynb_checkpoints/Dockerfile-checkpoint
  40. 1 1
      models_processing/model_training_lighgbm/Dockerfile
  41. 3 2
      models_processing/model_training_lighgbm/test.ipynb

+ 7 - 0
.gitignore

@@ -0,0 +1,7 @@
+# 忽略所有文件,但保留特定文件
+*.csv
+*.xls
+*.xlsx
+ipynb_checkpoints/**
+__pycache__/**
+*.zip

+ 56 - 0
.ipynb_checkpoints/Untitled-checkpoint.ipynb

@@ -0,0 +1,56 @@
+{
+ "cells": [
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "id": "dc9a90a7-162d-4f7c-9388-fd23b039ee36",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "import pandas as pd \n",
+    "import numpy as np\n",
+    "\n",
+    "def method_a():\n",
+    "    print(\"method_a print hello world!\")\n",
+    "    "
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "id": "193ae985-8f61-4c31-9a12-b82ded63eaf2",
+   "metadata": {},
+   "outputs": [],
+   "source": []
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "id": "b2e63274-e6ee-4f9e-b73e-666960f7f536",
+   "metadata": {},
+   "outputs": [],
+   "source": []
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python (panddlets)",
+   "language": "python",
+   "name": "panddlets"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.9.19"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}

+ 4 - 0
.ipynb_checkpoints/main-checkpoint.py

@@ -0,0 +1,4 @@
+import os
+
+# 获取当前工作目录
+current_dir = os.getcwd()

+ 81 - 0
Untitled.ipynb

@@ -0,0 +1,81 @@
+{
+ "cells": [
+  {
+   "cell_type": "code",
+   "execution_count": 15,
+   "id": "8e82214d-6c64-433d-800f-2dde5f4a18bc",
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "import pandas as pd \n",
+      "import numpy as np\n",
+      "\n",
+      "def method_a():\n",
+      "    print(\"method_a print hello world!\")\n"
+     ]
+    }
+   ],
+   "source": [
+    "\n",
+    "with open('D://jupyterProject//jyProject//algorithm_platform//docker_bulid//method_a.py', 'r') as file:\n",
+    "    data = file.read()\n",
+    "\n",
+    "print(data)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 2,
+   "id": "2d45d74a-1157-4226-9aec-a11e39b1e143",
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "method_a print hello world!\n",
+      "None\n"
+     ]
+    }
+   ],
+   "source": [
+    "# file2.py\n",
+    "import sys\n",
+    "import os\n",
+    "\n",
+    "# 将 file1.py 所在目录添加到 Python 路径\n",
+    "sys.path.append(os.path.abspath(\"D://jupyterProject//jyProject//algorithm_platform//docker_bulid\"))\n",
+    "\n",
+    "# 导入 file1.py 中的方法\n",
+    "import method_a\n",
+    "\n",
+    "# 使用 file1 中的方法\n",
+    "print(method_a.method_a())"
+   ]
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python (panddlets)",
+   "language": "python",
+   "name": "panddlets"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.9.19"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}

+ 1 - 1
data_processing/processing_limit_power/processing_limit_power_by_agcavc/.ipynb_checkpoints/Dockerfile-checkpoint

@@ -1,5 +1,5 @@
 # 使用官方 Python 镜像作为基础镜像
-FROM python:3.9
+192.168.1.36:5000/python:3.9-slim
 ENV LANG=en_US.UTF-8
 # 设置工作目录
 WORKDIR /app

+ 1 - 1
data_processing/processing_limit_power/processing_limit_power_by_agcavc/Dockerfile

@@ -1,5 +1,5 @@
 # 使用官方 Python 镜像作为基础镜像
-FROM python:3.9
+192.168.1.36:5000/python:3.9-slim
 ENV LANG=en_US.UTF-8
 # 设置工作目录
 WORKDIR /app

+ 1 - 1
data_processing/processing_limit_power/processing_limit_power_by_machines/.ipynb_checkpoints/Dockerfile-checkpoint

@@ -1,5 +1,5 @@
 # 使用官方 Python 镜像作为基础镜像
-FROM python:3.9
+192.168.1.36:5000/python:3.9-slim
 ENV LANG=en_US.UTF-8
 # 设置工作目录
 WORKDIR /app

+ 6 - 0
data_processing/processing_limit_power/processing_limit_power_by_machines/.ipynb_checkpoints/Untitled-checkpoint.ipynb

@@ -0,0 +1,6 @@
+{
+ "cells": [],
+ "metadata": {},
+ "nbformat": 4,
+ "nbformat_minor": 5
+}

+ 1 - 0
data_processing/processing_limit_power/processing_limit_power_by_machines/.ipynb_checkpoints/processing_limit_power_by_machines-checkpoint.py

@@ -69,6 +69,7 @@ def processing_limit_power_by_machines():
     print("Program starts execution!")
     try:
         args = request.values.to_dict()
+        print("*********",args,"*******")
         power_df = get_data_from_mongo(args)
         res_df = windLight_machine_judgment(power_df,args)
         insert_data_into_mongo(res_df,args)

+ 1 - 1
data_processing/processing_limit_power/processing_limit_power_by_machines/Dockerfile

@@ -1,5 +1,5 @@
 # 使用官方 Python 镜像作为基础镜像
-FROM python:3.9
+192.168.1.36:5000/python:3.9-slim
 ENV LANG=en_US.UTF-8
 # 设置工作目录
 WORKDIR /app

+ 89 - 0
data_processing/processing_limit_power/processing_limit_power_by_machines/Untitled.ipynb

@@ -0,0 +1,89 @@
+{
+ "cells": [
+  {
+   "cell_type": "code",
+   "execution_count": 11,
+   "id": "ec2c53de-6bb0-4358-9eb4-e7b7301877df",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "(<bound method Response.json of <Response [200]>>, <Response [200]>)"
+      ]
+     },
+     "execution_count": 11,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "import requests\n",
+    "url = 'http://localhost:10087/processing_limit_power_by_machines'\n",
+    "data = {\n",
+    "    'col_rp': '实际功率',\n",
+    "    'col_tp': '理论功率',\n",
+    "    'mongodb_connection': 'mongodb://root:Jydl3377@192.168.1.33:27017',\n",
+    "    'mongodb_database': 'algorithm_platform',\n",
+    "    'mongodb_read_table': 'J00260NWP_agcavc',\n",
+    "    'mongodb_write_table': 'J00260NWP_machines',\n",
+    "    # 添加其他参数\n",
+    "}\n",
+    "response = requests.post(url, data) \n"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 15,
+   "id": "5723d8bf-5711-45c0-a9e6-4649061d7c55",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "{'args': {'col_rp': '实际功率',\n",
+       "  'col_tp': '理论功率',\n",
+       "  'mongodb_connection': 'mongodb://root:Jydl3377@192.168.1.33:27017',\n",
+       "  'mongodb_database': 'algorithm_platform',\n",
+       "  'mongodb_read_table': 'J00260NWP_agcavc',\n",
+       "  'mongodb_write_table': 'J00260NWP_machines'},\n",
+       " 'end_time': '2024-09-27 11:30:00',\n",
+       " 'start_time': '2024-09-27 11:29:52',\n",
+       " 'success': 1}"
+      ]
+     },
+     "execution_count": 15,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "import json  \n",
+    "\n",
+    "parsed_json = json.loads(response.text)\n",
+    "parsed_json"
+   ]
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 3 (ipykernel)",
+   "language": "python",
+   "name": "python3"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.9.13"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}

+ 1 - 0
data_processing/processing_limit_power/processing_limit_power_by_machines/processing_limit_power_by_machines.py

@@ -69,6 +69,7 @@ def processing_limit_power_by_machines():
     print("Program starts execution!")
     try:
         args = request.values.to_dict()
+        print("*********",args,"*******")
         power_df = get_data_from_mongo(args)
         res_df = windLight_machine_judgment(power_df,args)
         insert_data_into_mongo(res_df,args)

+ 34 - 1
data_processing/processing_limit_power/processing_limit_power_by_machines/test.ipynb

@@ -234,7 +234,7 @@
      "name": "stderr",
      "output_type": "stream",
      "text": [
-      "2024-09-26 11:36:04,943 - waitress - INFO - Serving on http://0.0.0.0:10087\n"
+      "2024-09-27 11:28:37,433 - waitress - INFO - Serving on http://0.0.0.0:10087\n"
      ]
     },
     {
@@ -243,6 +243,10 @@
      "text": [
       "Program starts execution!\n",
       "Program starts execution!\n",
+      "********* {'col_rp': '实际功率', 'col_tp': '理论功率', 'mongondb_connection': 'mongodb://root:Jydl3377@192.168.1.33:27017', 'mongondb_database': 'algorithm_platform', 'mongondb_read_table': 'J00260NWP_agcavc', 'mongondb_write_table': 'J00260NWP_machines'} *******\n",
+      "Program execution ends!\n",
+      "Program starts execution!\n",
+      "********* {'col_rp': '实际功率', 'col_tp': '理论功率', 'mongodb_connection': 'mongodb://root:Jydl3377@192.168.1.33:27017', 'mongodb_database': 'algorithm_platform', 'mongodb_read_table': 'J00260NWP_agcavc', 'mongodb_write_table': 'J00260NWP_machines'} *******\n",
       "threshold 25.962767129908098\n"
      ]
     },
@@ -309,6 +313,35 @@
    "source": [
     "%run processing_limit_power_by_machines.py"
    ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "id": "eaf69e3c-cc2d-442e-9fcc-5fe6e0a82af2",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "import requests\n",
+    "url = 'http://localhost:10087/processing_limit_power_by_machines'\n",
+    "    data = {\n",
+    "        'col_rp': '实际功率',\n",
+    "        'col_tp': '理论功率',\n",
+    "        'mongondb_connection': 'mongodb://root:Jydl3377@192.168.1.33:27017',\n",
+    "        'mongondb_database': 'algorithm_platform',\n",
+    "        'mongondb_read_table': 'J00260NWP_agcavc',\n",
+    "        'mongondb_write_table': 'J00260NWP_machines',\n",
+    "        # 添加其他参数\n",
+    "    }\n",
+    "response = requests.post(url, data=data) "
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "id": "cf5ebae3-db2e-469c-af38-f6001ca70639",
+   "metadata": {},
+   "outputs": [],
+   "source": []
   }
  ],
  "metadata": {

+ 1 - 1
data_processing/processing_limit_power/processing_limit_power_by_records/.ipynb_checkpoints/Dockerfile-checkpoint

@@ -1,5 +1,5 @@
 # 使用官方 Python 镜像作为基础镜像
-FROM python:3.9
+192.168.1.36:5000/python:3.9-slim
 ENV LANG=en_US.UTF-8
 # 设置工作目录
 WORKDIR /app

+ 1 - 1
data_processing/processing_limit_power/processing_limit_power_by_records/Dockerfile

@@ -1,5 +1,5 @@
 # 使用官方 Python 镜像作为基础镜像
-FROM python:3.9
+192.168.1.36:5000/python:3.9-slim
 ENV LANG=en_US.UTF-8
 # 设置工作目录
 WORKDIR /app

+ 16 - 0
data_processing/processing_limit_power/processing_limit_power_by_statistics/.ipynb_checkpoints/Dockerfile-checkpoint

@@ -0,0 +1,16 @@
+# 使用官方 Python 镜像作为基础镜像
+FROM 192.168.1.36:5000/python:3.9-slim
+ENV LANG=en_US.UTF-8
+# 设置工作目录
+WORKDIR /app
+
+# 复制当前目录内容到工作目录
+COPY . /app
+
+# 安装依赖项(如果有)
+RUN set -ex \
+    && pip3 install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
+# 设置 ENTRYPOINT 为 Python 脚本
+ENTRYPOINT ["python", "processing_limit_power_by_statistics_light.py"]
+# 执行 Python 脚本
+CMD []

+ 128 - 0
data_processing/processing_limit_power/processing_limit_power_by_statistics/.ipynb_checkpoints/processing_limit_power_by_statistics_light-checkpoint.py

@@ -0,0 +1,128 @@
+import argparse
+import pandas as pd 
+from pymongo import MongoClient
+from sqlalchemy import create_engine
+from flask import Flask,request,jsonify
+from waitress import serve
+import time
+import logging
+import traceback
+from sklearn.linear_model import LinearRegression
+import numpy as np
+app = Flask('processing_limit_power_by_statistics_light——service')
+
+@app.route('/hello', methods=['GET'])
+def hello():
+    return jsonify(message='Hello, World!')
+
+
+def get_data_from_mongo(args):
+    mongodb_connection,mongodb_database,mongodb_read_table = args['mongodb_connection'],args['mongodb_database'],args['mongodb_read_table']
+    client = MongoClient(mongodb_connection)
+    # 选择数据库(如果数据库不存在,MongoDB 会自动创建)
+    db = client[mongodb_database]
+    collection = db[mongodb_read_table]  # 集合名称
+    data_from_db = collection.find()  # 这会返回一个游标(cursor)
+    # 将游标转换为列表,并创建 pandas DataFrame
+    df = pd.DataFrame(list(data_from_db))
+    client.close()
+    return df
+
+def insert_data_into_mongo(res_df,args):
+    mongodb_connection,mongodb_database,mongodb_write_table = args['mongodb_connection'],args['mongodb_database'],args['mongodb_write_table']
+    client = MongoClient(mongodb_connection)
+    db = client[mongodb_database]
+    if mongodb_write_table in db.list_collection_names():
+        db[mongodb_write_table].drop()
+        print(f"Collection '{mongodb_write_table} already exist, deleted successfully!")
+    collection = db[mongodb_write_table]  # 集合名称
+    # 将 DataFrame 转为字典格式
+    data_dict = res_df.to_dict("records")  # 每一行作为一个字典
+    # 插入到 MongoDB
+    collection.insert_many(data_dict)
+    print("data inserted successfully!")
+
+
+
+
+def light_statistics_judgement(df_power,args):
+    """
+    原理:基于实测辐照度与实际功率相关性强正相关,呈严格线性关系为假设前提,
+      假设误差大致呈现标准正态分布 mean + N*std   
+    """
+
+    col_radiance, col_power, sigma=args['col_radiance'],args['col_power'],float(args['sigma'])
+    # 提取辐射度和实际功率
+    X = df_power[[col_radiance]].values
+    y = df_power[col_power].values
+    
+    # 创建线性回归模型并拟合
+    model = LinearRegression()
+    model.fit(X, y)
+    
+    # 获取斜率和偏移量
+    k_final = model.coef_[0]
+    b = model.intercept_
+
+    # 计算预测的实际功率范围
+    predicted_power = model.predict(X)
+    margin = np.mean(abs(y - predicted_power))+ sigma * np.std(abs(y - predicted_power))
+    print("margin:",margin)
+    # 过滤数据
+    def filter_unlimited_power(zfs, real_power):
+        high = min(k_final * zfs + b + margin, 100)
+        low = max(k_final * zfs + b - margin, 0)
+        return low <= real_power <= high
+    
+    # 应用过滤并标记数据
+    df_power['c'] = df_power.apply(lambda row: 'green' if filter_unlimited_power(row[col_radiance], row[col_power]) else 'red', axis=1)
+    df_power['is_limit'] = df_power['c'].apply(lambda x: False if x=='green' else True)
+    # df_power.plot.scatter(x=col_radiance, y=col_power, c='c')
+    #过滤掉限电点
+    new_df_power = df_power[df_power['is_limit'] == False]    
+    print(f"未清洗限电前,总共有:{len(df_power)}条数据")
+    print(f"清除限电后保留的点有:{len(new_df_power)}, 占比:{round(len(new_df_power) / len(df_power), 2)}")
+    return df_power[df_power['is_limit'] == False].drop(['is_limit','c'],axis=1)
+
+
+@app.route('/processing_limit_power_by_statistics_light', methods=['POST','GET'])
+def processing_limit_power_by_statistics_light():
+    # 获取程序开始时间  
+    start_time = time.time()  
+    result = {}
+    success = 0
+    print("Program starts execution!")
+    try:
+        args = request.values.to_dict()
+        print('args',args)
+        logger.info(args)
+        power_df = get_data_from_mongo(args)
+        res_df = light_statistics_judgement(power_df,args)
+        insert_data_into_mongo(res_df,args)
+        success = 1
+    except Exception as e:
+        my_exception = traceback.format_exc()
+        my_exception.replace("\n","\t")
+        result['msg'] = my_exception
+    end_time = time.time() 
+   
+    result['success'] = success
+    result['args'] = args
+    result['start_time'] = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(start_time))
+    result['end_time'] = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(end_time))
+    print("Program execution ends!")
+    return result
+
+
+
+    
+if __name__=="__main__":
+    print("Program starts execution!")
+    logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
+    logger = logging.getLogger("统计法清洗光伏场站限电")
+    from waitress import serve
+    serve(app, host="0.0.0.0", port=10085)
+    print("server start!")
+    
+   
+    

+ 8 - 0
data_processing/processing_limit_power/processing_limit_power_by_statistics/.ipynb_checkpoints/requirements-checkpoint.txt

@@ -0,0 +1,8 @@
+pymongo==4.9.1
+pandas==2.1.4
+SQLAlchemy==2.0.30
+PyMySQL==1.1.1
+Flask==3.0.3
+waitress==3.0.0
+numpy== 1.26.4
+scikit-learn== 1.4.2

+ 298 - 0
data_processing/processing_limit_power/processing_limit_power_by_statistics/.ipynb_checkpoints/test-checkpoint.ipynb

@@ -0,0 +1,298 @@
+{
+ "cells": [
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "id": "752c3ab3-cdef-47b0-9d9a-805348d30d6e",
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stderr",
+     "output_type": "stream",
+     "text": [
+      "2024-09-26 11:00:17,560 - waitress - INFO - Serving on http://0.0.0.0:10086\n"
+     ]
+    },
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "Program starts execution!\n"
+     ]
+    },
+    {
+     "name": "stderr",
+     "output_type": "stream",
+     "text": [
+      "2024-09-26 11:00:24,004 - new_leads_classification - INFO - {'timeBegin': '2024-05-01', 'timeEnd': '2024-09-20', 'col_time': 'C_TIME', 'user': 'root', 'password': 'mysql_T7yN3E', 'host': '192.168.12.10', 'port': '19306', 'database': 'ipfcst_j00260_20240911093804', 'agc_avc_table': 't_power_station_status_data', 'mongodb_connection': 'mongodb://root:Jydl3377@192.168.1.33:27017', 'mongodb_database': 'algorithm_platform', 'mongodb_read_table': 'J00260NWP', 'mongodb_write_table': 'J00260NWP_agcavc'}\n"
+     ]
+    },
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "Program starts execution!\n",
+      "args {'timeBegin': '2024-05-01', 'timeEnd': '2024-09-20', 'col_time': 'C_TIME', 'user': 'root', 'password': 'mysql_T7yN3E', 'host': '192.168.12.10', 'port': '19306', 'database': 'ipfcst_j00260_20240911093804', 'agc_avc_table': 't_power_station_status_data', 'mongodb_connection': 'mongodb://root:Jydl3377@192.168.1.33:27017', 'mongodb_database': 'algorithm_platform', 'mongodb_read_table': 'J00260NWP', 'mongodb_write_table': 'J00260NWP_agcavc'}\n",
+      "Index(['_id', 'C_TIME', '理论功率', '第1个设备轮毂风速', '实际功率', '实时环境数据', '预测功率',\n",
+      "       'NWP预测总辐射', 'NWP-10米预测风速', 'NWP-10米预测风向', 'NWP-30米预测风速', 'NWP-30米预测风向',\n",
+      "       'NWP-50米预测风速', 'NWP-50米预测风向', 'NWP-70米预测风速', 'NWP-70米预测风向',\n",
+      "       'NWP-90米预测风速', 'NWP-90米预测风向', 'NWP-110米预测风速', 'NWP-110米预测风向',\n",
+      "       'NWP-150米预测风速', 'NWP-150米预测风向', 'NWP-170米预测风速', 'NWP-170米预测风向',\n",
+      "       'NWP-低云量', 'NWP-中云量', 'NWP-高云量', 'NWP-总云量', 'NWP-晴空总辐射', 'NWP-法相直辐射',\n",
+      "       'NWP-总降水强度', 'NWP-温度', 'NWP-湿度', 'NWP-气压'],\n",
+      "      dtype='object')\n",
+      "Collection 'J00260NWP_agcavc already exist, deleted successfully!\n",
+      "data inserted successfully!\n",
+      "Program execution ends!\n"
+     ]
+    }
+   ],
+   "source": [
+    "%run processing_limit_power_by_agcavc.py"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 2,
+   "id": "3537b980-9596-4204-967c-28122d03cb0d",
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "程序开始时间: 2024-09-26 08:52:23\n",
+      "程序结束时间: 2024-09-26 08:52:28\n",
+      "程序运行时间: 5.01秒\n"
+     ]
+    }
+   ],
+   "source": [
+    "import time  \n",
+    "  \n",
+    "# 获取程序开始时间  \n",
+    "start_time = time.time()  \n",
+    "  \n",
+    "# 这里是你的程序主体  \n",
+    "# 例如,我们可以简单地让程序等待一段时间来模拟一些工作  \n",
+    "time.sleep(5)  # 让程序暂停5秒  \n",
+    "  \n",
+    "# 获取程序结束时间  \n",
+    "end_time = time.time()  \n",
+    "  \n",
+    "# 计算程序运行时间  \n",
+    "elapsed_time = end_time - start_time  \n",
+    "  \n",
+    "# 打印程序开始时间、结束时间和运行时间  \n",
+    "print(f\"程序开始时间: {time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(start_time))}\")  \n",
+    "print(f\"程序结束时间: {time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(end_time))}\")  \n",
+    "print(f\"程序运行时间: {elapsed_time:.2f}秒\")"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 13,
+   "id": "acc6aa2a-0f1d-43f3-985d-cd37c4a5ac6e",
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "Output:\n",
+      "Program starts execution!\n",
+      "args: Namespace(timeBegin='2024-05-01', timeEnd='2024-09-20', col_time='C_TIME', user='root', password='mysql_T7yN3E', host='192.168.12.10', port=19306, database='ipfcst_j00260_20240911093804', agc_avc_table='t_power_station_status_data', mongodb_connection='mongodb://root:Jydl3377@192.168.1.33:27017', mongodb_database='algorithm_platform', mongodb_read_table='J00260NWP', mongodb_write_table='J00260NWP_agcavc')\n",
+      "Index(['_id', 'C_TIME', '理论功率', '第1个设备轮毂风速', '实际功率', '实时环境数据', '预测功率',\n",
+      "       'NWP预测总辐射', 'NWP-10米预测风速', 'NWP-10米预测风向', 'NWP-30米预测风速', 'NWP-30米预测风向',\n",
+      "       'NWP-50米预测风速', 'NWP-50米预测风向', 'NWP-70米预测风速', 'NWP-70米预测风向',\n",
+      "       'NWP-90米预测风速', 'NWP-90米预测风向', 'NWP-110米预测风速', 'NWP-110米预测风向',\n",
+      "       'NWP-150米预测风速', 'NWP-150米预测风向', 'NWP-170米预测风速', 'NWP-170米预测风向',\n",
+      "       'NWP-低云量', 'NWP-中云量', 'NWP-高云量', 'NWP-总云量', 'NWP-晴空总辐射', 'NWP-法相直辐射',\n",
+      "       'NWP-总降水强度', 'NWP-温度', 'NWP-湿度', 'NWP-气压'],\n",
+      "      dtype='object')\n",
+      "Collection 'J00260NWP_agcavc already exist, deleted successfully!\n",
+      "data inserted successfully!\n",
+      "Program execution ends!\n",
+      "\n",
+      "Error:\n",
+      "\n"
+     ]
+    }
+   ],
+   "source": [
+    "import subprocess\n",
+    "\n",
+    "# 构建命令\n",
+    "command = [\n",
+    "    \"python\", \"processing_limit_power_by_agcavc.py\",\n",
+    "    \"--timeBegin\", \"2024-05-01\",\n",
+    "    \"--timeEnd\", \"2024-09-20\",\n",
+    "    \"--col_time\", \"C_TIME\",\n",
+    "    \"--user\", \"root\",\n",
+    "    \"--password\", \"mysql_T7yN3E\",\n",
+    "    \"--host\", \"192.168.12.10\",\n",
+    "    \"--port\", \"19306\",\n",
+    "    \"--database\", \"ipfcst_j00260_20240911093804\",\n",
+    "    \"--agc_avc_table\",\"t_power_station_status_data\",\n",
+    "    \"--mongodb_connection\", \"mongodb://root:Jydl3377@192.168.1.33:27017\",\n",
+    "    \"--mongodb_database\", \"algorithm_platform\",\n",
+    "    \"--mongodb_read_table\", \"J00260NWP\",\n",
+    "    \"--mongodb_write_table\", \"J00260NWP_agcavc\"\n",
+    "]\n",
+    "\n",
+    "# 使用 subprocess.run 来执行命令\n",
+    "result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)\n",
+    "\n",
+    "# 输出结果和错误信息\n",
+    "print(\"Output:\")\n",
+    "print(result.stdout)\n",
+    "print(\"Error:\")\n",
+    "print(result.stderr)\n"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 46,
+   "id": "c0d791f8-12d8-4ab9-b561-b474e2a739f0",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/html": [
+       "<div>\n",
+       "<style scoped>\n",
+       "    .dataframe tbody tr th:only-of-type {\n",
+       "        vertical-align: middle;\n",
+       "    }\n",
+       "\n",
+       "    .dataframe tbody tr th {\n",
+       "        vertical-align: top;\n",
+       "    }\n",
+       "\n",
+       "    .dataframe thead th {\n",
+       "        text-align: right;\n",
+       "    }\n",
+       "</style>\n",
+       "<table border=\"1\" class=\"dataframe\">\n",
+       "  <thead>\n",
+       "    <tr style=\"text-align: right;\">\n",
+       "      <th></th>\n",
+       "      <th>C_TIME</th>\n",
+       "      <th>agc_avc_limit</th>\n",
+       "    </tr>\n",
+       "  </thead>\n",
+       "  <tbody>\n",
+       "  </tbody>\n",
+       "</table>\n",
+       "</div>"
+      ],
+      "text/plain": [
+       "Empty DataFrame\n",
+       "Columns: [C_TIME, agc_avc_limit]\n",
+       "Index: []"
+      ]
+     },
+     "execution_count": 46,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "from sqlalchemy import create_engine\n",
+    "import pandas as pd\n",
+    "engine = create_engine(f\"mysql+pymysql://root:mysql_T7yN3E@192.168.12.10:19306/ipfcst_j00260_20240911093804\")\n",
+    "df = pd.read_sql_query(\"select  C_TIME, 1 as agc_avc_limit from t_power_station_status_data where C_TIME>='2024-05-01 00:00:00' and C_TIME<='2024-09-20 23:59:59' and  (C_IS_RATIONING_BY_AUTO_CONTROL is True or C_IS_RATIONING_BY_MANUAL_CONTROL=1)\",engine)\n",
+    "df['C_TIME'] = pd.to_datetime(df['C_TIME']).dt.strftime('%Y-%m-%d %H:%M:%S')\n",
+    "df"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "id": "8b7a7834-530b-4afa-88f8-b1e51bb7d45b",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "docker run processing_limit_by_agcavc     --timeBegin \"2024-05-01\"     --timeEnd \"2024-09-20\"     --col_time \"C_TIME\"     --user \"root\"     --password \"mysql_T7yN3E\"     --host \"192.168.12.10\"     --port \"19306\"     --database \"ipfcst_j00260_20240911093804\"     --agc_avc_table \"t_power_station_status_data\"     --mongondb_connection \"mongodb://root:Jydl3377@192.168.1.33:27017\"     --mongondb_database \"algorithm_platform\"     --mongondb_read_table \"J00260NWP\"     --mongondb_write_table \"J00260NWP_agcavc\""
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 15,
+   "id": "3e295203-bc38-464e-923c-29149e558c1a",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "'2024-05-01'"
+      ]
+     },
+     "execution_count": 15,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "json_data = {\n",
+    "    \"timeBegin\":\"2024-05-01\",\n",
+    "    \"timeEnd\":\"2024-09-20\",\n",
+    "    \"col_time\":\"C_TIME\",\n",
+    "    \"user\":\"root\",\n",
+    "    \"password\":\"mysql_T7yN3E\",\n",
+    "    \"host\":\"192.168.12.10\",\n",
+    "    \"port\":\"19306\",\n",
+    "    \"database\":\"ipfcst_j00260_20240911093804\",\n",
+    "    \"agc_avc_table\":\"t_power_station_status_data\",\n",
+    "    \"mongodb_connection\":\"mongodb://root:Jydl3377@192.168.1.33:27017\",\n",
+    "    \"mongodb_database\":\"algorithm_platform\",\n",
+    "    \"mongodb_read_table\":\"J00260NWP\",\n",
+    "    \"mongodb_write_table\":\"J00260NWP_agcavc\"\n",
+    "}\n",
+    "json_data['timeBegin']"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 20,
+   "id": "cc57105c-df3c-4884-876e-8547bff4c98a",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "71"
+      ]
+     },
+     "execution_count": 20,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "16+15+17+23"
+   ]
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python (panddlets)",
+   "language": "python",
+   "name": "panddlets"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.9.19"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}

+ 16 - 0
data_processing/processing_limit_power/processing_limit_power_by_statistics/Dockerfile

@@ -0,0 +1,16 @@
+# 使用官方 Python 镜像作为基础镜像
+FROM 192.168.1.36:5000/python:3.9-slim
+ENV LANG=en_US.UTF-8
+# 设置工作目录
+WORKDIR /app
+
+# 复制当前目录内容到工作目录
+COPY . /app
+
+# 安装依赖项(如果有)
+RUN set -ex \
+    && pip3 install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
+# 设置 ENTRYPOINT 为 Python 脚本
+ENTRYPOINT ["python", "processing_limit_power_by_statistics_light.py"]
+# 执行 Python 脚本
+CMD []

+ 128 - 0
data_processing/processing_limit_power/processing_limit_power_by_statistics/processing_limit_power_by_statistics_light.py

@@ -0,0 +1,128 @@
+import argparse
+import pandas as pd 
+from pymongo import MongoClient
+from sqlalchemy import create_engine
+from flask import Flask,request,jsonify
+from waitress import serve
+import time
+import logging
+import traceback
+from sklearn.linear_model import LinearRegression
+import numpy as np
+app = Flask('processing_limit_power_by_statistics_light——service')
+
+@app.route('/hello', methods=['GET'])
+def hello():
+    return jsonify(message='Hello, World!')
+
+
+def get_data_from_mongo(args):
+    mongodb_connection,mongodb_database,mongodb_read_table = args['mongodb_connection'],args['mongodb_database'],args['mongodb_read_table']
+    client = MongoClient(mongodb_connection)
+    # 选择数据库(如果数据库不存在,MongoDB 会自动创建)
+    db = client[mongodb_database]
+    collection = db[mongodb_read_table]  # 集合名称
+    data_from_db = collection.find()  # 这会返回一个游标(cursor)
+    # 将游标转换为列表,并创建 pandas DataFrame
+    df = pd.DataFrame(list(data_from_db))
+    client.close()
+    return df
+
+def insert_data_into_mongo(res_df,args):
+    mongodb_connection,mongodb_database,mongodb_write_table = args['mongodb_connection'],args['mongodb_database'],args['mongodb_write_table']
+    client = MongoClient(mongodb_connection)
+    db = client[mongodb_database]
+    if mongodb_write_table in db.list_collection_names():
+        db[mongodb_write_table].drop()
+        print(f"Collection '{mongodb_write_table} already exist, deleted successfully!")
+    collection = db[mongodb_write_table]  # 集合名称
+    # 将 DataFrame 转为字典格式
+    data_dict = res_df.to_dict("records")  # 每一行作为一个字典
+    # 插入到 MongoDB
+    collection.insert_many(data_dict)
+    print("data inserted successfully!")
+
+
+
+
+def light_statistics_judgement(df_power,args):
+    """
+    原理:基于实测辐照度与实际功率相关性强正相关,呈严格线性关系为假设前提,
+      假设误差大致呈现标准正态分布 mean + N*std   
+    """
+
+    col_radiance, col_power, sigma=args['col_radiance'],args['col_power'],float(args['sigma'])
+    # 提取辐射度和实际功率
+    X = df_power[[col_radiance]].values
+    y = df_power[col_power].values
+    
+    # 创建线性回归模型并拟合
+    model = LinearRegression()
+    model.fit(X, y)
+    
+    # 获取斜率和偏移量
+    k_final = model.coef_[0]
+    b = model.intercept_
+
+    # 计算预测的实际功率范围
+    predicted_power = model.predict(X)
+    margin = np.mean(abs(y - predicted_power))+ sigma * np.std(abs(y - predicted_power))
+    print("margin:",margin)
+    # 过滤数据
+    def filter_unlimited_power(zfs, real_power):
+        high = min(k_final * zfs + b + margin, 100)
+        low = max(k_final * zfs + b - margin, 0)
+        return low <= real_power <= high
+    
+    # 应用过滤并标记数据
+    df_power['c'] = df_power.apply(lambda row: 'green' if filter_unlimited_power(row[col_radiance], row[col_power]) else 'red', axis=1)
+    df_power['is_limit'] = df_power['c'].apply(lambda x: False if x=='green' else True)
+    # df_power.plot.scatter(x=col_radiance, y=col_power, c='c')
+    #过滤掉限电点
+    new_df_power = df_power[df_power['is_limit'] == False]    
+    print(f"未清洗限电前,总共有:{len(df_power)}条数据")
+    print(f"清除限电后保留的点有:{len(new_df_power)}, 占比:{round(len(new_df_power) / len(df_power), 2)}")
+    return df_power[df_power['is_limit'] == False].drop(['is_limit','c'],axis=1)
+
+
+@app.route('/processing_limit_power_by_statistics_light', methods=['POST','GET'])
+def processing_limit_power_by_statistics_light():
+    # 获取程序开始时间  
+    start_time = time.time()  
+    result = {}
+    success = 0
+    print("Program starts execution!")
+    try:
+        args = request.values.to_dict()
+        print('args',args)
+        logger.info(args)
+        power_df = get_data_from_mongo(args)
+        res_df = light_statistics_judgement(power_df,args)
+        insert_data_into_mongo(res_df,args)
+        success = 1
+    except Exception as e:
+        my_exception = traceback.format_exc()
+        my_exception.replace("\n","\t")
+        result['msg'] = my_exception
+    end_time = time.time() 
+   
+    result['success'] = success
+    result['args'] = args
+    result['start_time'] = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(start_time))
+    result['end_time'] = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(end_time))
+    print("Program execution ends!")
+    return result
+
+
+
+    
+if __name__=="__main__":
+    print("Program starts execution!")
+    logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
+    logger = logging.getLogger("统计法清洗光伏场站限电")
+    from waitress import serve
+    serve(app, host="0.0.0.0", port=10085)
+    print("server start!")
+    
+   
+    

+ 8 - 0
data_processing/processing_limit_power/processing_limit_power_by_statistics/requirements.txt

@@ -0,0 +1,8 @@
+pymongo==4.9.1
+pandas==2.1.4
+SQLAlchemy==2.0.30
+PyMySQL==1.1.1
+Flask==3.0.3
+waitress==3.0.0
+numpy== 1.26.4
+scikit-learn== 1.4.2

+ 298 - 0
data_processing/processing_limit_power/processing_limit_power_by_statistics/test.ipynb

@@ -0,0 +1,298 @@
+{
+ "cells": [
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "id": "752c3ab3-cdef-47b0-9d9a-805348d30d6e",
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stderr",
+     "output_type": "stream",
+     "text": [
+      "2024-09-26 11:00:17,560 - waitress - INFO - Serving on http://0.0.0.0:10086\n"
+     ]
+    },
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "Program starts execution!\n"
+     ]
+    },
+    {
+     "name": "stderr",
+     "output_type": "stream",
+     "text": [
+      "2024-09-26 11:00:24,004 - new_leads_classification - INFO - {'timeBegin': '2024-05-01', 'timeEnd': '2024-09-20', 'col_time': 'C_TIME', 'user': 'root', 'password': 'mysql_T7yN3E', 'host': '192.168.12.10', 'port': '19306', 'database': 'ipfcst_j00260_20240911093804', 'agc_avc_table': 't_power_station_status_data', 'mongodb_connection': 'mongodb://root:Jydl3377@192.168.1.33:27017', 'mongodb_database': 'algorithm_platform', 'mongodb_read_table': 'J00260NWP', 'mongodb_write_table': 'J00260NWP_agcavc'}\n"
+     ]
+    },
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "Program starts execution!\n",
+      "args {'timeBegin': '2024-05-01', 'timeEnd': '2024-09-20', 'col_time': 'C_TIME', 'user': 'root', 'password': 'mysql_T7yN3E', 'host': '192.168.12.10', 'port': '19306', 'database': 'ipfcst_j00260_20240911093804', 'agc_avc_table': 't_power_station_status_data', 'mongodb_connection': 'mongodb://root:Jydl3377@192.168.1.33:27017', 'mongodb_database': 'algorithm_platform', 'mongodb_read_table': 'J00260NWP', 'mongodb_write_table': 'J00260NWP_agcavc'}\n",
+      "Index(['_id', 'C_TIME', '理论功率', '第1个设备轮毂风速', '实际功率', '实时环境数据', '预测功率',\n",
+      "       'NWP预测总辐射', 'NWP-10米预测风速', 'NWP-10米预测风向', 'NWP-30米预测风速', 'NWP-30米预测风向',\n",
+      "       'NWP-50米预测风速', 'NWP-50米预测风向', 'NWP-70米预测风速', 'NWP-70米预测风向',\n",
+      "       'NWP-90米预测风速', 'NWP-90米预测风向', 'NWP-110米预测风速', 'NWP-110米预测风向',\n",
+      "       'NWP-150米预测风速', 'NWP-150米预测风向', 'NWP-170米预测风速', 'NWP-170米预测风向',\n",
+      "       'NWP-低云量', 'NWP-中云量', 'NWP-高云量', 'NWP-总云量', 'NWP-晴空总辐射', 'NWP-法相直辐射',\n",
+      "       'NWP-总降水强度', 'NWP-温度', 'NWP-湿度', 'NWP-气压'],\n",
+      "      dtype='object')\n",
+      "Collection 'J00260NWP_agcavc already exist, deleted successfully!\n",
+      "data inserted successfully!\n",
+      "Program execution ends!\n"
+     ]
+    }
+   ],
+   "source": [
+    "%run processing_limit_power_by_agcavc.py"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 2,
+   "id": "3537b980-9596-4204-967c-28122d03cb0d",
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "程序开始时间: 2024-09-26 08:52:23\n",
+      "程序结束时间: 2024-09-26 08:52:28\n",
+      "程序运行时间: 5.01秒\n"
+     ]
+    }
+   ],
+   "source": [
+    "import time  \n",
+    "  \n",
+    "# 获取程序开始时间  \n",
+    "start_time = time.time()  \n",
+    "  \n",
+    "# 这里是你的程序主体  \n",
+    "# 例如,我们可以简单地让程序等待一段时间来模拟一些工作  \n",
+    "time.sleep(5)  # 让程序暂停5秒  \n",
+    "  \n",
+    "# 获取程序结束时间  \n",
+    "end_time = time.time()  \n",
+    "  \n",
+    "# 计算程序运行时间  \n",
+    "elapsed_time = end_time - start_time  \n",
+    "  \n",
+    "# 打印程序开始时间、结束时间和运行时间  \n",
+    "print(f\"程序开始时间: {time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(start_time))}\")  \n",
+    "print(f\"程序结束时间: {time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(end_time))}\")  \n",
+    "print(f\"程序运行时间: {elapsed_time:.2f}秒\")"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 13,
+   "id": "acc6aa2a-0f1d-43f3-985d-cd37c4a5ac6e",
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "Output:\n",
+      "Program starts execution!\n",
+      "args: Namespace(timeBegin='2024-05-01', timeEnd='2024-09-20', col_time='C_TIME', user='root', password='mysql_T7yN3E', host='192.168.12.10', port=19306, database='ipfcst_j00260_20240911093804', agc_avc_table='t_power_station_status_data', mongodb_connection='mongodb://root:Jydl3377@192.168.1.33:27017', mongodb_database='algorithm_platform', mongodb_read_table='J00260NWP', mongodb_write_table='J00260NWP_agcavc')\n",
+      "Index(['_id', 'C_TIME', '理论功率', '第1个设备轮毂风速', '实际功率', '实时环境数据', '预测功率',\n",
+      "       'NWP预测总辐射', 'NWP-10米预测风速', 'NWP-10米预测风向', 'NWP-30米预测风速', 'NWP-30米预测风向',\n",
+      "       'NWP-50米预测风速', 'NWP-50米预测风向', 'NWP-70米预测风速', 'NWP-70米预测风向',\n",
+      "       'NWP-90米预测风速', 'NWP-90米预测风向', 'NWP-110米预测风速', 'NWP-110米预测风向',\n",
+      "       'NWP-150米预测风速', 'NWP-150米预测风向', 'NWP-170米预测风速', 'NWP-170米预测风向',\n",
+      "       'NWP-低云量', 'NWP-中云量', 'NWP-高云量', 'NWP-总云量', 'NWP-晴空总辐射', 'NWP-法相直辐射',\n",
+      "       'NWP-总降水强度', 'NWP-温度', 'NWP-湿度', 'NWP-气压'],\n",
+      "      dtype='object')\n",
+      "Collection 'J00260NWP_agcavc already exist, deleted successfully!\n",
+      "data inserted successfully!\n",
+      "Program execution ends!\n",
+      "\n",
+      "Error:\n",
+      "\n"
+     ]
+    }
+   ],
+   "source": [
+    "import subprocess\n",
+    "\n",
+    "# 构建命令\n",
+    "command = [\n",
+    "    \"python\", \"processing_limit_power_by_agcavc.py\",\n",
+    "    \"--timeBegin\", \"2024-05-01\",\n",
+    "    \"--timeEnd\", \"2024-09-20\",\n",
+    "    \"--col_time\", \"C_TIME\",\n",
+    "    \"--user\", \"root\",\n",
+    "    \"--password\", \"mysql_T7yN3E\",\n",
+    "    \"--host\", \"192.168.12.10\",\n",
+    "    \"--port\", \"19306\",\n",
+    "    \"--database\", \"ipfcst_j00260_20240911093804\",\n",
+    "    \"--agc_avc_table\",\"t_power_station_status_data\",\n",
+    "    \"--mongodb_connection\", \"mongodb://root:Jydl3377@192.168.1.33:27017\",\n",
+    "    \"--mongodb_database\", \"algorithm_platform\",\n",
+    "    \"--mongodb_read_table\", \"J00260NWP\",\n",
+    "    \"--mongodb_write_table\", \"J00260NWP_agcavc\"\n",
+    "]\n",
+    "\n",
+    "# 使用 subprocess.run 来执行命令\n",
+    "result = subprocess.run(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)\n",
+    "\n",
+    "# 输出结果和错误信息\n",
+    "print(\"Output:\")\n",
+    "print(result.stdout)\n",
+    "print(\"Error:\")\n",
+    "print(result.stderr)\n"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 46,
+   "id": "c0d791f8-12d8-4ab9-b561-b474e2a739f0",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/html": [
+       "<div>\n",
+       "<style scoped>\n",
+       "    .dataframe tbody tr th:only-of-type {\n",
+       "        vertical-align: middle;\n",
+       "    }\n",
+       "\n",
+       "    .dataframe tbody tr th {\n",
+       "        vertical-align: top;\n",
+       "    }\n",
+       "\n",
+       "    .dataframe thead th {\n",
+       "        text-align: right;\n",
+       "    }\n",
+       "</style>\n",
+       "<table border=\"1\" class=\"dataframe\">\n",
+       "  <thead>\n",
+       "    <tr style=\"text-align: right;\">\n",
+       "      <th></th>\n",
+       "      <th>C_TIME</th>\n",
+       "      <th>agc_avc_limit</th>\n",
+       "    </tr>\n",
+       "  </thead>\n",
+       "  <tbody>\n",
+       "  </tbody>\n",
+       "</table>\n",
+       "</div>"
+      ],
+      "text/plain": [
+       "Empty DataFrame\n",
+       "Columns: [C_TIME, agc_avc_limit]\n",
+       "Index: []"
+      ]
+     },
+     "execution_count": 46,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "from sqlalchemy import create_engine\n",
+    "import pandas as pd\n",
+    "engine = create_engine(f\"mysql+pymysql://root:mysql_T7yN3E@192.168.12.10:19306/ipfcst_j00260_20240911093804\")\n",
+    "df = pd.read_sql_query(\"select  C_TIME, 1 as agc_avc_limit from t_power_station_status_data where C_TIME>='2024-05-01 00:00:00' and C_TIME<='2024-09-20 23:59:59' and  (C_IS_RATIONING_BY_AUTO_CONTROL is True or C_IS_RATIONING_BY_MANUAL_CONTROL=1)\",engine)\n",
+    "df['C_TIME'] = pd.to_datetime(df['C_TIME']).dt.strftime('%Y-%m-%d %H:%M:%S')\n",
+    "df"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "id": "8b7a7834-530b-4afa-88f8-b1e51bb7d45b",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "docker run processing_limit_by_agcavc     --timeBegin \"2024-05-01\"     --timeEnd \"2024-09-20\"     --col_time \"C_TIME\"     --user \"root\"     --password \"mysql_T7yN3E\"     --host \"192.168.12.10\"     --port \"19306\"     --database \"ipfcst_j00260_20240911093804\"     --agc_avc_table \"t_power_station_status_data\"     --mongondb_connection \"mongodb://root:Jydl3377@192.168.1.33:27017\"     --mongondb_database \"algorithm_platform\"     --mongondb_read_table \"J00260NWP\"     --mongondb_write_table \"J00260NWP_agcavc\""
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 15,
+   "id": "3e295203-bc38-464e-923c-29149e558c1a",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "'2024-05-01'"
+      ]
+     },
+     "execution_count": 15,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "json_data = {\n",
+    "    \"timeBegin\":\"2024-05-01\",\n",
+    "    \"timeEnd\":\"2024-09-20\",\n",
+    "    \"col_time\":\"C_TIME\",\n",
+    "    \"user\":\"root\",\n",
+    "    \"password\":\"mysql_T7yN3E\",\n",
+    "    \"host\":\"192.168.12.10\",\n",
+    "    \"port\":\"19306\",\n",
+    "    \"database\":\"ipfcst_j00260_20240911093804\",\n",
+    "    \"agc_avc_table\":\"t_power_station_status_data\",\n",
+    "    \"mongodb_connection\":\"mongodb://root:Jydl3377@192.168.1.33:27017\",\n",
+    "    \"mongodb_database\":\"algorithm_platform\",\n",
+    "    \"mongodb_read_table\":\"J00260NWP\",\n",
+    "    \"mongodb_write_table\":\"J00260NWP_agcavc\"\n",
+    "}\n",
+    "json_data['timeBegin']"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 20,
+   "id": "cc57105c-df3c-4884-876e-8547bff4c98a",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "71"
+      ]
+     },
+     "execution_count": 20,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "16+15+17+23"
+   ]
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python (panddlets)",
+   "language": "python",
+   "name": "panddlets"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 3
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython3",
+   "version": "3.9.19"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 5
+}

+ 0 - 0
docker_bulid/.ipynb_checkpoints/__init__-checkpoint.py


+ 0 - 0
docker_bulid/.ipynb_checkpoints/main-checkpoint.py


+ 5 - 0
docker_bulid/.ipynb_checkpoints/method_a-checkpoint.py

@@ -0,0 +1,5 @@
+import pandas as pd 
+import numpy as np
+
+def method_a():
+    print("method_a print hello world!")

+ 5 - 0
docker_bulid/.ipynb_checkpoints/method_b-checkpoint.py

@@ -0,0 +1,5 @@
+import pandas as pd 
+import numpy as np
+
+def method_b():
+    print("method_b print hello world!")

+ 0 - 0
docker_bulid/__init__.py


BIN
docker_bulid/__pycache__/method_a.cpython-39.pyc


+ 4 - 0
docker_bulid/main.py

@@ -0,0 +1,4 @@
+import os
+
+# 获取当前工作目录
+current_dir = os.getcwd()

+ 5 - 0
docker_bulid/method_a.py

@@ -0,0 +1,5 @@
+import pandas as pd 
+import numpy as np
+
+def method_a():
+    print("method_a print hello world!")

+ 5 - 0
docker_bulid/method_b.py

@@ -0,0 +1,5 @@
+import pandas as pd 
+import numpy as np
+
+def method_b():
+    print("method_b print hello world!")

+ 1 - 1
evaluation_processing/evaluation_accuracy/.ipynb_checkpoints/Dockerfile-checkpoint

@@ -1,5 +1,5 @@
 # 使用官方 Python 镜像作为基础镜像
-FROM python:3.9
+192.168.1.36:5000/python:3.9-slim
 ENV LANG=en_US.UTF-8
 # 设置工作目录
 WORKDIR /app

+ 1 - 1
evaluation_processing/evaluation_accuracy/Dockerfile

@@ -1,5 +1,5 @@
 # 使用官方 Python 镜像作为基础镜像
-FROM python:3.9
+192.168.1.36:5000/python:3.9-slim
 ENV LANG=en_US.UTF-8
 # 设置工作目录
 WORKDIR /app

+ 19 - 0
evaluation_processing/evaluation_accuracy/test.ipynb

@@ -785,6 +785,25 @@
    "source": [
     "df[df['C_TIME'].str.contains('2024-05-05')]"
    ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 1,
+   "id": "a3b9a9ca-6c1a-40c1-a9c4-f3500fcba937",
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "208"
+      ]
+     },
+     "execution_count": 1,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": []
   }
  ],
  "metadata": {

+ 5 - 0
main.py

@@ -0,0 +1,5 @@
+import os
+
+# 获取当前工作目录
+current_dir = os.getcwd()
+data_file_path = current_dir /current_dir/ 'current_dirt'

+ 1 - 1
models_processing/model_prediction_lightgbm/.ipynb_checkpoints/Dockerfile-checkpoint

@@ -1,5 +1,5 @@
 # 使用官方 Python 镜像作为基础镜像
-FROM python:3.9
+FROM 192.168.1.36:5000/python:3.9-slim
 ENV LANG=en_US.UTF-8
 # 设置工作目录
 WORKDIR /app

+ 1 - 1
models_processing/model_prediction_lightgbm/Dockerfile

@@ -1,5 +1,5 @@
 # 使用官方 Python 镜像作为基础镜像
-FROM python:3.9
+FROM 192.168.1.36:5000/python:3.9-slim
 ENV LANG=en_US.UTF-8
 # 设置工作目录
 WORKDIR /app

+ 1 - 1
models_processing/model_training_lighgbm/.ipynb_checkpoints/Dockerfile-checkpoint

@@ -1,5 +1,5 @@
 # 使用官方 Python 镜像作为基础镜像
-FROM python:3.9
+FROM 192.168.1.36:5000/python:3.9-slim
 ENV LANG=en_US.UTF-8
 # 设置工作目录
 WORKDIR /app

+ 1 - 1
models_processing/model_training_lighgbm/Dockerfile

@@ -1,5 +1,5 @@
 # 使用官方 Python 镜像作为基础镜像
-FROM python:3.9
+FROM 192.168.1.36:5000/python:3.9-slim
 ENV LANG=en_US.UTF-8
 # 设置工作目录
 WORKDIR /app

+ 3 - 2
models_processing/model_training_lighgbm/test.ipynb

@@ -37,7 +37,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": null,
+   "execution_count": 1,
    "id": "b47d615a-5953-43c0-9289-387d5c823a7a",
    "metadata": {},
    "outputs": [
@@ -124,7 +124,8 @@
       "Program starts execution!\n",
       "args {'numerical_features': 'NWP预测总辐射,NWP-10米预测风速,NWP-10米预测风向,NWP-30米预测风速,NWP-30米预测风向,NWP-50米预测风速,NWP-50米预测风向,NWP-70米预测风速,NWP-70米预测风向,NWP-90米预测风速,NWP-90米预测风向,NWP-110米预测风速,NWP-110米预测风向,NWP-150米预测风速,NWP-150米预测风向,NWP-170米预测风速,NWP-170米预测风向,NWP-低云量,NWP-中云量,NWP-高云量,NWP-总云量,NWP-晴空总辐射,NWP-法相直辐射,NWP-总降水强度,NWP-温度,NWP-湿度,NWP-气压', 'label': '实际功率', 'learning_rate': '0.01', 'num_leaves': '31', 'min_data_in_leaf': '21', 'mongodb_connection': 'mongodb://root:Jydl3377@192.168.1.33:27017', 'mongodb_database': 'algorithm_platform', 'col_pp': 'predict', 'mongodb_read_table': 'J00260NWP_records', 'mongodb_write_table': 'models', 'model_name': 'lightgbm_model', 'categorical_features': \"''\"}\n",
       "features:************ ['NWP预测总辐射', 'NWP-10米预测风速', 'NWP-10米预测风向', 'NWP-30米预测风速', 'NWP-30米预测风向', 'NWP-50米预测风速', 'NWP-50米预测风向', 'NWP-70米预测风速', 'NWP-70米预测风向', 'NWP-90米预测风速', 'NWP-90米预测风向', 'NWP-110米预测风速', 'NWP-110米预测风向', 'NWP-150米预测风速', 'NWP-150米预测风向', 'NWP-170米预测风速', 'NWP-170米预测风向', 'NWP-低云量', 'NWP-中云量', 'NWP-高云量', 'NWP-总云量', 'NWP-晴空总辐射', 'NWP-法相直辐射', 'NWP-总降水强度', 'NWP-温度', 'NWP-湿度', 'NWP-气压', \"''\"]\n",
-      "Program execution ends!\n"
+      "Program execution ends!\n",
+      "server start!\n"
      ]
     }
    ],