Failed to fetch fork details. Try again later.
-
unknown authoredbb3d10ca
Forked from
HYCAR-Hydro / airGR
Source project has a limited visibility.
############ A MODIFIER ############
# Path to the data
computer_data_path =
"/home/louis/Documents/bouleau/INRAE/CDD_stationnarite/data"
# "C:\\Users\\louis.heraut\\Documents\\CDD_stationnarite\\data"
# Work path (it needs to end with '/ASH' directory)
computer_work_path =
"/home/louis/Documents/bouleau/INRAE/CDD_stationnarite/ASH"
# "C:\\Users\\louis.heraut\\Documents\\CDD_stationnarite\\ASH"
### BANQUE HYDRO ###
# Path to the directory where BH data is stored from the work path
filedir =
# ""
"BanqueHydro_Export2021"
### MANUAL SELECTION ###
# Name of the file that will be analysed from the AG directory
filename =
# ""
# c(
# "S2235610_HYDRO_QJM.txt",
# "P1712910_HYDRO_QJM.txt",
# "P0885010_HYDRO_QJM.txt",
# "O5055010_HYDRO_QJM.txt",
# "Q7002910_HYDRO_QJM.txt"
# )
c("S4214010_HYDRO_QJM.txt",
"O0384010_HYDRO_QJM.txt",
"Q7002910_HYDRO_QJM.txt")
### AGENCE EAU ADOUR GARONNE SELECTION ###
# Path to the list file of AG data that will be analysed
AGlistdir =
""
AGlistname =
""
# "Liste-station_RRSE.docx"
### NIVALE SELECTION ###
# Path to the list file of metadata about station that will be analysed
NVlistdir =
""
NVlistname =
""
# "nival_selection.txt"
### TREND ANALYSIS ###
# Time period to analyse
periodAll = c("1800-01-01", "2019-12-31")
periodSub = c("1968-01-01", "2019-12-31")
trend_period = list(periodAll, periodSub)
# Time period to mean
period1 = c("1968-01-01", "1994-12-31")
period2 = c("1995-01-01", "2019-12-31")
mean_period = list(period1, period2)
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
# p value
p_thresold = 0.1 #c(0.01, 0.05, 0.1)
### MAP ###
fr_shpdir = 'map/france'
fr_shpname = 'gadm36_FRA_0.shp'
bs_shpdir = 'map/bassin'
bs_shpname = 'BassinHydrographique.shp'
rv_shpdir = 'map/river'
rv_shpname = 'CoursEau_FXX.shp'
####################################
# FILE STRUCTURE #
# Set working directory
setwd(computer_work_path)
# Sourcing R file
source('processing/extract.R', encoding='latin1')
source('processing/format.R', encoding='latin1')
source('processing/analyse.R', encoding='latin1')
source('plotting/panel.R', encoding='latin1')
source('plotting/layout.R', encoding='latin1')
# Result directory
resdir = file.path(computer_work_path, 'results')
if (!(file.exists(resdir))) {
dir.create(resdir)
}
print(paste('resdir :', resdir))
# Figure directory
figdir = file.path(computer_work_path, 'figures')
if (!(file.exists(figdir))) {
dir.create(figdir)
}
print(paste('figdir :', figdir))
# Initialization of null data frame if there is no data selected
df_data_AG = NULL
df_data_NV = NULL
df_meta_AG = NULL
df_meta_NV = NULL
# AGENCE EAU ADOUR GARONNE SELECTION #
if (AGlistname != ""){
# Get only the selected station from a list station file
df_selec_AG = get_selection_AG(computer_data_path,
AGlistdir,
AGlistname,
cnames=c('code',
'station',
'BV_km2',
'axe_principal_concerne',
'longueur_serie',
'commentaires',
'choix'),
c_num=c('BV_km2',
'longueur_serie'))
141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
# Get filenames of the selection
filename = df_selec_AG[df_selec_AG$ok,]$filename
#####
# filename = filename[(1+30):(16+30)]
#####
# Extract metadata about selected stations
df_meta_AG = extract_meta(computer_data_path, filedir, filename)
# Extract data about selected stations
df_data_AG = extract_data(computer_data_path, filedir, filename)
}
# NIVALE SELECTION #
if (NVlistname != ""){
# Get only the selected station from a list station file
df_selec_NV = get_selection_NV(computer_data_path,
NVlistdir,
NVlistname)
# Get filenames of the selection
filename = df_selec_NV[df_selec_NV$ok,]$filename
#####
# filename = filename[(1+20):(16+20)]
#####
# Extract metadata about selected stations
df_meta_NV = extract_meta(computer_data_path, filedir, filename)
# Extract data about selected stations
df_data_NV = extract_data(computer_data_path, filedir, filename)
}
# MANUAL SELECTION #
if (AGlistname == "" & NVlistname == "") {
# Extract metadata about selected stations
df_meta_AG = extract_meta(computer_data_path, filedir, filename)
# Extract data about selected stations
df_data_AG = extract_data(computer_data_path, filedir, filename)
}
# JOIN #
# Make the join
df_join = join(df_data_AG, df_data_NV, df_meta_AG, df_meta_NV)
df_data = df_join$data
df_meta = df_join$meta
# ANALYSE #
# Compute gap parameters for stations
# df_lac = get_lacune(df_data, df_meta)
# QA TREND #
res_QAtrend = get_QAtrend(df_data, period=trend_period,
p_thresold=p_thresold)
# QMNA TREND #
res_QMNAtrend = get_QMNAtrend(df_data, period=trend_period,
p_thresold=p_thresold)
# VCN10 TREND #
res_VCN10trend = get_VCN10trend(df_data, df_meta,
period=trend_period,
211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
p_thresold=p_thresold)
# df_break = get_break(res_QAtrend$data, df_meta)
# df_break = get_break(res_QMNAtrend$data, df_meta)
# df_break = get_break(res_VCN10trend$data, df_meta)
# histogram(df_break$Date, df_meta,
# figdir=figdir)
# cumulative(df_break$Date, df_meta, dyear=8,
# figdir=figdir)
# TIME PANEL #
# Plot time panel of debit by stations
# panels_layout(list(df_data, df_data),
# layout_matrix=c(1, 2),
# df_meta=df_meta,
# missRect=list(TRUE, TRUE),
# type=list('Q', 'sqrt(Q)'),
# info_header=TRUE,
# time_header=NULL,
# var_ratio=3,
# figdir=figdir,
# filename_opt='time')
panels_layout(list(res_QAtrend$data, res_QMNAtrend$data,
res_VCN10trend$data),
layout_matrix=c(1, 2, 3),
df_meta=df_meta,
df_trend=list(res_QAtrend$trend, res_QMNAtrend$trend,
res_VCN10trend$trend),
type=list(bquote(Q[A]), bquote(Q[MNA]), bquote(V[CN10])),
missRect=list(TRUE, TRUE, TRUE),
trend_period=trend_period,
mean_period=mean_period,
info_header=TRUE,
time_header=df_data,
info_ratio=2,
time_ratio=2,
var_ratio=3,
computer_data_path=computer_data_path,
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,
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 ###