Skip to content

Datasets Module

CMIP6 Downloader

Downloader for CMIP6 daily GCM data.

products_to_download property

List of all (gcm, ssp, var, year) combinations.

__init__(**kwargs)

Initialize the downloader.

Parameters:

Name Type Description Default
url_root str

Base URL containing CMIP6 data directories.

required

download_data(url, fn, output_path) staticmethod

Download remote file if not already present.

Parameters:

Name Type Description Default
url str

URL of the parent directory.

required
fn str

Filename.

required
output_path Path

Directory where file will be saved.

required

Returns:

Type Description
Path or None

Path to downloaded file or None if failed.

find_remote_file(gcm, ssp, var, year)

Attempt to locate a remote CMIP6 file matching known naming patterns.

Parameters:

Name Type Description Default
gcm str
required
ssp str
required
var str
required
year int
required

Returns:

Type Description
tuple

(url_dir, filename) if found, else (None, None)

Processing Tools

Utility functions for processing climate xarray datasets.

clip_spdata(extent, xrdata=None, xrdata_path=None, rotate=False, chunks='auto') staticmethod

Clip xarray dataset to a given spatial bounding box.

Parameters:

Name Type Description Default
extent tuple of float

(min_lon, min_lat, max_lon, max_lat).

required
xrdata Dataset

Dataset already loaded in memory.

None
xrdata_path str

Path to dataset on disk.

None
rotate bool

If True, shift longitudes from 0–360 → -180–180.

False
chunks str or dict

Dask chunking options.

'auto'

Returns:

Type Description
Dataset

Spatially clipped dataset.

preprocess_xrdata(xrdata, variable=None) staticmethod

Apply variable-specific preprocessing to CMIP6 data.

Parameters:

Name Type Description Default
xrdata Dataset

Dataset containing climate variables.

required
variable str

Variable name. If None, the first variable is used.

None

Returns:

Type Description
Dataset

Preprocessed dataset.

Notes
  • pr: converted to daily precipitation (kg m-2 s-1 → mm/day)
  • tasmax, tasmin: convert from Kelvin → Celsius
  • rsds: convert radiation (W/m2 → MJ/m2/day)

save_asnc(xrdata, fn) staticmethod

Save a dataset to a NetCDF file with appropriate encoding.

Parameters:

Name Type Description Default
xrdata Dataset

The dataset to save.

required
fn str

Output file name.

required