Code

Tools

Here I have listed some Python tools I have developed to improve research efficiency. I have limited capacity to update these but feel free to use them if useful.

Get weather station data (Global)

from get_station_data import ghcnd
from get_station_data.util import nearest_stn

### Read station metadata
stn_md = ghcnd.get_stn_metadata()

### Choose a location & number of nearest neighbours
lon_lat = -0.1278, 51.5074 # i.e., London
my_stns = nearest_stn(stn_md, lon_lat[0], lon_lat[1],
                        n_neighbours=5 )

### Download and extract data into a pandas DataFrame
df = ghcnd.get_data(my_stns)

Get climate model output (CMIP5/6)

import baspy as bp

### Retrieve a filtered catalogue as a Pandas DataFrame
df = bp.catalogue(dataset='cmip5', Model='HadGEM2-CC', 
                    RunID='r1i1p1', Experiment='historical', 
                    Var=['tas', 'pr'], Frequency='mon')

### Iterate over rows in catalogue
for index, row in df.iterrows():
    ds = bp.open_dataset(row) ### In Xarray
    cubes = bp.get_cube(row)  ### Or... In Iris

Notebooks

Here are some Python notebooks I use for research and teaching. Please feel free to get in touch if you have any comments, even if just to say you found them useful

Getting started

  • Using BASpy with Xarray to read in climate model data (CMIP5)
  • Getting weather station data from around the globe (both monthly and daily averaged data)

Research

Useful scripts

I have other notebooks here which I may or may not migrate over time to this site