Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents


Note

You only need to go through this procedure once, before you can use the CDS API on macOS to programmatically download data from either the Climate Data Store (CDS) or the Atmosphere Data Store (ADS).

Prerequisites

  1. Have You need to have a CDS or ADS account. If you don't have an account, please self register at the CDS registration page or the ADS registration, whichever is appropriate.
  2. You need Python
    • Option 1: use Python 2.

      Expand
      titleTest Python 2 and install pip

      If you want to use Python 2, then it should come with your macOS. Open a Terminal and type command 'python'. You should see something like 'Python 2.7.10 (default, Feb 22 2019, 21:17:52)'. Type 'Control + D' to quit.

      For Python 2, run the 2 commands below to install pip:

      Code Block
      curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
    • 
      python get-pip.py



    • Option 2: use Python 3. You are recommended to follow instructions here using Homebrew.xcode-select --install

      Expand
      titleInstall Python3 through Homebrew


      Code Block
      xcode-select --install
    • 
      
      /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/
    Homebrew
    • Homebrew/install/master/install)"
    • 
      
      brew install
    python3Option 2: use Python 3. You are recommended to follow instructions here using Homebrew.
    •  python3



  3. Optional: you are recommended to set up a virtual environment.

Python 3 comes up with this feature. For Python 2, you may want to use Virtualenv. This is out of the scope of this knowledge base article.

Step-by-step guide

  1. Login to CDS (or Login to ADS)
  2. Copy a 2 line code, which shows a url and your own uid:API key details as follows:
    1. For CDS users, Go to this page and copy the 2 line code displayed
    on this page for CDS users (or this page for ADS users). The code shows a url and your own uid:API key.
    1. in the black box in the "Install the CDS API key" section.
    2. For ADS users, Go to this page and copy the 2 line code displayed in the black box in the "Install the CDS API key" section.
  3. Create your key file in your home directory in your Terminal window as follows:

    Code Block
    touch ~/.cdsapirc


  4. Edit your key file and paste the two lines you copied in Step 2 above to your .cdsapirc key Run 'touch ~/.cdsapirc' in your Terminal to create your key file and copy the two lines you see in 1 to the file.
  5. Install the CDS API client using pip

    :  'pip install cdsapi'. You should run this under a Terminal.

    , by running the following command in your Terminal window:

    Code Block
    pip install cdsapi


  6. Once the CDS API client is installed, it can be used to request data from the datasets listed in the CDS and ADS catalogues. It is necessary to agree to the Terms of Use of every datasets that you intend to download. Attached to each dataset download form, the 'Show API request' button displays the python code to be used.


Info

If you are getting connection issues, we recommend that in the first instance you check your proxy settings with your local IT team.


Content by Label
showLabelsfalse
max5
spacesCKB
showSpacefalse
sortmodified
reversetrue
typepage
cqllabel = "cds" and type = "page" and space = "CKB"
labelscds

...