{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Read the data from RData" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Read the site data by a bounds of longitude and latitude\n", "\n", "Users can give a bounds of longitude and latitude to read the site 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": [], "source": [ "meta = obsaq.meta()\n", "site_table = meta.get_metadata_RData()" ] }, { "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": { "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
364BDMPBorehamwood Meadow ParkUrban Background51.662332-0.270001NONitric oxide2017-10-01ongoing2023-12-31EasternNaNHertsmere
365BDMPBorehamwood Meadow ParkUrban Background51.662332-0.270001NO2Nitrogen dioxide2017-10-01ongoing2023-12-31EasternNaNHertsmere
366BDMPBorehamwood Meadow ParkUrban Background51.662332-0.270001NOXasNO2Nitrogen oxides as nitrogen dioxide2017-10-01ongoing2023-12-31EasternNaNHertsmere
367BDMPBorehamwood Meadow ParkUrban Background51.662332-0.270001PM10PM10 particulate matter (Hourly measured)2022-03-22ongoing2023-12-31EasternNaNHertsmere
368BDMPBorehamwood Meadow ParkUrban Background51.662332-0.270001PM2.5PM2.5 particulate matter (Hourly measured)2022-03-22ongoing2023-12-31EasternNaNHertsmere
\n", "
" ], "text/plain": [ " site_id site_name location_type latitude longitude \\\n", "364 BDMP Borehamwood Meadow Park Urban Background 51.662332 -0.270001 \n", "365 BDMP Borehamwood Meadow Park Urban Background 51.662332 -0.270001 \n", "366 BDMP Borehamwood Meadow Park Urban Background 51.662332 -0.270001 \n", "367 BDMP Borehamwood Meadow Park Urban Background 51.662332 -0.270001 \n", "368 BDMP Borehamwood Meadow Park Urban Background 51.662332 -0.270001 \n", "\n", " parameter Parameter_name start_date \\\n", "364 NO Nitric oxide 2017-10-01 \n", "365 NO2 Nitrogen dioxide 2017-10-01 \n", "366 NOXasNO2 Nitrogen oxides as nitrogen dioxide 2017-10-01 \n", "367 PM10 PM10 particulate matter (Hourly measured) 2022-03-22 \n", "368 PM2.5 PM2.5 particulate matter (Hourly measured) 2022-03-22 \n", "\n", " end_date ratified_to zone agglomeration local_authority \n", "364 ongoing 2023-12-31 Eastern NaN Hertsmere \n", "365 ongoing 2023-12-31 Eastern NaN Hertsmere \n", "366 ongoing 2023-12-31 Eastern NaN Hertsmere \n", "367 ongoing 2023-12-31 Eastern NaN Hertsmere \n", "368 ongoing 2023-12-31 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": [ "### Choose a site by `site_id` and read it directly\n" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "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", " \n", " \n", "
dateNONO2NOXasNO2sitecode
02018-01-010.8309911.8859013.16008Borehamwood Meadow ParkBDMP
12018-01-024.5454225.9412532.91080Borehamwood Meadow ParkBDMP
22018-01-030.455676.423787.12245Borehamwood Meadow ParkBDMP
32018-01-041.7180517.9363020.57061Borehamwood Meadow ParkBDMP
42018-01-059.4288130.0230644.48037Borehamwood Meadow ParkBDMP
.....................
3602018-12-2773.5029131.44885144.15175Borehamwood Meadow ParkBDMP
3612018-12-2832.3912430.8410180.50689Borehamwood Meadow ParkBDMP
3622018-12-293.0108819.1553323.77195Borehamwood Meadow ParkBDMP
3632018-12-302.6868616.6948620.81466Borehamwood Meadow ParkBDMP
3642018-12-310.313898.331778.81307Borehamwood Meadow ParkBDMP
\n", "

365 rows × 6 columns

\n", "
" ], "text/plain": [ " date NO NO2 NOXasNO2 site code\n", "0 2018-01-01 0.83099 11.88590 13.16008 Borehamwood Meadow Park BDMP\n", "1 2018-01-02 4.54542 25.94125 32.91080 Borehamwood Meadow Park BDMP\n", "2 2018-01-03 0.45567 6.42378 7.12245 Borehamwood Meadow Park BDMP\n", "3 2018-01-04 1.71805 17.93630 20.57061 Borehamwood Meadow Park BDMP\n", "4 2018-01-05 9.42881 30.02306 44.48037 Borehamwood Meadow Park BDMP\n", ".. ... ... ... ... ... ...\n", "360 2018-12-27 73.50291 31.44885 144.15175 Borehamwood Meadow Park BDMP\n", "361 2018-12-28 32.39124 30.84101 80.50689 Borehamwood Meadow Park BDMP\n", "362 2018-12-29 3.01088 19.15533 23.77195 Borehamwood Meadow Park BDMP\n", "363 2018-12-30 2.68686 16.69486 20.81466 Borehamwood Meadow Park BDMP\n", "364 2018-12-31 0.31389 8.33177 8.81307 Borehamwood Meadow Park BDMP\n", "\n", "[365 rows x 6 columns]" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "obsaq.read_sites('BDMP', 'RData', year=2018)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Read data by a point of longitude and latitude\n", "\n", "Users can give a point of longitude and latitude to read the station data." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Load the obsaq package and Define the point" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [], "source": [ "import obsaq\n", "\n", "lon = 0.0\n", "lat = 55.0\n", "point = [lon, lat]" ] }, { "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 point." ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "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
1ABDAberdeenUrban Background57.15736-2.094278O3Ozone2003-08-012021-09-202021-09-20North East ScotlandNaNAberdeen City
2ABDAberdeenUrban Background57.15736-2.094278NONitric oxide1999-09-182021-09-202021-09-20North East ScotlandNaNAberdeen City
3ABDAberdeenUrban Background57.15736-2.094278NO2Nitrogen dioxide1999-09-182021-09-202021-09-20North East ScotlandNaNAberdeen City
4ABDAberdeenUrban Background57.15736-2.094278NOXasNO2Nitrogen oxides as nitrogen dioxide1999-09-182021-09-202021-09-20North East ScotlandNaNAberdeen City
5ABDAberdeenUrban 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", "1 ABD Aberdeen Urban Background 57.15736 -2.094278 O3 \n", "2 ABD Aberdeen Urban Background 57.15736 -2.094278 NO \n", "3 ABD Aberdeen Urban Background 57.15736 -2.094278 NO2 \n", "4 ABD Aberdeen Urban Background 57.15736 -2.094278 NOXasNO2 \n", "5 ABD Aberdeen Urban Background 57.15736 -2.094278 SO2 \n", "\n", " Parameter_name start_date end_date ratified_to \\\n", "1 Ozone 2003-08-01 2021-09-20 2021-09-20 \n", "2 Nitric oxide 1999-09-18 2021-09-20 2021-09-20 \n", "3 Nitrogen dioxide 1999-09-18 2021-09-20 2021-09-20 \n", "4 Nitrogen oxides as nitrogen dioxide 1999-09-18 2021-09-20 2021-09-20 \n", "5 Sulphur dioxide 2001-01-01 2007-09-30 2007-09-30 \n", "\n", " zone agglomeration local_authority \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 \n", "5 North East Scotland NaN Aberdeen City " ] }, "execution_count": 6, "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 point" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Site is selected by point: [0.0, 55.0]\n" ] }, { "data": { "text/plain": [ "site_id HM\n", "site_name High Muffles\n", "location_type Rural Background\n", "latitude 54.334497\n", "longitude -0.80882\n", "parameter O3\n", "Parameter_name Ozone\n", "start_date 1987-07-16\n", "end_date ongoing\n", "ratified_to 2023-12-31\n", "zone Yorkshire & Humberside\n", "agglomeration NaN\n", "local_authority Ryedale\n", "Name: 1200, dtype: object" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "final_sites = meta.get_site(point=point)\n", "final_sites" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Read the station data" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
dateO3NONO2NOXasNO2sitecode
02018-01-0158.925820.358584.081574.63138High MufflesHM
12018-01-0254.691880.325058.032218.53062High MufflesHM
22018-01-0374.206090.310641.473301.94961High MufflesHM
32018-01-0458.832270.355304.925585.47037High MufflesHM
42018-01-0552.633120.385104.918505.50898High MufflesHM
........................
3602018-12-2743.765120.528851.624712.43561High MufflesHM
3612018-12-2848.664710.571002.173623.04914High MufflesHM
3622018-12-2963.121640.620333.397744.34889High MufflesHM
3632018-12-3057.563650.527922.202393.01186High MufflesHM
3642018-12-3169.085200.493331.409542.16597High MufflesHM
\n", "

365 rows × 7 columns

\n", "
" ], "text/plain": [ " date O3 NO NO2 NOXasNO2 site code\n", "0 2018-01-01 58.92582 0.35858 4.08157 4.63138 High Muffles HM\n", "1 2018-01-02 54.69188 0.32505 8.03221 8.53062 High Muffles HM\n", "2 2018-01-03 74.20609 0.31064 1.47330 1.94961 High Muffles HM\n", "3 2018-01-04 58.83227 0.35530 4.92558 5.47037 High Muffles HM\n", "4 2018-01-05 52.63312 0.38510 4.91850 5.50898 High Muffles HM\n", ".. ... ... ... ... ... ... ...\n", "360 2018-12-27 43.76512 0.52885 1.62471 2.43561 High Muffles HM\n", "361 2018-12-28 48.66471 0.57100 2.17362 3.04914 High Muffles HM\n", "362 2018-12-29 63.12164 0.62033 3.39774 4.34889 High Muffles HM\n", "363 2018-12-30 57.56365 0.52792 2.20239 3.01186 High Muffles HM\n", "364 2018-12-31 69.08520 0.49333 1.40954 2.16597 High Muffles HM\n", "\n", "[365 rows x 7 columns]" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "obsaq.read_sites('HM', 'RData', year=2018)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "py38", "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.12.3" } }, "nbformat": 4, "nbformat_minor": 2 }