

getSkillScoreDefinition<-function(names){
names<-tolower(names)
definition <- switch(names,
                  "enscorr" = "Calculate correlation between forecasts and observations for an ensemble forecast, including an adjustment for finite ensemble sizes",
                  "corr_individual_members"="(...)",
                  "rps"="The Ranked Probability Score (RPS; Wilks, 2011) is defined as the sum of the squared differences between the cumulative forecast probabilities (computed from the ensemble members) and the observations (defined as 0 did not happen and 100 of multi-categorical probabilistic forecasts. The RPS ranges between 0 (perfect forecast) and n-1 (worst possible forecast), where n is the number of categories. In the case of a forecast divided into two categories (the lowest number of categories that a probabilistic forecast can have), the RPS corresponds to the Brier Score (BS; Wilks, 2011), therefore ranging between 0 and 1. The function first calculates the probabilities for forecasts and observations, then use them to calculate RPS. Or, the probabilities of exp and obs can be provided directly to compute the score. If there is more than one dataset, RPS will be computed for each pair of exp and obs data. The fraction of acceptable NAs can be adjusted.",
                  "rpss"="The Ranked Probability Skill Score (RPSS; Wilks, 2011) is the skill score based on the Ranked Probability Score (RPS; Wilks, 2011). It can be used to assess whether a forecast presents an improvement or worsening with respect to a reference forecast. The RPSS ranges between minus infinite and 1. If the RPSS is positive, it indicates that the forecast has higher skill than the reference forecast, while a negative value means that it has a lower skill. Examples of reference forecasts are the climatological forecast (same probabilities for all categories for all time steps), persistence, a previous model version, and another model. It is computed as RPSS = 1 - RPS_exp / RPS_ref. The statistical significance is obtained based on a Random Walk test at the specified confidence level (DelSole and Tippett, 2016). The function accepts either the ensemble members or the probabilities of each data as inputs. If there is more than one dataset, RPSS will be computed for each pair of exp and obs data. The NA ratio of data will be examined before the calculation. If the ratio is higher than the threshold (assigned by parameter na.rm), NA will be returned directly. NAs are counted by per-pair method, which means that only the time steps that all the datasets have values count as non-NA values. ",
                  "frps"="Calculate the difference (mean score of the reference forecast) minus (mean score of the forecast). Uncertainty is assessed by the Diebold-Mariano test for equality of predictive accuracy.",
                  "frpss"="Calculate the difference (mean skill score of the reference forecast) minus (mean skill score of the forecast). Uncertainty is assessed by the Diebold-Mariano test for equality of predictive accuracy.",
                  "crps"=" The Continuous Ranked Probability Score (CRPS; Wilks, 2011) is the continuous version of the Ranked Probability Score (RPS; Wilks, 2011). It is a skill metric to evaluate the full distribution of probabilistic forecasts. It has a negative orientation (i.e., the higher-quality forecast the smaller CRPS) and it rewards the forecast that has probability concentration around the observed value. In case of a deterministic forecast, the CRPS is reduced to the mean absolute error. It has the same units as the data. The function is based on enscrps_cpp from SpecsVerification. If there is more than one dataset, CRPS will be computed for each pair of exp and obs data.",
                  "crpss"="The Continuous Ranked Probability Skill Score (CRPSS; Wilks, 2011) is the skill score based on the Continuous Ranked Probability Score (CRPS; Wilks, 2011). It can be used to assess whether a forecast presents an improvement or worsening with respect to a reference forecast. The CRPSS ranges between minus infinite and 1. If the CRPSS is positive, it indicates that the forecast has higher skill than the reference forecast, while a negative value means that it has a lower skill. Examples of reference forecasts are the climatological forecast, persistence, a previous model version, or another model. It is computed as ’CRPSS = 1 - CRPS_exp / CRPS_ref. The statistical significance is obtained based on a Random Walk test at the specified confidence level (DelSole and Tippett, 2016).",
                  "bss10"="Compute the lower extreme Brier score (BS) and the components of its standard decompostion with the two withinbin components described in Stephenson et al., (2008). It also returns the bias-corrected decomposition of the BS (Ferro and Fricker, 2012). It has the climatology as the reference forecast.",
                  "bss90"="Compute the upper extreme Brier score (BS) and the components of its standard decompostion with the two withinbin components described in Stephenson et al., (2008). It also returns the bias-corrected decomposition of the BS (Ferro and Fricker, 2012). It has the climatology as the reference forecast.",
                  "mean_bias"="The Mean Bias or Mean Error (Wilks, 2011) is defined as the mean difference between the ensemble mean forecast and the observations. It is a deterministic metric. Positive values indicate that the forecasts are on average too high and negative values indicate that the forecasts are on average too low. It also allows to compute the Absolute Mean Bias or bias without temporal mean. If there is more than one dataset, the result will be computed for each pair of exp and obs data",
                  "mean_bias_ss"="The Absolute Mean Bias Skill Score is based on the Absolute Mean Error (Wilks, 2011) between the ensemble mean forecast and the observations. It measures the accuracy of the forecast in comparison with a reference forecast to assess whether the forecast presents an improvement or a worsening with respect to that reference. The Mean Bias Skill Score ranges between minus infinite and 1. Positive values indicate that the forecast has higher skill than the reference forecast, while negative values indicate that it has a lower skill. Examples of reference forecasts are the climatological forecast (average of the observations), a previous model version, or another model. It is computed as AbsBiasSS = 1 - AbsBias_exp / AbsBias_ref. The statistical significance is obtained based on a Random Walk test at the confidence level specified (DelSole and Tippett, 2016). If there is more than one dataset, the result will be computed for each pair of exp and obs data.",
                  "enssprerr"="(...)",
                  "msss"="Compute the mean square error skill score (MSSS) between an array of forecast ’exp’ and an array of observation ’obs’. The two arrays should have the same dimensions except along ’dat_dim’ and ’memb_dim’. The MSSSs are computed along ’time_dim’, the dimension which corresponds to the start date dimension. MSSS computes the mean square error skill score of each exp in 1:nexp against each obs in 1:nobs which gives nexp * nobs MSSS for each grid point of the array. The p-value and significance test are optionally provided by an one-sided Fisher test or Random Walk test.",
                  "mse"="Compute the mean square error for an array of forecasts and an array of observations. The MSEs are computed along time_dim, the dimension which corresponds to the start date dimension. If comp_dim is given, the MSEs are computed only if obs along the comp_dim dimension are complete between limits[1] and limits[2], i.e. there are no NAs between limits[1] and limits[2]. This option can be activated if the user wants to account only for the forecasts for which the corresponding observations are available at all leadtimes. The confidence interval is computed by the chi2 distribution.")  

return(definition)
}

