Skip to content

Commit

Permalink
Implemented asyncio approach for fetching raw historical data.
Browse files Browse the repository at this point in the history
  • Loading branch information
MeenaBana committed Aug 9, 2024
1 parent 936a677 commit 579cad3
Show file tree
Hide file tree
Showing 5 changed files with 2,306 additions and 4,045 deletions.
52 changes: 8 additions & 44 deletions notebooks/Exploring_API_Functions_Authentication.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -250,23 +250,6 @@
"opc_data = OPC_UA(rest_url=opcua_rest_url, opcua_url=opcua_server_url, namespaces=namespace_list, auth_client=auth_client)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# History data\n",
"inverters_hist_df = opc_data.get_historical_aggregated_values(\n",
" start_time=datetime.datetime.now() - datetime.timedelta(2),\n",
" end_time=datetime.datetime.now() - datetime.timedelta(1),\n",
" pro_interval=600000,\n",
" agg_name=\"Average\",\n",
" variable_list=inverters.variables_as_list([\"DCPower\"]),\n",
")\n",
"inverters_hist_df"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -286,32 +269,13 @@
"metadata": {},
"outputs": [],
"source": [
"# Historic value data of trackers, 1 days worth of data 30 days ago\n",
"one_day_historic_tracker_data = opc_data.get_historical_aggregated_values(\n",
" start_time=(datetime.datetime.now() - datetime.timedelta(30)),\n",
" end_time=(datetime.datetime.now() - datetime.timedelta(29)),\n",
" pro_interval=3600000,\n",
" agg_name=\"Average\",\n",
" variable_list=string_sets_for_first_park.variables_as_list([\"DCPower\"]),\n",
")\n",
"one_day_historic_tracker_data"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# 1 day aggregated historical inverter data in asyncio process\n",
"one_days_historic_inverter_data2 = await opc_data.get_historical_aggregated_values_async(\n",
" start_time=(datetime.datetime.now() - datetime.timedelta(30)),\n",
" end_time=(datetime.datetime.now() - datetime.timedelta(29)),\n",
" pro_interval=60*1000,\n",
" agg_name=\"Average\",\n",
"# 1 day raw historical data\n",
"one_day_raw_historical_data = await opc_data.get_raw_historical_values_async(\n",
" start_time = datetime.datetime(2023, 11, 13, 00, 00),\n",
" end_time = datetime.datetime(2023, 11, 13, 23, 59),\n",
" variable_list=string_sets_for_first_park.variables_as_list([\"DCPower\"])\n",
")\n",
"one_days_historic_inverter_data2"
"one_day_raw_historical_data"
]
},
{
Expand All @@ -321,9 +285,9 @@
"outputs": [],
"source": [
"# 1 day aggregated historical data\n",
"one_day_historical_data = await opc_data.get_historical_aggregated_values_batch_time_vars_async(\n",
" start_time=(datetime.datetime.now() - datetime.timedelta(30)),\n",
" end_time=(datetime.datetime.now() - datetime.timedelta(29)),\n",
"one_day_historical_data = await opc_data.get_historical_aggregated_values_async(\n",
" start_time = datetime.datetime(2023, 11, 13, 00, 00),\n",
" end_time = datetime.datetime(2023, 11, 13, 23, 59),\n",
" pro_interval=60*1000,\n",
" agg_name=\"Average\",\n",
" variable_list=string_sets_for_first_park.variables_as_list([\"DCPower\"])\n",
Expand Down
Loading

0 comments on commit 579cad3

Please sign in to comment.