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.
- src.data_loading.download.get_cmip6_mmm(force_refresh=False)
Downloads cmip6 means.
- Return type
- src.data_loading.download.get_cmip6_mmm_clim60(force_refresh=False)
Downloads cmip6 means.
- Return type
- src.data_loading.download.get_data(force_refresh=False)
Download the relevant dataset from a Dropbox link and extract it.
- Return type
- src.data_loading.download.get_figure_data(force_refresh=False)
Downloads figure nc.
- Return type
- src.data_loading.download.get_member_data(force_refresh=False)
Downloads ensemble members.
- Return type
- 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
- src.data_loading.download.get_ts_ensemble(force_refresh=False)
Downloads cmip6 ensemble for ts.
- Return type
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:
objectClass 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
- src.data_loading.ecmwf.get_main_variables(regrid=False)
Make the main ERA5 variables for seager19.
- Return type
- src.data_loading.ecmwf.get_mekong_variables()
Download and archive mekong variables
- Return type
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.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.regrid module
src.data_loading.zenodo module
Zenodo download scripts.