getSkillScoreRepresentation <- function(names) {
    representation <- switch(names,
                 "enscorr" = "DeterministicContinuous",
                 "corr_individual_members"="DeterministicContinuous",
                 "rps"="MulticategoryProbability",
                 "rpss"="MulticategoryProbability",
                 "frps"="MulticategoryProbability",
                 "frpss"="MulticategoryProbability",
                 "crps"=" EnsembleForecast",
                 "crpss"="EnsembleForecast",
                 "bss10"="BinaryProbability",
                 "bss90"="BinaryProbability",
                 "mean_bias"="DeterministicContinuous",
                 "mean_bias_ss"="DeterministicContinuous",
                 "enssprerr"="EnsembleForecast",
                 "msss"="DeterministicContinuous",
                 "mse"="DeterministicContinuous")
    return(paste0("veri:", representation))
}

getSkillScoreLabel<-function(names){
label.name <- switch(names,
                  "enscorr" = "Ensemble Mean Correlation",
                  "corr_individual_members"="Correlation for each individual member of the ensemble",
                  "rps"="Ranked Probability Score",
                  "rpss"="Ranked Probability Skill Score",
                  "frps"="Fair Ranked Probability Score",
                  "frpss"="Fair Ranked Probability Skill Score",
                  "crps"=" Continuous Ranked Probability Score",
                  "crpss"="Continuous Ranked Probability Skill Score",
                  "bss10"="Brier Skill Score (lower extreme)",
                  "bss90"="Brier Skill Score (upper extreme)",
                  "mean_bias"="Mean bias of the ensemble",
                  "mean_bias_ss"="Mean Bias Skill Score",
                  "enssprerr"="Ensemble Spread-to-Error Ratio",
                  "msss"="Mean Square Skill Score",
                  "mse"="Mean Square Error")  
    return(label.name)
}