Obtain the data from AURN
Download data by a bounds of longitude and latitude
Users can give a bounds of longitude and latitude to download the station data.
Load the OBSAQ package and Define the range
[1]:
import obsaq
lon_min = -1
lon_max = 2
lat_min = 50
lat_max = 55
bounds=[lon_min, lon_max, lat_min, lat_max]
Get the station metadata
NOTE: This is the all station information and the next step will choose the stations by bounds.
[2]:
meta = obsaq.meta()
site_table = meta.get_metadata('aurn')
Choose the stations by range
[3]:
final_sites = meta.get_site(bounds=bounds)
final_sites.head(5)
Site is selected by bounds: [-1, 2, 50, 55]
[3]:
site_id | site_name | location_type | latitude | longitude | parameter | Parameter_name | start_date | end_date | ratified_to | zone | agglomeration | local_authority | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
rownames | |||||||||||||
364 | BDMP | Borehamwood Meadow Park | Urban Background | 51.662332 | -0.270001 | NO | Nitric oxide | 2017-10-01 | ongoing | 2023-12-31 | Eastern | NaN | Hertsmere |
365 | BDMP | Borehamwood Meadow Park | Urban Background | 51.662332 | -0.270001 | NO2 | Nitrogen dioxide | 2017-10-01 | ongoing | 2023-12-31 | Eastern | NaN | Hertsmere |
366 | BDMP | Borehamwood Meadow Park | Urban Background | 51.662332 | -0.270001 | NOXasNO2 | Nitrogen oxides as nitrogen dioxide | 2017-10-01 | ongoing | 2023-12-31 | Eastern | NaN | Hertsmere |
367 | BDMP | Borehamwood Meadow Park | Urban Background | 51.662332 | -0.270001 | PM10 | PM10 particulate matter (Hourly measured) | 2022-03-22 | ongoing | 2023-12-31 | Eastern | NaN | Hertsmere |
368 | BDMP | Borehamwood Meadow Park | Urban Background | 51.662332 | -0.270001 | PM2.5 | PM2.5 particulate matter (Hourly measured) | 2022-03-22 | ongoing | 2023-12-31 | Eastern | NaN | Hertsmere |
Start to download the selected station data
year
: the year of data to be downloaded. Defaults to 2010.output_dir
: the directory to save the downloaded data. Defaults tometadata/prep_obs_data
.log
: whether to print the log. Defaults toFalse
.
[4]:
meta.download_sites('aurn', year=2010, output_dir='metadata/prep_obs_data', log=False)
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/BEX_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/BOT_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/BRIT_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/BRT3_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/CA1_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/CAM_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/CANT_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/CHAT_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/CLL2_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/CRD2_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/EB_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/HG1_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/HG2_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/HIL_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/HM_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/HOPE_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/HORE_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/HORS_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/HR3_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/HRL_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/HUL2_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/KC1_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/LH_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/LON6_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/MKTH_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/MY1_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/NO12_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/NTON_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/OSY_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/REA1_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/ROCH_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/SCN2_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/SDY_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/SEND_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/SIB_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/SK5_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/STOR_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/TED_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/TH2_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/THUR_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/WEYB_2010.csv
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/WFEN_2010.csv
Download data by a point of longitude and latitude
Users can give a point of longitude and latitude to download the station data.
[5]:
import obsaq
lon = 0.0
lat = 55.0
point = [lon, lat]
NOTE: This is the all station information and the next step will choose the stations by point.
[6]:
meta = obsaq.meta()
site_table = meta.get_metadata('aurn')
site_table.head(5)
[6]:
site_id | site_name | location_type | latitude | longitude | parameter | Parameter_name | start_date | end_date | ratified_to | zone | agglomeration | local_authority | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
rownames | |||||||||||||
1 | ABD | Aberdeen | Urban Background | 57.15736 | -2.094278 | O3 | Ozone | 2003-08-01 | 2021-09-20 | 2021-09-20 | North East Scotland | NaN | Aberdeen City |
2 | ABD | Aberdeen | Urban Background | 57.15736 | -2.094278 | NO | Nitric oxide | 1999-09-18 | 2021-09-20 | 2021-09-20 | North East Scotland | NaN | Aberdeen City |
3 | ABD | Aberdeen | Urban Background | 57.15736 | -2.094278 | NO2 | Nitrogen dioxide | 1999-09-18 | 2021-09-20 | 2021-09-20 | North East Scotland | NaN | Aberdeen City |
4 | 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 | NaN | Aberdeen City |
5 | ABD | Aberdeen | Urban Background | 57.15736 | -2.094278 | SO2 | Sulphur dioxide | 2001-01-01 | 2007-09-30 | 2007-09-30 | North East Scotland | NaN | Aberdeen City |
[7]:
final_sites = meta.get_site(point=point)
final_sites
Site is selected by point: [0.0, 55.0]
[7]:
site_id HM
site_name High Muffles
location_type Rural Background
latitude 54.334497
longitude -0.80882
parameter O3
Parameter_name Ozone
start_date 1987-07-16
end_date ongoing
ratified_to 2023-12-31
zone Yorkshire & Humberside
agglomeration NaN
local_authority Ryedale
Name: 1200, dtype: object
[8]:
meta.download_sites('aurn', year=2010, output_dir='data/prep_obs_data', log=False)
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/HM_2010.csv
Download data by site_id
[9]:
import obsaq
meta = obsaq.meta()
site_table = meta.get_metadata('aurn')
site_table.head(5)
[9]:
site_id | site_name | location_type | latitude | longitude | parameter | Parameter_name | start_date | end_date | ratified_to | zone | agglomeration | local_authority | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
rownames | |||||||||||||
1 | ABD | Aberdeen | Urban Background | 57.15736 | -2.094278 | O3 | Ozone | 2003-08-01 | 2021-09-20 | 2021-09-20 | North East Scotland | NaN | Aberdeen City |
2 | ABD | Aberdeen | Urban Background | 57.15736 | -2.094278 | NO | Nitric oxide | 1999-09-18 | 2021-09-20 | 2021-09-20 | North East Scotland | NaN | Aberdeen City |
3 | ABD | Aberdeen | Urban Background | 57.15736 | -2.094278 | NO2 | Nitrogen dioxide | 1999-09-18 | 2021-09-20 | 2021-09-20 | North East Scotland | NaN | Aberdeen City |
4 | 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 | NaN | Aberdeen City |
5 | ABD | Aberdeen | Urban Background | 57.15736 | -2.094278 | SO2 | Sulphur dioxide | 2001-01-01 | 2007-09-30 | 2007-09-30 | North East Scotland | NaN | Aberdeen City |
[10]:
final_sites = meta.get_site(site_id='ABD')
final_sites.drop_duplicates(subset='site_id')
Site is selected by site_id: ABD
[10]:
site_id | site_name | location_type | latitude | longitude | parameter | Parameter_name | start_date | end_date | ratified_to | zone | agglomeration | local_authority | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
rownames | |||||||||||||
1 | ABD | Aberdeen | Urban Background | 57.15736 | -2.094278 | O3 | Ozone | 2003-08-01 | 2021-09-20 | 2021-09-20 | North East Scotland | NaN | Aberdeen City |
[11]:
meta.download_sites('aurn', year=2010, output_dir='data/prep_obs_data', log=False)
Data has downloaded successfully. URL: https://uk-air.defra.gov.uk/data_files/site_data/ABD_2010.csv
[ ]: