{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Obtain the data from RData" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Read data by a bounds of longitude and latitude\n", "Users can give a bounds of longitude and latitude to read the station data." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Load the ObsAQ package and Define the range" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import obsaq\n", "\n", "lon_min = -1\n", "lon_max = 2\n", "lat_min = 50\n", "lat_max = 55\n", "bounds=[lon_min, lon_max, lat_min, lat_max]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Get the station metadata\n", "\n", "NOTE: This is the all station information and the next step will choose the stations by bounds." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "application/vnd.microsoft.datawrangler.viewer.v0+json": { "columns": [ { "name": "index", "rawType": "int64", "type": "integer" }, { "name": "site_id", "rawType": "object", "type": "string" }, { "name": "site_name", "rawType": "object", "type": "string" }, { "name": "location_type", "rawType": "object", "type": "string" }, { "name": "latitude", "rawType": "float64", "type": "float" }, { "name": "longitude", "rawType": "float64", "type": "float" }, { "name": "parameter", "rawType": "object", "type": "string" }, { "name": "Parameter_name", "rawType": "object", "type": "string" }, { "name": "start_date", "rawType": "object", "type": "string" }, { "name": "end_date", "rawType": "object", "type": "string" }, { "name": "ratified_to", "rawType": "object", "type": "string" }, { "name": "zone", "rawType": "object", "type": "string" }, { "name": "agglomeration", "rawType": "object", "type": "unknown" }, { "name": "local_authority", "rawType": "object", "type": "string" } ], "ref": "226373af-c679-4652-b00a-662e322d98c5", "rows": [ [ "0", "ABD", "Aberdeen", "Urban Background", "57.15736", "-2.094278", "O3", "Ozone", "2003-08-01", "2021-09-20", "2021-09-20", "North East Scotland", null, "Aberdeen City" ], [ "1", "ABD", "Aberdeen", "Urban Background", "57.15736", "-2.094278", "NO", "Nitric oxide", "1999-09-18", "2021-09-20", "2021-09-20", "North East Scotland", null, "Aberdeen City" ], [ "2", "ABD", "Aberdeen", "Urban Background", "57.15736", "-2.094278", "NO2", "Nitrogen dioxide", "1999-09-18", "2021-09-20", "2021-09-20", "North East Scotland", null, "Aberdeen City" ], [ "3", "ABD", "Aberdeen", "Urban Background", "57.15736", "-2.094278", "NOXasNO2", "Nitrogen oxides as nitrogen dioxide", "1999-09-18", "2021-09-20", "2021-09-20", "North East Scotland", null, "Aberdeen City" ], [ "4", "ABD", "Aberdeen", "Urban Background", "57.15736", "-2.094278", "SO2", "Sulphur dioxide", "2001-01-01", "2007-09-30", "2007-09-30", "North East Scotland", null, "Aberdeen City" ] ], "shape": { "columns": 13, "rows": 5 } }, "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", "
site_idsite_namelocation_typelatitudelongitudeparameterParameter_namestart_dateend_dateratified_tozoneagglomerationlocal_authority
0ABDAberdeenUrban Background57.15736-2.094278O3Ozone2003-08-012021-09-202021-09-20North East ScotlandNaNAberdeen City
1ABDAberdeenUrban Background57.15736-2.094278NONitric oxide1999-09-182021-09-202021-09-20North East ScotlandNaNAberdeen City
2ABDAberdeenUrban Background57.15736-2.094278NO2Nitrogen dioxide1999-09-182021-09-202021-09-20North East ScotlandNaNAberdeen City
3ABDAberdeenUrban Background57.15736-2.094278NOXasNO2Nitrogen oxides as nitrogen dioxide1999-09-182021-09-202021-09-20North East ScotlandNaNAberdeen City
4ABDAberdeenUrban Background57.15736-2.094278SO2Sulphur dioxide2001-01-012007-09-302007-09-30North East ScotlandNaNAberdeen City
\n", "
" ], "text/plain": [ " site_id site_name location_type latitude longitude parameter \\\n", "0 ABD Aberdeen Urban Background 57.15736 -2.094278 O3 \n", "1 ABD Aberdeen Urban Background 57.15736 -2.094278 NO \n", "2 ABD Aberdeen Urban Background 57.15736 -2.094278 NO2 \n", "3 ABD Aberdeen Urban Background 57.15736 -2.094278 NOXasNO2 \n", "4 ABD Aberdeen Urban Background 57.15736 -2.094278 SO2 \n", "\n", " Parameter_name start_date end_date ratified_to \\\n", "0 Ozone 2003-08-01 2021-09-20 2021-09-20 \n", "1 Nitric oxide 1999-09-18 2021-09-20 2021-09-20 \n", "2 Nitrogen dioxide 1999-09-18 2021-09-20 2021-09-20 \n", "3 Nitrogen oxides as nitrogen dioxide 1999-09-18 2021-09-20 2021-09-20 \n", "4 Sulphur dioxide 2001-01-01 2007-09-30 2007-09-30 \n", "\n", " zone agglomeration local_authority \n", "0 North East Scotland NaN Aberdeen City \n", "1 North East Scotland NaN Aberdeen City \n", "2 North East Scotland NaN Aberdeen City \n", "3 North East Scotland NaN Aberdeen City \n", "4 North East Scotland NaN Aberdeen City " ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "meta = obsaq.meta()\n", "site_table = meta.get_metadata_RData()\n", "\n", "site_table.head(5)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Choose the stations by range" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Site is selected by bounds: [-1, 2, 50, 55]\n" ] }, { "data": { "application/vnd.microsoft.datawrangler.viewer.v0+json": { "columns": [ { "name": "index", "rawType": "int64", "type": "integer" }, { "name": "site_id", "rawType": "object", "type": "string" }, { "name": "site_name", "rawType": "object", "type": "string" }, { "name": "location_type", "rawType": "object", "type": "string" }, { "name": "latitude", "rawType": "float64", "type": "float" }, { "name": "longitude", "rawType": "float64", "type": "float" }, { "name": "parameter", "rawType": "object", "type": "string" }, { "name": "Parameter_name", "rawType": "object", "type": "string" }, { "name": "start_date", "rawType": "object", "type": "string" }, { "name": "end_date", "rawType": "object", "type": "string" }, { "name": "ratified_to", "rawType": "object", "type": "string" }, { "name": "zone", "rawType": "object", "type": "string" }, { "name": "agglomeration", "rawType": "object", "type": "unknown" }, { "name": "local_authority", "rawType": "object", "type": "string" } ], "ref": "86f2652c-3794-46e6-9ca6-b592eb6d1354", "rows": [ [ "93", "AYLA", "Aylesbury A4157", "Urban Traffic", "51.822161", "-0.793884", "PM2.5", "PM2.5 particulate matter (Hourly measured)", "2025-08-11", "ongoing", "2025-09-30", "South East", null, "Aylesbury Vale" ], [ "94", "AYLA", "Aylesbury A4157", "Urban Traffic", "51.822161", "-0.793884", "wd", "Modelled Wind Direction", "2025-08-11", "ongoing", "Never", "South East", null, "Aylesbury Vale" ], [ "95", "AYLA", "Aylesbury A4157", "Urban Traffic", "51.822161", "-0.793884", "ws", "Modelled Wind Speed", "2025-08-11", "ongoing", "Never", "South East", null, "Aylesbury Vale" ], [ "96", "AYLA", "Aylesbury A4157", "Urban Traffic", "51.822161", "-0.793884", "temp", "Modelled Temperature", "2025-08-11", "ongoing", "Never", "South East", null, "Aylesbury Vale" ], [ "386", "BDMP", "Borehamwood Meadow Park", "Urban Background", "51.661229", "-0.27055", "NO", "Nitric oxide", "2017-10-01", "ongoing", "2025-09-30", "Eastern", null, "Hertsmere" ] ], "shape": { "columns": 13, "rows": 5 } }, "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", "
site_idsite_namelocation_typelatitudelongitudeparameterParameter_namestart_dateend_dateratified_tozoneagglomerationlocal_authority
93AYLAAylesbury A4157Urban Traffic51.822161-0.793884PM2.5PM2.5 particulate matter (Hourly measured)2025-08-11ongoing2025-09-30South EastNaNAylesbury Vale
94AYLAAylesbury A4157Urban Traffic51.822161-0.793884wdModelled Wind Direction2025-08-11ongoingNeverSouth EastNaNAylesbury Vale
95AYLAAylesbury A4157Urban Traffic51.822161-0.793884wsModelled Wind Speed2025-08-11ongoingNeverSouth EastNaNAylesbury Vale
96AYLAAylesbury A4157Urban Traffic51.822161-0.793884tempModelled Temperature2025-08-11ongoingNeverSouth EastNaNAylesbury Vale
386BDMPBorehamwood Meadow ParkUrban Background51.661229-0.270550NONitric oxide2017-10-01ongoing2025-09-30EasternNaNHertsmere
\n", "
" ], "text/plain": [ " site_id site_name location_type latitude longitude \\\n", "93 AYLA Aylesbury A4157 Urban Traffic 51.822161 -0.793884 \n", "94 AYLA Aylesbury A4157 Urban Traffic 51.822161 -0.793884 \n", "95 AYLA Aylesbury A4157 Urban Traffic 51.822161 -0.793884 \n", "96 AYLA Aylesbury A4157 Urban Traffic 51.822161 -0.793884 \n", "386 BDMP Borehamwood Meadow Park Urban Background 51.661229 -0.270550 \n", "\n", " parameter Parameter_name start_date \\\n", "93 PM2.5 PM2.5 particulate matter (Hourly measured) 2025-08-11 \n", "94 wd Modelled Wind Direction 2025-08-11 \n", "95 ws Modelled Wind Speed 2025-08-11 \n", "96 temp Modelled Temperature 2025-08-11 \n", "386 NO Nitric oxide 2017-10-01 \n", "\n", " end_date ratified_to zone agglomeration local_authority \n", "93 ongoing 2025-09-30 South East NaN Aylesbury Vale \n", "94 ongoing Never South East NaN Aylesbury Vale \n", "95 ongoing Never South East NaN Aylesbury Vale \n", "96 ongoing Never South East NaN Aylesbury Vale \n", "386 ongoing 2025-09-30 Eastern NaN Hertsmere " ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "final_sites = meta.get_site(bounds=bounds)\n", "final_sites.head(5)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Read data by site_id" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Load the ObsAQ package and check the site information" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "application/vnd.microsoft.datawrangler.viewer.v0+json": { "columns": [ { "name": "index", "rawType": "int64", "type": "integer" }, { "name": "site_id", "rawType": "object", "type": "string" }, { "name": "site_name", "rawType": "object", "type": "string" }, { "name": "location_type", "rawType": "object", "type": "string" }, { "name": "latitude", "rawType": "float64", "type": "float" }, { "name": "longitude", "rawType": "float64", "type": "float" }, { "name": "parameter", "rawType": "object", "type": "string" }, { "name": "Parameter_name", "rawType": "object", "type": "string" }, { "name": "start_date", "rawType": "object", "type": "string" }, { "name": "end_date", "rawType": "object", "type": "string" }, { "name": "ratified_to", "rawType": "object", "type": "string" }, { "name": "zone", "rawType": "object", "type": "string" }, { "name": "agglomeration", "rawType": "object", "type": "unknown" }, { "name": "local_authority", "rawType": "object", "type": "string" } ], "ref": "40add5a9-b7da-4a08-ada2-28c9ec0f2ca0", "rows": [ [ "0", "ABD", "Aberdeen", "Urban Background", "57.15736", "-2.094278", "O3", "Ozone", "2003-08-01", "2021-09-20", "2021-09-20", "North East Scotland", null, "Aberdeen City" ], [ "1", "ABD", "Aberdeen", "Urban Background", "57.15736", "-2.094278", "NO", "Nitric oxide", "1999-09-18", "2021-09-20", "2021-09-20", "North East Scotland", null, "Aberdeen City" ], [ "2", "ABD", "Aberdeen", "Urban Background", "57.15736", "-2.094278", "NO2", "Nitrogen dioxide", "1999-09-18", "2021-09-20", "2021-09-20", "North East Scotland", null, "Aberdeen City" ], [ "3", "ABD", "Aberdeen", "Urban Background", "57.15736", "-2.094278", "NOXasNO2", "Nitrogen oxides as nitrogen dioxide", "1999-09-18", "2021-09-20", "2021-09-20", "North East Scotland", null, "Aberdeen City" ], [ "4", "ABD", "Aberdeen", "Urban Background", "57.15736", "-2.094278", "SO2", "Sulphur dioxide", "2001-01-01", "2007-09-30", "2007-09-30", "North East Scotland", null, "Aberdeen City" ] ], "shape": { "columns": 13, "rows": 5 } }, "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", "
site_idsite_namelocation_typelatitudelongitudeparameterParameter_namestart_dateend_dateratified_tozoneagglomerationlocal_authority
0ABDAberdeenUrban Background57.15736-2.094278O3Ozone2003-08-012021-09-202021-09-20North East ScotlandNaNAberdeen City
1ABDAberdeenUrban Background57.15736-2.094278NONitric oxide1999-09-182021-09-202021-09-20North East ScotlandNaNAberdeen City
2ABDAberdeenUrban Background57.15736-2.094278NO2Nitrogen dioxide1999-09-182021-09-202021-09-20North East ScotlandNaNAberdeen City
3ABDAberdeenUrban Background57.15736-2.094278NOXasNO2Nitrogen oxides as nitrogen dioxide1999-09-182021-09-202021-09-20North East ScotlandNaNAberdeen City
4ABDAberdeenUrban Background57.15736-2.094278SO2Sulphur dioxide2001-01-012007-09-302007-09-30North East ScotlandNaNAberdeen City
\n", "
" ], "text/plain": [ " site_id site_name location_type latitude longitude parameter \\\n", "0 ABD Aberdeen Urban Background 57.15736 -2.094278 O3 \n", "1 ABD Aberdeen Urban Background 57.15736 -2.094278 NO \n", "2 ABD Aberdeen Urban Background 57.15736 -2.094278 NO2 \n", "3 ABD Aberdeen Urban Background 57.15736 -2.094278 NOXasNO2 \n", "4 ABD Aberdeen Urban Background 57.15736 -2.094278 SO2 \n", "\n", " Parameter_name start_date end_date ratified_to \\\n", "0 Ozone 2003-08-01 2021-09-20 2021-09-20 \n", "1 Nitric oxide 1999-09-18 2021-09-20 2021-09-20 \n", "2 Nitrogen dioxide 1999-09-18 2021-09-20 2021-09-20 \n", "3 Nitrogen oxides as nitrogen dioxide 1999-09-18 2021-09-20 2021-09-20 \n", "4 Sulphur dioxide 2001-01-01 2007-09-30 2007-09-30 \n", "\n", " zone agglomeration local_authority \n", "0 North East Scotland NaN Aberdeen City \n", "1 North East Scotland NaN Aberdeen City \n", "2 North East Scotland NaN Aberdeen City \n", "3 North East Scotland NaN Aberdeen City \n", "4 North East Scotland NaN Aberdeen City " ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import obsaq\n", "\n", "meta = obsaq.meta()\n", "site_table = meta.get_metadata_RData()\n", "\n", "site_table.head(5)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Choose the stations by site_id" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Site is selected by site_id: LH\n" ] }, { "data": { "application/vnd.microsoft.datawrangler.viewer.v0+json": { "columns": [ { "name": "index", "rawType": "int64", "type": "integer" }, { "name": "site_id", "rawType": "object", "type": "string" }, { "name": "site_name", "rawType": "object", "type": "string" }, { "name": "location_type", "rawType": "object", "type": "string" }, { "name": "latitude", "rawType": "float64", "type": "float" }, { "name": "longitude", "rawType": "float64", "type": "float" }, { "name": "parameter", "rawType": "object", "type": "string" }, { "name": "Parameter_name", "rawType": "object", "type": "string" }, { "name": "start_date", "rawType": "object", "type": "string" }, { "name": "end_date", "rawType": "object", "type": "string" }, { "name": "ratified_to", "rawType": "object", "type": "string" }, { "name": "zone", "rawType": "object", "type": "string" }, { "name": "agglomeration", "rawType": "object", "type": "unknown" }, { "name": "local_authority", "rawType": "object", "type": "string" } ], "ref": "95943cab-b7ef-4053-b5e3-af344ad6aabe", "rows": [ [ "1949", "LH", "Lullington Heath", "Rural Background", "50.7937", "0.18125", "O3", "Ozone", "1986-10-04", "ongoing", "2025-09-30", "South East", null, "Wealden" ] ], "shape": { "columns": 13, "rows": 1 } }, "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", "
site_idsite_namelocation_typelatitudelongitudeparameterParameter_namestart_dateend_dateratified_tozoneagglomerationlocal_authority
1949LHLullington HeathRural Background50.79370.18125O3Ozone1986-10-04ongoing2025-09-30South EastNaNWealden
\n", "
" ], "text/plain": [ " site_id site_name location_type latitude longitude \\\n", "1949 LH Lullington Heath Rural Background 50.7937 0.18125 \n", "\n", " parameter Parameter_name start_date end_date ratified_to zone \\\n", "1949 O3 Ozone 1986-10-04 ongoing 2025-09-30 South East \n", "\n", " agglomeration local_authority \n", "1949 NaN Wealden " ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "final_sites = meta.get_site(site_id='LH')\n", "final_sites.drop_duplicates(subset='site_id')" ] } ], "metadata": { "kernelspec": { "display_name": "obsaq39v2", "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.9.20" } }, "nbformat": 4, "nbformat_minor": 2 }