From 55eab8b1329490933f2d5e490511ec7ccbcc4bdd Mon Sep 17 00:00:00 2001 From: tomsail Date: Mon, 16 Sep 2024 15:18:43 +0200 Subject: [PATCH] added WebCritech --- explore_WebCritech.html | 8826 ++++++++++++++++++++++++++++++++++++++ explore_WebCritech.ipynb | 135 + index.html | 1 + 3 files changed, 8962 insertions(+) create mode 100644 explore_WebCritech.html create mode 100644 explore_WebCritech.ipynb diff --git a/explore_WebCritech.html b/explore_WebCritech.html new file mode 100644 index 0000000..a82464a --- /dev/null +++ b/explore_WebCritech.html @@ -0,0 +1,8826 @@ + + + + + +explore_WebCritech + + + + + + + + + + + + +
+
+ + diff --git a/explore_WebCritech.ipynb b/explore_WebCritech.ipynb new file mode 100644 index 0000000..dbd6ea4 --- /dev/null +++ b/explore_WebCritech.ipynb @@ -0,0 +1,135 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import requests\n", + "import pandas as pd\n", + "import hvplot.pandas\n", + "import json\n", + "import holoviews as hv\n", + "\n", + "hv.extension('bokeh')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Define the base URL for the API\n", + "base_url = \"https://webcritech.jrc.ec.europa.eu/SeaLevelsDb/api/Group/\"\n", + "\n", + "# Fetch the list of providers\n", + "providers_response = requests.get(base_url)\n", + "providers_data = json.loads(providers_response.text) # Parse the JSON response\n", + "providers_data" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "\n", + "# Initialize a list to hold all station data\n", + "all_stations_data = []\n", + "\n", + "# Loop through the list of providers and fetch their stations\n", + "for provider in providers_data:\n", + " provider_name = provider['Name']\n", + " stations_url = base_url + provider_name + \"/Devices\"\n", + " stations_response = requests.get(stations_url)\n", + " stations_data = json.loads(stations_response.text) # Parse the JSON response\n", + " \n", + " # Loop through each station and extract data\n", + " for device in stations_data:\n", + " station_data = {\n", + " 'Provider': provider_name,\n", + " 'Id': device['Id'],\n", + " 'Name': device['Name'],\n", + " 'lat': device['Lat'],\n", + " 'lon': device['Lon'],\n", + " 'LastAccessStatus': device['CurrentStatus']['LastAccessStatus'],\n", + " 'LastDate': device['CurrentStatus']['LastDate'],\n", + " 'State': device['CurrentStatus']['State'],\n", + " 'SyncStatus': device['CurrentStatus']['SyncStatus'],\n", + " 'FileType': device['FileType'],\n", + " 'GroupId': device['GroupId'],\n", + " 'MovAvgNp': device['MovAvgNp'],\n", + " 'Notes': device.get('Notes'), # Use .get() to handle missing keys\n", + " 'Source': device['Source']\n", + " # Add other fields as necessary\n", + " }\n", + " all_stations_data.append(station_data)\n", + "\n", + "df = pd.DataFrame(all_stations_data)\n", + "df" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "df.groupby(['Provider','State']).count()[['Id']].hvplot.bar(\n", + " rot = 90,\n", + " logy = True,\n", + " ylim = [1, 2000], \n", + " grid = True\n", + ").opts(\n", + " width = 1200,\n", + " height = 800,\n", + " title = \"data availability\"\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "df.hvplot.points(\n", + " x = 'lon',\n", + " y='lat',\n", + " c = 'Provider',\n", + " line_color = 'k',\n", + " cmap = 'glasbey',\n", + " geo = True,\n", + " tiles=\"EsriImagery\",\n", + ").opts(\n", + " width = 1200,\n", + " height = 800\n", + ")" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": ".venv", + "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.11.9" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} diff --git a/index.html b/index.html index a7f4443..700adcb 100644 --- a/index.html +++ b/index.html @@ -45,6 +45,7 @@