Compare commits

..

2 Commits

Author SHA1 Message Date
Wir
752610a905 Falsches Model 2024-10-28 09:37:33 +01:00
Wir
8a0e38c13c Datumformat verbessert 2024-10-23 12:30:38 +02:00
3 changed files with 112 additions and 3524 deletions

View File

@@ -5,9 +5,6 @@
"execution_count": 1,
"id": "73e934a8-9027-4ad1-ad15-e68fba847768",
"metadata": {
"jupyter": {
"source_hidden": true
},
"scrolled": true
},
"outputs": [],
@@ -33,22 +30,14 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"id": "dcf25e45-f887-4fd5-aed8-44090ed75680",
"metadata": {
"jupyter": {
"source_hidden": true
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Die Datei wurde erfolgreich unter '/Users/Wir/Downloads/assets_1.xlsx' gespeichert.\n"
]
}
],
"outputs": [],
"source": [
"#Excel Export\n",
"import os\n",
@@ -87,218 +76,15 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "ca74d822-4f5c-46d7-8129-31bbf28a1e00",
"metadata": {
"collapsed": true,
"jupyter": {
"outputs_hidden": true,
"source_hidden": true
},
"scrolled": true
},
"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>Name</th>\n",
" <th>Status</th>\n",
" <th>Created</th>\n",
" <th>Area (ha)</th>\n",
" <th>Asset type</th>\n",
" <th>Is fixed</th>\n",
" <th>land_type</th>\n",
" <th>Is location</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Helmacker</td>\n",
" <td>active</td>\n",
" <td>06.05.2024</td>\n",
" <td>3.0321</td>\n",
" <td>asset--land</td>\n",
" <td>True</td>\n",
" <td>field</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Neureut</td>\n",
" <td>active</td>\n",
" <td>06.05.2024</td>\n",
" <td>4.1875</td>\n",
" <td>asset--land</td>\n",
" <td>True</td>\n",
" <td>field</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Schusterinsel</td>\n",
" <td>active</td>\n",
" <td>06.05.2024</td>\n",
" <td>4.9563</td>\n",
" <td>asset--land</td>\n",
" <td>True</td>\n",
" <td>field</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>Kesselacker</td>\n",
" <td>active</td>\n",
" <td>06.05.2024</td>\n",
" <td>2.1625</td>\n",
" <td>asset--land</td>\n",
" <td>True</td>\n",
" <td>field</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Kapelle</td>\n",
" <td>active</td>\n",
" <td>06.05.2024</td>\n",
" <td>5.6771</td>\n",
" <td>asset--land</td>\n",
" <td>True</td>\n",
" <td>field</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>Loehle</td>\n",
" <td>active</td>\n",
" <td>06.05.2024</td>\n",
" <td>2.0614</td>\n",
" <td>asset--land</td>\n",
" <td>True</td>\n",
" <td>field</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>Kirchenberg</td>\n",
" <td>active</td>\n",
" <td>06.05.2024</td>\n",
" <td>2.4701</td>\n",
" <td>asset--land</td>\n",
" <td>True</td>\n",
" <td>field</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>7</th>\n",
" <td>Nachtweide</td>\n",
" <td>active</td>\n",
" <td>06.05.2024</td>\n",
" <td>3.0704</td>\n",
" <td>asset--land</td>\n",
" <td>True</td>\n",
" <td>field</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>8</th>\n",
" <td>Steinacker</td>\n",
" <td>active</td>\n",
" <td>06.05.2024</td>\n",
" <td>2.6109</td>\n",
" <td>asset--land</td>\n",
" <td>True</td>\n",
" <td>field</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>9</th>\n",
" <td>Siegelwoerth</td>\n",
" <td>active</td>\n",
" <td>06.05.2024</td>\n",
" <td>0.7707</td>\n",
" <td>asset--land</td>\n",
" <td>True</td>\n",
" <td>field</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>10</th>\n",
" <td>Waethle</td>\n",
" <td>active</td>\n",
" <td>06.05.2024</td>\n",
" <td>1.4308</td>\n",
" <td>asset--land</td>\n",
" <td>True</td>\n",
" <td>field</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>11</th>\n",
" <td>Wolfsfeld</td>\n",
" <td>active</td>\n",
" <td>06.05.2024</td>\n",
" <td>3.5169</td>\n",
" <td>asset--land</td>\n",
" <td>True</td>\n",
" <td>field</td>\n",
" <td>True</td>\n",
" </tr>\n",
" <tr>\n",
" <th>12</th>\n",
" <td>Grosser Acker</td>\n",
" <td>active</td>\n",
" <td>06.05.2024</td>\n",
" <td>12.5316</td>\n",
" <td>asset--land</td>\n",
" <td>True</td>\n",
" <td>field</td>\n",
" <td>True</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Name Status Created Area (ha) Asset type Is fixed land_type Is location\n",
"0 Helmacker active 06.05.2024 3.0321 asset--land True field True\n",
"1 Neureut active 06.05.2024 4.1875 asset--land True field True\n",
"2 Schusterinsel active 06.05.2024 4.9563 asset--land True field True\n",
"3 Kesselacker active 06.05.2024 2.1625 asset--land True field True\n",
"4 Kapelle active 06.05.2024 5.6771 asset--land True field True\n",
"5 Loehle active 06.05.2024 2.0614 asset--land True field True\n",
"6 Kirchenberg active 06.05.2024 2.4701 asset--land True field True\n",
"7 Nachtweide active 06.05.2024 3.0704 asset--land True field True\n",
"8 Steinacker active 06.05.2024 2.6109 asset--land True field True\n",
"9 Siegelwoerth active 06.05.2024 0.7707 asset--land True field True\n",
"10 Waethle active 06.05.2024 1.4308 asset--land True field True\n",
"11 Wolfsfeld active 06.05.2024 3.5169 asset--land True field True\n",
"12 Grosser Acker active 06.05.2024 12.5316 asset--land True field True"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"#Zeige alle \"Land\" Daten\n",
"import pandas as pd\n",
@@ -541,14 +327,57 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"id": "96784d50-f9bf-43a2-ae95-1e53f9c8ffb4",
"metadata": {
"jupyter": {
"source_hidden": true
}
"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>Name</th>\n",
" <th>Status</th>\n",
" <th>Created</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>W-Raps Saatgut Otello KWS Seed 08/24</td>\n",
" <td>active</td>\n",
" <td>14.10.2024</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Name Status Created\n",
"0 W-Raps Saatgut Otello KWS Seed 08/24 active 14.10.2024"
]
},
"outputs": [],
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"#Zeige alle \"seed\" Daten\n",
"import pandas as pd\n",
@@ -605,7 +434,7 @@
" {\n",
" \"Name\": asset[\"attributes\"][\"name\"],\n",
" \"Status\": asset[\"attributes\"][\"status\"],\n",
" \"Created\": pd.to_datetime(asset[\"attributes\"][\"created\"]).strftime('%d.%m.%Y'),\n",
" \"Timestamp\": pd.to_datetime(asset[\"attributes\"][\"timestamp\"]).strftime('%d.%m.%Y'),\n",
" \n",
" }\n",
" for asset in all_harvest_assets\n",
@@ -646,7 +475,7 @@
" {\n",
" \"Name\": asset[\"attributes\"][\"name\"],\n",
" \"Status\": asset[\"attributes\"][\"status\"],\n",
" \"Created\": pd.to_datetime(asset[\"attributes\"][\"created\"]).strftime('%d.%m.%Y'),\n",
" \"Timestamp\": pd.to_datetime(asset[\"attributes\"][\"timestamp\"]).strftime('%d.%m.%Y'),\n",
" \n",
" }\n",
" for asset in all_activity_assets\n",
@@ -668,63 +497,14 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"id": "3dab14bd-e7e6-4a5f-b838-c6498fb20f23",
"metadata": {
"collapsed": true,
"jupyter": {
"outputs_hidden": true,
"source_hidden": true
}
},
"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>Name</th>\n",
" <th>Status</th>\n",
" <th>Created</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Innovert Raps Input 24/25</td>\n",
" <td>done</td>\n",
" <td>14.10.2024</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Name Status Created\n",
"0 Innovert Raps Input 24/25 done 14.10.2024"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"outputs": [],
"source": [
"#Zeige alle \"input\" Daten\n",
"import pandas as pd\n",
@@ -736,7 +516,7 @@
" {\n",
" \"Name\": asset[\"attributes\"][\"name\"],\n",
" \"Status\": asset[\"attributes\"][\"status\"],\n",
" \"Created\": pd.to_datetime(asset[\"attributes\"][\"created\"]).strftime('%d.%m.%Y'),\n",
" \"Timestamp\": pd.to_datetime(asset[\"attributes\"][\"timestamp\"]).strftime('%d.%m.%Y'),\n",
" \n",
" }\n",
" for asset in all_input_assets\n",
@@ -777,7 +557,7 @@
" {\n",
" \"Name\": asset[\"attributes\"][\"name\"],\n",
" \"Status\": asset[\"attributes\"][\"status\"],\n",
" \"Created\": pd.to_datetime(asset[\"attributes\"][\"created\"]).strftime('%d.%m.%Y'),\n",
" \"Timestamp\": pd.to_datetime(asset[\"attributes\"][\"timestamp\"]).strftime('%d.%m.%Y'),\n",
" \n",
" }\n",
" for asset in all_maintenance_assets\n",
@@ -818,7 +598,7 @@
" {\n",
" \"Name\": asset[\"attributes\"][\"name\"],\n",
" \"Status\": asset[\"attributes\"][\"status\"],\n",
" \"Created\": pd.to_datetime(asset[\"attributes\"][\"created\"]).strftime('%d.%m.%Y'),\n",
" \"Timestamp\": pd.to_datetime(asset[\"attributes\"][\"timestamp\"]).strftime('%d.%m.%Y'),\n",
" \n",
" }\n",
" for asset in all_medical_assets\n",
@@ -859,7 +639,7 @@
" {\n",
" \"Name\": asset[\"attributes\"][\"name\"],\n",
" \"Status\": asset[\"attributes\"][\"status\"],\n",
" \"Created\": pd.to_datetime(asset[\"attributes\"][\"created\"]).strftime('%d.%m.%Y'),\n",
" \"Timestamp\": pd.to_datetime(asset[\"attributes\"][\"timestamp\"]).strftime('%d.%m.%Y'),\n",
" \n",
" }\n",
" for asset in all_seeding_assets\n",
@@ -891,8 +671,6 @@
"outputs": [],
"source": [
"#filter auf einen harvest log\n",
"import pandas as pd\n",
"\n",
"response = farm_client.log.get('harvest')\n",
"all_harvest_assets = response['data']\n",
"\n",
@@ -900,7 +678,7 @@
" {\n",
" \"Name\": asset[\"attributes\"][\"name\"],\n",
" \"Status\": asset[\"attributes\"][\"status\"],\n",
" \"Created\": pd.to_datetime(asset[\"attributes\"][\"created\"]).strftime('%d.%m.%Y'),\n",
" \"Timestamp\": pd.to_datetime(asset[\"attributes\"][\"timestamp\"]).strftime('%d.%m.%Y'),\n",
" }\n",
" for asset in all_harvest_assets\n",
"]\n",
@@ -922,15 +700,9 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 3,
"id": "d23c84ac-9a04-4019-9b0c-0c549620af35",
"metadata": {
"collapsed": true,
"jupyter": {
"outputs_hidden": true,
"source_hidden": true
}
},
"metadata": {},
"outputs": [
{
"data": {
@@ -953,32 +725,36 @@
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Name</th>\n",
" <th>Timestamp</th>\n",
" <th>Plant</th>\n",
" <th>Area</th>\n",
" <th>Timestamp</th>\n",
" <th>Log Name</th>\n",
" <th>Status</th>\n",
" <th>Revision Created</th>\n",
" <th>Link</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>W-Raps Helmacker Harvest 24/25</td>\n",
" <td>2024-10-20T10:11:15+00:00</td>\n",
" <td>W-Raps Helmacker Plant 24/25</td>\n",
" <td>3.12</td>\n",
" <td>20.10.2024</td>\n",
" <td>W-Raps Helmacker Harvest 24/25</td>\n",
" <td>done</td>\n",
" <td>2024-10-21T10:56:27+00:00</td>\n",
" <td>21.10.2024</td>\n",
" <td>https://farmos.wagframe.duckdns.org/api/log/ha...</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Name Timestamp Plant Status Revision Created\n",
"0 W-Raps Helmacker Harvest 24/25 2024-10-20T10:11:15+00:00 W-Raps Helmacker Plant 24/25 done 2024-10-21T10:56:27+00:00"
" Plant Area Timestamp Log Name Status Revision Created Link\n",
"0 W-Raps Helmacker Plant 24/25 3.12 20.10.2024 W-Raps Helmacker Harvest 24/25 done 21.10.2024 https://farmos.wagframe.duckdns.org/api/log/ha..."
]
},
"execution_count": 5,
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
@@ -987,14 +763,13 @@
"#Versuch\n",
"import pandas as pd\n",
"\n",
"\n",
"def get_related_logs_of_type(asset, type): \n",
" response = farm_client.resource.get('log', type)\n",
" ret = []\n",
" for log in response['data']:\n",
" assets = log['relationships']['asset']['data']\n",
" for asset in assets:\n",
" if asset['id'] == id:\n",
" log_assets = log['relationships']['asset']['data']\n",
" for log_asset in log_assets:\n",
" if log_asset['id'] == asset['id']:\n",
" ret.append(log)\n",
" return ret\n",
"\n",
@@ -1020,8 +795,11 @@
" for asset in assets:\n",
" if asset['type'] == 'asset--plant': \n",
" plant_id = asset['id']\n",
" seedings = get_related_logs_of_type(plant_id, 'seeding')\n",
" \n",
" seedings = get_related_logs_of_type(asset, 'seeding')\n",
" for seeding in seedings:\n",
" area_quants = get_related_quantities_of_measure(seeding, 'area')\n",
" for area_quant in area_quants:\n",
" plant_area += float(area_quant['data']['attributes']['value']['decimal'])\n",
" plant = farm_client.asset.get_id('plant', plant_id)\n",
" plant_name = plant['data']['attributes']['name']\n",
" \n",
@@ -1029,34 +807,43 @@
" # log aufbauen\n",
" log = {\n",
" \n",
" 'Name': item['attributes']['name'],\n",
" 'Timestamp': item['attributes']['timestamp'],\n",
" 'Plant': plant_name,\n",
" \n",
" 'Plant': plant_name,\n",
" 'Area': plant_area,\n",
" \n",
" 'Timestamp': pd.to_datetime(item[\"attributes\"][\"timestamp\"]).strftime('%d.%m.%Y'),\n",
" 'Log Name': item['attributes']['name'],\n",
" 'Status': item['attributes']['status'],\n",
" 'Revision Created': item['attributes']['revision_created'],\n",
" 'Revision Created': pd.to_datetime(item[\"attributes\"][\"revision_created\"]).strftime('%d.%m.%Y'),\n",
" 'Link': item['links']['self']['href']\n",
" }\n",
" logs.append(log)\n",
"\n",
"\n",
"\n",
"# Erstelle ein Pandas DataFrame aus den extrahierten Daten\n",
"# Erstelle ein DataFrame aus den Harvest Logs\n",
"df = pd.DataFrame(logs)\n",
"\n",
"\n",
"\n",
"# Setze Pandas-Optionen für eine bessere Anzeige\n",
"pd.set_option('display.max_columns', None) # Alle Spalten anzeigen\n",
"pd.set_option('display.max_colwidth', 50) # Maximale Spaltenbreite setzen\n",
"pd.set_option('display.width', 1000) # Maximale Breite der Tabelle\n",
"\n",
"df\n"
"df"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c74becaa-5899-4ad0-bb6e-5399cc5d0aa2",
"id": "434b8acb-89da-4ac0-8a36-0cb70df6db11",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "5e6566de-ba49-4566-87c1-37ed165aaff9",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "2c4d4aa6-0a3b-4860-b186-965e827f8eed",
"metadata": {},
"outputs": [],
"source": []

Binary file not shown.

File diff suppressed because it is too large Load Diff