HadISD

source is the same for Hadisd: “HadISD”, “hadisd”, “Hadisd”, “HADISD”, “Had-isd”, “had-isd”, “HAD-ISD”, “Had-isd”

get meta load, if true, read the metadata as Dataframe

[2]:
from obswx import *

# Get the metadata for the HadISD dataset
met = obswx(source='hadisd')

# Load the metadata
met.get_meta(load=True).head()
[2]:
station_id lat lon elevation
0 010010-99999 70.933 -8.667 9.0
1 010014-99999 59.792 5.341 48.8
2 010030-99999 77.000 15.500 12.0
3 010070-99999 78.917 11.933 7.7
4 010080-99999 78.246 15.466 26.8

metadata is from hadisd_meta.csv (last access: 2024-04-30), originally from: https://www.metoffice.gov.uk/hadobs/hadisd/v341_202403p/station_download.html

  • get_data ids_source, ‘AWS’ is using AWS S3 ids, isd

  • get_data station, the station id in metadata

  • get_data output, optional, the path dir of output file, e.g., “pyxw/”. By default, the file nc file will be save in current work dir.

[3]:
ds = met.get_data(station="010010-99999", ids_source='hadisd')
Getting data from HadISD
Goto here to help select station:  https://junjieyu-uom.github.io/obswx/hadisd_map
Downloading data from https://www.metoffice.gov.uk/hadobs/hadisd/v341_202403p/data/hadisd.3.4.1.202403p_19310101-20240401_010010-99999.nc.gz
Extracting 010010-99999.nc.gz to 010010-99999.nc
[4]:
ds
[4]:
<xarray.Dataset> Size: 254MB
Dimensions:                (coordinate_length: 1, time: 278217, test: 71,
                            flagged: 19, reporting_v: 19, reporting_t: 1128,
                            reporting_2: 2)
Coordinates:
    longitude              (coordinate_length) float64 8B ...
    latitude               (coordinate_length) float64 8B ...
    elevation              (coordinate_length) float64 8B ...
  * time                   (time) datetime64[ns] 2MB 1931-01-01T06:00:00 ... ...
Dimensions without coordinates: coordinate_length, test, flagged, reporting_v,
                                reporting_t, reporting_2
Data variables: (12/27)
    station_id             |S12 12B ...
    temperatures           (time) float64 2MB ...
    dewpoints              (time) float64 2MB ...
    slp                    (time) float64 2MB ...
    stnlp                  (time) float64 2MB ...
    windspeeds             (time) float64 2MB ...
    ...                     ...
    wind_gust              (time) float64 2MB ...
    past_sigwx1            (time) float64 2MB ...
    input_station_id       (time) object 2MB ...
    quality_control_flags  (time, test) float64 158MB ...
    flagged_obs            (time, flagged) float64 42MB ...
    reporting_stats        (reporting_v, reporting_t, reporting_2) float64 343kB ...
Attributes: (12/39)
    title:                       HadISD
    institution:                 Met Office Hadley Centre, Exeter, UK
    source:                      HadISD data product
    references:                  Dunn, 2019, Met Office Hadley Centre Technic...
    creator_name:                Robert Dunn
    creator_url:                 www.metoffice.gov.uk
    ...                          ...
    station_information:         Where station is a composite the station id ...
    Conventions:                 CF-1.6
    Metadata_Conventions:        Unidata Dataset Discovery v1.0, CF Discrete ...
    featureType:                 timeSeries
    processing_date:             04-Apr-2024
    history:                     Created by mk_netcdf_files.py \nDuplicate Mo...

transform to pandas dataframe

[5]:
ds['temperatures'].to_dataframe()
[5]:
temperatures
time
1931-01-01 06:00:00 -5.0
1931-01-01 12:00:00 -5.0
1931-01-01 18:00:00 -5.0
1931-01-02 06:00:00 -5.0
1931-01-02 12:00:00 -5.0
... ...
2024-03-27 13:00:00 -2.7
2024-03-27 14:00:00 -2.7
2024-03-27 15:00:00 -2.7
2024-03-27 16:00:00 -3.0
2024-03-27 17:00:00 -3.5

278217 rows × 1 columns

save to a csv file

[ ]:
df = ds['temperatures'].to_dataframe()
df.to_csv('data.csv')