<div align="center">
  <img src="/logo_BSC.png" alt="Logo 1" height="50">
  <img src="/logo_FOCUS.png" alt="Logo 2" height="50">
</div>

<br>
<div align="center">

**In this READ.me, we provide the instructions necessary to run the vignette [FOCUS_calibration_t2m.ipynb](https://earth.bsc.es/gitlab/amartine/vignette/-/blob/main/FOCUS_calibration_t2m.ipynb) locally on a personal computer**

This project is licensed under GNU General Public License version 3 ([GPL-3](https://www.gnu.org/licenses/gpl-3.0)|[View on GitLab](https://earth.bsc.es/gitlab/amartine/vignette/-/blob/main/LICENSE.txt))

[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)    

</div>



#### COMPUTATIONAL REQUIREMENTS
If you want to run the vignette [FOCUS_calibration_t2m.ipynb](https://earth.bsc.es/gitlab/amartine/vignette/-/blob/main/FOCUS_calibration_t2m.ipynb) locally on a computer you must ensure that the next computational requirements are met:

- **R - version 3.6.1**. It can be downloaded from [https://cran.r-project.org/](https://cran.r-project.org/)  
- **CDO - version 1.9.8**. It can be downloaded from [https://code.mpimet.mpg.de/projects/cdo](https://code.mpimet.mpg.de/projects/cdo) (with previous registration). Some useful information can be found on [https://code.mpimet.mpg.de/projects/cdo/embedded/cdo.pdf]() , specially on the section 1.1.
- **JupyterLab or similar**: A tool able to open a Jupyter notebook is needed. We recommend using JupyterLab. It can be installed from [https://jupyter.org/install](https://jupyter.org/install)




A relatively easy way to download and install JupyterLab and the requested versions of R and CDO may be through conda. Conda quickly installs, runs and updates packages and their dependencies (more detailed information of conda can be found here: https://docs.conda.io/en/latest/). Some details and a guide regarding the Conda download and installation are described in: https://docs.conda.io/projects/conda/en/latest/user-guide/install/. In this regard, we encourage to download Anaconda, which is a set of about a hundred packages including conda, numpy, scipy, ipython notebook, ecc,. Complementary information regarding how Anaconda works and how can be used for installing some packages (as well as installing R, CDO or Jupyter-Lab)  can be found in their user guide: https://docs.anaconda.com/anaconda/user-guide/. 

#### STEPS TO INSTALL JupyterLab AND THE REQUIRED VERSIONS OF R AND CDO THROUGH ANACONDA

#### WITH LINUX
**Only once**:

1. Go to the [repository](https://earth.bsc.es/gitlab/amartine/vignette) containing the FOCUS vignette and download it (we have choosen the download source code to be "tar.gz"): 

 ![first_instruction](./instructions_screenshots/instruction_screenshot_1.png)
 
2. Extract the contents in the path that you prefer within your computer. To do so, go to what you have downloaded in **Step 1**, open it and clik on "Extract":

![second_instruction](./instructions_screenshots/instruction_screenshot_2.png)

Once you have done it, you need to choose where you want to store it. As a piece of example, we have choosen a folder named "work_folder" which has the next path (in our example, yours will be different): "/amartine/home/work_folder":

![third_instruction](./instructions_screenshots/instruction_screenshot_3.png)

once we have selected the folder where the repo will be stored, the last thing to do (within this step) is to click in "Extract":

![fourth_instruction](./instructions_screenshots/instruction_screenshot_4.png)

3. Once we have the repository downloade and stored in our computer, we have to download and install Anaconda. To do so, go to: [https://docs.conda.io/projects/conda/en/latest/user-guide/install/#regular-installation](https://docs.conda.io/projects/conda/en/latest/user-guide/install/#regular-installation) and within the "Regular installation" section select "Linux". Once this is done you should select "Anaconda installer for "Linux" and finally proceed with the download and installation. 
4. Open a terminal and execute the following commands in order to set the environment properly:
    - `conda env create -f <repository_path>/in_computer/settings_conda.yml`
   
    **Note 1**: you should replace <repository_path> by the path where the contents of the downloaded repository were stored (**Step 2**). As a piece of example, <repository_path>= '/amartine/home/work_folder/vignette-main/'
   
    - `conda activate settings_conda`
    - `R -e "install.packages('devtools', repos='https://ftp.cixug.es/CRAN/')"`
    - `R -e "library(devtools); path_anaconda <-'/home/amartine/anaconda3/'; Sys.setenv(TAR = paste0(path_anaconda,'/envs/settings_conda/bin/tar'));install_version('Rcpp',version='1.0.8.3', quiet=T, repos='https://ftp.cixug.es/CRAN/'); install_version('uuid',version='1.1.0', quiet=T, repos='https://ftp.cixug.es/CRAN/'); install_version('pillar',version='1.6.2', quiet=T, repos='https://ftp.cixug.es/CRAN/')"`

    **Note 2**: 'path_anaconda' must specify the path where anaconda3 has been installed in your computer. 
    

**Steps that need to be followed every time you want to run the vignette**:
1. Open a terminal.
2. Type `conda activate settings_conda`. If it does not work try `source activate settings_conda`. More info in https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html#activating-an-environment
3. Open Jupyter Lab.
4. Set the Rkernel. (imagelink)
5. On the left you can now go to the repository path (which is the path within your computer where you have archived the [repository](https://earth.bsc.es/gitlab/amartine/vignette) containing the FOCUS vignette). (imagelink)
6. Click on the vignette script and you can now run the code line by line.

<br>
<div align="center">

This project is licensed under GNU General Public License version 3 ([GPL-3](https://www.gnu.org/licenses/gpl-3.0)|[View on GitLab](https://earth.bsc.es/gitlab/amartine/vignette/-/blob/main/LICENSE.txt))

[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)    

<br>
</div>

<div align="center">
  <img src="/logo_BSC.png" alt="Logo 1" height="50">
  <img src="/logo_FOCUS.png" alt="Logo 2" height="50">
</div>

