From af962d35a4848f45623e3e6a8be3e8b9353a3110 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Mastalerz?= Date: Mon, 31 Jul 2023 21:47:09 +0400 Subject: [PATCH] Initial commit --- Web_Sustainability_GRI_Impact_est.ipynb | 1069 +++++++++++++++++++++++ 1 file changed, 1069 insertions(+) create mode 100644 Web_Sustainability_GRI_Impact_est.ipynb diff --git a/Web_Sustainability_GRI_Impact_est.ipynb b/Web_Sustainability_GRI_Impact_est.ipynb new file mode 100644 index 0000000..2b6136f --- /dev/null +++ b/Web_Sustainability_GRI_Impact_est.ipynb @@ -0,0 +1,1069 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "provenance": [], + "authorship_tag": "ABX9TyO67vVi+w01UNcnXPsIagIE", + "include_colab_link": true + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + } + }, + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "source": [ + "This notebook tries to assess environmental impact of W3C Sustainable Web recommendations across a number of categories aligned with GRI reporting.\n", + "\n", + "As an input it takes a spreadsheet with recommendations and their indicators of impact on reduction of server resource usage, network transfer and end user device usage.\n", + "Then it takes data from greenIT.fr report which estimates environmental impact of above categories across material use, water use, energy use and GHG emissions.\n", + "It then combines these datasets and estimates comparative impact of given recomendation on different sections of GRI taxonomy." + ], + "metadata": { + "id": "LAiULQzYwhvj" + } + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "p2ZlWXdNbTKj" + }, + "outputs": [], + "source": [ + "import gspread\n", + "import pandas as pd\n", + "from google.colab import auth\n", + "from google.colab import files\n", + "from google.auth import credentials\n", + "from google.auth import default\n", + "\n" + ] + }, + { + "cell_type": "code", + "source": [ + "# All the recommendations in the spreadsheet are scored in terms of their impact on end user devices, network and servers in data centre\n", + "# Scores are from 0 to MAX_THRESHOLD, by default 2\n", + "# If maximum score in the spreadsheet is changed, it needs to updated here\n", + "MAX_THRESHOLD = 2\n", + "\n", + "# Labels to be assigned to metrics\n", + "labels = {'Low': MAX_THRESHOLD / 3 ,\n", + " 'Moderate': MAX_THRESHOLD / 3 * 2,\n", + " 'High': MAX_THRESHOLD }\n", + "\n", + "# Set to missing if assessment undefined\n", + "MISSING = 'Missing'" + ], + "metadata": { + "id": "NaYxpRteOqam" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "# Auth and read the spreadsheet into pandas\n", + "auth.authenticate_user()\n", + "creds, _ = default()\n", + "gc = gspread.authorize(creds)\n", + "\n", + "sheet_url = 'https://docs.google.com/spreadsheets/d/12nGydnSv24fvmvCM-665_pFGPG9u3RgTwe1sCz4eiGk'\n", + "df = pd.read_csv(sheet_url + '/export?gid=0&format=csv', skiprows=[0, 1])\n", + "\n", + "df.head(5)" + ], + "metadata": { + "id": "SV8OdvVkbpNf", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 204 + }, + "outputId": "efcd9531-2e4d-4cc9-8d7a-9f44a56a2135" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + " Guideline Spec \\\n", + "0 Undertake Systemic Impacts Mapping UX \n", + "1 Assess And Research Visitor Needs UX \n", + "2 Research Non-visitors Needs UX \n", + "3 Consider Sustainability In Early Ideation UX \n", + "4 Account For Stakeholder Issues UX \n", + "\n", + " Tags Data Centre Network \\\n", + "0 Social Equity\\n Accessibility\\n Ideation\\n Res... 0.0 0.0 \n", + "1 Social Equity\\n Accessibility\\n UI\\n Patterns\\... 0.0 0.0 \n", + "2 Social Equity\\n Ideation\\n Research\\n Usabilit... 0.0 0.0 \n", + "3 UI\\n Ideation\\n Research\\n Software\\n Strategy 1.0 1.0 \n", + "4 Social Equity\\n Accessibility\\n Ideation\\n Res... 0.0 0.0 \n", + "\n", + " Device \n", + "0 0.0 \n", + "1 0.0 \n", + "2 0.0 \n", + "3 1.0 \n", + "4 0.0 " + ], + "text/html": [ + "\n", + "\n", + "
\n", + "
\n", + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
GuidelineSpecTagsData CentreNetworkDevice
0Undertake Systemic Impacts MappingUXSocial Equity\\n Accessibility\\n Ideation\\n Res...0.00.00.0
1Assess And Research Visitor NeedsUXSocial Equity\\n Accessibility\\n UI\\n Patterns\\...0.00.00.0
2Research Non-visitors NeedsUXSocial Equity\\n Ideation\\n Research\\n Usabilit...0.00.00.0
3Consider Sustainability In Early IdeationUXUI\\n Ideation\\n Research\\n Software\\n Strategy1.01.01.0
4Account For Stakeholder IssuesUXSocial Equity\\n Accessibility\\n Ideation\\n Res...0.00.00.0
\n", + "
\n", + " \n", + "\n", + "\n", + "\n", + "
\n", + " \n", + "
\n", + "\n", + "\n", + "\n", + " \n", + "\n", + " \n", + " \n", + "\n", + " \n", + "
\n", + "
\n" + ] + }, + "metadata": {}, + "execution_count": 71 + } + ] + }, + { + "cell_type": "code", + "source": [ + "\n", + "# Impact factors across number of areas split by end user devices, network equipment and data centers\n", + "# Source: GreenIT.fr: https://www.greenit.fr/wp-content/uploads/2019/11/GREENIT_EENM_etude_EN_accessible.pdf\n", + "data = [ [.6, .63, .83, .75]\n", + " , [.23, .22, .09, .16]\n", + " , [.17, .15, .07, .08] ]\n", + "\n", + "factors = pd.DataFrame(data, columns=['Energy', 'Emissions', 'Water', 'Materials'],\n", + " index=['Device', 'Network', 'Data Centre'])\n", + "\n", + "factors.head()\n" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 142 + }, + "id": "fesQf4yAd7La", + "outputId": "4bf290e3-ee3f-49d0-cb88-8a0538cf4a77" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + " Energy Emissions Water Materials\n", + "Device 0.60 0.63 0.83 0.75\n", + "Network 0.23 0.22 0.09 0.16\n", + "Data Centre 0.17 0.15 0.07 0.08" + ], + "text/html": [ + "\n", + "\n", + "
\n", + "
\n", + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
EnergyEmissionsWaterMaterials
Device0.600.630.830.75
Network0.230.220.090.16
Data Centre0.170.150.070.08
\n", + "
\n", + " \n", + "\n", + "\n", + "\n", + "
\n", + " \n", + "
\n", + "\n", + "\n", + "\n", + " \n", + "\n", + " \n", + " \n", + "\n", + " \n", + "
\n", + "
\n" + ] + }, + "metadata": {}, + "execution_count": 76 + } + ] + }, + { + "cell_type": "code", + "source": [ + "# Calculate impacts (numerical)\n", + "\n", + "# GRI-301: Materials\n", + "df['GRI-301'] = df['Data Centre'] * factors['Materials']['Data Centre'] \\\n", + " + df['Network'] * factors['Materials']['Network'] \\\n", + " + df['Device'] * factors['Materials']['Device']\n", + "\n", + "# GRI-302: Enegry\n", + "df['GRI-302'] = df['Data Centre'] * factors['Energy']['Data Centre'] \\\n", + " + df['Network'] * factors['Energy']['Network'] \\\n", + " + df['Device'] * factors['Energy']['Device']\n", + "\n", + "# GRI-303: Water\n", + "df['GRI-303'] = df['Data Centre'] * factors['Water']['Data Centre'] \\\n", + " + df['Network'] * factors['Water']['Network'] \\\n", + " + df['Device'] * factors['Water']['Device']\n", + "\n", + "# GRI-305: Emissions\n", + "df['GRI-304'] = df['Data Centre'] * factors['Emissions']['Data Centre'] \\\n", + " + df['Network'] * factors['Emissions']['Network'] \\\n", + " + df['Device'] * factors['Emissions']['Device']\n", + "\n" + ], + "metadata": { + "id": "fWqVehnyb-7I" + }, + "execution_count": null, + "outputs": [] + }, + { + "cell_type": "code", + "source": [ + "# Assign labels to calculated impacts\n", + "# If assessment for a given recommendation is missing it will be set to MISSING\n", + "df['GRI-301 Label'] = df.apply(lambda x: 'Low' if x['GRI-301'] < labels['Low']\n", + " else ('Moderate' if x['GRI-301'] < labels['Moderate']\n", + " else 'High' if x['GRI-301'] <= labels['High']\n", + " else MISSING), axis=1 )\n", + "\n", + "df['GRI-302 Label'] = df.apply(lambda x: 'Low' if x['GRI-302'] < labels['Low']\n", + " else ('Moderate' if x['GRI-302'] < labels['Moderate']\n", + " else 'High' if x['GRI-302'] <= labels['High']\n", + " else MISSING), axis=1 )\n", + "\n", + "df['GRI-303 Label'] = df.apply(lambda x: 'Low' if x['GRI-303'] < labels['Low']\n", + " else ('Moderate' if x['GRI-303'] < labels['Moderate']\n", + " else 'High' if x['GRI-303'] <= labels['High']\n", + " else MISSING), axis=1 )\n", + "\n", + "df['GRI-304 Label'] = df.apply(lambda x: 'Low' if x['GRI-304'] < labels['Low']\n", + " else ('Moderate' if x['GRI-304'] < labels['Moderate']\n", + " else 'High' if x['GRI-304'] <= labels['High']\n", + " else MISSING), axis=1 )\n", + "\n", + "\n", + "df.head()" + ], + "metadata": { + "id": "eY6WRm6jQW6A", + "colab": { + "base_uri": "https://localhost:8080/", + "height": 350 + }, + "outputId": "d93561f5-13d1-4170-c3c5-7d1a8bbcbcd8" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + " Guideline Spec \\\n", + "0 Undertake Systemic Impacts Mapping UX \n", + "1 Assess And Research Visitor Needs UX \n", + "2 Research Non-visitors Needs UX \n", + "3 Consider Sustainability In Early Ideation UX \n", + "4 Account For Stakeholder Issues UX \n", + "\n", + " Tags Data Centre Network \\\n", + "0 Social Equity\\n Accessibility\\n Ideation\\n Res... 0.0 0.0 \n", + "1 Social Equity\\n Accessibility\\n UI\\n Patterns\\... 0.0 0.0 \n", + "2 Social Equity\\n Ideation\\n Research\\n Usabilit... 0.0 0.0 \n", + "3 UI\\n Ideation\\n Research\\n Software\\n Strategy 1.0 1.0 \n", + "4 Social Equity\\n Accessibility\\n Ideation\\n Res... 0.0 0.0 \n", + "\n", + " Device GRI-301 GRI-302 GRI-303 GRI-304 GRI-301 Label GRI-302 Label \\\n", + "0 0.0 0.00 0.0 0.00 0.0 Low Low \n", + "1 0.0 0.00 0.0 0.00 0.0 Low Low \n", + "2 0.0 0.00 0.0 0.00 0.0 Low Low \n", + "3 1.0 0.99 1.0 0.99 1.0 Moderate Moderate \n", + "4 0.0 0.00 0.0 0.00 0.0 Low Low \n", + "\n", + " GRI-303 Label GRI-304 Label \n", + "0 Low Low \n", + "1 Low Low \n", + "2 Low Low \n", + "3 Moderate Moderate \n", + "4 Low Low " + ], + "text/html": [ + "\n", + "\n", + "
\n", + "
\n", + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
GuidelineSpecTagsData CentreNetworkDeviceGRI-301GRI-302GRI-303GRI-304GRI-301 LabelGRI-302 LabelGRI-303 LabelGRI-304 Label
0Undertake Systemic Impacts MappingUXSocial Equity\\n Accessibility\\n Ideation\\n Res...0.00.00.00.000.00.000.0LowLowLowLow
1Assess And Research Visitor NeedsUXSocial Equity\\n Accessibility\\n UI\\n Patterns\\...0.00.00.00.000.00.000.0LowLowLowLow
2Research Non-visitors NeedsUXSocial Equity\\n Ideation\\n Research\\n Usabilit...0.00.00.00.000.00.000.0LowLowLowLow
3Consider Sustainability In Early IdeationUXUI\\n Ideation\\n Research\\n Software\\n Strategy1.01.01.00.991.00.991.0ModerateModerateModerateModerate
4Account For Stakeholder IssuesUXSocial Equity\\n Accessibility\\n Ideation\\n Res...0.00.00.00.000.00.000.0LowLowLowLow
\n", + "
\n", + " \n", + "\n", + "\n", + "\n", + "
\n", + " \n", + "
\n", + "\n", + "\n", + "\n", + " \n", + "\n", + " \n", + " \n", + "\n", + " \n", + "
\n", + "
\n" + ] + }, + "metadata": {}, + "execution_count": 78 + } + ] + }, + { + "cell_type": "code", + "source": [ + "# Save to excel and download locally\n", + "\n", + "df.to_excel('Recommendations scored.xlsx')\n", + "\n", + "files.download('Recommendations scored.xlsx')" + ], + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 34 + }, + "id": "5FtienoEvf7_", + "outputId": "9984250c-9ef4-4e84-e481-c298a28269f0" + }, + "execution_count": null, + "outputs": [ + { + "output_type": "display_data", + "data": { + "text/plain": [ + "" + ], + "application/javascript": [ + "\n", + " async function download(id, filename, size) {\n", + " if (!google.colab.kernel.accessAllowed) {\n", + " return;\n", + " }\n", + " const div = document.createElement('div');\n", + " const label = document.createElement('label');\n", + " label.textContent = `Downloading \"${filename}\": `;\n", + " div.appendChild(label);\n", + " const progress = document.createElement('progress');\n", + " progress.max = size;\n", + " div.appendChild(progress);\n", + " document.body.appendChild(div);\n", + "\n", + " const buffers = [];\n", + " let downloaded = 0;\n", + "\n", + " const channel = await google.colab.kernel.comms.open(id);\n", + " // Send a message to notify the kernel that we're ready.\n", + " channel.send({})\n", + "\n", + " for await (const message of channel.messages) {\n", + " // Send a message to notify the kernel that we're ready.\n", + " channel.send({})\n", + " if (message.buffers) {\n", + " for (const buffer of message.buffers) {\n", + " buffers.push(buffer);\n", + " downloaded += buffer.byteLength;\n", + " progress.value = downloaded;\n", + " }\n", + " }\n", + " }\n", + " const blob = new Blob(buffers, {type: 'application/binary'});\n", + " const a = document.createElement('a');\n", + " a.href = window.URL.createObjectURL(blob);\n", + " a.download = filename;\n", + " div.appendChild(a);\n", + " a.click();\n", + " div.remove();\n", + " }\n", + " " + ] + }, + "metadata": {} + }, + { + "output_type": "display_data", + "data": { + "text/plain": [ + "" + ], + "application/javascript": [ + "download(\"download_fc9bd32e-54cc-46e3-9ea2-c3519ae11ea3\", \"Recommendations scored.xlsx\", 12844)" + ] + }, + "metadata": {} + } + ] + }, + { + "cell_type": "code", + "source": [], + "metadata": { + "id": "HNoO30Nqd8_T" + }, + "execution_count": null, + "outputs": [] + } + ] +} \ No newline at end of file