diff --git a/plotting/layout.R b/plotting/layout.R index e46e4d5d423bc7bd782f975dde835e86a771df99..b118aecb8bb2cc2fa0fabf16cd680b436e3792f7 100644 --- a/plotting/layout.R +++ b/plotting/layout.R @@ -436,6 +436,10 @@ get_power = function (value) { # The magnitude is the number of character of integer part # of the value minus one power = nchar(as.character(as.integer(value))) - 1 + # If value is zero + } else if (value == 0) { + # The power is zero + power = 0 # If the value is less than one } else { # Extract the decimal part diff --git a/plotting/map.R b/plotting/map.R index cdba53ce6c316e2f16a97824249bc411e525b4c1..31acce4a9940e2122aa78af52969163be23793c1 100644 --- a/plotting/map.R +++ b/plotting/map.R @@ -69,6 +69,7 @@ map_panel = function (list_df2plot, df_meta, df_shapefile, idPer=1, outdirTmp='' } } + # Blank array to store time info tab_Start = array(rep('', nCode*nbp*nPeriod_max), dim=c(nCode, nbp, nPeriod_max)) tab_End = array(rep('', nCode*nbp*nPeriod_max), @@ -82,7 +83,7 @@ map_panel = function (list_df2plot, df_meta, df_shapefile, idPer=1, outdirTmp='' for (k in 1:nCode) { # Gets the code code = Code[k] - + # For all the variable for (i in 1:nbp) { df_trend = list_df2plot[[i]]$trend # Extracts the trend corresponding to the code @@ -105,7 +106,8 @@ map_panel = function (list_df2plot, df_meta, df_shapefile, idPer=1, outdirTmp='' Periods = paste(Start[j], End[j], sep=' / ') - + + # Saves the time info tab_Start[k, i, j] = as.character(Start[j]) tab_End[k, i, j] = as.character(End[j]) tab_Code[k, i, j] = code @@ -118,7 +120,7 @@ map_panel = function (list_df2plot, df_meta, df_shapefile, idPer=1, outdirTmp='' # Blank array to store mean of the trend for each # station, perdiod and variable - TrendMean_code = array(rep(1, nPeriod_max*nbp*nCode), + TrendValue_code = array(rep(1, nPeriod_max*nbp*nCode), dim=c(nPeriod_max, nbp, nCode)) # For all the period for (j in 1:nPeriod_max) { @@ -134,6 +136,8 @@ map_panel = function (list_df2plot, df_meta, df_shapefile, idPer=1, outdirTmp='' # Extracts the trend corresponding to the # current variable df_trend = list_df2plot[[i]]$trend + # Extracts the type of the variable + type = list_df2plot[[i]]$type p_threshold = list_df2plot[[i]]$p_threshold # Extracts the data corresponding to the code df_data_code = df_data[df_data$code == code,] @@ -162,26 +166,32 @@ map_panel = function (list_df2plot, df_meta, df_shapefile, idPer=1, outdirTmp='' df_trend_code_per = df_trend_code_per[1,] } - # Computes the mean of the data on the period - dataMean = mean(df_data_code_per$Value, na.rm=TRUE) - # Normalises the trend value by the mean of the data - trendMean = df_trend_code_per$trend / dataMean + # If it is a flow variable + if (type == 'sévérité') { + # Computes the mean of the data on the period + dataMean = mean(df_data_code_per$Value, na.rm=TRUE) + # Normalises the trend value by the mean of the data + trendValue = df_trend_code_per$trend / dataMean + # If it is a date variable + } else if (type == 'saisonnalité') { + trendValue = df_trend_code_per$trend + } # If the p value is under the threshold if (df_trend_code_per$p <= p_threshold){ # Stores the mean trend - TrendMean_code[j, i, k] = trendMean + TrendValue_code[j, i, k] = trendValue # Otherwise } else { # Do not stocks it - TrendMean_code[j, i, k] = NA + TrendValue_code[j, i, k] = NA } } } } # Compute the min and the max of the mean trend for all the station - minTrendMean = apply(TrendMean_code, c(1, 2), min, na.rm=TRUE) - maxTrendMean = apply(TrendMean_code, c(1, 2), max, na.rm=TRUE) + minTrendValue = apply(TrendValue_code, c(1, 2), min, na.rm=TRUE) + maxTrendValue = apply(TrendValue_code, c(1, 2), max, na.rm=TRUE) # Number of ticks for the colorbar nbTick = 10 @@ -195,6 +205,8 @@ map_panel = function (list_df2plot, df_meta, df_shapefile, idPer=1, outdirTmp='' } # Extracts the variable of the plot var = list_df2plot[[i]]$var + # Extracts the type of variable of the plot + type = list_df2plot[[i]]$type # Createsa name for the map outname = paste('map_', var, sep='') # If there is the verbose option @@ -381,21 +393,27 @@ map_panel = function (list_df2plot, df_meta, df_shapefile, idPer=1, outdirTmp='' df_trend_code_per = df_trend_code_per[1,] } - # Computes the mean of the data on the period - dataMean = mean(df_data_code_per$Value, na.rm=TRUE) - # Normalises the trend value by the mean of the data - trendMean = df_trend_code_per$trend / dataMean + # If it is a flow variable + if (type == 'sévérité') { + # Computes the mean of the data on the period + dataMean = mean(df_data_code_per$Value, na.rm=TRUE) + # Normalises the trend value by the mean of the data + trendValue = df_trend_code_per$trend / dataMean + # If it is a date variable + } else if (type == 'saisonnalité') { + trendValue = df_trend_code_per$trend + } # Computes the color associated to the mean trend - color_res = get_color(trendMean, - minTrendMean[idPer, i], - maxTrendMean[idPer, i], + color_res = get_color(trendValue, + minTrendValue[idPer, i], + maxTrendValue[idPer, i], palette_name='perso', reverse=TRUE, ncolor=256) # Computes the colorbar info - palette_res = get_palette(minTrendMean[idPer, i], - maxTrendMean[idPer, i], + palette_res = get_palette(minTrendValue[idPer, i], + maxTrendValue[idPer, i], palette_name='perso', reverse=TRUE, ncolor=256, @@ -406,7 +424,7 @@ map_panel = function (list_df2plot, df_meta, df_shapefile, idPer=1, outdirTmp='' # The computed color is stored filltmp = color_res # If the mean tend is positive - if (trendMean >= 0) { + if (trendValue >= 0) { # Uses a triangle up for the shape of the marker shapetmp = 24 # If negative @@ -433,7 +451,7 @@ map_panel = function (list_df2plot, df_meta, df_shapefile, idPer=1, outdirTmp='' lat = c(lat, lattmp) fill = c(fill, filltmp) shape = c(shape, shapetmp) - trend = c(trend, trendMean) + trend = c(trend, trendValue) # If the trend analysis is significative a TRUE is stored p_threshold_Ok = c(p_threshold_Ok, df_trend_code_per$p <= p_threshold) @@ -468,7 +486,7 @@ map_panel = function (list_df2plot, df_meta, df_shapefile, idPer=1, outdirTmp='' geom_point(data=plot_map_code, aes(x=lon, y=lat), shape=21, size=1.5, stroke=0.5, - color='grey40', fill='grey40') + color='#00A3A8', fill='#00A3A8') } # Extracts the position of the tick of the colorbar @@ -482,9 +500,17 @@ map_panel = function (list_df2plot, df_meta, df_shapefile, idPer=1, outdirTmp='' valNorm = nbTick * 10 # Normalisation of the position of ticks ytick = posTick / max(posTick) * valNorm - # Formatting of label in pourcent - labTick = as.character(round(labTick*100, 2)) + # If it is a flow variable + if (type == 'sévérité') { + # Formatting of label in pourcent + labTick = as.character(round(labTick*100, 2)) + # If it is a date variable + } else if (type == 'saisonnalité') { + # Formatting of label + labTick = as.character(round(labTick, 2)) + } + # X position of ticks all similar xtick = rep(0, times=nbTick) @@ -522,6 +548,14 @@ map_panel = function (list_df2plot, df_meta, df_shapefile, idPer=1, outdirTmp='' shape=21, size=5, stroke=1, color='white', fill=colTick) + # If it is a flow variable + if (type == 'sévérité') { + unit = bquote(bold("% par an")) + # If it is a date variable + } else if (type == 'saisonnalité') { + unit = bquote(bold("jour par an")) + } + pal = pal + # Name of the colorbar annotate('text', @@ -532,7 +566,7 @@ map_panel = function (list_df2plot, df_meta, df_shapefile, idPer=1, outdirTmp='' # Unit legend of the colorbar annotate('text', x=-0.2, y= valNorm + 13, - label=bquote(bold("% par an")), + label=unit, hjust=0, vjust=0.5, size=4, color='grey40') # For all the ticks @@ -584,8 +618,8 @@ map_panel = function (list_df2plot, df_meta, df_shapefile, idPer=1, outdirTmp='' # Normalises all the trend values for each station # according to the colorbar - yTrend = (trend - minTrendMean[idPer, i]) / - (maxTrendMean[idPer, i] - minTrendMean[idPer, i]) * valNorm + yTrend = (trend - minTrendValue[idPer, i]) / + (maxTrendValue[idPer, i] - minTrendValue[idPer, i]) * valNorm # Takes only the significative ones yTrend = yTrend[p_threshold_Ok] @@ -656,21 +690,22 @@ map_panel = function (list_df2plot, df_meta, df_shapefile, idPer=1, outdirTmp='' # color="grey20", fill="grey20") alpha=0.4) - - pal = pal + - # Arrow to show a worsening of the situation - geom_segment(aes(x=2.7, y=valNorm*0.75, - xend=2.7, yend=valNorm*0.25), - color='grey50', size=0.3, - arrow=arrow(length=unit(2, "mm"))) + - # Text associated to the arrow - annotate('text', - x=2.8, y=valNorm*0.5, - label= "Plus sévère", - angle=90, - hjust=0.5, vjust=1, - size=3, color='grey50') - + # If it is a flow variable + if (type == 'sévérité') { + pal = pal + + # Arrow to show a worsening of the situation + geom_segment(aes(x=2.7, y=valNorm*0.75, + xend=2.7, yend=valNorm*0.25), + color='grey50', size=0.3, + arrow=arrow(length=unit(2, "mm"))) + + # Text associated to the arrow + annotate('text', + x=2.8, y=valNorm*0.5, + label= "Plus sévère", + angle=90, + hjust=0.5, vjust=1, + size=3, color='grey50') + } pal = pal + # X axis of the colorbar diff --git a/plotting/matrix.R b/plotting/matrix.R index e376c8ee0ca0900cbf53b62282e8ea210787280b..aeeb47b34bd4cdf66ff150bf94d194f517b16a04 100644 --- a/plotting/matrix.R +++ b/plotting/matrix.R @@ -70,6 +70,7 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice } } + # Blank array to store time info tab_Start = array(rep('', nCode*nbp*nPeriod_max), dim=c(nCode, nbp, nPeriod_max)) tab_End = array(rep('', nCode*nbp*nPeriod_max), @@ -83,7 +84,7 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice for (k in 1:nCode) { # Gets the code code = Code[k] - + # For all the variable for (i in 1:nbp) { df_trend = list_df2plot[[i]]$trend # Extracts the trend corresponding to the code @@ -106,7 +107,8 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice Periods = paste(Start[j], End[j], sep=' / ') - + + # Saves the time info tab_Start[k, i, j] = as.character(Start[j]) tab_End[k, i, j] = as.character(End[j]) tab_Code[k, i, j] = code @@ -120,7 +122,7 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice # Blank array to store mean of the trend for each # station, perdiod and variable - TrendMean_code = array(rep(1, nPeriod_trend*nbp*nCode), + TrendValue_code = array(rep(1, nPeriod_trend*nbp*nCode), dim=c(nPeriod_trend, nbp, nCode)) # For all the trend period for (j in 1:nPeriod_trend) { @@ -136,6 +138,8 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice # Extracts the trend corresponding to the # current variable df_trend = list_df2plot[[i]]$trend + # Extracts the type of the variable + type = list_df2plot[[i]]$type p_threshold = list_df2plot[[i]]$p_threshold # Extracts the data corresponding to the code df_data_code = df_data[df_data$code == code,] @@ -163,28 +167,35 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice # Takes only the first because they are similar df_trend_code_per = df_trend_code_per[1,] } - # Computes the mean of the data on the period dataMean = mean(df_data_code_per$Value, na.rm=TRUE) - # Normalises the trend value by the mean of the data - trendMean = df_trend_code_per$trend / dataMean + + # If it is a flow variable + if (type == 'sévérité') { + # Normalises the trend value by the mean of the data + trendValue = df_trend_code_per$trend / dataMean + # If it is a date variable + } else if (type == 'saisonnalité') { + # Just stocks the trend value + trendValue = df_trend_code_per$trend + } # If the p value is under the threshold if (df_trend_code_per$p <= p_threshold){ # Stores the averaged trend - TrendMean_code[j, i, k] = trendMean + TrendValue_code[j, i, k] = trendValue # Otherwise } else { # Do not stocks it - TrendMean_code[j, i, k] = NA + TrendValue_code[j, i, k] = NA } } } } # Computes the min and the max of the mean trend for # all the station - minTrendMean = apply(TrendMean_code, c(1, 2), min, na.rm=TRUE) - maxTrendMean = apply(TrendMean_code, c(1, 2), max, na.rm=TRUE) + minTrendValue = apply(TrendValue_code, c(1, 2), min, na.rm=TRUE) + maxTrendValue = apply(TrendValue_code, c(1, 2), max, na.rm=TRUE) # Blank vectors to store info about trend analyses Periods_trend = c() @@ -193,7 +204,7 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice Type_trend = c() Code_trend = c() Pthresold_trend = c() - TrendMean_trend = c() + TrendValue_trend = c() DataMean_trend = c() Fill_trend = c() Color_trend = c() @@ -244,15 +255,23 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice # Computes the mean of the data on the period dataMean = mean(df_data_code_per$Value, na.rm=TRUE) - # Normalises the trend value by the mean of the data - trendMean = df_trend_code_per$trend / dataMean + + # If it is a flow variable + if (type == 'sévérité') { + # Normalises the trend value by the mean of the data + trendValue = df_trend_code_per$trend / dataMean + # If it is a date variable + } else if (type == 'saisonnalité') { + # Just stocks the trend value + trendValue = df_trend_code_per$trend + } # If the p value is under the threshold if (df_trend_code_per$p <= p_threshold){ # Gets the color associated to the averaged trend - color_res = get_color(trendMean, - minTrendMean[j, i], - maxTrendMean[j, i], + color_res = get_color(trendValue, + minTrendValue[j, i], + maxTrendValue[j, i], palette_name='perso', reverse=TRUE) # Specifies the color fill and contour of @@ -274,7 +293,7 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice Type_trend = append(Type_trend, type) Code_trend = append(Code_trend, code) Pthresold_trend = append(Pthresold_trend, Pthresold) - TrendMean_trend = append(TrendMean_trend, trendMean) + TrendValue_trend = append(TrendValue_trend, trendValue) DataMean_trend = append(DataMean_trend, dataMean) Fill_trend = append(Fill_trend, fill) Color_trend = append(Color_trend, color) @@ -291,7 +310,7 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice Type_mean = c() Code_mean = c() DataMean_mean = c() - BreakMean_mean = c() + breakValue_mean = c() # Convert 'mean_period' to list mean_period = as.list(mean_period) @@ -299,7 +318,7 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice nPeriod_mean = length(mean_period) # Blank array to store difference of mean between two periods - BreakMean_code = array(rep(1, nPeriod_mean*nbp*nCode), + breakValue_code = array(rep(1, nPeriod_mean*nbp*nCode), dim=c(nPeriod_mean, nbp, nCode)) # Blank array to store mean for a temporary period in order # to compute the difference of mean with a second period @@ -353,11 +372,20 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice # Stocks NA Break = NA } - # Normalises the break by the mean of the - # initial period - BreakMean = Break / dataMeantmp[i, k] + + # If it is a flow variable + if (type == 'sévérité') { + # Normalises the break by the mean of the + # initial period + breakValue = Break / dataMeantmp[i, k] + # If it is a date variable + } else if (type == 'saisonnalité') { + # Just stocks the break value + breakValue = Break + } + # Stores the result - BreakMean_code[j, i, k] = BreakMean + breakValue_code[j, i, k] = breakValue # Stores temporarily the mean of the current period dataMeantmp[i, k] = dataMean @@ -368,16 +396,16 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice Type_mean = append(Type_mean, type) Code_mean = append(Code_mean, code) DataMean_mean = append(DataMean_mean, dataMean) - BreakMean_mean = append(BreakMean_mean, - BreakMean) + breakValue_mean = append(breakValue_mean, + breakValue) } } } # Computes the min and the max of the averaged trend for # all the station - minBreakMean = apply(BreakMean_code, c(1, 2), + minBreakValue = apply(breakValue_code, c(1, 2), min, na.rm=TRUE) - maxBreakMean = apply(BreakMean_code, c(1, 2), + maxBreakValue = apply(breakValue_code, c(1, 2), max, na.rm=TRUE) # Blanks vector to store color info Fill_mean = c() @@ -392,11 +420,11 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice # For all variable for (i in 1:nbp) { # Extracts averaged breaking - BreakMean = BreakMean_mean[ii] + breakValue = breakValue_mean[ii] # Gets the color associated - color_res = get_color(BreakMean, - minBreakMean[j, i], - maxBreakMean[j, i], + color_res = get_color(breakValue, + minBreakValue[j, i], + maxBreakValue[j, i], palette_name='perso', reverse=TRUE) # Gets the fill and contour color @@ -473,7 +501,7 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice subType_trend = Type_trend[CodefL_trend] subCode_trend = Code_trend[CodefL_trend] subPthresold_trend = Pthresold_trend[CodefL_trend] - subTrendMean_trend = TrendMean_trend[CodefL_trend] + subTrendValue_trend = TrendValue_trend[CodefL_trend] subDataMean_trend = DataMean_trend[CodefL_trend] subFill_trend = Fill_trend[CodefL_trend] subColor_trend = Color_trend[CodefL_trend] @@ -488,7 +516,7 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice subType_mean = Type_mean[CodefL_mean] subCode_mean = Code_mean[CodefL_mean] subDataMean_mean = DataMean_mean[CodefL_mean] - subBreakMean_mean = BreakMean_mean[CodefL_mean] + subbreakValue_mean = breakValue_mean[CodefL_mean] subFill_mean = Fill_mean[CodefL_mean] subColor_mean = Color_mean[CodefL_mean] @@ -553,8 +581,8 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice subCode_trend[subNPeriod_trend == j] Pthresold_trend_per = subPthresold_trend[subNPeriod_trend == j] - TrendMean_trend_per = - subTrendMean_trend[subNPeriod_trend == j] + TrendValue_trend_per = + subTrendValue_trend[subNPeriod_trend == j] DataMean_trend_per = subDataMean_trend[subNPeriod_trend == j] Fill_trend_per = @@ -625,14 +653,28 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice gg_circle(r=0.45, xc=Xc, yc=Y[i], fill='white', color='grey40') } + # For all averaged trends on this periods - for (i in 1:length(TrendMean_trend_per)) { + for (i in 1:length(TrendValue_trend_per)) { # Extracts the value of the averaged trend - trendMean = TrendMean_trend_per[i] - # Converts it to the right format with two - # significant figures - trendMeanC = signif(trendMean*100, 2) + trendValue = TrendValue_trend_per[i] + type = Type_trend_per[i] + # If it is a flow variable + if (type == 'sévérité') { + Nsign_mean = 2 + # Converts it to the right format with + # two significant figures + trendValueC = signif(trendValue*100, 2) + # If it is a date variable + } else if (type == 'saisonnalité') { + # Fixes the significants number for mean to 3 + Nsign_mean = 3 + # Converts the trend value with two + # significant figures + trendValueC = signif(trendValue, 2) + } + # If it is significative if (!is.na(Pthresold_trend_per[i])) { # The text color is white @@ -646,12 +688,12 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice # Same for averaged variables over # the current period dataMean = DataMean_trend_per[i] - dataMeanC = signif(dataMean, 2) + dataMeanC = signif(dataMean, Nsign_mean) mat = mat + # Writes the mean trend annotate('text', x=X[i], y=Y[i], - label=trendMeanC, + label=trendValueC, hjust=0.5, vjust=0.5, size=3, color=Tcolor) + # Writes the mean of the associated variable @@ -676,10 +718,26 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice for (i in 1:nbpMod) { # Extract the variable of the plot var = subVar_trend[i] + type = subType_trend[i] + + # If it is a flow variable + if (type == 'sévérité') { + # Fixes the unit of the mean and the trend + # for the flow + unit_mean = bquote('['*m^3*'.'*s^{-1}*']') + unit_trend = bquote('[%.'*an^{-1}*']') + # If it is a date variable + } else if (type == 'saisonnalité') { + # Fixes the unit of the mean and the trend + # for the date + unit_mean = bquote('[jour]') + unit_trend = bquote('[jour.'*an^{-1}*']') + } + mat = mat + # Writes the unit of the variable annotate('text', x=X[i], y=max(Y) + 0.63, - label=bquote('[%.'*ans^{-1}*']'), + label=unit_trend, hjust=0.5, vjust=0.5, size=2, color='grey40') + # Writes the type of the variable @@ -689,7 +747,7 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice size=3.25, color='grey20') + # Writes the unit of the averaged variable annotate('text', x=Xm[i], y=max(Y) + 0.63, - label=bquote('['*m^3*'.'*s^{-1}*']'), + label=unit_mean, hjust=0.5, vjust=0.5, size=2, color='grey40') + # Writes the type of the averaged variable @@ -742,8 +800,8 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice subCode_mean[subNPeriod_mean == j] DataMean_mean_per = subDataMean_mean[subNPeriod_mean == j] - BreakMean_mean_per = - subBreakMean_mean[subNPeriod_mean == j] + breakValue_mean_per = + subbreakValue_mean[subNPeriod_mean == j] Fill_mean_per = subFill_mean[subNPeriod_mean == j] Color_mean_per = @@ -839,14 +897,27 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice color=Color_mean_per[i]) } } - + # For all averaged variables on this period for (i in 1:length(DataMean_mean_per)) { + type = Type_mean_per[i] + # If it is a flow variable + if (type == 'sévérité') { + # The number of significant figures for + # flow mean is 2 + Nsign_mean = 2 + # If it is a date variable + } else if (type == 'saisonnalité') { + # The number of significant figures for + # date mean is 3 + Nsign_mean = 3 + } # Extracts values of averaged variables dataMean = DataMean_mean_per[i] + # Converts it to the right format with two # significant figures - dataMeanC = signif(dataMean, 2) + dataMeanC = signif(dataMean, Nsign_mean) # Writes averaged variables values mat = mat + annotate('text', x=Xm_mean[i], y=Y[i], @@ -856,14 +927,23 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice # If this is not the first period if (j > 1) { # Extracts values of breaking between periods - BreakMean = BreakMean_mean_per[i] - # Converts it to the right format with two - # significant figures - BreakMeanC = signif(BreakMean*100, 2) + breakValue = breakValue_mean_per[i] + # If it is a flow variable + if (type == 'sévérité') { + # Converts it to the right format with two + # significant figures + breakValueC = signif(breakValue*100, 2) + # If it is a date variable + } else if (type == 'saisonnalité') { + # Converts the break value with two + # significant figures + breakValueC = signif(breakValue, 2) + } + # Writes breaking values mat = mat + annotate('text', x=Xr_mean[i], y=Y[i], - label=BreakMeanC, + label=breakValueC, hjust=0.5, vjust=0.5, size=3, color='white') } @@ -884,11 +964,27 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice for (i in 1:nbpMod) { # Extract the variable of the plot var = subVar_mean[i] + type = subType_mean[i] + + # If it is a flow variable + if (type == 'sévérité') { + # Fixes the unit of the mean and the break + # for the flow + unit_mean = bquote('['*m^3*'.'*s^{-1}*']') + unit_break = bquote('[%]') + # If it is a date variable + # Fixes the unit of the mean and the break + # for the date + } else if (type == 'saisonnalité') { + unit_mean = bquote('[jour]') + unit_break = bquote('[jour]') + } + mat = mat + # Writes the unit of the averaged variable annotate('text', x=Xm_mean[i], y=max(Y) + 0.63, - label=bquote('['*m^3*'.'*s^{-1}*']'), + label=unit_mean, hjust=0.5, vjust=0.5, size=2, color='grey40') + # Writes the type of the averaged variable @@ -904,7 +1000,7 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice # Writes the unit of the breaking variable annotate('text', x=Xr_mean[i], y=max(Y) + 0.63, - label=bquote('[%]'), + label=unit_break, hjust=0.5, vjust=0.5, size=2, color='grey40') + # Writes the type of the breaking variable diff --git a/processing/analyse.R b/processing/analyse.R index 5bcb229c29015c2c72af23cc44a7af30f645912d..b58519d2e35c8dc339bd67e843139e231602b70d 100644 --- a/processing/analyse.R +++ b/processing/analyse.R @@ -97,8 +97,12 @@ get_intercept = function (df_Xtrend, df_Xlist, unit2day=365.25) { ### 1.1. QA # Realise the trend analysis of the average annual flow (QA) # hydrological variable -get_QAtrend = function (df_data, period, p_thresold) { +get_QAtrend = function (df_data, df_meta, period, p_thresold) { + # Removes incomplete data from time series + df_data = remove_incomplete_data(df_data, df_meta, + yearLac_pct=1, yearStart='01-01') + # Make sure to convert the period to a list period = as.list(period) @@ -146,8 +150,15 @@ get_QAtrend = function (df_data, period, p_thresold) { ### 1.2. QMNA # Realise the trend analysis of the monthly minimum flow in the # year (QMNA) hydrological variable -get_QMNAtrend = function (df_data, period, p_thresold) { - +get_QMNAtrend = function (df_data, df_meta, period, p_thresold) { + + # Removes incomplete data from time series + df_data = remove_incomplete_data(df_data, df_meta, + yearLac_pct=1, yearStart='01-01') + # Samples the data + df_data = sampling_data(df_data, df_meta, + sampleSpan=c('05-01', '11-30')) + # Make sure to convert the period to a list period = as.list(period) @@ -210,6 +221,14 @@ get_QMNAtrend = function (df_data, period, p_thresold) { # over the year (VCN10) hydrological variable get_VCN10trend = function (df_data, df_meta, period, p_thresold) { + # Removes incomplete data from time series + df_data = remove_incomplete_data(df_data, df_meta, + yearLac_pct=1, yearStart='01-01') + + # Samples the data + df_data = sampling_data(df_data, df_meta, + sampleSpan=c('05-01', '11-30')) + # Get all different stations code Code = levels(factor(df_meta$code)) # Blank tibble to store the data averaged @@ -286,22 +305,22 @@ get_tINItrend = function (df_data, df_meta, period, p_thresold) { # Gets the number of station nCode = length(Code) - # Blank tibble to store the data averaged - df_data_roll = tibble() - - # For all the code - for (code in Code) { - # Get the data associated to the code - df_data_code = df_data[df_data$code == code,] - # Perform the roll mean of the flow over 10 days - df_data_roll_code = tibble(Date=df_data_code$Date, - Value=rollmean(df_data_code$Value, - 10, - fill=NA), - code=code) - # Store the results - df_data_roll = bind_rows(df_data_roll, df_data_roll_code) - } + # # Blank tibble to store the data averaged + # df_data_roll = tibble() + + # # For all the code + # for (code in Code) { + # # Get the data associated to the code + # df_data_code = df_data[df_data$code == code,] + # # Perform the roll mean of the flow over 10 days + # df_data_roll_code = tibble(Date=df_data_code$Date, + # Value=rollmean(df_data_code$Value, + # 10, + # fill=NA), + # code=code) + # # Store the results + # df_data_roll = bind_rows(df_data_roll, df_data_roll_code) + # } # Make sure to convert the period to a list period = as.list(period) @@ -322,16 +341,46 @@ get_tINItrend = function (df_data, df_meta, period, p_thresold) { code = Code[k] # print(code) + # Get the data associated to the code + df_data_code = df_data[df_data$code == code,] + # Perform the roll mean of the flow over 10 days + df_data_roll_code = tibble(Date=df_data_code$Date, + Value=rollmean(df_data_code$Value, + 10, + fill=NA), + code=code) + per.start = df_meta$start_year[df_meta$code == code] per.start = paste(sprintf("%02d", per.start), '-01', sep='') - - # Get the data associated to the code - df_data_roll_code = df_data_roll[df_data_roll$code == code,] # print('aa') - # Get the data associated to the code - df_data_code = df_data[df_data$code == code,] + # Removes incomplete data from time series + df_data_code = remove_incomplete_data(df_data_code, + df_meta=NULL, + yearLac_pct=1, + yearStart=per.start, + Code=code) + # Samples the data + df_data_code = sampling_data(df_data_code, + df_meta=NULL, + sampleSpan=c('05-01', + '11-30'), + Code=code) + + # Removes incomplete data from the averaged time series + df_data_roll_code = + remove_incomplete_data(df_data_roll_code, + df_meta=NULL, + yearLac_pct=1, + yearStart=per.start, + Code=code) + # Samples the data + df_data_roll_code = sampling_data(df_data_roll_code, + df_meta=NULL, + sampleSpan=c('05-01', + '11-30'), + Code=code) # print('bb') @@ -436,7 +485,7 @@ get_tINItrend = function (df_data, df_meta, period, p_thresold) { # Realises the trend analysis of the date of the minimum 10 day # average flow over the year (VCN10) hydrological variable get_tMIDtrend = function (df_data, df_meta, period, p_thresold) { - + # Get all different stations code Code = levels(factor(df_meta$code)) # Blank tibble to store the data averaged @@ -456,6 +505,14 @@ get_tMIDtrend = function (df_data, df_meta, period, p_thresold) { df_data_roll = bind_rows(df_data_roll, df_data_roll_code) } + # Removes incomplete data from time series + df_data_roll = remove_incomplete_data(df_data_roll, df_meta, + yearLac_pct=1, + yearStart='01-01') + # Samples the data + df_data_roll = sampling_data(df_data_roll, df_meta, + sampleSpan=c('05-01', '11-30')) + # Make sure to convert the period to a list period = as.list(period) # Set the max interval period as the minimal possible @@ -507,27 +564,27 @@ get_tMIDtrend = function (df_data, df_meta, period, p_thresold) { ### 2.1. Hydrograph xref = matrix( c(0.099, 0.100, 0.101, 0.099, 0.088, 0.078, 0.072, - 0.064, 0.064, 0.069, 0.076, 0.089 + 0.064, 0.064, 0.069, 0.076, 0.089, 0.133, 0.126, 0.111, 0.110, 0.081, 0.056, 0.038, - 0.027, 0.042, 0.063, 0.098, 0.117 + 0.027, 0.042, 0.063, 0.098, 0.117, 0.128, 0.142, 0.122, 0.128, 0.105, 0.065, 0.035, - 0.024, 0.031, 0.044, 0.074, 0.101 + 0.024, 0.031, 0.044, 0.074, 0.101, 0.157, 0.130, 0.119, 0.094, 0.062, 0.042, 0.028, - 0.021, 0.035, 0.062, 0.099, 0.150 + 0.021, 0.035, 0.062, 0.099, 0.150, 0.204, 0.163, 0.118, 0.102, 0.060, 0.030, 0.018, - 0.012, 0.023, 0.041, 0.087, 0.143 + 0.012, 0.023, 0.041, 0.087, 0.143, 0.156, 0.154, 0.117, 0.119, 0.086, 0.044, 0.025, - 0.015, 0.025, 0.044, 0.089, 0.127 + 0.015, 0.025, 0.044, 0.089, 0.127, 0.139, 0.092, 0.082, 0.099, 0.087, 0.039, 0.015, - 0.012, 0.036, 0.108, 0.159, 0.131 + 0.012, 0.036, 0.108, 0.159, 0.131, 0.112, 0.098, 0.101, 0.125, 0.122, 0.072, 0.036, - 0.024, 0.039, 0.067, 0.102, 0.102 + 0.024, 0.039, 0.067, 0.102, 0.102, 0.058, 0.050, 0.100, 0.142, 0.158, 0.092, 0.067, - 0.050, 0.042, 0.058, 0.083, 0.100 + 0.050, 0.042, 0.058, 0.083, 0.100, 0.050, 0.050, 0.058, 0.083, 0.150, 0.167, 0.117, - 0.083, 0.058, 0.058, 0.067, 0.058 + 0.083, 0.058, 0.058, 0.067, 0.058, 0.033, 0.025, 0.033, 0.075, 0.167, 0.217, 0.142, - 0.092, 0.067, 0.058, 0.050, 0.042 + 0.092, 0.067, 0.058, 0.050, 0.042, 0.017, 0.008, 0.017, 0.042, 0.108, 0.183, 0.200, 0.175, 0.117, 0.067, 0.042, 0.025), ncol=12, byrow=TRUE) diff --git a/processing/format.R b/processing/format.R index a46934fef19d3fd7853a0602238fb6738f40bb69..911ff7762bb36ea63da5af96e9568c13a54d97df 100644 --- a/processing/format.R +++ b/processing/format.R @@ -33,8 +33,145 @@ library(dplyr) -## 1. INPUT -### 1.1. Preparation +## 1. BEFORE TREND ANALYSE +### 1.1. Joining selection +# Joins tibbles of different selection of station as a unique one +join = function (df_data_AG, df_data_IN, df_meta_AG, df_meta_IN) { + + # If there is an INRAE and an Agence de l'eau Adour-Garonne selection + if (!is.null(df_data_IN) & !is.null(df_data_AG)) { + + # Gets the station in common + common = levels(factor(df_meta_IN[df_meta_IN$code %in% df_meta_AG$code,]$code)) + # Gets the Nv station to add + INadd = levels(factor(df_meta_IN[!(df_meta_IN$code %in% df_meta_AG$code),]$code)) + + # Selects only the IN meta to add + df_meta_INadd = df_meta_IN[df_meta_IN$code %in% INadd,] + + # Names the source of the selection + df_meta_AG$source = 'AG' + df_meta_INadd$source = 'IN' + + # Joins IN data to AG data + df_meta = full_join(df_meta_AG, df_meta_INadd) + + # Selects only the IN data to add + df_data_INadd = df_data_IN[df_data_IN$code %in% INadd,] + # Joins IN meta to AG meta + df_data = full_join(df_data_AG, df_data_INadd) + + # If there is just an Agence de l'eau Adour-Garonne selection + } else if (is.null(df_data_IN) & !is.null(df_data_AG)) { + df_meta_AG$source = 'AG' + df_meta = df_meta_AG + df_data = df_data_AG + + # If there is just an INRAE selection + } else if (!is.null(df_data_IN) & is.null(df_data_AG)) { + df_meta_IN$source = 'IN' + df_meta = df_meta_IN + df_data = df_data_IN + + # If there is no selection + } else { + stop('No data') + } + return (list(data=df_data, meta=df_meta)) +} + +### 1.2. Remove incomplete data +remove_incomplete_data = function (df_data, df_meta, yearLac_pct=1, yearStart='01-01', Code=NULL) { + + if (is.null(Code)) { + # Get all different stations code + Code = levels(factor(df_meta$code)) + nCode = length(Code) + } else { + nCode = length(Code) + } + + for (code in Code) { + # Extracts the data corresponding to the code + df_data_code = df_data[df_data$code == code,] + DateMD = substr(df_data_code$Date, 6, 10) + + idyearStart = which(DateMD == yearStart) + if (DateMD[1] != yearStart) { + idyearStart = c(1, idyearStart) + } + NidyearStart = length(idyearStart) + + for (i in 1:NidyearStart) { + Start = df_data_code$Date[idyearStart[i]] + if (i < NidyearStart) { + End = df_data_code$Date[idyearStart[i+1] - 1] + } else { + End = df_data_code$Date[length(df_data_code$Date)] + } + + OkYear = df_data_code$Date >= Start & df_data_code$Date <= End + df_data_code_year = df_data_code[OkYear,] + + StartReal = as.Date(paste(substr(Start, 1, 4), + yearStart, sep='-')) + EndReal = as.Date(paste(as.numeric(substr(Start, 1, 4)) + 1, + yearStart, sep='-')) + + nbDate = as.numeric(difftime(EndReal, StartReal, + units="days")) + + nbNA = sum(as.numeric(is.na(df_data_code_year$Value))) + nbNA = nbNA + abs(as.numeric(difftime(StartReal, Start, + units="days"))) + nbNA = nbNA + abs(as.numeric(difftime(EndReal, End+1, + units="days"))) + + yearLacMiss_pct = nbNA/nbDate * 100 + + if (yearLacMiss_pct > yearLac_pct) { + df_data_code_year$Value = NA + df_data_code[OkYear,] = df_data_code_year + } + } + df_data[df_data$code == code,] = df_data_code + } + + return (df_data) +} + +### 1.3. Sampling of the data +sampling_data = function (df_data, df_meta, sampleSpan=c('05-01', '11-30'), Code=NULL) { + + if (is.null(Code)) { + # Get all different stations code + Code = levels(factor(df_meta$code)) + nCode = length(Code) + } else { + nCode = length(Code) + } + + sampleStart = as.Date(paste('1970', sampleSpan[1], sep='-')) + sampleEnd = as.Date(paste('1970', sampleSpan[2], sep='-')) + + for (code in Code) { + # Extracts the data corresponding to the code + df_data_code = df_data[df_data$code == code,] + + DateMD = substr(df_data_code$Date, 6, 10) + Date = paste('1970', DateMD, sep='-') + + df_data_code$Value[Date < sampleStart | Date > sampleEnd] = NA + + df_data[df_data$code == code,] = df_data_code + } + + return (df_data) +} + + +## 2. DURING TREND ANALYSE +### 2.1. Preparation # Prepares the data in order to have a list of a data tibble with # date, group and flow column and a info tibble with the station code # and group column to fit the entry of the 'extract.Var' function in @@ -65,7 +202,7 @@ prepare = function(df_data, colnamegroup=NULL) { return (res) } -### 1.2. Re-preparation +### 2.2. Re-preparation # Re-prepares the data in outing of the 'extract.Var' function in # the 'StatsAnalysisTrend' package in order to fit again to the # entry of the same function @@ -106,10 +243,7 @@ reprepare = function(df_XEx, df_Xlist, colnamegroup=NULL) { return (df_XlistEx) } - - - - +### 2.3. Prepare date prepare_date = function(df_XEx, df_Xlist, per.start="01-01") { df_dateStart = summarise(group_by(df_Xlist$data, group), @@ -175,93 +309,8 @@ prepare_date = function(df_XEx, df_Xlist, per.start="01-01") { } - - - - -## 2. OUTPUT -# Cleans the trend results of the function 'Estimate.stats' in the -# 'StatsAnalysisTrend' package. It adds the station code and the -# intercept of the trend to the trend results. Also makes the data -# more presentable. -clean = function (df_Xtrend, df_XEx, df_Xlist) { - - # Reprepares the list of data and info in order to be presentable - df_Xlist = reprepare(df_XEx, df_Xlist, colnamegroup=c('code')) - - # Adds a column of station code - df_Xlist$data$code = NA - # For all the group - for (g in df_Xlist$info$group) { - # Adds the station code corresponding to each group info - df_Xlist$data$code[which(df_Xlist$data$group == g)] = df_Xlist$info$code[df_Xlist$info$group == g] - } - - # Adds the info to trend tibble - df_Xtrend = bind_cols(df_Xtrend, - df_Xlist$info[df_Xtrend$group1, - 2:ncol(df_Xlist$info)]) - # Renames the column of group of trend results - colnames(df_Xtrend)[1] = 'group' - # Adds the intercept value of trend - df_Xtrend = get_intercept(df_Xtrend, df_Xlist, unit2day=365.25) - # Changes the position of the intercept column - df_Xtrend = relocate(df_Xtrend, intercept, .after=trend) - - # Creates a list of results to return - res = list(trend=df_Xtrend, data=df_Xlist$data, info=df_Xlist$info) - return (res) -} - - -## 3. OTHER -### 3.1. Joining selection -# Joins tibbles of different selection of station as a unique one -join = function (df_data_AG, df_data_IN, df_meta_AG, df_meta_IN) { - - # If there is an INRAE and an Agence de l'eau Adour-Garonne selection - if (!is.null(df_data_IN) & !is.null(df_data_AG)) { - - # Gets the station in common - common = levels(factor(df_meta_IN[df_meta_IN$code %in% df_meta_AG$code,]$code)) - # Gets the Nv station to add - INadd = levels(factor(df_meta_IN[!(df_meta_IN$code %in% df_meta_AG$code),]$code)) - - # Selects only the IN meta to add - df_meta_INadd = df_meta_IN[df_meta_IN$code %in% INadd,] - - # Names the source of the selection - df_meta_AG$source = 'AG' - df_meta_INadd$source = 'IN' - - # Joins IN data to AG data - df_meta = full_join(df_meta_AG, df_meta_INadd) - - # Selects only the IN data to add - df_data_INadd = df_data_IN[df_data_IN$code %in% INadd,] - # Joins IN meta to AG meta - df_data = full_join(df_data_AG, df_data_INadd) - - # If there is just an Agence de l'eau Adour-Garonne selection - } else if (is.null(df_data_IN) & !is.null(df_data_AG)) { - df_meta_AG$source = 'AG' - df_meta = df_meta_AG - df_data = df_data_AG - - # If there is just an INRAE selection - } else if (!is.null(df_data_IN) & is.null(df_data_AG)) { - df_meta_IN$source = 'IN' - df_meta = df_meta_IN - df_data = df_data_IN - - # If there is no selection - } else { - stop('No data') - } - return (list(data=df_data, meta=df_meta)) -} - -### 3.2. Period of trend +## 3. AFTER TREND ANALYSE +### 3.1. Period of trend # Compute the start and the end of the period for a trend analysis # according to the accessible data get_period = function (per, df_Xtrend, df_XEx, df_Xlist) { @@ -308,3 +357,38 @@ get_period = function (per, df_Xtrend, df_XEx, df_Xlist) { } return (df_Xtrend) } + +### 3.2. Cleaning +# Cleans the trend results of the function 'Estimate.stats' in the +# 'StatsAnalysisTrend' package. It adds the station code and the +# intercept of the trend to the trend results. Also makes the data +# more presentable. +clean = function (df_Xtrend, df_XEx, df_Xlist) { + + # Reprepares the list of data and info in order to be presentable + df_Xlist = reprepare(df_XEx, df_Xlist, colnamegroup=c('code')) + + # Adds a column of station code + df_Xlist$data$code = NA + # For all the group + for (g in df_Xlist$info$group) { + # Adds the station code corresponding to each group info + df_Xlist$data$code[which(df_Xlist$data$group == g)] = df_Xlist$info$code[df_Xlist$info$group == g] + } + + # Adds the info to trend tibble + df_Xtrend = bind_cols(df_Xtrend, + df_Xlist$info[df_Xtrend$group1, + 2:ncol(df_Xlist$info)]) + # Renames the column of group of trend results + colnames(df_Xtrend)[1] = 'group' + # Adds the intercept value of trend + df_Xtrend = get_intercept(df_Xtrend, df_Xlist, unit2day=365.25) + # Changes the position of the intercept column + df_Xtrend = relocate(df_Xtrend, intercept, .after=trend) + + # Creates a list of results to return + res = list(trend=df_Xtrend, data=df_Xlist$data, info=df_Xlist$info) + return (res) +} + diff --git a/script.R b/script.R index d48b522f4cc6fd8e37c99a6a8ca2b57e8a41f016..ce5eb3868deb231729f75a44187ea614e248fd3e 100644 --- a/script.R +++ b/script.R @@ -55,20 +55,20 @@ filedir = # Name of the file that will be analysed from the BH directory # (if 'all', all the file of the directory will be chosen) filename = - "" + # "" - # c( - # "S2235610_HYDRO_QJM.txt", + c( + # "S2235610_HYDRO_QJM.txt" # "P1712910_HYDRO_QJM.txt", # "P0885010_HYDRO_QJM.txt", # "O5055010_HYDRO_QJM.txt", - # "O0384010_HYDRO_QJM.txt", + "O0384010_HYDRO_QJM.txt" # "S4214010_HYDRO_QJM.txt", - # "Q7002910_HYDRO_QJM.txt", + # "Q7002910_HYDRO_QJM.txt" # "O3035210_HYDRO_QJM.txt", - # "O3121010_HYDRO_QJM.txt" - # "O7635010_HYDRO_QJM.txt" - # ) + # "O3121010_HYDRO_QJM.txt", + # "O0362510_HYDRO_QJM.txt" + ) ## AGENCE EAU ADOUR GARONNE SELECTION @@ -78,8 +78,8 @@ AGlistdir = "" AGlistname = - # "" - "Liste-station_RRSE.docx" + "" + # "Liste-station_RRSE.docx" ## NIVALE SELECTION @@ -179,10 +179,6 @@ if (AGlistname != ""){ # Get filenames of the selection filename = df_selec_AG[df_selec_AG$ok,]$filename - ##### - # filename = filename[(1):(10)] - ##### - # Extract metadata about selected stations df_meta_AG = extract_meta(computer_data_path, filedir, filename) # Extract data about selected stations @@ -200,10 +196,6 @@ if (INlistname != ""){ # Get filenames of the selection filename = df_selec_IN[df_selec_IN$ok,]$filename - ##### - # filename = filename[(1+20):(16+20)] - ##### - # Extract metadata about selected stations df_meta_IN = extract_meta(computer_data_path, filedir, filename) # Extract data about selected stations @@ -233,11 +225,13 @@ df_meta = get_hydrograph(df_data, df_meta, period=mean_period[[1]])$meta ### 3.2. Trend analysis # QA trend -res_QAtrend = get_QAtrend(df_data, period=trend_period, +res_QAtrend = get_QAtrend(df_data, df_meta, + period=trend_period, p_thresold=p_thresold) # QMNA tend -res_QMNAtrend = get_QMNAtrend(df_data, period=trend_period, +res_QMNAtrend = get_QMNAtrend(df_data, df_meta, + period=trend_period, p_thresold=p_thresold) # VCN10 trend @@ -246,10 +240,10 @@ res_VCN10trend = get_VCN10trend(df_data, df_meta, p_thresold=p_thresold) # Start date for low water trend -# res_tINItrend = get_tINItrend(df_data, df_meta, - # period=trend_period, - # p_thresold=p_thresold) -res_tINItrend = read_listofdf(resdir, 'res_tINItrend') +res_tINItrend = get_tINItrend(df_data, df_meta, + period=trend_period, + p_thresold=p_thresold) +# res_tINItrend = read_listofdf(resdir, 'res_tINItrend') # Center date for low water trend res_tMIDtrend = get_tMIDtrend(df_data, df_meta, @@ -274,7 +268,7 @@ df_shapefile = ini_shapefile(computer_data_path, fr_shpdir, fr_shpname, bs_shpdir, bs_shpname, sbs_shpdir, sbs_shpname, - rv_shpdir, rv_shpname, riv=TRUE) + rv_shpdir, rv_shpname, riv=FALSE) ### 4.1. Simple time panel to criticize station data # Plot time panel of debit by stations @@ -291,9 +285,9 @@ df_shapefile = ini_shapefile(computer_data_path, ### 4.2. Analysis layout datasheet_layout(toplot=c( - 'datasheet', - 'matrix', - 'map' + 'datasheet' + # 'matrix', + # 'map' ), df_meta=df_meta, @@ -315,11 +309,11 @@ datasheet_layout(toplot=c( 'tINI', 'tMID'), - type=list('flow', - 'flow', - 'flow', - 'date', - 'date'), + type=list('sévérité', + 'sévérité', + 'sévérité', + 'saisonnalité', + 'saisonnalité'), layout_matrix=matrix(c(1, 2, 3, 4, 5), ncol=1),