diff --git a/plotting/datasheet.R b/plotting/datasheet.R index 0cc1f5ede05c6c54ec2851818fea37e49db79ea8..2c7c284cfb0f2b3da38e81b700961ae77530759b 100644 --- a/plotting/datasheet.R +++ b/plotting/datasheet.R @@ -34,7 +34,7 @@ source('processing/analyse.R', encoding='UTF-8') # Manages datasheets creations for all stations. Makes the call to # the different headers, trend analysis graphs and realises arranging # every plots. -datasheet_panel = function (list_df2plot, df_meta, trend_period, info_header, time_header, foot_note, layout_matrix, info_ratio, time_ratio, var_ratio, foot_height, resources_path, AEAGlogo_file, INRAElogo_file, FRlogo_file, outdirTmp, df_page=NULL) { +datasheet_panel = function (list_df2plot, df_meta, trend_period, info_header, time_header, foot_note, layout_matrix, info_ratio, time_ratio, var_ratio, foot_height, resources_path, logo_dir, AEAGlogo_file, INRAElogo_file, FRlogo_file, outdirTmp, df_page=NULL) { # The percentage of augmentation and diminution of the min # and max limits for y axis @@ -450,6 +450,7 @@ datasheet_panel = function (list_df2plot, df_meta, trend_period, info_header, ti } foot = foot_panel(footName, n_page, resources_path, + logo_dir, AEAGlogo_file, INRAElogo_file, FRlogo_file, foot_height) P[[nbg]] = foot diff --git a/plotting/layout.R b/plotting/layout.R index ec53ea93d97ba5f8ac6167fb4a6e59bc2c002885..9b36075641441d7f21305d7c62701e098e5c98e1 100644 --- a/plotting/layout.R +++ b/plotting/layout.R @@ -138,7 +138,7 @@ datasheet_layout = function (df_data, df_meta, layout_matrix, figdir='', filedir_opt='', filename_opt='', variable='', df_trend=NULL, alpha=0.1, unit2day=365.25, var='', - type='', trend_period=NULL, + type='', glose='', trend_period=NULL, mean_period=NULL, axis_xlim=NULL, missRect=FALSE, time_header=NULL, info_header=TRUE, foot_note=FALSE, @@ -146,6 +146,7 @@ datasheet_layout = function (df_data, df_meta, layout_matrix, var_ratio=3, foot_height=1, df_shapefile=NULL, resources_path=NULL, + logo_dir=NULL, AEAGlogo_file=NULL, INRAElogo_file=NULL, FRlogo_file=NULL) { @@ -249,11 +250,13 @@ datasheet_layout = function (df_data, df_meta, layout_matrix, df_page = map_panel(list_df2plot, df_meta, idPer_trend=length(trend_period), + trend_period=trend_period, mean_period=mean_period, df_shapefile=df_shapefile, foot_note=foot_note, foot_height=foot_height, resources_path=resources_path, + logo_dir=logo_dir, AEAGlogo_file=AEAGlogo_file, INRAElogo_file=INRAElogo_file, FRlogo_file=FRlogo_file, @@ -273,6 +276,7 @@ datasheet_layout = function (df_data, df_meta, layout_matrix, foot_note=foot_note, foot_height=foot_height, resources_path=resources_path, + logo_dir=logo_dir, AEAGlogo_file=AEAGlogo_file, INRAElogo_file=INRAElogo_file, FRlogo_file=FRlogo_file, @@ -293,6 +297,7 @@ datasheet_layout = function (df_data, df_meta, layout_matrix, var_ratio=var_ratio, foot_height=foot_height, resources_path=resources_path, + logo_dir=logo_dir, AEAGlogo_file=AEAGlogo_file, INRAElogo_file=INRAElogo_file, FRlogo_file=FRlogo_file, @@ -304,6 +309,7 @@ datasheet_layout = function (df_data, df_meta, layout_matrix, foot_note, foot_height, resources_path, + logo_dir=logo_dir, AEAGlogo_file, INRAElogo_file, FRlogo_file, @@ -487,7 +493,7 @@ palette_tester = function (n=256) { ### Summary panel -summary_panel = function (df_page, foot_note, foot_height, resources_path, AEAGlogo_file, INRAElogo_file, FRlogo_file, outdirTmp) { +summary_panel = function (df_page, foot_note, foot_height, resources_path, logo_dir, AEAGlogo_file, INRAElogo_file, FRlogo_file, outdirTmp) { text_title = paste( "<b>Analyse de Stationnarité Hydrologique</b>", @@ -611,6 +617,7 @@ summary_panel = function (df_page, foot_note, foot_height, resources_path, AEAGl footName = 'sommaire' foot = foot_panel(footName, 1, resources_path, + logo_dir, AEAGlogo_file, INRAElogo_file, FRlogo_file, foot_height) @@ -678,7 +685,7 @@ summary_panel = function (df_page, foot_note, foot_height, resources_path, AEAGl ### Foot note panel -foot_panel = function (name, n_page, resources_path, AEAGlogo_file, INRAElogo_file, FRlogo_file, foot_height) { +foot_panel = function (name, n_page, resources_path, logo_dir, AEAGlogo_file, INRAElogo_file, FRlogo_file, foot_height) { text_page = paste( name, " <b>p. ", n_page, "</b>", @@ -701,9 +708,9 @@ foot_panel = function (name, n_page, resources_path, AEAGlogo_file, INRAElogo_fi hjust=1, vjust=0.5, gp=gpar(col="#00A3A8", fontsize=6)) - AEAGlogo_path = file.path(resources_path, AEAGlogo_file) - INRAElogo_path = file.path(resources_path, INRAElogo_file) - FRlogo_path = file.path(resources_path, FRlogo_file) + AEAGlogo_path = file.path(resources_path, logo_dir, AEAGlogo_file) + INRAElogo_path = file.path(resources_path, logo_dir, INRAElogo_file) + FRlogo_path = file.path(resources_path, logo_dir, FRlogo_file) AEAGlogo_img = readPNG(AEAGlogo_path) AEAGlogo_grob = rasterGrob(AEAGlogo_img, diff --git a/plotting/map.R b/plotting/map.R index 5f6ede5dfda8aa7536e6d8852a7cba87431aae36..603ea24d01955f96de816e5e24323995ed441f69 100644 --- a/plotting/map.R +++ b/plotting/map.R @@ -29,10 +29,12 @@ ## 1. MAP PANEL # Generates a map plot of the tendancy of a hydrological variable map_panel = function (list_df2plot, df_meta, df_shapefile, idPer_trend=1, + trend_period=NULL, mean_period=NULL, outdirTmp='', codeLight=NULL, margin=NULL, showSea=TRUE, foot_note=FALSE, foot_height=0, resources_path=NULL, + logo_dir=NULL, AEAGlogo_file=NULL, INRAElogo_file=NULL, FRlogo_file=NULL, df_page=NULL, verbose=TRUE) { @@ -742,23 +744,30 @@ map_panel = function (list_df2plot, df_meta, df_shapefile, idPer_trend=1, shape=21, size=5, stroke=1, color='white', fill=colTick) + periodName = paste( + format(as.Date(trend_period[[idPer_trend]][1]), + '%Y'), + format(as.Date(trend_period[[idPer_trend]][2]), + '%Y'), + sep='-') + if (j > 1) { ValueName = "Écarts observés" # If it is a flow variable if (type == 'sévérité') { - unit = bquote(bold("(%)")) + unit = bquote(.(periodName)~~bold("(%)")) # If it is a date variable } else if (type == 'saisonnalité') { - unit = bquote(bold("(jour)")) + unit = bquote(.(periodName)~~bold("(jour)")) } } else { ValueName = "Tendances observées" # If it is a flow variable if (type == 'sévérité') { - unit = bquote(bold("(% par an)")) + unit = bquote(.(periodName)~~bold("(% par an)")) # If it is a date variable } else if (type == 'saisonnalité') { - unit = bquote(bold("(jour par an)")) + unit = bquote(.(periodName)~~bold("(jour par an)")) } } @@ -771,7 +780,7 @@ map_panel = function (list_df2plot, df_meta, df_shapefile, idPer_trend=1, size=6, color='grey40') + # Unit legend of the colorbar annotate('text', - x=-0.2, y= valNorm + 13, + x=-0.3, y= valNorm + 12, label=unit, hjust=0, vjust=0.5, size=4, color='grey40') @@ -963,6 +972,7 @@ map_panel = function (list_df2plot, df_meta, df_shapefile, idPer_trend=1, foot = foot_panel(footName, n_page, resources_path, + logo_dir, AEAGlogo_file, INRAElogo_file, FRlogo_file, foot_height) diff --git a/plotting/matrix.R b/plotting/matrix.R index 189ea3775595d4b245940043e40519bc0a84a453..d15d26d5572a973bc4470929b27a9d176c9cb968 100644 --- a/plotting/matrix.R +++ b/plotting/matrix.R @@ -31,6 +31,7 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice=NULL, outdirTmp='', outnameTmp='matrix', title=NULL, A3=FALSE, foot_note=FALSE, foot_height=0, resources_path=NULL, + logo_dir=NULL, AEAGlogo_file=NULL, INRAElogo_file=NULL, FRlogo_file=NULL, df_page=NULL) { @@ -1164,6 +1165,7 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice foot = foot_panel(footName, n_page, resources_path, + logo_dir, AEAGlogo_file, INRAElogo_file, FRlogo_file, foot_height) diff --git a/processing/extract.R b/processing/extract.R index aac50b48f9d6d5deaf167919361989a6781e5b15..07cb39fa816cec0ad3d2988d4290e59fb8a68ffe 100644 --- a/processing/extract.R +++ b/processing/extract.R @@ -477,13 +477,13 @@ extract_data = function (computer_data_path, filedir, filename, ## 4. SHAPEFILE MANAGEMENT # Generates a list of shapefiles to draw a hydrological map of # the France -ini_shapefile = function (computer_data_path, fr_shpdir, fr_shpname, bs_shpdir, bs_shpname, sbs_shpdir, sbs_shpname, rv_shpdir, rv_shpname, is_river=TRUE) { +ini_shapefile = function (resources_path, fr_shpdir, fr_shpname, bs_shpdir, bs_shpname, sbs_shpdir, sbs_shpname, rv_shpdir, rv_shpname, is_river=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) - sbs_shppath = file.path(computer_data_path, sbs_shpdir, sbs_shpname) - rv_shppath = file.path(computer_data_path, rv_shpdir, rv_shpname) + fr_shppath = file.path(resources_path, fr_shpdir, fr_shpname) + bs_shppath = file.path(resources_path, bs_shpdir, bs_shpname) + sbs_shppath = file.path(resources_path, sbs_shpdir, sbs_shpname) + rv_shppath = file.path(resources_path, rv_shpdir, rv_shpname) # France fr_spdf = readOGR(dsn=fr_shppath, verbose=FALSE) diff --git a/resources/Logo-INRAE_Transparent.png b/resources/Logo-INRAE_Transparent.png deleted file mode 100644 index 0cd93142e9ad2127cf167eac4acf97afed6be74b..0000000000000000000000000000000000000000 Binary files a/resources/Logo-INRAE_Transparent.png and /dev/null differ diff --git a/resources/Republique_Francaise_RVB.png b/resources/Republique_Francaise_RVB.png deleted file mode 100644 index 668b03d3b93ff589a7dc375e59c8d084a896e3d0..0000000000000000000000000000000000000000 Binary files a/resources/Republique_Francaise_RVB.png and /dev/null differ diff --git a/resources/agence-de-leau-adour-garonne_logo.png b/resources/agence-de-leau-adour-garonne_logo.png deleted file mode 100644 index f6df308202f2a77c0ca6b66264a893687a90a54c..0000000000000000000000000000000000000000 Binary files a/resources/agence-de-leau-adour-garonne_logo.png and /dev/null differ diff --git a/script.R b/script.R index b049e48badc65443583ac29ef1fb7b91c57f939b..d9952242776c3ec4f44b051e5151cb5a64aebbf9 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( + # "" + c( # "S2235610_HYDRO_QJM.txt", # "P1712910_HYDRO_QJM.txt", # "P0885010_HYDRO_QJM.txt", # "O5055010_HYDRO_QJM.txt", # "O0384010_HYDRO_QJM.txt", # "S4214010_HYDRO_QJM.txt", - # "Q7002910_HYDRO_QJM.txt" + "Q7002910_HYDRO_QJM.txt" # "Q0214010_HYDRO_QJM.txt" # "O3035210_HYDRO_QJM.txt" # "O0554010_HYDRO_QJM.txt", # "O1584610_HYDRO_QJM.txt" - # ) + ) ## AGENCE EAU ADOUR GARONNE SELECTION @@ -78,8 +78,8 @@ AGlistdir = "" AGlistname = - # "" - "Liste-station_RRSE.docx" + "" + # "Liste-station_RRSE.docx" ## NIVALE SELECTION @@ -115,23 +115,8 @@ sampleSpan = c('05-01', '11-30') ## MAP # Is the hydrological network needs to be plot -is_river = TRUE - -# Path to the shapefile for france contour from 'computer_data_path' -fr_shpdir = 'map/france' -fr_shpname = 'gadm36_FRA_0.shp' - -# Path to the shapefile for basin shape from 'computer_data_path' -bs_shpdir = 'map/bassin' -bs_shpname = 'BassinHydrographique.shp' +is_river = FALSE -# Path to the shapefile for sub-basin shape from 'computer_data_path' -sbs_shpdir = 'map/sous_bassin' -sbs_shpname = 'SousBassinHydrographique.shp' - -# Path to the shapefile for river shape from 'computer_data_path' -rv_shpdir = 'map/river' -rv_shpname = 'CoursEau_FXX.shp' ############### END OF REGION TO MODIFY (without risk) ############### @@ -168,10 +153,27 @@ if (!(file.exists(resources_path))) { print(paste('resources_path :', resources_path)) # Logo filename +logo_dir = 'logo' AEAGlogo_file = 'agence-de-leau-adour-garonne_logo.png' INRAElogo_file = 'Logo-INRAE_Transparent.png' FRlogo_file = 'Republique_Francaise_RVB.png' +# Path to the shapefile for france contour from 'computer_data_path' +fr_shpdir = 'map/france' +fr_shpname = 'gadm36_FRA_0.shp' + +# Path to the shapefile for basin shape from 'computer_data_path' +bs_shpdir = 'map/bassin' +bs_shpname = 'BassinHydrographique.shp' + +# Path to the shapefile for sub-basin shape from 'computer_data_path' +sbs_shpdir = 'map/sous_bassin' +sbs_shpname = 'SousBassinHydrographique.shp' + +# Path to the shapefile for river shape from 'computer_data_path' +rv_shpdir = 'map/river' +rv_shpname = 'CoursEau_FXX.shp' + ## 2. SELECTION OF STATION # Initialization of null data frame if there is no data selected @@ -294,7 +296,7 @@ res_tCENtrend = get_tCENtrend(df_data, df_meta, ## 4. PLOTTING # Shapefile importation in order to it only once time -df_shapefile = ini_shapefile(computer_data_path, +df_shapefile = ini_shapefile(resources_path, fr_shpdir, fr_shpname, bs_shpdir, bs_shpname, sbs_shpdir, sbs_shpname, @@ -315,43 +317,51 @@ df_shapefile = ini_shapefile(computer_data_path, ### 4.2. Analysis layout datasheet_layout(toplot=c( - 'datasheet', - 'matrix', + # 'datasheet', + # 'matrix', 'map' ), df_meta=df_meta, df_data=list( - res_QAtrend$data, - res_QMNAtrend$data, - res_VCN10trend$data, - res_tDEBtrend$data, + # res_QAtrend$data, + # res_QMNAtrend$data, + # res_VCN10trend$data, + # res_tDEBtrend$data, res_tCENtrend$data ), df_trend=list( - res_QAtrend$trend, - res_QMNAtrend$trend, - res_VCN10trend$trend, - res_tDEBtrend$trend, + # res_QAtrend$trend, + # res_QMNAtrend$trend, + # res_VCN10trend$trend, + # res_tDEBtrend$trend, res_tCENtrend$trend ), var=list( - 'QA', - 'QMNA', - 'VCN10', - 'tDEB', + # 'QA', + # 'QMNA', + # 'VCN10', + # 'tDEB', 'tCEN' ), type=list( - 'sévérité', - 'sévérité', - 'sévérité', - 'saisonnalité', + # 'sévérité', + # 'sévérité', + # 'sévérité', + # 'saisonnalité', 'saisonnalité' ), + + glose=list( + "Moyenne annuelle du débit journalier", + "Minimum annuel de la moyenne menusuelle du débit journalier", + "Minimum annuel de la moyenne sur 10 jours du débit journalier", + "Début d'étiage (jour de l'année de la première moyenne sur 10 sous le maximum des VCN10)", + "Centre d'étiage (jour de l'année du VCN10)" + ) layout_matrix=matrix(c(1, 2, 3, 4, 5), ncol=1), @@ -369,6 +379,7 @@ datasheet_layout(toplot=c( figdir=figdir, filename_opt='', resources_path=resources_path, + logo_dir=logo_dir, AEAGlogo_file=AEAGlogo_file, INRAElogo_file=INRAElogo_file, FRlogo_file=FRlogo_file)