src.data_loading package

Submodules

src.data_loading.download module

Download the data from dropbox links.

Example

Import statement:

from src.data_loading import get_data
src.data_loading.download.get_and_unzip(direc, url, name)

Get the data and unzip it.

Parameters
  • direc (str) – directory to put the data in.

  • url (str) – url of the zip file.

  • name (str) – name of file.

Return type

None

src.data_loading.download.get_cmip6_mmm(force_refresh=False)

Downloads cmip6 means.

Return type

None

src.data_loading.download.get_cmip6_mmm_clim60(force_refresh=False)

Downloads cmip6 means.

Return type

None

src.data_loading.download.get_data(force_refresh=False)

Download the relevant dataset from a Dropbox link and extract it.

Return type

None

src.data_loading.download.get_figure_data(force_refresh=False)

Downloads figure nc.

Return type

None

src.data_loading.download.get_member_data(force_refresh=False)

Downloads ensemble members.

Return type

None

src.data_loading.download.get_mmm(force_refresh=False)

Downloads multimodel mean.

Return type

None

src.data_loading.download.get_noaa_data()

Downloads noaa sst nc.

Return type

None

src.data_loading.download.get_original_models()

Downloads original models.

# https://www.dropbox.com/s/u5ufak4kv8peajd/atmos-model.zip?dl=0 # https://www.dropbox.com/s/s6u80p1s1e5qom4/ocean-model.zip?dl=0

Return type

None

src.data_loading.download.get_test_nino_data()

Downloads noaa sst nc.

Return type

None

src.data_loading.download.get_ts_ensemble(force_refresh=False)

Downloads cmip6 ensemble for ts.

Return type

None

src.data_loading.download.get_uv(force_refresh=False)

Downloads uv mean.

Return type

None

src.data_loading.ecmwf module

ECMWF ERA5 download script.

This script requires you to have registered for an account at:

https://cds.climate.copernicus.eu/

And to have added the login details to your computer user profile as described there.

The script can take a long time to run, as requests at the CDS can be held in a very long queue (i.e for many hours on weekdays).

class src.data_loading.ecmwf.FileNames(variable='total_precipitation', region='')

Bases: object

Class to store ERA5 file names, both to create the files, and to reference them later.

Properties:

back_extension_path main_era5_path initial_combined_path archive_combined_path

Example Usage:

import xarray as xr
from src.data_loading.ecmwf import FileNames
precip_names = FileNames(variable="total_precipitation", region="mekong")
xr.open_dataset(precip_names.archive_combined_path)
src.data_loading.ecmwf.get_era5(variable='total_precipitation', area=[90, -180, -90, 180], region='', start_year=1950, end_year=2022, download=True, regrid=False, archive=True)

Get ECMWF monthly average variable.

Parameters

variable (str, optional) – ECMWF API variable name.

Defaults to “total_precipitation”.

area (List[int], optional): Defaults to global [ 90, -180, -90, 180]. region (str, optional): Region name to add to files. Defaults to “”. start_year (int, optional): Start year of timeseries. Defaults to 1950. end_year (int, optional): End year of timeseries. Defaults to 2022. regrid (int, optional): Whether or not to regrid the data to my standard grid. archive (bool, optional): Defaults to True.

Return type

None

src.data_loading.ecmwf.get_main_variables(regrid=False)

Make the main ERA5 variables for seager19.

Return type

None

src.data_loading.ecmwf.get_mekong_variables()

Download and archive mekong variables

Return type

None

src.data_loading.ecmwf.rename_mekong()

Rename mekong files.

Return type

None

src.data_loading.ingrid module

Script to cut out spin up conditions.

Seeks to replicate:

```
\begin{ingrid}

(DATA/qflx-0.nc)readCDF .X /XM exch def
(DATA/qflx-0.nc)readCDF .Y /YM exch def

(output/om_diag.nc)readCDF .SST_QFLX
T last 11 sub last RANGE
T /T (months since 1960-01-01) periodic 0.5 1 11.5 NewEvenGRID replaceGRID
/X X periodic setgridtype def
Y -91 1 91 evengridAverage
0 replaceNaN
L /Z renameGRID
(qflx)rn
(DATA/qflx.nc)writeCDF
\end{ingrid}
```
src.data_loading.ingrid.linear_qflx_replacement(setup, output_file_name='qflx.nc')

Uses xarray linear interpolation to replace netcdf with qflx in.

Parameters

output_file_name (str, optional) – Default is ‘qflx.nc’

Return type

None

src.data_loading.make_inputs module

src.data_loading.pangeo module

src.data_loading.psl module

PSL data reader.

You can find all of these indices indexed here:

<https://psl.noaa.gov/data/climateindices/list/>

src.data_loading.psl.get_ersstv5(reload=False)

Get ERSSTV5 datarray.

Parameters

reload (bool, optional) – Whether to prefer redownloading. Defaults to False.

Returns

Straight from website.

Return type

xr.DataArray

src.data_loading.psl.get_psl_indices(reload=False)

A function to return the psl indices, either from memory, or by reading them from the web.

Parameters

reload (bool, optional) – Whether to prefer to reload them. Defaults to False.

Returns

Dataset with indices from the PSL over

all available datapoints. Missing values are marked as nan.

Return type

xr.Dataset

src.data_loading.psl.psl_index_da(var='tni')

Read an index from the psl website, and reformat it into an xarray.Datarray object.

Parameters

var (str, optional) – Which index to read. Defaults to “tni”.

Returns

A standard xarray 1D datarray with the index values,

and a datetime axis. Assumes that the value corresponds to the 1st of the month, and nans out missing values.

Return type

xr.DataArray

src.data_loading.psl.psl_metric_test()

Test to see if the psl and I agree on the metrics given the ERSSTv5 SST data (i.e. to debug metrics etc.)

Return type

None

src.data_loading.regrid module

src.data_loading.zenodo module

Zenodo download scripts.

src.data_loading.zenodo.get_zip()
Return type

None

Module contents