Modules used by the DWR project

DWR: A module for accessing Daily Weather Report observations

This package provides access to UK-region station observations recently digitised from the Daily Weather Reports

The data included come from two sources:

  • The Weather Rescue citizen science project run by Ed Hawkins.
  • A commercial digitisation project run back in 2002 by Lisa Alexander and Rob Allan, but never published.

The DWR provides synoptic observations, from around 50 stations in and around the UK, typically twice a day, but the list of stations providing observations, and the frequency of observation, both vary over the many years of the series.

The DWR provides observations of several variables, but so far we have digitised data only from one:

  • Mean-sea-level pressure: ‘mslp’

Access to the data is through the load_observations() function:

import DWR
import datetime
obs=DWR.load_observations('prmsl',
                          datetime.datetime(1903,10,1,0),
                          datetime.datetime(1903,10,31,23))

Will load the mslp observations (as a pandas.DataFrame) from the whole of October 1903.


DWR.at_station_and_time(obs, station, dte)[source]

Get, from these observations, the value at the selected station and time.

Typically there are observations from each station only twice a day (sometimes less) to get the observed value at the specified time we do linear interpolation in time (using only observations for the selected station.

Parameters:
Returns:

Interpolated observed value from station at time.

Return type:

float

Raises:

StandardError – obs does not contain at least two values for selected station, one before and one after specified time. So interpolation not possible.


DWR.get_station_location(obs, station)[source]

Get, from these observations, the location (lat and lon) of the named station.

Parameters:
Raises:

StandardError – obs does not contain any observations for selected station.


DWR.load_observations(variable, start, end)[source]

Load observations from disc, for the selected period

Data must be available in directory $SCRATCH/DWR. Requires a data file for all calendar months in the period start to end.

Parameters:
  • variable (str) – Variable name (‘prmsl’,’air.2m’, ‘prate’, etc.)
  • start (datetime.datetime) – Get observations at or after this time.
  • end (datetime.datetime) – Get observations before this time.
Returns:

Dataframe of observations.

Return type:

pandas.DataFrame

Raises:

IOError – No data on disc for this variable, for a year and month in the selected period.


DWR.load_observations_1file(variable, year, month)[source]

Load all observations for one calendar month (for one variable)

Data must be available in directory ../../data.

Parameters:
  • variable (str) – Variable name (‘prmsl’,’air.2m’, ‘prate’, etc.)
  • year (int) – Year of assimilation run.
  • month (int) – Month of assimilation run (1-12)
Returns:

Dataframe of observations.

Return type:

pandas.DataFrame

Raises:

IOError – No data on disc for this variable, year, and month.


DWR.pretty_name(name)[source]

Convert station names from DATAFORMAT to Print Format.

The station names included in the DWR data files are in all caps and contain no spaces. This function maps them to a readable format - so FORTWILLIAM becomes ‘Fort William’.

Parameters:name (str) – Name as in data file (e.g. ‘CAPGRISNEZ’)
Returns:Name in readable format (e.g. ‘Cap Gris-Nez’)
Return type:str