diff --git a/binder/FOCUS_calibration_tasmax.ipynb b/binder/FOCUS_calibration_tasmax.ipynb index 3d8b7e7a8bfc59960e90d3bbaf43a6f850bb3c2b..b5b02da8b05a945b7af470e29069a87f5774bede 100644 --- a/binder/FOCUS_calibration_tasmax.ipynb +++ b/binder/FOCUS_calibration_tasmax.ipynb @@ -48,7 +48,10 @@ "source": [ "#This first lines allow installing in the binder environment (or within your computer) the packages that will be used afterwards \n", "# Using setwd(\"\") you can set the working directory where the analysis is conducted\n", - "dir.create(paste0(getwd(),\"/R_libs/\"))" + "dir.create(paste0(getwd(),\"/R_libs/\"))\n", + "\n", + "# Execute only on binder (only if R is not installed on your computer)\n", + ".libPaths(paste0(getwd(),\"/R_libs/\"))" ] }, { @@ -68,17 +71,11 @@ "install_version(\"s2dv\", version=\"1.1.0\", destdir=(paste0(getwd(),\"/R_libs/\")), lib=(paste0(getwd(),\"/R_libs/\")), quiet=T)\n", "install_version(\"s2dverification\", version=\"2.10.1\", destdir=(paste0(getwd(),\"/R_libs/\")), lib=(paste0(getwd(),\"/R_libs/\")), quiet=T)\n", "install_version(\"RColorBrewer\", version=\"1.1.2\", destdir=(paste0(getwd(),\"/R_libs/\")), lib=(paste0(getwd(),\"/R_libs/\")), quiet=T)\n", - "install_version(\"CSTools\", version=\"4.0.1\", destdir=(paste0(getwd(),\"/R_libs/\")), lib=(paste0(getwd(),\"/R_libs/\")), quiet=T)\n" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [ - "# Execute only on binder (only if R is not installed on your computer)\n", - ".libPaths(paste0(getwd(),\"/R_libs/\"))" + "install_version(\"CSTools\", version=\"4.0.1\", destdir=(paste0(getwd(),\"/R_libs/\")), lib=(paste0(getwd(),\"/R_libs/\")), quiet=T)\n", + "\n", + "install_version(\"tibble\", destdir=(paste0(getwd(),\"/R_libs/\")), lib=(paste0(getwd(),\"/R_libs/\")), quiet=T)\n", + "install_version(\"stringr\", destdir=(paste0(getwd(),\"/R_libs/\")), lib=(paste0(getwd(),\"/R_libs/\")), quiet=T)\n", + "install_version(\"R6\", destdir=(paste0(getwd(),\"/R_libs/\")), lib=(paste0(getwd(),\"/R_libs/\")), quiet=T)\n" ] }, { @@ -91,7 +88,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 1, "metadata": {}, "outputs": [ { @@ -131,11 +128,6 @@ " StatSeasAtlHurr, ToyModel, Trend, UltimateBrier\n", "\n", "\n", - "The following object is masked from ‘package:base’:\n", - "\n", - " Filter\n", - "\n", - "\n", "\n", "Attaching package: ‘ClimProjDiags’\n", "\n", @@ -175,15 +167,8 @@ " Corr\n", "\n", "\n", - "\n", - "Attaching package: ‘easyVerification’\n", - "\n", - "\n", - "The following object is masked from ‘package:SpecsVerification’:\n", - "\n", - " EnsCorr\n", - "\n", - "\n" + "Warning message:\n", + "“replacing previous import ‘lifecycle::last_warnings’ by ‘rlang::last_warnings’ when loading ‘tibble’”\n" ] } ], @@ -200,22 +185,22 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "'/home/Earth/amartine/repositories/cstools/binder'" + "'/esarchive/scratch/lpalma/git/CST_test_albert_vignette/binder'" ], "text/latex": [ - "'/home/Earth/amartine/repositories/cstools/binder'" + "'/esarchive/scratch/lpalma/git/CST\\_test\\_albert\\_vignette/binder'" ], "text/markdown": [ - "'/home/Earth/amartine/repositories/cstools/binder'" + "'/esarchive/scratch/lpalma/git/CST_test_albert_vignette/binder'" ], "text/plain": [ - "[1] \"/home/Earth/amartine/repositories/cstools/binder\"" + "[1] \"/esarchive/scratch/lpalma/git/CST_test_albert_vignette/binder\"" ] }, "metadata": {}, @@ -245,11 +230,11 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 11, "metadata": {}, "outputs": [], "source": [ - "# Select variable\n", + "2# Select variable\n", "var_name = 'tasmax'\n", "\n", "# Specify the reference period for forecast calibration (\"years\"), and the inisialization month (\"ini\" - in this case November (11)):\n", @@ -262,14 +247,12 @@ "time_forecast <- indices(1:3) # As the initialisation month is November (ini=11),\n", " # the predicted months will be November, December and January (NDJ)\n", "\n", - "\n", "# Specify the longitude and latitude boundaries of the region of interest\n", "lons.min <- 0\n", "lons.max <- 49\n", "lats.min <- -40\n", "lats.max <- -10\n", "\n", - "\n", "# Get the path of the hindcast and observational data (if the netCDF are stored on your computer)\n", "# or download the netCDFs from the CDS and get the path where they will be kept.\n", "\n", @@ -283,8 +266,15 @@ " # '/esarchive/exp/ecmwf/system5c3s/monthly_mean/tasmax_f24h/',\n", " # should contain as many netcdf as elements contained in the sdates array: \n", " # tasmax_19991101.nc, tasmax_20001101.nc,..., tasmax_20141101.nc, tasmax_20151101.nc\n", - " exp_path <- '/esarchive/exp/ecmwf/system5c3s/monthly_mean/$var$_f24h/$var$_$sdate$01.nc'\n", - " obs_path <- '/esarchive/recon/ecmwf/era5/monthly_mean/$var$_f24h/$var$_$date$.nc'\n", + " exp_path <- paste0(getwd(),'/../',\n", + " '/esarchive/exp/ecmwf/system5c3s/monthly_mean/$var$_f24h/$var$_$sdate$01.nc')\n", + " obs_path <- paste0(getwd(),'/../',\n", + " '/esarchive/recon/ecmwf/era5/monthly_mean/$var$_f24h-r1440x721cds/$var$_$date$.nc')\n", + " \n", + " # Specify one file of the hindcast (System5). The grid of the reanalysis (ERA5)\n", + " # will be converted to the hindcast's grid to allow the calibration,\n", + " # as both datasets must have the same number and structure of grid points.\n", + " grid <- paste0(getwd(),'/../','/esarchive/exp/ecmwf/system5c3s/reference_seas5.nc')\n", " \n", " \n", "}else{\n", @@ -313,7 +303,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 12, "metadata": {}, "outputs": [ { @@ -341,15 +331,18 @@ "Warning message in (function (data_array, variables, file_selectors = NULL, crop_domain = NULL, :\n", "“Argument 'crop' in 'transform_params' for CDORemapper() is deprecated. It is automatically assigned as the selected domain in Start() call.”\n", "Warning message in (function (data_array = NULL, lons, lats, grid, method, avoid_writes = TRUE, :\n", - "“CDORemap: Using CDO version 1.6.3.”\n", + "“CDORemap: Using CDO version 1.9.8.”\n", + "Warning message:\n", + "“! Warning: Adding parameter transform_extra_cells = 8 to the transformed index\n", + "! excesses the border. The border index is used for transformation.”\n", "Warning message in (function (data_array, variables, file_selectors = NULL, crop_domain = NULL, :\n", "“Argument 'crop' in 'transform_params' for CDORemapper() is deprecated. It is automatically assigned as the selected domain in Start() call.”\n", "Warning message in (function (data_array = NULL, lons, lats, grid, method, avoid_writes = TRUE, :\n", - "“CDORemap: Using CDO version 1.6.3.”\n", + "“CDORemap: Using CDO version 1.9.8.”\n", "Warning message in (function (data_array, variables, file_selectors = NULL, crop_domain = NULL, :\n", "“Argument 'crop' in 'transform_params' for CDORemapper() is deprecated. It is automatically assigned as the selected domain in Start() call.”\n", "Warning message in (function (data_array = NULL, lons, lats, grid, method, avoid_writes = TRUE, :\n", - "“CDORemap: Using CDO version 1.6.3.”\n", + "“CDORemap: Using CDO version 1.9.8.”\n", "* Detected dimension sizes:\n", "\n", "* dat: 1\n", @@ -393,15 +386,18 @@ "Warning message in (function (data_array, variables, file_selectors = NULL, crop_domain = NULL, :\n", "“Argument 'crop' in 'transform_params' for CDORemapper() is deprecated. It is automatically assigned as the selected domain in Start() call.”\n", "Warning message in (function (data_array = NULL, lons, lats, grid, method, avoid_writes = TRUE, :\n", - "“CDORemap: Using CDO version 1.6.3.”\n", + "“CDORemap: Using CDO version 1.9.8.”\n", + "Warning message:\n", + "“! Warning: Adding parameter transform_extra_cells = 8 to the transformed index\n", + "! excesses the border. The border index is used for transformation.”\n", "Warning message in (function (data_array, variables, file_selectors = NULL, crop_domain = NULL, :\n", "“Argument 'crop' in 'transform_params' for CDORemapper() is deprecated. It is automatically assigned as the selected domain in Start() call.”\n", "Warning message in (function (data_array = NULL, lons, lats, grid, method, avoid_writes = TRUE, :\n", - "“CDORemap: Using CDO version 1.6.3.”\n", + "“CDORemap: Using CDO version 1.9.8.”\n", "Warning message in (function (data_array, variables, file_selectors = NULL, crop_domain = NULL, :\n", "“Argument 'crop' in 'transform_params' for CDORemapper() is deprecated. It is automatically assigned as the selected domain in Start() call.”\n", "Warning message in (function (data_array = NULL, lons, lats, grid, method, avoid_writes = TRUE, :\n", - "“CDORemap: Using CDO version 1.6.3.”\n", + "“CDORemap: Using CDO version 1.9.8.”\n", "* Detected dimension sizes:\n", "\n", "* dat: 1\n", @@ -435,12 +431,6 @@ "# Array containing the calibration methods\n", "methods <- c('raw','bias','evmos','mse_min','crps_min','rpc-based')\n", "\n", - "\n", - "# Specify one file of the hindcast (System5). The grid of the reanalysis (ERA5)\n", - "# will be converted to the hindcast's grid to allow the calibration,\n", - "# as both datasets must have the same number and structure of grid points.\n", - "grid <- '/esarchive/exp/ecmwf/system5c3s/monthly_mean/prlr_s0-24h/prlr_20000501.nc'\n", - "\n", "# Load the forecast\n", "exp <- startR::Start(\n", " # Select the path of the forecast\n", @@ -459,7 +449,7 @@ " # Reorder longitude points from [0,360] to [-180, 180]\n", " longitude_reorder = CircularSort(-180,180),\n", " transform = CDORemapper,\n", - "\t\t transform_extra_cells = 8,\n", + " transform_extra_cells = 8,\n", " transform_params = list(grid = grid,\n", " method = 'conservative',\n", " crop = c(lons.min, lons.max, lats.min, lats.max)),\n", @@ -481,7 +471,6 @@ "dim(dates_file) <- list(sdate = length(sdate_forecast),\n", " time = length(time_forecast))\n", "\n", - "\n", "obs <- Start(# load observational (reanalysis) data\n", " dat = obs_path,\n", " # Variable of interest\n", diff --git a/binder/apt.txt b/binder/apt.txt new file mode 100644 index 0000000000000000000000000000000000000000..5e0cd85c0741d25bbe7154eb12d1f60d01a0fd70 --- /dev/null +++ b/binder/apt.txt @@ -0,0 +1,3 @@ + +libnetcdf-* + diff --git a/binder/environment.yml b/binder/environment.yml index d16b8e6e6f2facfc1535844da9fa51acb8ae5365..a70aca87aeb22a9a597eae65bc57b61d47b543b7 100644 --- a/binder/environment.yml +++ b/binder/environment.yml @@ -2,5 +2,3 @@ channels: - conda-forge dependencies: - cdo==1.9.8 - - netcdf4=1 - - hdf5>=1.10.6 diff --git a/binder/postBuild b/binder/postBuild new file mode 100644 index 0000000000000000000000000000000000000000..7af1f3aceb1a6423b227ca723dac8e1d67016e0b --- /dev/null +++ b/binder/postBuild @@ -0,0 +1,10 @@ +#!/bin/bash + +# Downloads ERA5 reanalysis +wget -r -nH --no-parent --cut-dirs=1 ftp://bscesftp.bsc.es/FOCUS/esarchive/recon/ecmwf/era5/monthly_mean/tasmax_f24h-r1440x721cds/tasmax_* + +# Downloads SEAS5 forecast files +wget -r -nH --no-parent --cut-dirs=1 ftp://bscesftp.bsc.es/FOCUS/esarchive/exp/ecmwf/system5c3s/monthly_mean/tasmax_f24h/tasmax_* + +# Downloads reference .nc for re-gridding +wget -r -nH --no-parent --cut-dirs=1 ftp://bscesftp.bsc.es/FOCUS/esarchive/exp/ecmwf/system5c3s/*.nc diff --git a/binder/runtime.txt b/binder/runtime.txt index b958f9d92ddd201050c121bfff8c93c29bf83808..edae250f463e648238255bbcd16c8e0aedd2f09b 100644 --- a/binder/runtime.txt +++ b/binder/runtime.txt @@ -1 +1,2 @@ + r-3.6.1-2022-02-23