{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## UK monthly historical station data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "`source` is the same for UK-hist_station: \"UK-hist_station\", \"UK-hist-station\", \"UK_hist_station\", \"UK_hist-station\", \"UK_hist_station\", \"UK_hist-station\"\n", "\n", "get meta `load`, if true, read the metadata as Dataframe" ] }, { "cell_type": "code", "execution_count": 1, "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", "
NamelonlatOpenedLink
0Aberporth-4.57052.1391941https://www.metoffice.gov.uk/pub/data/weather/...
1Armagh-6.64954.3521853https://www.metoffice.gov.uk/pub/data/weather/...
2Ballypatrick Forest-6.15355.1811961https://www.metoffice.gov.uk/pub/data/weather/...
3Bradford-1.77253.8131908https://www.metoffice.gov.uk/pub/data/weather/...
4Braemar No 2-3.39657.0111959https://www.metoffice.gov.uk/pub/data/weather/...
\n", "
" ], "text/plain": [ " Name lon lat Opened \\\n", "0 Aberporth -4.570 52.139 1941 \n", "1 Armagh -6.649 54.352 1853 \n", "2 Ballypatrick Forest -6.153 55.181 1961 \n", "3 Bradford -1.772 53.813 1908 \n", "4 Braemar No 2 -3.396 57.011 1959 \n", "\n", " Link \n", "0 https://www.metoffice.gov.uk/pub/data/weather/... \n", "1 https://www.metoffice.gov.uk/pub/data/weather/... \n", "2 https://www.metoffice.gov.uk/pub/data/weather/... \n", "3 https://www.metoffice.gov.uk/pub/data/weather/... \n", "4 https://www.metoffice.gov.uk/pub/data/weather/... " ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from obswx import *\n", "\n", "# initialize the UK-hist_station source\n", "met = obswx(source='UK-hist_station')\n", "\n", "# get the metadata\n", "met.get_meta(load=True).head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "metadata is from [UK-hist-stataion-meta](https://github.com/envdes/obswx/blob/main/metadata/UK-hist-stataion-meta.csv) (last access: 2024-04-30), originally from the UK Met Office, and is available at:\n", "https://www.metoffice.gov.uk/research/climate/maps-and-data/historic-station-data ." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- get_data `station`, station name when `obswx(source='UK-hist_station')`" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Getting data from UK Historical Station\n", "Goto here to help select station: https://junjieyu-uom.github.io/obswx/UK-hist-station-map\n", "Getting data from https://www.metoffice.gov.uk/pub/data/weather/uk/climate/stationdata/armaghdata.txt\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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
yyyy [nan]mm [nan]tmax [degC]tmin [degC]af [days]rain [mm]sun [hours]
11853.01.0---------57.3---
21853.02.0---------32.3---
31853.03.0---------65.5---
41853.04.0---------46.2---
51853.05.0---------13.2---
........................
20512023.011.010.64.2358.267.3
20522023.012.09.65.0496.624.7
20532024.01.07.81.51039.458.1
20542024.02.010.24.1156.269.4
20552024.03.010.54.1297.089.9
\n", "

2055 rows × 7 columns

\n", "
" ], "text/plain": [ " yyyy [nan] mm [nan] tmax [degC] tmin [degC] af [days] rain [mm] \\\n", "1 1853.0 1.0 --- --- --- 57.3 \n", "2 1853.0 2.0 --- --- --- 32.3 \n", "3 1853.0 3.0 --- --- --- 65.5 \n", "4 1853.0 4.0 --- --- --- 46.2 \n", "5 1853.0 5.0 --- --- --- 13.2 \n", "... ... ... ... ... ... ... \n", "2051 2023.0 11.0 10.6 4.2 3 58.2 \n", "2052 2023.0 12.0 9.6 5.0 4 96.6 \n", "2053 2024.0 1.0 7.8 1.5 10 39.4 \n", "2054 2024.0 2.0 10.2 4.1 1 56.2 \n", "2055 2024.0 3.0 10.5 4.1 2 97.0 \n", "\n", " sun [hours] \n", "1 --- \n", "2 --- \n", "3 --- \n", "4 --- \n", "5 --- \n", "... ... \n", "2051 67.3 \n", "2052 24.7 \n", "2053 58.1 \n", "2054 69.4 \n", "2055 89.9 \n", "\n", "[2055 rows x 7 columns]" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "met.get_data(station=\"Armagh\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "- Mean daily maximum temperature (tmax)\n", "- Mean daily minimum temperature (tmin)\n", "- Days of air frost (af)\n", "- Total rainfall (rain)\n", "- Total sunshine duration (sun)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "save the data" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "df = met.get_data(station=\"Armagh\")\n", "df.to_csv(\"Armagh.csv\", index=False) # save the data to a csv file" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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": 4 }