diff --git a/modules/Units/R/transform_units_precipitation.R b/modules/Units/R/transform_units_precipitation.R index 5cc1e812fd31a8aec507c3cae283707a30c273b8..d0dd7ffd50dfb6f04db35006a06cd61b1d8f43e9 100644 --- a/modules/Units/R/transform_units_precipitation.R +++ b/modules/Units/R/transform_units_precipitation.R @@ -96,22 +96,25 @@ transform_units_precipitation <- function(data, original_units, new_units, } -.days_in_month <- function(x, cal) { - if (cal %in% c('gregorian', 'standard', 'proleptic_gregorian')) { - N_DAYS_IN_MONTHS <- lubridate:::N_DAYS_IN_MONTHS - if (leap_year(year(x))) { - N_DAYS_IN_MONTHS[2] <- N_DAYS_IN_MONTHS[2] + 1 - } - } else if (cal %in% c('360', '360_day')) { - N_DAYS_IN_MONTHS <- rep(30, 12) - names(N_DAYS_IN_MONTHS) <- month.abb - } else if (cal %in% c('365', '365_day')) { - N_DAYS_IN_MONTHS <- lubridate:::N_DAYS_IN_MONTHS - } else { - stop("Unknown calendar") - } - month_x <- month(x, label = TRUE, locale = "C") - n_days <- N_DAYS_IN_MONTHS[month_x] - n_days[month_x == "Feb" & leap_year(x)] <- 29L +.days_in_month <- function(dates, cal) { + n_days <- array() + for (x in 1:length(dates)) { + if (cal %in% c('gregorian', 'standard', 'proleptic_gregorian')) { + N_DAYS_IN_MONTHS <- lubridate:::N_DAYS_IN_MONTHS + if (leap_year(year(dates[x]))) { + N_DAYS_IN_MONTHS[2] <- N_DAYS_IN_MONTHS[2] + 1 + } + } else if (cal %in% c('360', '360_day')) { + N_DAYS_IN_MONTHS <- rep(30, 12) + names(N_DAYS_IN_MONTHS) <- month.abb + } else if (cal %in% c('365', '365_day')) { + N_DAYS_IN_MONTHS <- lubridate:::N_DAYS_IN_MONTHS + } else { + stop("Unknown calendar") + } + month_x <- month(dates[x], label = TRUE, locale = "C") + n_days[x] <- N_DAYS_IN_MONTHS[month_x] + # n_days[month_x == "Feb" & leap_year(x)] <- 29L + } return(n_days) } diff --git a/recipes/atomic_recipes/recipe_system7c3s-prlr.yml b/recipes/atomic_recipes/recipe_system7c3s-prlr.yml index 1cba3c97f76f05fddec5aefe294f02207e6459b9..590d4499d07b1761737f4c0d2f89bec2bb5e30c7 100644 --- a/recipes/atomic_recipes/recipe_system7c3s-prlr.yml +++ b/recipes/atomic_recipes/recipe_system7c3s-prlr.yml @@ -4,8 +4,9 @@ Description: Analysis: Horizon: Seasonal Variables: - name: prlr + name: prlr freq: monthly_mean + units: mm Datasets: System: name: Meteo-France-System7 @@ -36,7 +37,7 @@ Analysis: method: mse_min save: 'all' Skill: - metric: RPS RPSS CRPS CRPSS FRPSS BSS10 BSS90 EnsCorr Corr + metric: RPS RPSS CRPS CRPSS FRPSS BSS10 BSS90 EnsCorr save: 'all' Probabilities: percentiles: [[1/3, 2/3], [1/10, 9/10], [1/4, 2/4, 3/4]]