University of Cape Town
Browse

Python code to analyse the association between rainfall data and synoptic wind direction

Version 2 2022-12-19, 11:03
Version 1 2021-09-16, 11:41
software
posted on 2022-12-19, 11:03 authored by Stefaan ConradieStefaan Conradie, Bruce Hewitson, Piotr Wolski


https://cds.climate.copernicus.eu/cdsapp#!/dataset/reanalysis-era5-pressure-levels?tab=overview

This item contains python functions to analyse rainfall and wind data and find relationships between them. The item takes the form of three "modules" used to analyse point rainfall data (`fn`). gridded rainfall data (`gridfn`) and plot maps (`maps`), as well as scripts employing these functions to analyse the spatial pattern of rainfall under various synoptic wind direction regimes over the Winter Rainfall Zone of South Africa.

Suggested directory structure [scripts should be run from ${root}/py_scripts as the working directory]


|-- data
| |-- wind
| | |-- contrib_rain_dirn.nc
| | |-- ERA5_u900.nc
| | `-- ERA5_v900.nc
| |-- GPCC_V2020_025deg_SWSA_SPI12.nc
| |-- GPCC_V2020_025deg_SWSA_SPI24.nc
| |-- GPCC_V2020_025deg_SWSA_SPI36.nc
| |-- GPCC_V2020_025deg_SWSA_SPI3.nc
| |-- GPCC_V2020_025deg_SWSA_SPI60.nc

| | -- gpcc_normals_025.nc

| | -- gpcc_V2020_SWSA_025deg_14-26E_-35.5--26N.nc

| | -- mapnames.csv
| `-- rainfall.csv
|-- figures
|-- metadata
| `-- WRZ_meta.csv
|-- py_scripts
| |-- fn
| | |-- basemap_clusterplots.py
| | |-- basemap_plots.py
| | |-- __init__.py {empty file}
| | |-- station_clusters.py
| | |-- wind_dirn.py
| | |-- wind_plots.py
| | `-- xrclim_fns.py
| |-- gridfn
| | |-- analysis.py

| | |-- __init__.py

| | |-- read.py

| | `-- maps.py
| |-- maps
| | |-- __init__.py
| | `-- stamen_map.py
| |-- GPCC_SPI.py
| |-- GPCC_domain.py

| |-- wind_dirn_WRZ.py
| `-- WRZmap.py


Required packages:

for functions in the "fn" directory:

pandas

xarray

numpy

maplotlib

mpl_toolkits.basemap

seaborn

scipy

sklearn

datetime


For those functions in the gridfn directory, the following packages are required:

xarray

pandas

numpy

scipy

cycler

cartopy

seaborn


For those functions in the directory maps, required packages are:

pandas

numpy

cartopy

matplotlib



The "rainfall.csv" included in this item uses only freely available data from the DWS and has been infilled but not cleaned, is not very dense and consequently is not a very high quality dataset, but it can be used to demonstrate all functionality of the functions included.


The file "WRZ_meta.csv" contains metadata regarding the stations included in rainfall.csv. It is a subset of data included in 10.25375/uct.16453452.

The GPCC SPI data can be generated using code in the "R code for SPI calculations" item (doi: 10.25375/uct.16545690). GPCC normals (climatology) data can be obtained directly from: http://dx.doi.org/10.5676/DWD_GPCC/CLIM_M_V2020_025.


The clustering step of "wind_dirn_WRZ.py" can be run using data included in this item ("contrib_rain_dirn.nc").


ERA 5 wind data can be obtained from the ECMWF CDS:


UPDATE: It was pointed out by Eftychia Koukouraki that the original version did not contain the file mapnames.csv, which is now included in this updated version, together with corresponding changes to the suggested directory structure.

Funding

South African National Research Foundation (NRF) grant 121047

History

Department/Unit

Climate System Analysis Group

Usage metrics

    Climate System Analysis Group (CSAG)

    Categories

    Licence

    Exports

    RefWorks
    BibTeX
    Ref. manager
    Endnote
    DataCite
    NLM
    DC