PyCPT config and notebook
PyCPT is a Python interface and enhancement for the command line version of the International Research Institute for Climate and Society's Climate Predictability Tool (CPT), for seasonal and sub-seasonal skill assessment and forecast experiments.
This notes is describing on how to use PyCPT s2sv1.92 and seav1.92 for Subseasonal and Seasonal Forecasting in Indonesia
1 Installation
This section will explain on how to install the PyCPT inside Windows Subsystem for Linux (WSL) 2. This step-by-step guide was tested using Windows 11 with WSL2 - Ubuntu 22 enabled running on Thinkpad T480 2019, i7-8650U 1.9GHz, 64 GB 2400 MHz DDR4.
1.1 Anaconda Python3
Download and install Anaconda Python on your WSL Ubuntu Linux.
Go to https://repo.anaconda.com/archive/ to find the list of Anaconda releases
Select the release you want. I have a 64-bit computer, so I chose the latest release ending in
x86_64.sh. If I had a 32-bit computer, I'd select thex86.shversion. If you accidentally try to install the wrong one, you'll get a warning in the terminal. I choseAnaconda3-2022.10-Linux-x86_64.From the terminal run
wget https://repo.anaconda.com/archive/[YOUR VERSION]. Example:wget https://repo.anaconda.com/archive/Anaconda3-2022.10-Linux-x86_64After download process completed, Run the installation script:
bash Anaconda[YOUR VERSION].shbash Anaconda3-2022.10-Linux-x86_64.shRead the license agreement and follow the prompts to press Return/Enter to accept. Later will follow with question on accept the license terms, type
yesand Enter. When asks you if you'd like the installer to prepend it to the path, press Return/Enter to confirm the location. Last question will be about initialize Anaconda3, typeyesthen Enter.Close the terminal and reopen it to reload .bash configs. It will automatically activate
baseenvironment.Deactivate
baseenvironment then set tofalsethe confirguration of auto activate thebaseenvironment by typingconda deactivate && conda config --set auto_activate_base falseTo test that it worked,
which pythonin your Terminal. It should print a path that has anaconda in it. Mine is/home/bennyistanto/anaconda3/bin/python. If it doesn't have anaconda in the path, do the next step.Manually add the Anaconda bin folder to your PATH. To do this, I added
"export PATH=/home/bennyistanto/anaconda3/bin:$PATH"to the bottom of my~/.bashrcfile.You should use Anaconda Virtual Environments. This step must only be done the first time. Once the environment has been created there is no need to do it again.
First, open your Terminal (in your Ubuntu Linux on WSL), create the Python environment:
conda create -n cptProceed with
yThe environment created can now be ‘activated’ and ready to install the supporting packages:
conda activate cpt conda install -c conda-forge xarray matplotlib scipy cartopy netcdf4 numpy pandas subprocess
1.2 CPT
Download the 16.5.8 version of CPT from https://academiccommons.columbia.edu/doi/10.7916/d8-em5q-0f07. Use the source code tarfile CPT.16.5.8.tar.gz
1.2.1 Prerequisites:
I f you don't have GCC and GFortran, please install it before continuing to install the CPT
sudo apt install gcc gfortran make git
1.2.2 Install CPT
Navigate to your
homedirectory by typingcd ~in your terminalUntar the CPT tar file into CPT/XX.X.X
tar xvzf CPT.16.5.8.tar.gzBuild CPT
cd CPT/XX.X.X make distclean makeInstall CPT: Determine where you want to install CPT, making sure this folder is in your PATH
make INSTALL_DIR=~/CPT/16.5.8 installUpdate your PATH and add CPT_BIN_DIR
Edit the file ~/.bashrc, adding the following lines to the file:
export PATH=$PATH:~/CPT/16.5.8/bin export CPT_BIN_DIR=~/CPT/16.5.8/binClone PyCPT
Use git to download from the Bitbucket Git Repository into your home directory You will need to install a GIT client if you want to keep the PyCPT source up to date.
use git clone to get iri-pycpt from bitbucket https://bitbucket.org/py-iri/iri-pycpt.git
cd ~/CPT git clone https://bitbucket.org/py-iri/iri-pycpt.git
2 Supporting Files
There are one authentication file that required to be available and also two modified py files that need to be copied and replaced the existing files in the PyCPT folder.
2.1 Authentication File
ONLY needed for the s2s version
Create the file .IRIDLAUTH in the main PyCPT folder. It must contain only one line with the Data Library S2S key (104 characters) obtained via this link. Please do not share your key.
If you have file
.IRIDLAUTHin your PyCPT folder, don't forget to set the permission.chmod 644 ~/CPT/iri-pycpt/.IRIDLAUTH
2.2 PyCPT python function
There are some minor revision in both py functions. You need to copy and replace the pycpt_functions.py and pycpt_functions_seasonal.py
2.3 Notebook Files
I provide four ipynb files (2 Subseasonal and 2 Seasonal Forecasts), with study case for Indonesia. Put these files inside PyCPT folder.
3 Run the Forecasts
Make sure you are inside the PyCPT folder or navigate your Terminal to cd ~/CPT/iri-pycpt.
Run the Jupyter Notebook.
jupyter notebookTry one of the notebook I have provided.
Seasonal Forecasts
]PyCPT_seav1.9.2-IDN_CCA_PRCP_16N_18S_85E_150E_CHIRPS__PRCP_11N_13S_90E_145E_NCEP-CFSv2_NASA-GEOSS2S_Mar2023.ipynb](https://gist.github.com/bennyistanto/3c87cca14fec4ce2bb35203b37593135/raw/0d964a18f93ac376302f9b8ca3c3fbe839fa4a5f/PyCPT_seav1.9.2-IDN_CCA_PRCP_16N_18S_85E_150E_CHIRPS__PRCP_11N_13S_90E_145E_NCEP-CFSv2_NASA-GEOSS2S_Mar2023.ipynb)
-
Subseasonal Forecasts
Feel free to adjust the study area, model, etc.