Skip to main content

A package to download NASA NEX/GDDP-CMIP6 downscaled climate change scenarios

Project description

cmip6d

DOI

This python library downloads downscaled climate change scenarios from NASA NEX-GDDP-CMIP6 (https://ds.nccs.nasa.gov/thredds/catalog/AMES/NEX/GDDP-CMIP6/catalog.html).

Instructions

To use this library install the requirements:

  • wget
  • csv
  • numpy
  • pandas
  • xarray
  • beautifulsoup4

If you are using windows, wget needs to be downloaded and added to your paths If you don't want to get the .csv summary you do not need xarray, but it is highly recommended for post-processing.

Install

pip install cmip6d

Examples

To import the library:

from cmip6d import cmip6d

Define the main variables. Until

out_path = 'test' # Defines your output folder
coords = [-75,-69.5,-17.5,-14] # xmin,xmax,ymin,ymax
models = [] # If empty, downloads everything, if not, downloads specified packages
ssp=['ssp245','ssp585'] # DEFAULT VARIABLE. Target scenarios from the NASA server
variables = ['pr','tasmax','tasmin'] # DEFAULT VARIABLE. Target variables from the NASA server

To create the main Python object:

cc = cmip6d(out_path,coords,models,variables=variables,ssp=ssp)

First, it creates the folder structure based on the MODELS, then it generates a "link.txt" file with the links to be downloaded. The "check_links" argument allows you to not re-create the "link.txt" file if it already exists.

cc.get_links(out_path,check_links=True)

To download the links you need to specify a number of workers "nworker", which speeds up the download. Once completed these step you will have all the netcdf files for your climate change model, these can be loaded with xarray or whatever other method you prefer.

cc.download_links(nworker=4)

If you want to merge the yearly individual ".nc" files into one for each variable use:

cc.merge_files(cont)

Additional steps

If you would like to get 2 ".csv" files with coordinates of the following structure:

ID Latitude Longitude
P_0_0 .... .....
P_0_1 .... .....
... .... .....

and

Date P_0_0 P_0_1 ...
2015-01-01 .... ..... ...
2015-01-02 .... ..... ...
... .... ..... ...

You can use the following function after running "merge_files", where "cont=True" does not process the data if the files already exist. This function returns a dictionary of the climate change models and dates that were not processed because of missing dates in the timeserie from 2015-01-01 to 2100-12-31.

todel = cc.get_csv(cont)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cmip6d-1.1.tar.gz (5.5 kB view hashes)

Uploaded Source

Built Distribution

cmip6d-1.1-py3-none-any.whl (5.8 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page