Commit 4c4526a0 authored by Heraut Louis's avatar Heraut Louis
Browse files

Aes layout

parent 2a0f173b
No related merge requests found
Showing with 180 additions and 180 deletions
+180 -180
...@@ -14,7 +14,7 @@ library(RColorBrewer) ...@@ -14,7 +14,7 @@ library(RColorBrewer)
source('plotting/panel.R', encoding='latin1') source('plotting/panel.R', encoding='latin1')
panels_layout = function (df_data, df_meta, layout_matrix, isplot=c('datasheet', 'matrix', 'map'), figdir='', filedir_opt='', filename_opt='', variable='', df_trend=NULL, p_threshold=0.1, unit2day=365.25, type='', trend_period=NULL, mean_period=NULL, axis_xlim=NULL, missRect=FALSE, time_header=NULL, info_header=TRUE, info_ratio=1, time_ratio=2, var_ratio=3, fr_shpdir=NULL, fr_shpname=NULL, bs_shpdir=NULL, bs_shpname=NULL, rv_shpdir=NULL, rv_shpname=NULL, computer_data_path=NULL) { panels_layout = function (df_data, df_meta, layout_matrix, isplot=c('datasheet', 'matrix', 'map'), figdir='', filedir_opt='', filename_opt='', variable='', df_trend=NULL, p_threshold=0.1, unit2day=365.25, type='', trend_period=NULL, mean_period=NULL, axis_xlim=NULL, missRect=FALSE, time_header=NULL, info_header=TRUE, info_ratio=1, time_ratio=2, var_ratio=3, df_shapefile=NULL) {
outfile = "Panels" outfile = "Panels"
if (filename_opt != '') { if (filename_opt != '') {
...@@ -195,7 +195,11 @@ panels_layout = function (df_data, df_meta, layout_matrix, isplot=c('datasheet', ...@@ -195,7 +195,11 @@ panels_layout = function (df_data, df_meta, layout_matrix, isplot=c('datasheet',
dataMean = mean(df_data_code_per$Qm3s, na.rm=TRUE) dataMean = mean(df_data_code_per$Qm3s, na.rm=TRUE)
trendMean = df_trend_code_per$trend / dataMean trendMean = df_trend_code_per$trend / dataMean
TrendMean_code[j, i, k] = trendMean if (df_trend_code_per$p <= p_threshold){
TrendMean_code[j, i, k] = trendMean
} else {
TrendMean_code[j, i, k] = NA
}
} }
} }
} }
...@@ -218,16 +222,11 @@ panels_layout = function (df_data, df_meta, layout_matrix, isplot=c('datasheet', ...@@ -218,16 +222,11 @@ panels_layout = function (df_data, df_meta, layout_matrix, isplot=c('datasheet',
Hinfo = info_panel(list_df2plot, Hinfo = info_panel(list_df2plot,
df_meta, df_meta,
computer_data_path=computer_data_path, df_shapefile=df_shapefile,
fr_shpdir=fr_shpdir,
fr_shpname=fr_shpname,
bs_shpdir=bs_shpdir,
bs_shpname=bs_shpname,
rv_shpdir=rv_shpdir,
rv_shpname=rv_shpname,
codeLight=code, codeLight=code,
df_data_code=time_header_code) df_data_code=time_header_code)
P[[1]] = Hinfo P[[1]] = Hinfo
# P[[1]] = void
} }
if (!is.null(time_header)) { if (!is.null(time_header)) {
...@@ -401,13 +400,7 @@ panels_layout = function (df_data, df_meta, layout_matrix, isplot=c('datasheet', ...@@ -401,13 +400,7 @@ panels_layout = function (df_data, df_meta, layout_matrix, isplot=c('datasheet',
map_panel(list_df2plot, map_panel(list_df2plot,
df_meta, df_meta,
idPer=length(trend_period), idPer=length(trend_period),
computer_data_path=computer_data_path, df_shapefile=df_shapefile,
fr_shpdir=fr_shpdir,
fr_shpname=fr_shpname,
bs_shpdir=bs_shpdir,
bs_shpname=bs_shpname,
rv_shpdir=rv_shpdir,
rv_shpname=rv_shpname,
outdirTmp=outdirTmp, outdirTmp=outdirTmp,
margin=margin(t=5, r=0, b=5, l=5, unit="mm")) margin=margin(t=5, r=0, b=5, l=5, unit="mm"))
} }
......
This diff is collapsed.
...@@ -161,18 +161,18 @@ get_selection_AG = function (computer_data_path, listdir, listname, ...@@ -161,18 +161,18 @@ get_selection_AG = function (computer_data_path, listdir, listname,
} }
# Example # Example
df_selec_AG = get_selection_AG( # df_selec_AG = get_selection_AG(
"/home/louis/Documents/bouleau/INRAE/CDD_stationnarite/data", # "/home/louis/Documents/bouleau/INRAE/CDD_stationnarite/data",
"", # "",
"Liste-station_RRSE.docx", # "Liste-station_RRSE.docx",
cnames=c('code','station', # cnames=c('code','station',
'BV_km2', # 'BV_km2',
'axe_principal_concerne', # 'axe_principal_concerne',
'longueur_serie', # 'longueur_serie',
'commentaires', # 'commentaires',
'choix'), # 'choix'),
c_num=c('BV_km2', # c_num=c('BV_km2',
'longueur_serie')) # 'longueur_serie'))
get_selection_NV = function (computer_data_path, listdir, listname) { get_selection_NV = function (computer_data_path, listdir, listname) {
...@@ -410,3 +410,34 @@ extract_data = function (computer_data_path, filedir, filename, verbose=TRUE) { ...@@ -410,3 +410,34 @@ extract_data = function (computer_data_path, filedir, filename, verbose=TRUE) {
# "/home/louis/Documents/bouleau/INRAE/CDD_stationnarite/data", # "/home/louis/Documents/bouleau/INRAE/CDD_stationnarite/data",
# '', # '',
# c('H5920011_HYDRO_QJM.txt', 'K4470010_HYDRO_QJM.txt')) # c('H5920011_HYDRO_QJM.txt', 'K4470010_HYDRO_QJM.txt'))
ini_shapefile = function (computer_data_path, fr_shpdir, fr_shpname, bs_shpdir, bs_shpname, rv_shpdir, rv_shpname, riv=TRUE) {
# Path for shapefile
fr_shppath = file.path(computer_data_path, fr_shpdir, fr_shpname)
bs_shppath = file.path(computer_data_path, bs_shpdir, bs_shpname)
rv_shppath = file.path(computer_data_path, rv_shpdir, rv_shpname)
# France
fr_spdf = readOGR(dsn=fr_shppath, verbose=FALSE)
proj4string(fr_spdf) = CRS("+proj=longlat +ellps=WGS84")
# Transformation in Lambert93
france = spTransform(fr_spdf, CRS("+init=epsg:2154"))
df_france = tibble(fortify(france))
# Bassin hydrographique
bassin = readOGR(dsn=bs_shppath, verbose=FALSE)
df_bassin = tibble(fortify(bassin))
if (riv) {
# Rseau hydrographique
river = readOGR(dsn=rv_shppath, verbose=FALSE) ### trop long ###
river = river[which(river$Classe == 1),]
df_river = tibble(fortify(river))
} else {
df_river = NULL
}
return (list(france=df_france, bassin=df_bassin, river=df_river))
}
...@@ -22,7 +22,7 @@ filedir = ...@@ -22,7 +22,7 @@ filedir =
### MANUAL SELECTION ### ### MANUAL SELECTION ###
# Name of the file that will be analysed from the AG directory # Name of the file that will be analysed from the AG directory
filename = filename =
"" # ""
# c( # c(
# "S2235610_HYDRO_QJM.txt", # "S2235610_HYDRO_QJM.txt",
...@@ -32,9 +32,9 @@ filename = ...@@ -32,9 +32,9 @@ filename =
# "Q7002910_HYDRO_QJM.txt" # "Q7002910_HYDRO_QJM.txt"
# ) # )
# c("S4214010_HYDRO_QJM.txt", c("S4214010_HYDRO_QJM.txt",
# "O0384010_HYDRO_QJM.txt", "O0384010_HYDRO_QJM.txt",
# "Q7002910_HYDRO_QJM.txt") "Q7002910_HYDRO_QJM.txt")
...@@ -44,8 +44,8 @@ AGlistdir = ...@@ -44,8 +44,8 @@ AGlistdir =
"" ""
AGlistname = AGlistname =
# "" ""
"Liste-station_RRSE.docx" # "Liste-station_RRSE.docx"
### NIVALE SELECTION ### ### NIVALE SELECTION ###
...@@ -142,7 +142,7 @@ if (AGlistname != ""){ ...@@ -142,7 +142,7 @@ if (AGlistname != ""){
filename = df_selec_AG[df_selec_AG$ok,]$filename filename = df_selec_AG[df_selec_AG$ok,]$filename
##### #####
filename = filename[(1):(20)] # filename = filename[(1):(25)]
##### #####
# Extract metadata about selected stations # Extract metadata about selected stations
...@@ -234,14 +234,22 @@ res_VCN10trend = get_VCN10trend(df_data, df_meta, ...@@ -234,14 +234,22 @@ res_VCN10trend = get_VCN10trend(df_data, df_meta,
# figdir=figdir, # figdir=figdir,
# filename_opt='time') # filename_opt='time')
panels_layout(isplot=c('datasheet', 'matrix', 'map'),
# df_shapefile = ini_shapefile(computer_data_path, fr_shpdir, fr_shpname, bs_shpdir, bs_shpname, rv_shpdir, rv_shpname, riv=FALSE)
panels_layout(isplot=c(
'datasheet'
# 'matrix'
# 'map'
),
df_data=list(res_QAtrend$data, res_QMNAtrend$data, df_data=list(res_QAtrend$data, res_QMNAtrend$data,
res_VCN10trend$data), res_VCN10trend$data),
layout_matrix=c(1, 2, 3), layout_matrix=c(1, 2, 3),
df_meta=df_meta, df_meta=df_meta,
df_trend=list(res_QAtrend$trend, res_QMNAtrend$trend, df_trend=list(res_QAtrend$trend, res_QMNAtrend$trend,
res_VCN10trend$trend), res_VCN10trend$trend),
type=list(bquote(Q[A]), bquote(Q[MNA]), bquote(V[CN10])), type=list('QA', 'QMNA', 'VCN10'),
missRect=list(TRUE, TRUE, TRUE), missRect=list(TRUE, TRUE, TRUE),
trend_period=trend_period, trend_period=trend_period,
mean_period=mean_period, mean_period=mean_period,
...@@ -250,26 +258,7 @@ panels_layout(isplot=c('datasheet', 'matrix', 'map'), ...@@ -250,26 +258,7 @@ panels_layout(isplot=c('datasheet', 'matrix', 'map'),
info_ratio=2, info_ratio=2,
time_ratio=2, time_ratio=2,
var_ratio=3, var_ratio=3,
computer_data_path=computer_data_path, df_shapefile=df_shapefile,
fr_shpdir=fr_shpdir,
fr_shpname=fr_shpname,
bs_shpdir=bs_shpdir,
bs_shpname=bs_shpname,
rv_shpdir=rv_shpdir,
rv_shpname=rv_shpname,
figdir=figdir, figdir=figdir,
filename_opt='') filename_opt='')
# map_panel(computer_data_path,
# fr_shpdir, fr_shpname,
# bs_shpdir, bs_shpname,
# rv_shpdir, rv_s hpname)
### /!\ Removed 185 row(s) containing missing values (geom_path) -> remove NA ###
...@@ -14,6 +14,8 @@ install.packages('ggh4x') ...@@ -14,6 +14,8 @@ install.packages('ggh4x')
install.packages('extrafont') install.packages('extrafont')
install.packages("RColorBrewer") install.packages("RColorBrewer")
install.packages('trend') install.packages('trend')
install.packages("shadowtext")
# linux # linux
# sudo apt-get install gdal-bin proj-bin libgdal-dev libproj-dev # sudo apt-get install gdal-bin proj-bin libgdal-dev libproj-dev
...@@ -28,7 +30,7 @@ install_github("https://github.com/benRenard/BFunk") #type '1' ...@@ -28,7 +30,7 @@ install_github("https://github.com/benRenard/BFunk") #type '1'
# install_git("git@gitlab-ssh.irstea.fr:valentin.mansanarez/statistical-analysis-of-trends.git") # SSH # install_git("git@gitlab-ssh.irstea.fr:valentin.mansanarez/statistical-analysis-of-trends.git") # SSH
install_git("https://gitlab.irstea.fr/valentin.mansanarez/statistical-analysis-of-trends.git") install_git("https://gitlab.irstea.fr/valentin.mansanarez/statistical-analysis-of-trends.git")
# + shapefile
......
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