CDS seasonal netcdf downloader
======================================

These python scripts allow netcdf files from the CDS seasonal forecasts, in a format compatible with CSTools.

The requests provided by the CDS will work well for one start date. However, if one is interested in multiple start dates and/or variables, it will be time consuming. For those working on Linux, we offer an efficient solution to download multiple start dates and variables at once.

It requires the following modules:

- Python/3.7.3-foss-2015a

- NCO/4.4.9-foss-2015a

- netCDF/4.3.3.1-foss-2015a

- cdsapi/0.2.3-foss-2015a-Python-3.7.3

If you don’t have these modules/libraries installed on your system, installation can be done through conda. Conda allows you to install locally all the python and the necessary dependencies and libraries without needing root permissions nor conflicting with other installations

If conda is not installed on your system (the command “which conda” doesn’t return anything), you can install install Miniconda on your system following the official instructions: https://docs.conda.io/projects/continuumio-conda/en/latest/user-guide/install/)

Create a virtual environment in which the dependencies will be installed (skip if it is not the first time you run it)

` conda create -n cdsdownloader `

Activate the newly created environment. From there, all what you do will be inside this environment. 

`conda activate cdsdownloader`

(Note: It might ask you to select a shell to log out and back in again.)

Install the 2 main libraries needed by the tool (skip if it is not the first time you run it)
```
conda install -c conda-forge/label/cf202003 pynco  
conda install -c conda-forge/label/cf202003 cdsapi  
```


A copy of the scripts is available on Gitlab. There is a python file (.py) and a config file (.conf). Once you have retrieved these files, you can copy them to your working directory. The python file is a script similar to what one gets with a regular CDS request, however it contains loops which will allow to retrieve multiple start dates and variables in the same request. Do not modify this file. 


- The config file is where you select 
- The directory where to put the data
- The model you want to download
- The variables
- The start dates

While you can download as many start dates and variables as you want, you can only select one model at the time. All the available options are provided in the .conf file.

To run the downloader, simply run the following command after updating the configuration file:
`python download_seasonal_cds_6h.py 6h.conf`

There are currently 2 sets of scripts. One to obtain monthly mean data and one to obtain data at the original frequency that they are produced (daily or 6-hourly).

The advantage of using this script over the simpler options presented above are:
- Files are in NetCDF format.
- Can request multiple start dates and variables at once. The script will also organize the files and rename the variables/dimensions in such a way that is compatible/expected by the CSTools package.
- It will automatically detect the number of lead times, so you don’t have to specify it.

