Commit d145aeed authored by Heraut Louis's avatar Heraut Louis
Browse files

Plot for all station for 3 variables

parent a483e81d
No related merge requests found
Showing with 46 additions and 43 deletions
+46 -43
......@@ -9,7 +9,7 @@ library(grid)
# Time panel
panel = function (df_data, df_meta, figdir, filedir_opt='', filename_opt='', variable='', df_trend=NULL, p_threshold=0.1, unit2day=365.25, is_sqrt=FALSE, missRect=FALSE) {
panel = function (df_data, df_meta, figdir, filedir_opt='', filename_opt='', variable='', df_trend=NULL, p_threshold=0.1, unit2day=365.25, type='', missRect=FALSE) {
if (all(class(df_data) != 'list')) {
df_data = list(df_data)
......@@ -34,11 +34,11 @@ panel = function (df_data, df_meta, figdir, filedir_opt='', filename_opt='', var
if (length(unit2day) == 1) {
unit2day = replicate(nbp, unit2day)
}}
if (all(class(is_sqrt) != 'list')) {
is_sqrt = list(is_sqrt)
if (length(is_sqrt) == 1) {
is_sqrt = replicate(nbp, is_sqrt)
if (all(class(type) != 'list')) {
type = list(type)
if (length(type) == 1) {
type = replicate(nbp, type)
}}
if (all(class(missRect) != 'list')) {
......@@ -52,7 +52,6 @@ panel = function (df_data, df_meta, figdir, filedir_opt='', filename_opt='', var
# print(p_threshold)
# print(unit2day)
# print(missRect)
# print(is_sqrt)
list_df2plot = vector(mode='list', length=nbp)
......@@ -62,8 +61,8 @@ panel = function (df_data, df_meta, figdir, filedir_opt='', filename_opt='', var
trend=df_trend[[i]],
p_threshold=p_threshold[[i]],
unit2day=unit2day[[i]],
missRect=missRect[[i]],
is_sqrt=is_sqrt[[i]])
type=type[[i]],
missRect=missRect[[i]])
list_df2plot[[i]] = df2plot
}
......@@ -96,6 +95,7 @@ panel = function (df_data, df_meta, figdir, filedir_opt='', filename_opt='', var
print(paste("Plotting for sation :", code))
P = vector(mode='list', length=nbp)
# P = as.list(rep(void, nbp))
# print(nbp)
# print(P)
......@@ -105,7 +105,7 @@ panel = function (df_data, df_meta, figdir, filedir_opt='', filename_opt='', var
p_threshold = list_df2plot[[i]]$p_threshold
unit2day = list_df2plot[[i]]$unit2day
missRect = list_df2plot[[i]]$missRect
is_sqrt = list_df2plot[[i]]$is_sqrt
type = list_df2plot[[i]]$type
# print(list_df2plot)
......@@ -114,10 +114,9 @@ panel = function (df_data, df_meta, figdir, filedir_opt='', filename_opt='', var
# print(p_threshold)
# print(unit2day)
# print(missRect)
# print(is_sqrt)
p = time_panel(code, df_data, df_trend, missRect,
p_threshold, unit2day, is_sqrt)
p_threshold, unit2day, type)
P[[i]] = p
......@@ -126,7 +125,13 @@ panel = function (df_data, df_meta, figdir, filedir_opt='', filename_opt='', var
gtext = text_panel(code, df_meta)
plot = grid.arrange(gtext, P[[1]], P[[2]], void, ncol=1, nrow=4, heights=c(1/7, 2/7, 2/7, 2/7))
plot = grid.arrange(gtext, P[[1]], P[[2]], P[[3]], P[[4]],
heights=c(1/8, 1/8, 2/8, 2/8, 2/8),
ncol=1, nrow=5)
# plot = grid.arrange(gtext, P[[1]], void, void, void,
# heights=c(1/7, 3/7, 1/7, 1/7, 1/7),
# ncol=1, nrow=5)
# Saving
ggsave(plot=plot,
......@@ -146,9 +151,9 @@ panel = function (df_data, df_meta, figdir, filedir_opt='', filename_opt='', var
time_panel = function (code, df_data, df_trend, missRect, p_threshold, unit2day, is_sqrt) {
time_panel = function (code, df_data, df_trend, missRect, p_threshold, unit2day, type) {
if (is_sqrt) {
if (type == 'sqrt') {
df_data[, 'Qm3s'] = apply(df_data[, 'Qm3s'], 1, sqrt)
}
......@@ -205,7 +210,7 @@ time_panel = function (code, df_data, df_trend, missRect, p_threshold, unit2day,
max(df_data_code$Date)),
expand=c(0, 0))
if (is_sqrt) {
if (type == 'sqrt') {
p = p +
scale_y_continuous(breaks=seq(0, 100, 10),
minor_breaks=seq(0, 100, 5),
......@@ -213,7 +218,7 @@ time_panel = function (code, df_data, df_trend, missRect, p_threshold, unit2day,
max(df_data_code$Qm3s,
na.rm=TRUE)*1.1),
expand=c(0, 0))
} else {
} else if (type == 'time') {
p = p +
scale_y_continuous(breaks=seq(0, 10000, 1000),
minor_breaks=seq(0, 10000, 500),
......@@ -221,6 +226,12 @@ time_panel = function (code, df_data, df_trend, missRect, p_threshold, unit2day,
max(df_data_code$Qm3s,
na.rm=TRUE)*1.1),
expand=c(0, 0))
} else {
p = p +
scale_y_continuous(limits=c(0,
max(df_data_code$Qm3s,
na.rm=TRUE)*1.1),
expand=c(0, 0))
}
p = p +
......
......@@ -138,40 +138,32 @@ df_data = df_join$data
df_meta = df_join$meta
# TIME PANEL #
# Plot time panel of debit by stations
panel(list(df_data, df_data),
df_meta=df_meta,
figdir=figdir,
missRect=list(TRUE, TRUE),
is_sqrt=list(FALSE, TRUE))
# panel(df_data, df_meta=df_meta, figdir=figdir, missRect=TRUE, is_sqrt=TRUE)
### /!\ Removed 185 row(s) containing missing values (geom_path) -> remove NA ###
# ANALYSE #
# Compute gap parameters for stations
# df_lac = get_lacune(df_data, df_meta)
# QA TREND #
# res_QAtrend = get_QAtrend(df_data, period)
# panel(df_data=res_QAtrend$data,
# df_meta=df_meta,
# df_trend=res_QAtrend$trend,
# p_threshold=0.1,
# figdir=figdir, filedir_opt='QA', variable='QA')
res_QAtrend = get_QAtrend(df_data, period)
# QMNA TREND #
# res_QMNAtrend = get_QMNAtrend(df_data, period)
# VCN10 TREND #
# res_VCN10trend = get_VCN10trend(df_data, df_meta, period)
# panel(df_data=res_VCN10trend$data,
# df_meta=df_meta,
# df_trend=res_VCN10trend$trend,
# figdir=figdir, filedir="VCN10")
res_VCN10trend = get_VCN10trend(df_data, df_meta, period)
# TIME PANEL #
# Plot time panel of debit by stations
panel(list(df_data, res_QAtrend$data, res_QMNAtrend$data,
res_VCN10trend$data),
df_meta=df_meta,
figdir=figdir,
df_trend=list(NULL, res_QAtrend$trend, res_QMNAtrend$trend,
res_VCN10trend$trend),
type=list('time', '', '', ''),
missRect=list(TRUE, TRUE, TRUE, TRUE),
)
# panel(df_data, df_meta=df_meta, figdir=figdir, missRect=TRUE, type='sqrt')
### /!\ Removed 185 row(s) containing missing values (geom_path) -> remove NA ###
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment