From 9b63cdee057437bdb82c100b4d3ed3812aa0666a Mon Sep 17 00:00:00 2001 From: obellpra Date: Fri, 20 Nov 2015 13:30:08 +0100 Subject: [PATCH 01/12] Add old conf file --- inst/config/BSC.conf.old | 370 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 370 insertions(+) create mode 100644 inst/config/BSC.conf.old diff --git a/inst/config/BSC.conf.old b/inst/config/BSC.conf.old new file mode 100644 index 00000000..661b9e91 --- /dev/null +++ b/inst/config/BSC.conf.old @@ -0,0 +1,370 @@ +# s2dverification configuration file +# +# Check ?ConfigFileOpen after loading s2dverification for detailed +# documentation on this configuration file. + +######################### +!!2-dimensional variables +######################### +tas +prlr +tos +g500 +g200 +ta50 +psl +hflsd +hfssd +rls +rss +rsds +uas +vas +vpot +sic +tasmin +tasmax +tas_mean +prlr_mean +tas_q90 +prlr_q90 +tas_ndaysq90 +prlr_ndaysq90 +tasmax_q90 +tasmin_q10 +prlr_q90 +prlr_q10 +tasmax_nbdaysq90_.* +tasmin_nbdaysq10_.* +prlr_nbdaysq90_.* +prlr_nbdaysq10_.* +tos_error + +####################### +!!global mean variables +####################### +siaN +sieN +sivN +siaS +sieS +sivS +sia_.* +sie_.* +siv_.* +moc_40N55N_1-2km +moc_30N40N_1-2km +max_moc_38N50N_500m-2km +max_moc_40N +NAtl_stc_0N25N_0-200m +SAtl_stc_25S0S_0-200m +SPac_stc_25S0S_0-200m +NPac_stc_0N25N_0-200m +heatc +.*_heatc +tas_mean +tos_mean + +############################################ +!!file per startdate experiments definitions +############################################ +DEFAULT_EXP_MAIN_PATH = /esnas/exp/*/$EXP_NAME$ +DEFAULT_EXP_FILE_PATH = $STORE_FREQ$_mean/$VAR_NAME$_[36]hourly/$EXP_FILE$ +DEFAULT_GRID = t106grid +DEFAULT_NC_VAR_NAME = $VAR_NAME$ +DEFAULT_SUFFIX = +DEFAULT_VAR_MIN = -1e19 +DEFAULT_VAR_MAX = 1e19 +DEFAULT_DIM_NAME_LONGITUDES = longitude +DEFAULT_DIM_NAME_LATITUDES = latitude +DEFAULT_DIM_NAME_MEMBERS = ensemble +DEFAULT_OBS_MAIN_PATH = /esnas/obs/*/$OBS_NAME$ +DEFAULT_OBS_FILE_PATH = $STORE_FREQ$_mean/$VAR_NAME$/$OBS_FILE$ +EXP_FILE = $VAR_NAME$_$START_DATE$.nc +LONG_EXP_FILE = $VAR_NAME$_$EXP_NAME$_$START_DATE$*.nc +EXP_FULL_PATH = $EXP_MAIN_PATH$/$EXP_FILE_PATH$ +ROOTA = /esnas/exp/ENSEMBLES/decadal/MME +ROOTB = /esnas/exp/ENSEMBLES +ROOTC = /esnas/exp/CMIP5/decadal +ROOTD = /esnas/exp/CMIP5/historical +ROOTE = /esnas/exp/ECMWF/seasonal +ROOTF = /esnas/exp/SPECS/decadal +OBS_FILE = $VAR_NAME$_$YEAR$$MONTH$.nc +OBS_FULL_PATH = $OBS_MAIN_PATH$/$OBS_FILE_PATH$ +ROOTG = /esnas/obs +ROOTH = /cfu/diagnostics/postprocessed + +######################################### +!!table of file per startdate experiments +######################################### +#exp_name, var_name[, exp_main_path[, exp_file_path[, grid[, nc_var_name[, suffix[, var_min[, var_max]]]]]]] +.*, .*, *, *, *, *, *, *, * +ECMWF_S4_sea, .*, $ROOTE$/0001/s004/m001, *, t170grid, *, *, *, * +ECMWF_S4_ann, .*, $ROOTE$/0001/s004/m003, *, t170grid, *, *, *, * +EnsEcmwfDec, .*, $ROOTA$/ecmwf/2005/s001/m001, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, r144x73, *, *, *, * +EnsCerfacsDec, .*, $ROOTA$/cerfacs/2002/s000/m001, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, r144x73, *, *, *, * +EnsIfmDec, .*, $ROOTA$/ifm/2002/s001/m010, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, r144x73, *, *, *, * +EnsUkmoDec, .*, $ROOTA$/ukmo/2026/s001/m001, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, r144x73, *, *, *, * +EnsEcmwfSeas, .*, $ROOTB$/seasonal/ecmwf, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, r144x73, *, *, *, * +EnsCerfacsSeas, .*, $ROOTB$/seasonal/cerfacs, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, r144x73, *, *, *, * +EnsIfmSeas, .*, $ROOTB$/seasonal/ifm, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, r144x73, *, *, *, * +EnsUkmoSeas, .*, $ROOTB$/seasonal/ukmo, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, r144x73, *, *, *, * +EnsCmccSeas, .*, $ROOTB$/seasonal/cmcc, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, r144x73, *, *, *, * +EnsMetfrSeas, .*, $ROOTB$/seasonal/metfr, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, r144x73, *, *, *, * +ecmwf, .*, $ROOTB$/ecmwf/2005/s001/m001, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, r144x73, *, *, *, * +cerfacs, .*, $ROOTA$/cerfacs/2002/s000/m001, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, r144x73, *, *, *, * +ifm, .*, $ROOTA$/ifm/2002/s001/m010, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, r144x73, *, *, *, * +ukmo, .*, $ROOTA$/ukmo/2026/s001/m001, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, r144x73, *, *, *, * +ECMWF_S3Seas, .*, $ROOTE$/0001/s003/m001, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +bccdec, .*, $ROOTC$/bcc/i1p1, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, t42grid, *, *, *, * +hadcm3dec, .*, $ROOTC$/hadcm3/i2p1, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, r96x73, *, *, *, * +hadcm3dec2, .*, $ROOTC$/hadcm3/i3p1, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, r96x73, *, *, *, * +miroc4dec, .*, $ROOTC$/miroc4h/i1p1, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, r360x180, *, *, *, * +miroc5dec, .*, $ROOTC$/miroc5/i1p1, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, t85grid, *, *, *, * +mri-cgcm3dec, .*, $ROOTC$/mri-cgcm3/i1p1, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +cnrm-cm5dec, .*, $ROOTC$/cnrm-cm5/i1p1, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, t85grid, *, *, *, * +cancm4dec1, .*, $ROOTC$/cancm4/i1p1, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, t42grid, *, *, *, * +cancm4dec2, .*, $ROOTC$/cancm4/i1p2, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, t42grid, *, *, *, * +knmidec, .*, $ROOTC$/ecearth/i1p1, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, r320x161, *, *, *, * +smhidec, .*, $ROOTC$/ecearth/i3p1, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +mpimdec, .*, $ROOTC$/mpi-esm-lr/i1p1, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, t63grid, *, *, *, * +mpimdec2, .*, $ROOTF$/mpi-esm-lr/i1p1, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, t63grid, *, *, *, * +gfdldec, .*, $ROOTC$/gfdl/i1p1, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, r144x90, *, *, *, * +cmcc-cmdec, .*, $ROOTC$/cmcc-cm/i1p1, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, t159grid, *, *, *, * +ipsldec, .*, $ROOTC$/ipsl/i1p1, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, r96x96, *, *, *, * +ipsldec2, .*, $ROOTF$/ipsl/i1p1, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, r96x96, *, *, *, * +bcchis, .*, $ROOTD$/bcc/i0p1, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, t42grid, *, *, *, * +hadcm3his, .*, $ROOTD$/hadcm3/i0p1, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, r96x73, *, *, *, * +miroc4his, .*, $ROOTD$/miroc4h/i0p1, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, r360x180, *, *, *, * +miroc5his, .*, $ROOTD$/miroc5/i0p1, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, t85grid, *, *, *, * +mri-cgcm3his, .*, $ROOTD$/mri-cgcm3/i0p1, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +cnrm-cm5his, .*, $ROOTD$/cnrm-cm5/i0p1, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, t85grid, *, *, *, * +knmihis, .*, $ROOTD$/ecearth/iXpY, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +cancm4his, .*, $ROOTD$/cancm4/i0p1, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, t42grid, *, *, *, * +mpihis, .*, $ROOTD$/mpi-esm-lr/i0p1, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, t63grid, *, *, *, * +gfdlhis, .*, $ROOTD$/gfdl/i0p1, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, r144x90, *, *, *, * +ipslhis, .*, $ROOTD$/ipsl/i1p1, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, r96x96, *, *, *, * +cmcc-cmhis, .*, $ROOTD$/cmcc-cm/i0p1, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, t159grid, *, *, *, * +CMC1-CanCM3, .*, /esnas/exp/NMME/$EXP_NAME$, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, r360x180, *, *, *, * +CMC2-CanCM4, .*, /esnas/exp/NMME/$EXP_NAME$, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, r360x180, *, *, *, * +COLA-RSMAS-CCSM4, .*, /esnas/exp/NMME/$EXP_NAME$, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, r360x180, *, *, *, * +GFDL-CM2p1, .*, /esnas/exp/NMME/$EXP_NAME$, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, r360x180, *, *, *, * +GFDL-CM2p1-aer04, .*, /esnas/exp/NMME/$EXP_NAME$, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, r360x180, *, *, *, * +GFDL-CM2p5-FLOR-A06, .*, /esnas/exp/NMME/$EXP_NAME$, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, r360x180, *, *, *, * +GFDL-CM2p5-FLOR-B01, .*, /esnas/exp/NMME/$EXP_NAME$, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, r360x180, *, *, *, * +IRI-ECHAM4p5-AnomalyCoupled, .*, /esnas/exp/NMME/$EXP_NAME$, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, r360x180, *, *, *, * +IRI-ECHAM4p5-DirectCoupled, .*, /esnas/exp/NMME/$EXP_NAME$, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, r360x180, *, *, *, * +NASA-GMAO, .*, /esnas/exp/NMME/$EXP_NAME$, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, r360x180, *, *, *, * +NASA-GMAO-062012, .*, /esnas/exp/NMME/$EXP_NAME$, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, r360x180, *, *, *, * +eucleia_h, .*, /esnas/exp/MetOffice/EUCLEIA_historical, $STORE_FREQ$_mean/$VAR_NAME$*/$EXP_FILE$, r432x324, *, *, *, * +eucleia_n, .*, /esnas/exp/MetOffice/EUCLEIA_natural, $STORE_FREQ$_mean/$VAR_NAME$*/$EXP_FILE$, r432x324, *, *, *, * + +.*, tas_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$_[36]hourly/$EXP_FILE$, *, *, *, *, * +.*, prlr_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$_[36]hourly/$EXP_FILE$, *, *, *, *, * +.*, tasmin_q10, *, $STORE_FREQ$_statistics/$VAR_NAME$_[36]hourly/$EXP_FILE$, *, *, *, *, * +.*, tasmax_q90, *, $STORE_FREQ$_statistics/$VAR_NAME$_[36]hourly/$EXP_FILE$, *, *, *, *, * +.*, siaN, *, $STORE_FREQ$_mean/ice/siasiesiv_N_$EXP_NAME$_$START_DATE$*.nc, *, sia, *, *, * +.*, sieN, *, $STORE_FREQ$_mean/ice/siasiesiv_N_$EXP_NAME$_$START_DATE$*.nc, *, sie, *, *, * +.*, sivN, *, $STORE_FREQ$_mean/ice/siasiesiv_N_$EXP_NAME$_$START_DATE$*.nc, *, siv, *, *, * +.*, siaS, *, $STORE_FREQ$_mean/ice/siasiesiv_S_$EXP_NAME$_$START_DATE$*.nc, *, sia, *, *, * +.*, sieS, *, $STORE_FREQ$_mean/ice/siasiesiv_S_$EXP_NAME$_$START_DATE$*.nc, *, sie, *, *, * +.*, sivS, *, $STORE_FREQ$_mean/ice/siasiesiv_S_$EXP_NAME$_$START_DATE$*.nc, *, siv, *, *, * +.*, sia_.*, *, $STORE_FREQ$_mean/ice/sia_Arcticreg1_$EXP_NAME$_$START_DATE$*.nc, *, *, *, *, * +.*, sie_.*, *, $STORE_FREQ$_mean/ice/sie_Arcticreg1_$EXP_NAME$_$START_DATE$*.nc, *, *, *, *, * +.*, siv_.*, *, $STORE_FREQ$_mean/ice/siv_Arcticreg1_$EXP_NAME$_$START_DATE$*.nc, *, *, *, *, * +.*, moc_40N55N_1-2km, *, $STORE_FREQ$_mean/moc/$LONG_EXP_FILE$, *, zomsfatl, *, *, * +.*, moc_30N40N_1-2km, *, $STORE_FREQ$_mean/moc/$LONG_EXP_FILE$, *, zomsfatl, *, *, * +.*, max_moc_38N50N_500m-2km, *, $STORE_FREQ$_mean/moc/$LONG_EXP_FILE$, *, maxmoc, *, *, * +.*, max_moc_40N, *, $STORE_FREQ$_mean/moc/$LONG_EXP_FILE$, *, maxmoc, *, *, * +.*, .*Pac_stc_.*, *, $STORE_FREQ$_mean/moc/$LONG_EXP_FILE$, *, zomsfpac, *, *, * +.*, .*Atl_stc_.*, *, $STORE_FREQ$_mean/moc/$LONG_EXP_FILE$, *, zomsfatl, *, *, * +.*, heatc, *, $STORE_FREQ$_mean/heatc/$LONG_EXP_FILE$, *, thc, *, *, * +.*, .*_heatc, *, $STORE_FREQ$_mean/heatc/$LONG_EXP_FILE$, *, thc, *, *, * +.*, ta50, *, *, t159grid, *, *, *, * +EnsEcmwfDec, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +EnsCerfacsDec, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +EnsIfmDec, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +EnsUkmoDec, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +EnsEcmwfSeas, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +EnsCerfacsSeas, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +EnsIfmSeas, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +EnsUkmoSeas, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +EnsCmccSeas, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +EnsMetfrSeas, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +ecmwf, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +cerfacs, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +ifm, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +ukmo, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +ECMWF_S3Seas, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +bccdec, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +hadcm3dec, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +miroc4dec, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +miroc5dec, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +mri-cgcm3dec, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +cnrm-cm5dec, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +cancm4dec1, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +cancm4dec2, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +knmidec, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +smhidec, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +mpimdec, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +mpimdec2, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +gfdldec, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +cmcc-cmdec, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +ipsldec, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +ipsldec2, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +bcchis, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +hadcm3his, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +miroc4his, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +miroc5his, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +mri-cgcm3his, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +cnrm-cm5his, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +knmihis, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +cancm4his, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +mpihis, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +gfdlhis, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +ipslhis, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +cmc-cmhis, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +ECMWF_S3Seas, tos, *, $STORE_FREQ$_mean/$VAR_NAME$_24hourly/$EXP_FILE$, *, *, *, *, * +ECMWF_S4_sea, tos, *, $STORE_FREQ$_mean/$VAR_NAME$_24hourly/$EXP_FILE$, *, *, *, *, * +ECMWF_S4_ann, tos, *, $STORE_FREQ$_mean/$VAR_NAME$_24hourly/$EXP_FILE$, *, *, *, *, * +ECMWF_S3Seas, tas, *, $STORE_FREQ$_mean/$VAR_NAME$_6hourly/$EXP_FILE$, *, *, *, *, * +ECMWF_S4_ann, prlr, *, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, *, *, *, *, * +hadcm3(dec|his), tos, *, *, r288x144, *, *, *, * +mri-cgcm3(dec|his), tos, *, *, r240x188, *, *, *, * +gfdl(dec|his), tos, *, *, r144x90, *, *, *, * +hadcm3(dec|his), (tas|prlr|psl), *, *, r96x73, *, *, *, * +mri-cgcm3(dec|his), (tas|prlr|psl), *, *, t106grid, *, *, *, * +cancm4(dec(1|2)|his), (tas|prlr|psl), *, *, t42grid, *, *, *, * +gfdl(dec|his), (tas|prlr|psl), *, *, r144x90, *, *, *, * +cmcc-cmdec, (tas|prlr|psl), *, *, t159grid, *, *, *, * + +######################################### +!!file per member experiments definitions +######################################### + +###################################### +!!table of file per member experiments +###################################### +#exp_name, var_name[, exp_main_path[, exp_file_path[, grid[, nc_var_name[, suffix[, var_min[, var_max]]]]]]] +DePreSysAsimDec, .*, $ROOTB$/decadal/DePreSys/2502/s051/m01$MEMBER_NUMBER$, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, r96x73, *, *, *, * +DePreSysNoAsimDec, .*, $ROOTB$/decadal/DePreSys/2501/s051/m01$MEMBER_NUMBER$, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, r96x73, *, *, *, * +DePreSysAsimSeas, .*, $ROOTB$/seasonal/DePreSys/2502/s051/m01$MEMBER_NUMBER$, $STORE_FREQ$_mean/$VAR_NAME$/$EXP_FILE$, r144x73, *, *, *, * +DePreSys.*, (u|v)as, *, $STORE_FREQ$_mean/$VAR_NAME$_rg/$EXP_FILE$, *, *, *, *, * +DePreSys.*Dec, hf(s|l)sd, *, *, r144x73, *, *, *, * + +######################################### +!!file per month observations definitions +######################################### + +###################################### +!!table of file per month observations +###################################### +#obs_name, var_name[, obs_main_path[, obs_file_path[, nc_var_name[, suffix[, var_min[, var_max]]]]]] +.*, .*, *, *, *, *, *, * +JRA, .*, $ROOTG$/jma/jra-55, *, *, *, *, * +GHCN, .*, $ROOTG$/noaa/ghcn_v2, *, *, *, *, * +GHCNERSSTGISS, .*, $ROOTG$/noaanasa/ghcnersstgiss, *, *, *, *, * +ERSST, .*, $ROOTG$/noaa/ersstv3b, *, *, *, *, * +ERSST4, .*, $ROOTG$/noaa/ersstv4, $STORE_FREQ$_mean/$VAR_NAME$/$VAR_NAME$_$YEAR$$MONTH$01.nc, *, *, *, * +UKMO, .*, $ROOTG$/ukmo/hadisstv1.1, *, *, *, *, * +HadISST, .*, $ROOTG$/ukmo/hadisstv1.1, *, *, *, *, * +HadSLP, .*, $ROOTG$/ukmo/hadslp2, *, *, *, *, * +GPCC, .*, $ROOTG$/dwd/gpcc_combined1x1_v6, *, *, *, *, * +GPCP, .*, $ROOTG$/noaa/gpcp_v2.2, *, *, *, *, * +DS94, .*, $ROOTG$/iri/DaSilva, *, *, *, *, * +OAFlux, .*, $ROOTG$/whoi/oaflux, *, *, *, *, * +DFS4.3, .*, $ROOTG$/legi/dfs4.3, *, *, *, *, * +NCDCoc, .*, $ROOTG$/noaa/merged_ocean_mean, *, *, *, *, * +NCDCland, .*, $ROOTG$/noaa/merged_land_mean, *, *, *, *, * +NCDCglo, .*, $ROOTG$/noaa/merged_global_mean, *, *, *, *, * +NCEP, .*, $ROOTG$/ncep, $STORE_FREQ$_mean/$VAR_NAME$_6hourly/$VAR_NAME$_ncep_$YEAR$$MONTH$.nc, *, *, *, * +ERA40, .*, $ROOTG$/ecmwf/era40, $STORE_FREQ$_mean/$VAR_NAME$_f6h/$OBS_FILE$, *, *, *, * +ERAint, .*, $ROOTG$/ecmwf/eraint, $STORE_FREQ$_mean/$VAR_NAME$_f6h/$OBS_FILE$, *, *, *, * +20thCv2, .*, $ROOTG$/noaa/20thc_reanv2, $STORE_FREQ$_mean/$VAR_NAME$_f6h/$OBS_FILE$, *, *, *, * +CRU, .*, $ROOTG$/cru, $STORE_FREQ$_mean/$VAR_NAME$/$VAR_NAME$_cru_$YEAR$$MONTH$.nc, *, *, *, * +EOBS, .*, $ROOTG$/eobs/eobs_v10, $STORE_FREQ$_mean/$VAR_NAME$/$VAR_NAME$_$YEAR$$MONTH$.nc, *, *, *, * +GISSglo, .*, $ROOTG$/nasa/global_mean, $VAR_NAME$_GISS_$YEAR$$MONTH$.nc, *, *, *, * +GISSland, .*, $ROOTG$/nasa/land_mean, $VAR_NAME$_GISS_$YEAR$$MONTH$.nc, *, *, *, * +GISSoc, .*, $ROOTG$/nasa/ocean_mean, $VAR_NAME$_GISS_$YEAR$$MONTH$.nc, *, *, *, * +CRUTEM3land, .*, $ROOTG$/ukmo/land_mean, $VAR_NAME$_CRUTEM3_$YEAR$$MONTH$.nc, *, *, *, * +HadSST2oc, .*, $ROOTG$/ukmo/ocean_mean, $VAR_NAME$_HadSST2_$YEAR$$MONTH$.nc, *, *, *, * +HadCRUT3glo, .*, $ROOTG$/ukmo/global_mean, $VAR_NAME$_HadCRUT3_$YEAR$$MONTH$.nc, *, *, *, * +HadCRUT4, .*, $ROOTG$/ukmo/hadcrut4, $STORE_FREQ$_mean/$VAR_NAME$_anom/$VAR_NAME$_$YEAR$$MONTH$.nc, *, *, *, * +ESA, .*, $ROOTG$/esa, $STORE_FREQ$_mean/$VAR_NAME$/$VAR_NAME$_$YEAR$$MONTH$.nc, *, *, *, * +PATHFINDER, .*, $ROOTG$/pathfinder, $STORE_FREQ$_mean/$VAR_NAME$/$VAR_NAME$_$YEAR$$MONTH$01.nc, *, *, *, * +NSIDC, .*, $ROOTG$/nsidc, $STORE_FREQ$_mean/$VAR_NAME$/$VAR_NAME$_$YEAR$$MONTH$.nc, *, *, *, * +.*, tas_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$OBS_FILE$, *, *, *, * +.*, prlr_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$OBS_FILE$, *, *, *, * +.*, tasmin_q10, *, $STORE_FREQ$_statistics/$VAR_NAME$/$OBS_FILE$, *, *, *, * +.*, tasmax_q90, *, $STORE_FREQ$_statistics/$VAR_NAME$/$OBS_FILE$, *, *, *, * +.*, (tos|tas|prlr), *, *, *, *, -999, 599 +GHCN, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$OBS_FILE$, *, *, *, * +GHCNERSSTGISS, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$OBS_FILE$, *, *, *, * +ERSST, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$OBS_FILE$, tos, *, *, * +UKMO, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$OBS_FILE$, tos, *, *, * +HadISST, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$OBS_FILE$, tos, *, *, * +HadSLP, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$OBS_FILE$, *, *, *, * +GPCC, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$OBS_FILE$, *, *, *, * +GPCP, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$OBS_FILE$, *, *, *, * +DS94, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$OBS_FILE$, *, *, *, * +OAFlux, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$OBS_FILE$, *, *, *, * +DFS4.3, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$OBS_FILE$, *, *, *, * +NCDCoc, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$OBS_FILE$, *, *, *, * +NCDCland, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$OBS_FILE$, *, *, *, * +NCDCglo, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$OBS_FILE$, *, *, *, * +NCEP, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$_6hourly/$VAR_NAME$_ncep_$YEAR$$MONTH$.nc, *, *, *, * +ERA40, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$_f6h/$OBS_FILE$, *, *, *, * +ERAint, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$_f6h/$OBS_FILE$, *, *, *, * +20thCv2, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$_f6h/$OBS_FILE$, *, *, *, * +CRU, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$VAR_NAME$_cru_$YEAR$$MONTH$.nc, *, *, *, * +EOBS, (tas|prlr).*_.*, *, $VAR_NAME$_eobs_0.5x0.5/$VAR_NAME$_eobs_$YEAR$$MONTH$.nc, *, *, *, * +GISSglo, (tas|prlr).*_.*, *, $VAR_NAME$_GISS_$YEAR$$MONTH$.nc, *, *, *, * +GISSland, (tas|prlr).*_.*, *, $VAR_NAME$_GISS_$YEAR$$MONTH$.nc, *, *, *, * +GISSoc, (tas|prlr).*_.*, *, $VAR_NAME$_GISS_$YEAR$$MONTH$.nc, *, *, *, * +CRUTEM3land, (tas|prlr).*_.*, *, $VAR_NAME$_CRUTEM3_$YEAR$$MONTH$.nc, *, *, *, * +HadSST2oc, (tas|prlr).*_.*, *, $VAR_NAME$_HadSST2_$YEAR$$MONTH$.nc, *, *, *, * +HadCRUT3glo, (tas|prlr).*_.*, *, $VAR_NAME$_HadCRUT3_$YEAR$$MONTH$.nc, *, *, *, * +HadCRUT4, (tas|prlr).*_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$_anom/$VAR_NAME$_$YEAR$$MONTH$.nc, *, *, *, * +NCEP, (hf(l|s)sd|r(l|s)s|rsds), *, $STORE_FREQ$_mean/$VAR_NAME$_step6h/$VAR_NAME$_ncep_$YEAR$$MONTH$.nc, *, *, *, * +ERAint, (hf(l|s)sd|r(l|s)s|rsds|prlr), *, $STORE_FREQ$_mean/$VAR_NAME$_s0-12h/$OBS_FILE$, *, *, *, * +20thCv2, (hf(l|s)sd|r(l|s)s|rsds|prlr), *, $STORE_FREQ$_mean/$VAR_NAME$_s0-12h/$OBS_FILE$, *, *, *, * +ERAint, (tasm(in|ax)|prlr_.*q(1|9)0)_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$OBS_FILE$, *, *, *, * +20thCv2, (tasm(in|ax)|prlr_.*q(1|9)0)_.*, *, $STORE_FREQ$_statistics/$VAR_NAME$/$OBS_FILE$, *, *, *, * + +########################################## +!!file per member observations definitions +########################################## + +####################################### +!!table of file per member observations +####################################### +#obs_name, var_name[, obs_main_path[, obs_file_path[, nc_var_name[, suffix[, var_min[, var_max]]]]]] + +########################################### +!!file per dataset observations definitions +########################################### + +######################################## +!!table of file per dataset observations +######################################## +#obs_name, var_name[, obs_main_path[, obs_file_path[, nc_var_name[, suffix[, var_min[, var_max]]]]]] +.*, moc_.*, /esnas/exp/ECMWF/NEMOVAR_S4, $STORE_FREQ$_mean/moc/$VAR_NAME$_nemovar_s4_19570901_fc0-4_195709_201212.nc, zomsfatl, *, *, * +.*, max_moc_.*, /esnas/exp/ECMWF/NEMOVAR_S4, $STORE_FREQ$_mean/moc/$VAR_NAME$_nemovar_s4_19570901_fc0-4_195709_201212.nc, maxmoc, *, *, * +.*, .*Pac_stc_.*, /esnas/exp/ECMWF/NEMOVAR_S4, $STORE_FREQ$_mean/moc/$VAR_NAME$_nemovar_s4_19570901_fc0-4_195709_201212.nc, zomsfpac, *, *, * +.*, .*Atl_stc_.*, /esnas/exp/ECMWF/NEMOVAR_S4, $STORE_FREQ$_mean/moc/$VAR_NAME$_nemovar_s4_19570901_fc0-4_195709_201212.nc, zomsfatl, *, *, * +.*, heatc, /esnas/exp/ECMWF/NEMOVAR_S4, $STORE_FREQ$_mean/heatc/$VAR_NAME$_nemovar_s4_19570901_fc0-4_195709_201212.nc, thc, *, *, * +.*, .*_heatc, /esnas/exp/ECMWF/NEMOVAR_S4, $STORE_FREQ$_mean/heatc/$VAR_NAME$_nemovar_s4_19570901_fc0-4_195709_201212.nc, thc, *, *, * +PIOMAS, sivN, $ROOTG$/psc/piomas/original_files, $VAR_NAME$_piomas.nc, sivN, *, *, * +PIOMAS, sivS, $ROOTG$/psc/piomas/original_files, $VAR_NAME$_piomas.nc, sivS, *, *, * +UCL, sivN, /esnas/exp/UCL, monthly_mean/ice/siasiesiv_N_ucl_fc0-0_19790101_197901_200712.nc, siv, *, *, * +UCL, sivS, /esnas/exp/UCL, monthly_mean/ice/siasiesiv_S_ucl_fc0-0_19790101_197901_200712.nc, siv, *, *, * +HadISST, sieN, /esnas/OLD/cfu/diagnostics/postprocessed/ice/ukmo, ice_hadisst_N.nc, sie, *, *, * +HadISST, siaN, ", ", sia, *, *, * +HadISST, sieS, ", ice_hadisst_S.nc, sie, *, *, * +HadISST, siaS, ", ", sia, *, *, * +NSIDC, sieN, /esnas/OLD/cfu/diagnostics/postprocessed/ice/nsidc,ice_nsidc_N.nc, sie, *, *, * +NSIDC, siaN, ", ", sia, *, *, * +NSIDC, sieS, ", ice_nsidc_S.nc, sie, *, *, * +NSIDC, siaS, ", ", sia, *, *, * +HadISST, si(a|e|v)_.*, /esnas/OLD/cfu/diagnostics/postprocessed/ice/ukmo, siasie_HadISST.nc, *, *, *, * +NSIDC, si(a|e|v)_.*, /esnas/OLD/cfu/diagnostics/postprocessed/ice/nsidc, siasie_NSIDC.nc, *, *, *, * -- GitLab From ee6ba283c185fbb415e91a8939e222f3c9e470bf Mon Sep 17 00:00:00 2001 From: obellpra Date: Tue, 18 Oct 2016 17:28:54 +0200 Subject: [PATCH 02/12] Add function to compute Weissheimer and Palmer (2014) reliability --- R/Reliability.R | 103 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 R/Reliability.R diff --git a/R/Reliability.R b/R/Reliability.R new file mode 100644 index 00000000..1cffbc89 --- /dev/null +++ b/R/Reliability.R @@ -0,0 +1,103 @@ +Reliability <- function(ano_exp, ano_obs,quantile = TRUE,nbins=5,thr = c(2/3),nboot=1000) { + + # Checking ano_exp + if (!is.numeric(ano_exp) || !is.array(ano_exp)) { + stop("Parameter 'ano_exp' must be a numeric array.") + } + + # Checking ano_obs + if (!is.numeric(ano_obs) || !is.array(ano_obs)) { + stop("Parameter 'ano_obs' must be a numeric array.") + } + + # Checking consistency in ano_exp and ano_obs + if (!(length(dim(ano_exp)) == length(dim(ano_obs)))) { + stop("'ano_obs' and 'ano_exp' must have the same number of dimensions.") + } + + # Checking quantile + if (!is.logical(quantile)) { + stop("Parameter 'quantile' must be either TRUE or FALSE.") + } + + # Checking thr + if (!is.numeric(thr)) { + stop("Parameter 'thr' must be a numerical vector.") + } + + if (quantile) { + if (!all(thr <= 1 & thr >= 0)) { + stop("All quantiles specified in parameter 'thr' must fall in the range [0, 1].") + } + } + + if (quantile) { + tau_m <- quantile(ano_exp,probs=thr,na.rm=TRUE) + tau_o <- quantile(ano_obs,probs=thr,na.rm=TRUE) + } else { + tau_m <- thr; tau_o <- thr + } + + ensc <- rowSums(t(ano_exp) > tau_m,na.rm=TRUE) + obsc <- 1*(t(ano_obs) > tau_o) + + exp_probs <- ensc/nmemb + obs_probs <- obsc + + ws_slope <- array(NA,dim=nboot) + + for (i in 1:nboot) { + n <- sample(length(exp_probs),length(exp_probs),replace=TRUE) + probst <- exp_probs[n] + vert <- obs_probs[n] + + # This part of the code is from SpecsVerification + # should we re-formulate this? + # -------------------------------------------------- + # breaks of bins + bn <- seq(0, 1, length.out=nbins+1) + + c(-.Machine$double.eps, rep(0, nbins-1), .Machine$double.eps) + + counts.bins <- hist(probst, breaks=bn, plot=FALSE)$counts + g <- hist(probst[vert==1], breaks=bn, plot=FALSE)$counts + cond.probs <- g / counts.bins + + # In bin average + p.bins <- as.numeric(cut(probst, breaks=bn)) + p.avgs <- sapply(seq(nbins),function(ii) mean(probst[p.bins == ii], na.rm=TRUE)) + # -------------------------------------------------- + + rel.data=data.frame(p.avgs,cond.probs,counts.bins) + + # Fit regression such that it goes through the climatology of obs and ens + rel.data$cond.probs <- rel.data$cond.probs - cprob + rel.data$p.avgs <- rel.data$p.avgs - cprob + + # Reliability using weighted linear regression (Weissheimer and Palmer (2014)) + weiss.rel<-glm(cond.probs ~ 0 + p.avgs ,data=rel.data,weights=counts.bins,na.action="na.exclude") + ws_slope[i] <- summary(weiss.rel)$coefficients[1] + } + + slope.stat<-quantile(ws_slope,probs=c(.25,0.5,.75),na.rm=TRUE) + + # Define reliability classes + + if (slope.stat[1]>0.5 & slope.stat[3]>1){ + ws_cat<-5 + } else if (slope.stat[1]>=0.5 & slope.stat[3]<1){ + ws_cat<-4 + } else if (slope.stat[1]>0){ + ws_cat<-3 + } else if (slope.stat[1]<0 & slope.stat[3]>0){ + ws_cat<-2 + } else if (slope.stat[3]<0){ + ws_cat<-1 + } else { + ws_cat<-6 + } + + ws_rel<-list() + ws_rel$cat<-ws_cat + ws_rel$slope<-slope.stat[2] + return(ws_rel) +} -- GitLab From 665d2c64f13106a5024e11a1a3f85fc3a8c9da1c Mon Sep 17 00:00:00 2001 From: obellpra Date: Tue, 18 Oct 2016 17:53:43 +0200 Subject: [PATCH 03/12] Add manual to Reliability.R --- man/Reliability.Rd | 55 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 man/Reliability.Rd diff --git a/man/Reliability.Rd b/man/Reliability.Rd new file mode 100644 index 00000000..206afafc --- /dev/null +++ b/man/Reliability.Rd @@ -0,0 +1,55 @@ +\name{Reliability} +\alias{Reliability} +\title{ +Forecast reliability as measured by the linear regression +of the reliability diagram +} +\description{ +The function regresses a linear regress through the conditional probabilities +in a reliability diagram. The regression is weighed by the number of +predictions that fall into each probability bin. The linear regression is +addition forced to intercept with the climatological probability. The resulting +reliability is measured as the slope of the regression and a classification of +the slope into 5 reliability catagories. The catagories are defined on the +basis of the uncertainty range of the slope determined by boot strapping. + +This measure of reliability is an alternative to the reliablity component +of the Brier score and has been defined in Weisheimer A and Palmer TN.(2014). +On the reliability of seasonal climate forecasts. +J. R. Soc. Interface 11: 20131162. http://dx.doi.org/10.1098/rsif.2013.1162 +} +\usage{ +Reliability(ano_exp=ano_exp,ano_obs=ano_obs,quantile = TRUE,nbins=5, + thr = c(2/3),nboot=1000) +} +\arguments{ + \item{ano_exp}{ +Matrix of forecast anomalies with dimension of # ensemble members and +# start dates. + } + \item{beta}{ +Vector of observed anomalies with dimension of # start dates. + } + \item{quantile}{ +Logical switch to define whether a quantile should be used a threshold to compute +the reliability + } + \item{nbins}{ +Number of bins used to compute the conditional probabilities + } + \item{thr}{ +Threshold defined as a quantile (if quantile=TRUE) or a physical threshold applied +to both model and observations + } + \item{nboot}{ +Number of resamples drawn from the start dates with replacement + } +} + +\examples{ +} +\author{ +History: +1.0 - 2016-10 (O.Bellprat) - Original code +} +\keyword{reliability} -- GitLab From 877c814daa4b0340359ed9fb4b34abdfdb418819 Mon Sep 17 00:00:00 2001 From: obellpra Date: Wed, 19 Oct 2016 15:34:19 +0200 Subject: [PATCH 04/12] Add Calibrate.R function and man description --- R/Calibrate.R | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ man/Calibrate.Rd | 45 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 R/Calibrate.R create mode 100644 man/Calibrate.Rd diff --git a/R/Calibrate.R b/R/Calibrate.R new file mode 100644 index 00000000..f3e3e6bc --- /dev/null +++ b/R/Calibrate.R @@ -0,0 +1,55 @@ +Calibrate <- function(ano_exp, ano_obs, alpha=NULL, beta=NULL) { + + # Checking ano_exp + if (!is.numeric(ano_exp) || !is.array(ano_exp)) { + stop("Parameter 'ano_exp' must be a numeric array.") + } + + # Checking ano_obs + if (!is.numeric(ano_obs) || !is.array(ano_obs)) { + stop("Parameter 'ano_obs' must be a numeric array.") + } + + # Checking consistency in ano_exp and ano_obs + if (!(length(dim(ano_exp)) == length(dim(ano_obs)))) { + stop("'ano_obs' and 'ano_exp' must have the same number of dimensions.") + } + + m_mod <- Mean1Dim(ano_exp,2) # Ensemble mean of model + m_ver <- Mean1Dim(ano_obs,2) # Ensemble mean of obserations + + # Ensemble inflation of a forecast following Doblas-Reyes et al. (2005) + m_mod_conf <- InsertDim(m_mod,2,dim(ano_exp)[2]) + ediff<-ano_exp-m_mod_conf # Deviation of members from the ensemble mean + + if (is.null(alpha)){ + rho<-s2dverification::Corr(m_mod,m_ver, posloop = 1, poscor = 2) # Ensemble mean correlation + rhot <- rho[,,2,] # Select only central correlation value + sr <- apply(m_ver,FUN=sd,c(1,3)) # Standard deviation of observations + dr <- InsertDim(sr,1,dim(ano_exp)[1]) + sr_conf <- dr[,1,] # Conformed to number of model systems + sem<-apply(m_mod,FUN=sd,c(1,3)) # Standard deviation of ensemble mean + se<-apply(ediff,FUN=sd,c(1,4)) # Standard deviation of the enemble spread + arho<-abs(rhot) # Absolute value of correlation + + # Calibration parameters + alpha<-arho*sr_conf/sem + beta<-sqrt(1-rhot^2)*sr_conf/se + } else { + alpha <- InsertDim(alpha,1,1) + beta <- InsertDim(beta,1,1) + } + + # Conform calibration parameters to experiments + alpha_conf <- InsertDim(InsertDim(alpha,2,dim(ano_exp)[2]),3,dim(ano_exp)[3]) + beta_conf <- InsertDim(InsertDim(beta,2,dim(ano_exp)[2]),3,dim(ano_exp)[3]) + + # Calibration forecasts + mod_cal <- alpha_conf*m_mod_conf+beta_conf*ediff + cal <- list() + cal$mod <- mod_cal + cal$alpha <- as.vector(alpha) + cal$beta <- as.vector(beta) + return(cal) +} + diff --git a/man/Calibrate.Rd b/man/Calibrate.Rd new file mode 100644 index 00000000..190015ec --- /dev/null +++ b/man/Calibrate.Rd @@ -0,0 +1,45 @@ +\name{Reliability} +\alias{Reliability} +\title{ +Ensemble calibration using the ensemble inflation method +described in Doblas-Reyes et al. (2005) +} +\description{ +The function calibrates an ensemble of hindcast following the definitions +of DOBLAS‐REYES, F. J., Hagedorn, R., & Palmer, T. N. (2005). +The rationale behind the success of multi‐model ensembles in seasonal +forecasting–II. Calibration and combination. Tellus A, 57(3), 234-252. + +The calibration requires an forecast ensemble and an observational +reference to which it is calibrated. The functions does currently use +all forecast years (no cross-validation) +} +\usage{ +Reliability(ano_exp=ano_exp,ano_obs=ano_obs,quantile = TRUE,nbins=5, + thr = c(2/3),nboot=1000) +} +\arguments{ + \item{ano_exp}{ +Matrix of forecast anomalies with dimension of # ensemble members and +# start dates. + } + \item{beta}{ +Vector of observed anomalies with dimension of # start dates. + } + \item{alpha}{ +Calibration parameter for the ensemble mean. If not specified determined +from the data (default) + } + \item{beta}{ +Calibration parameter for the ensemble spread. If not specified determined +from the data (default) + } +} + +\examples{ +} +\author{ +History: +1.0 - 2016-10 (O.Bellprat) - Original code +} +\keyword{calibration} -- GitLab From ba6131d4dccb1935681b27b8cc5806b618258969 Mon Sep 17 00:00:00 2001 From: obellpra Date: Wed, 19 Oct 2016 15:36:28 +0200 Subject: [PATCH 05/12] Spelling corrections in Calibrate.Rd --- man/Calibrate.Rd | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/man/Calibrate.Rd b/man/Calibrate.Rd index 190015ec..3e031bd1 100644 --- a/man/Calibrate.Rd +++ b/man/Calibrate.Rd @@ -5,12 +5,12 @@ Ensemble calibration using the ensemble inflation method described in Doblas-Reyes et al. (2005) } \description{ -The function calibrates an ensemble of hindcast following the definitions -of DOBLAS‐REYES, F. J., Hagedorn, R., & Palmer, T. N. (2005). +The function calibrates a forecast ensemble for a hindcast following +the definitions of Dolbas-Reyes, F. J., Hagedorn, R., & Palmer, T. N. (2005). The rationale behind the success of multi‐model ensembles in seasonal forecasting–II. Calibration and combination. Tellus A, 57(3), 234-252. -The calibration requires an forecast ensemble and an observational +The calibration requires a forecast ensemble and an observational reference to which it is calibrated. The functions does currently use all forecast years (no cross-validation) } -- GitLab From f7ff3bcfe83e6948618d50ef7c1db2700c2a9492 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ver=C3=B3nica=20Torralba-Fern=C3=A1ndez?= Date: Fri, 6 Oct 2017 12:02:16 +0200 Subject: [PATCH 06/12] Calibrate has been changed by Calibration --- R/Calibrate.R | 55 -------------------------------------- R/Calibration.R | 71 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 55 deletions(-) delete mode 100644 R/Calibrate.R create mode 100644 R/Calibration.R diff --git a/R/Calibrate.R b/R/Calibrate.R deleted file mode 100644 index f3e3e6bc..00000000 --- a/R/Calibrate.R +++ /dev/null @@ -1,55 +0,0 @@ -Calibrate <- function(ano_exp, ano_obs, alpha=NULL, beta=NULL) { - - # Checking ano_exp - if (!is.numeric(ano_exp) || !is.array(ano_exp)) { - stop("Parameter 'ano_exp' must be a numeric array.") - } - - # Checking ano_obs - if (!is.numeric(ano_obs) || !is.array(ano_obs)) { - stop("Parameter 'ano_obs' must be a numeric array.") - } - - # Checking consistency in ano_exp and ano_obs - if (!(length(dim(ano_exp)) == length(dim(ano_obs)))) { - stop("'ano_obs' and 'ano_exp' must have the same number of dimensions.") - } - - m_mod <- Mean1Dim(ano_exp,2) # Ensemble mean of model - m_ver <- Mean1Dim(ano_obs,2) # Ensemble mean of obserations - - # Ensemble inflation of a forecast following Doblas-Reyes et al. (2005) - m_mod_conf <- InsertDim(m_mod,2,dim(ano_exp)[2]) - ediff<-ano_exp-m_mod_conf # Deviation of members from the ensemble mean - - if (is.null(alpha)){ - rho<-s2dverification::Corr(m_mod,m_ver, posloop = 1, poscor = 2) # Ensemble mean correlation - rhot <- rho[,,2,] # Select only central correlation value - sr <- apply(m_ver,FUN=sd,c(1,3)) # Standard deviation of observations - dr <- InsertDim(sr,1,dim(ano_exp)[1]) - sr_conf <- dr[,1,] # Conformed to number of model systems - sem<-apply(m_mod,FUN=sd,c(1,3)) # Standard deviation of ensemble mean - se<-apply(ediff,FUN=sd,c(1,4)) # Standard deviation of the enemble spread - arho<-abs(rhot) # Absolute value of correlation - - # Calibration parameters - alpha<-arho*sr_conf/sem - beta<-sqrt(1-rhot^2)*sr_conf/se - } else { - alpha <- InsertDim(alpha,1,1) - beta <- InsertDim(beta,1,1) - } - - # Conform calibration parameters to experiments - alpha_conf <- InsertDim(InsertDim(alpha,2,dim(ano_exp)[2]),3,dim(ano_exp)[3]) - beta_conf <- InsertDim(InsertDim(beta,2,dim(ano_exp)[2]),3,dim(ano_exp)[3]) - - # Calibration forecasts - mod_cal <- alpha_conf*m_mod_conf+beta_conf*ediff - cal <- list() - cal$mod <- mod_cal - cal$alpha <- as.vector(alpha) - cal$beta <- as.vector(beta) - return(cal) -} - diff --git a/R/Calibration.R b/R/Calibration.R new file mode 100644 index 00000000..10decb88 --- /dev/null +++ b/R/Calibration.R @@ -0,0 +1,71 @@ +Calibration<-function(var_obs,var_exp,anom=FALSE){ + # Ensemble inflation of a forecast following Doblas-Reyes et al. (2005) + if (!is.vector(var_obs)){ + stop('var_obs should be a vector') + } + + if (length(dim(var_exp))!=2){ + stop('var_exp should be a matrix') + } + + if (length(which(dim(var_exp)==length(var_obs)))==0){ + stop('var_exp should have a dimension (time) with the same length that var_obs') + } + + ntime<-length(var_obs) + nmembers<-dim(var_exp)[-which(dim(var_exp)==length(var_obs))] + + if (!all(dim(var_exp),c(nmembers,ntime))){ + var_exp<-t(var_exp) + } + + if (!anom){ + climObs<-NA*var_obs + climPred<-NA*var_obs + for (t in 1:length(var_obs)) + { + climObs[t]<-mean(var_obs) + climPred[t]<-mean(var_exp[,-t]) + } + var_obs<-var_obs-climObs + for (i in 1:nmembers){ + var_exp[i,]<-var_exp[i,]-climPred + } + } + + calibrated<-NA*var_exp + + for (t in 1:ntime){ + # defining forecast,hindcast and observation in cross-validation + fcst<-var_exp[,t] + hcst<-var_exp[,-t] + obs<-var_obs[-t] + + #coefficients + em_fcst<-mean(fcst) + em_hcst<-apply(hcst,c(2),mean) + corr<-cor(em_hcst,obs) + sd_obs<-sd(obs) + sd_em_hcst<-sd(em_hcst) + + fcst_diff<-fcst-em_fcst + hcst_diff<-NA*hcst + for (n in 1:nmembers){ + hcst_diff[n,]<-hcst[n,]-em_hcst + } + sd_hcst_diff<-sd(hcst_diff) + + a<-corr*(sd_obs/sd_em_hcst) + b<-(sd_obs/sd_hcst_diff)*sqrt(1-(corr^2)) + + # calibrated output + calibrated[,t]<-(a*em_fcst)+(b*fcst_diff) + + if (!anom){ + calibrated[,t]<-calibrated[,t]+climObs[t] + } + } + + return(calibrated) + +} -- GitLab From 4a383d9bad8615eb44e54838f089d16b2823d950 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ver=C3=B3nica=20Torralba-Fern=C3=A1ndez?= Date: Fri, 6 Oct 2017 12:10:17 +0200 Subject: [PATCH 07/12] Changes in the documentation to adapt the new version of the function --- man/Calibrate.Rd | 45 --------------------------------------------- man/Calibration.Rd | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 45 deletions(-) delete mode 100644 man/Calibrate.Rd create mode 100644 man/Calibration.Rd diff --git a/man/Calibrate.Rd b/man/Calibrate.Rd deleted file mode 100644 index 3e031bd1..00000000 --- a/man/Calibrate.Rd +++ /dev/null @@ -1,45 +0,0 @@ -\name{Reliability} -\alias{Reliability} -\title{ -Ensemble calibration using the ensemble inflation method -described in Doblas-Reyes et al. (2005) -} -\description{ -The function calibrates a forecast ensemble for a hindcast following -the definitions of Dolbas-Reyes, F. J., Hagedorn, R., & Palmer, T. N. (2005). -The rationale behind the success of multi‐model ensembles in seasonal -forecasting–II. Calibration and combination. Tellus A, 57(3), 234-252. - -The calibration requires a forecast ensemble and an observational -reference to which it is calibrated. The functions does currently use -all forecast years (no cross-validation) -} -\usage{ -Reliability(ano_exp=ano_exp,ano_obs=ano_obs,quantile = TRUE,nbins=5, - thr = c(2/3),nboot=1000) -} -\arguments{ - \item{ano_exp}{ -Matrix of forecast anomalies with dimension of # ensemble members and -# start dates. - } - \item{beta}{ -Vector of observed anomalies with dimension of # start dates. - } - \item{alpha}{ -Calibration parameter for the ensemble mean. If not specified determined -from the data (default) - } - \item{beta}{ -Calibration parameter for the ensemble spread. If not specified determined -from the data (default) - } -} - -\examples{ -} -\author{ -History: -1.0 - 2016-10 (O.Bellprat) - Original code -} -\keyword{calibration} diff --git a/man/Calibration.Rd b/man/Calibration.Rd new file mode 100644 index 00000000..f033e54a --- /dev/null +++ b/man/Calibration.Rd @@ -0,0 +1,40 @@ +\name{Calibration} +\alias{Calibration} +\title{ +Ensemble calibration using the ensemble inflation method +described in Doblas-Reyes et al. (2005) +} +\description{ +The function calibrates a forecast ensemble for a hindcast following +the definitions of Dolbas-Reyes, F. J., Hagedorn, R., & Palmer, T. N. (2005). +The rationale behind the success of multi‐model ensembles in seasonal +forecasting–II. Calibration and combination. Tellus A, 57(3), 234-252. + +The calibration requires a forecast ensemble and an observational +reference to which it is calibrated. This method is applied in leave-one-out cross-validation. + +} +\usage{ +Calibration(var_obs,var_exp,anom=TRUE) +} +\arguments{ + \item{var_obs}{ +vector of observations with dimension of # start dates. + } + \item{var_exp}{ +Matrix of forecasts with dimension of # ensemble members and +# start dates. + } + \item{anom}{ +TRUE/FALSE: if var_exp and var_obs are anomalies or not. + } + +} + +\examples{ +} +\author{ +History: +1.0 - 2017-10 (V.Torralba) - Original code +} +\keyword{calibration,bias correction} -- GitLab From 9f55bd3bf90d28fc761d6b3823b3e6c3cbb8b1a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ver=C3=B3nica=20Torralba-Fern=C3=A1ndez?= Date: Fri, 6 Oct 2017 12:30:42 +0200 Subject: [PATCH 08/12] changes in the format --- R/Calibration.R | 82 ++++++++++++++++++++++++------------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/R/Calibration.R b/R/Calibration.R index 10decb88..ba01422e 100644 --- a/R/Calibration.R +++ b/R/Calibration.R @@ -1,71 +1,71 @@ -Calibration<-function(var_obs,var_exp,anom=FALSE){ +Calibration <- function(var_obs, var_exp, anom = FALSE) { # Ensemble inflation of a forecast following Doblas-Reyes et al. (2005) - if (!is.vector(var_obs)){ + if (!is.vector(var_obs)) { stop('var_obs should be a vector') } - if (length(dim(var_exp))!=2){ + if (length(dim(var_exp)) != 2) { stop('var_exp should be a matrix') } - if (length(which(dim(var_exp)==length(var_obs)))==0){ + if (length(which(dim(var_exp) == length(var_obs))) == 0) { stop('var_exp should have a dimension (time) with the same length that var_obs') } - - ntime<-length(var_obs) - nmembers<-dim(var_exp)[-which(dim(var_exp)==length(var_obs))] - if (!all(dim(var_exp),c(nmembers,ntime))){ - var_exp<-t(var_exp) + ntime <- length(var_obs) + nmembers <- dim(var_exp)[-which(dim(var_exp) == length(var_obs))] + + if (!all(dim(var_exp), c(nmembers, ntime))) { + var_exp <- t(var_exp) } - if (!anom){ - climObs<-NA*var_obs - climPred<-NA*var_obs + if (!anom) { + climObs <- NA * var_obs + climPred <- NA * var_obs for (t in 1:length(var_obs)) { - climObs[t]<-mean(var_obs) - climPred[t]<-mean(var_exp[,-t]) + climObs[t] <- mean(var_obs) + climPred[t] <- mean(var_exp[, -t]) } - var_obs<-var_obs-climObs - for (i in 1:nmembers){ - var_exp[i,]<-var_exp[i,]-climPred + var_obs <- var_obs - climObs + for (i in 1:nmembers) { + var_exp[i, ] <- var_exp[i, ] - climPred } } - - calibrated<-NA*var_exp - for (t in 1:ntime){ + calibrated <- NA * var_exp + + for (t in 1:ntime) { # defining forecast,hindcast and observation in cross-validation - fcst<-var_exp[,t] - hcst<-var_exp[,-t] - obs<-var_obs[-t] + fcst <- var_exp[, t] + hcst <- var_exp[, -t] + obs <- var_obs[-t] #coefficients - em_fcst<-mean(fcst) - em_hcst<-apply(hcst,c(2),mean) - corr<-cor(em_hcst,obs) - sd_obs<-sd(obs) - sd_em_hcst<-sd(em_hcst) + em_fcst <- mean(fcst) + em_hcst <- apply(hcst, c(2), mean) + corr <- cor(em_hcst, obs) + sd_obs <- sd(obs) + sd_em_hcst <- sd(em_hcst) - fcst_diff<-fcst-em_fcst - hcst_diff<-NA*hcst - for (n in 1:nmembers){ - hcst_diff[n,]<-hcst[n,]-em_hcst + fcst_diff <- fcst - em_fcst + hcst_diff <- NA * hcst + for (n in 1:nmembers) { + hcst_diff[n, ] <- hcst[n, ] - em_hcst } - sd_hcst_diff<-sd(hcst_diff) - - a<-corr*(sd_obs/sd_em_hcst) - b<-(sd_obs/sd_hcst_diff)*sqrt(1-(corr^2)) + sd_hcst_diff <- sd(hcst_diff) + + a <- corr * (sd_obs / sd_em_hcst) + b <- (sd_obs / sd_hcst_diff) * sqrt(1 - (corr ^ 2)) # calibrated output - calibrated[,t]<-(a*em_fcst)+(b*fcst_diff) + calibrated[, t] <- (a * em_fcst) + (b * fcst_diff) - if (!anom){ - calibrated[,t]<-calibrated[,t]+climObs[t] + if (!anom) { + calibrated[, t] <- calibrated[, t] + climObs[t] } } - + return(calibrated) - + } -- GitLab From b03765aa8b7d4a6de770d8bb1a9e90a513ad95d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ver=C3=B3nica=20Torralba-Fern=C3=A1ndez?= Date: Fri, 6 Oct 2017 16:29:40 +0200 Subject: [PATCH 09/12] add BiasCorrection function --- R/BiasCorrection.R | 43 +++++++++++++++++++++++++++++++++++++++++++ man/BiasCorrection.Rd | 37 +++++++++++++++++++++++++++++++++++++ man/Calibration.Rd | 2 +- 3 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 R/BiasCorrection.R create mode 100644 man/BiasCorrection.Rd diff --git a/R/BiasCorrection.R b/R/BiasCorrection.R new file mode 100644 index 00000000..77407acb --- /dev/null +++ b/R/BiasCorrection.R @@ -0,0 +1,43 @@ +BiasCorrection <- function(var_obs, var_exp) { + # Simple bias correction as in Torralba et al. 2017 + # Journal of Applied Meteorology and Climatology + + if (!is.vector(var_obs)) { + stop('var_obs should be a vector') + } + + if (length(dim(var_exp)) != 2) { + stop('var_exp should be a matrix') + } + + if (length(which(dim(var_exp) == length(var_obs))) == 0) { + stop('var_exp should have a dimension (time) with the same length that var_obs') + } + + ntime <- length(var_obs) + nmembers <- dim(var_exp)[-which(dim(var_exp) == length(var_obs))] + + if (!all(dim(var_exp), c(nmembers, ntime))) { + var_exp <- t(var_exp) + } + + corrected <- NA * var_exp + + for (t in 1:ntime) { + # defining forecast,hindcast and observation in cross-validation + fcst <- var_exp[, t] + hcst <- var_exp[,-t] + obs <- var_obs[-t] + + # parameters + sd_obs <- sd(obs) + sd_exp <- sd(hcst) + clim_exp <- mean(hcst) + clim_obs <- mean(obs) + + # bias corrected forecast + corrected[, t] <- ((fcst - clim_exp) * (sd_obs / sd_exp)) + clim_obs + } + + return(corrected) +} diff --git a/man/BiasCorrection.Rd b/man/BiasCorrection.Rd new file mode 100644 index 00000000..b8addc24 --- /dev/null +++ b/man/BiasCorrection.Rd @@ -0,0 +1,37 @@ +\name{BiasCorrection} +\alias{BiasCorrection} +\title{ +Bias correction using simple method +described in Torralba et al. (2017) +} +\description{ +The function correctes a forecast ensemble for a hindcast following +the definitions of Torralba, V., Doblas-Reyes, F. J., MacLeod, D., + Christel, I., & Davis, M. (2017). Seasonal Climate Prediction: A + New Source of Information for the Management of Wind Energy Resources. +Journal of Applied Meteorology and Climatology, 56(5), 1231-1247. + +The bias correction method requires a forecast ensemble and an observational +reference to which it is corrected. This method is applied in leave-one-out cross-validation. + +} +\usage{ +BiasCorrection(var_obs,var_exp) +} +\arguments{ + \item{var_obs}{ +vector of observations with dimension of # start dates. + } + \item{var_exp}{ +Matrix of forecasts with dimension of # ensemble members and +# start dates. + } +} + +\examples{ +} +\author{ +History: +1.0 - 2017-10 (V.Torralba) - Original code +} +\keyword{calibration,bias correction} diff --git a/man/Calibration.Rd b/man/Calibration.Rd index f033e54a..57c027c0 100644 --- a/man/Calibration.Rd +++ b/man/Calibration.Rd @@ -6,7 +6,7 @@ described in Doblas-Reyes et al. (2005) } \description{ The function calibrates a forecast ensemble for a hindcast following -the definitions of Dolbas-Reyes, F. J., Hagedorn, R., & Palmer, T. N. (2005). +the definitions of Doblas-Reyes, F. J., Hagedorn, R., & Palmer, T. N. (2005). The rationale behind the success of multi‐model ensembles in seasonal forecasting–II. Calibration and combination. Tellus A, 57(3), 234-252. -- GitLab From cf8b561bb1ba945b909eb1bdaa7e2a131b05b876 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ver=C3=B3nica=20Torralba-Fern=C3=A1ndez?= Date: Tue, 24 Oct 2017 17:43:41 +0200 Subject: [PATCH 10/12] check for the NAs has been added --- R/BiasCorrection.R | 4 ++++ R/Calibration.R | 3 +++ 2 files changed, 7 insertions(+) diff --git a/R/BiasCorrection.R b/R/BiasCorrection.R index 77407acb..874fcf99 100644 --- a/R/BiasCorrection.R +++ b/R/BiasCorrection.R @@ -5,6 +5,10 @@ BiasCorrection <- function(var_obs, var_exp) { if (!is.vector(var_obs)) { stop('var_obs should be a vector') } + + if (is.na(var_obs)|is.na(var_exp)) { + stop('NAs are not allowed') + } if (length(dim(var_exp)) != 2) { stop('var_exp should be a matrix') diff --git a/R/Calibration.R b/R/Calibration.R index ba01422e..edcba600 100644 --- a/R/Calibration.R +++ b/R/Calibration.R @@ -3,6 +3,9 @@ Calibration <- function(var_obs, var_exp, anom = FALSE) { if (!is.vector(var_obs)) { stop('var_obs should be a vector') } + if (is.na(var_obs)|is.na(var_exp)) { + stop('NAs are not allowed') + } if (length(dim(var_exp)) != 2) { stop('var_exp should be a matrix') -- GitLab From d2c33c0769f728f41e3700666ebd71a86a6c1ca9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ver=C3=B3nica=20Torralba-Fern=C3=A1ndez?= Date: Wed, 29 Nov 2017 20:14:07 +0100 Subject: [PATCH 11/12] small change --- R/BiasCorrection.R | 2 +- R/Calibration.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/BiasCorrection.R b/R/BiasCorrection.R index 874fcf99..5c073415 100644 --- a/R/BiasCorrection.R +++ b/R/BiasCorrection.R @@ -6,7 +6,7 @@ BiasCorrection <- function(var_obs, var_exp) { stop('var_obs should be a vector') } - if (is.na(var_obs)|is.na(var_exp)) { + if (any(is.na(var_obs))|any(is.na(var_exp))) { stop('NAs are not allowed') } diff --git a/R/Calibration.R b/R/Calibration.R index edcba600..f27062ea 100644 --- a/R/Calibration.R +++ b/R/Calibration.R @@ -3,7 +3,7 @@ Calibration <- function(var_obs, var_exp, anom = FALSE) { if (!is.vector(var_obs)) { stop('var_obs should be a vector') } - if (is.na(var_obs)|is.na(var_exp)) { + if (any(is.na(var_obs))|any(is.na(var_exp))) { stop('NAs are not allowed') } -- GitLab From c5ee4ca4f187964754f02bf128bfc627e2e45d06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ver=C3=B3nica=20Torralba-Fern=C3=A1ndez?= Date: Mon, 22 Oct 2018 19:55:52 +0200 Subject: [PATCH 12/12] compatibility Apply + fix --- R/BiasCorrection.R | 24 ++++++------------------ R/Calibration.R | 25 +++++++++---------------- 2 files changed, 15 insertions(+), 34 deletions(-) diff --git a/R/BiasCorrection.R b/R/BiasCorrection.R index 5c073415..2f409803 100644 --- a/R/BiasCorrection.R +++ b/R/BiasCorrection.R @@ -2,26 +2,14 @@ BiasCorrection <- function(var_obs, var_exp) { # Simple bias correction as in Torralba et al. 2017 # Journal of Applied Meteorology and Climatology - if (!is.vector(var_obs)) { - stop('var_obs should be a vector') - } - - if (any(is.na(var_obs))|any(is.na(var_exp))) { - stop('NAs are not allowed') - } - - if (length(dim(var_exp)) != 2) { - stop('var_exp should be a matrix') - } - - if (length(which(dim(var_exp) == length(var_obs))) == 0) { - stop('var_exp should have a dimension (time) with the same length that var_obs') - } - ntime <- length(var_obs) - nmembers <- dim(var_exp)[-which(dim(var_exp) == length(var_obs))] + if (dim(var_exp)[1]!=dim(var_exp)[2]){ + nmembers <- dim(var_exp)[-which(dim(var_exp) == length(var_obs))] + }else{ + nmembers<-dim(var_exp)[1] + } - if (!all(dim(var_exp), c(nmembers, ntime))) { + if (!all(dim(var_exp)== c(nmembers, ntime))) { var_exp <- t(var_exp) } diff --git a/R/Calibration.R b/R/Calibration.R index f27062ea..c4533a3e 100644 --- a/R/Calibration.R +++ b/R/Calibration.R @@ -1,27 +1,20 @@ Calibration <- function(var_obs, var_exp, anom = FALSE) { # Ensemble inflation of a forecast following Doblas-Reyes et al. (2005) - if (!is.vector(var_obs)) { - stop('var_obs should be a vector') - } - if (any(is.na(var_obs))|any(is.na(var_exp))) { - stop('NAs are not allowed') - } - if (length(dim(var_exp)) != 2) { - stop('var_exp should be a matrix') + ntime <- length(var_obs) + if (dim(var_exp)[1]!=dim(var_exp)[2]){ + nmembers <- dim(var_exp)[-which(dim(var_exp) == length(var_obs))] + }else{ + nmembers<-dim(var_exp)[1] } - - if (length(which(dim(var_exp) == length(var_obs))) == 0) { - stop('var_exp should have a dimension (time) with the same length that var_obs') + + if (!all(dim(var_exp)== c(nmembers, ntime))) { + var_exp <- t(var_exp) } - ntime <- length(var_obs) - nmembers <- dim(var_exp)[-which(dim(var_exp) == length(var_obs))] - - if (!all(dim(var_exp), c(nmembers, ntime))) { + if (!all(dim(var_exp)== c(nmembers, ntime))) { var_exp <- t(var_exp) } - if (!anom) { climObs <- NA * var_obs climPred <- NA * var_obs -- GitLab