|
@@ -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
|
|
|
+}
|