script.R 3.66 KiB
###### 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
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
BHfiledir = 
    # "test"
    "BanqueHydro_Export2021"
## Manual selection ##
# Name of the file that will be analysed from the BH directory
BHfilename =
    FALSE
    # c("H5920011_HYDRO_QJM.txt", "K4470010_HYDRO_QJM.txt")
    # "all"
## Or list selection ##
# Path to the list file of BH data that will be analysed
BHlistdir = 
    # FALSE
BHlistname = 
    # FALSE
    "Liste-station_RRSE.docx" 
### NIVALE ###
# Path to the directory where NV data is stored
NVfiledir = 
    "France207"
# Name of the file that will be analysed from the NV directory
NVfilename = 
    "all"
# Path to the list file of information about station that will be analysed
NVlistdir =
NVlistname = 
    "liste_bv_principaux_global.txt"
########################
# Set working directory
setwd(computer_work_path)
# Sourcing R file
source('processing/extractBH.R')
source('processing/extractNV.R')
source('processing/analyse.R')
source('plotting/panel.R')
# Usefull library
7172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
# 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)) # BANQUE HYDRO # # Get only the selected station from a list station file if (is.character(BHlistdir) & is.character(BHlistname) & is.character(BHfiledir)){ df_selec = get_selection(computer_data_path, BHlistdir, BHlistname, cnames=c('code', 'station', 'BV_km2', 'axe_principal_concerne', 'longueur_serie', 'commentaires', 'choix'), c_num=c('BV_km2', 'longueur_serie')) BHfilename = df_selec[df_selec$ok,]$filename } # Extract information about selected stations df_info_BH = extractBH_info(computer_data_path, BHfiledir, BHfilename) # Extract data about selected stations df_data_BH = extractBH_data(computer_data_path, BHfiledir, BHfilename) # NIVALE # # Extract information about selected stations df_info_NV = extractNVlist_info(computer_data_path, NVfiledir, NVlistdir, NVlistname) ### /!\ missing station info # Extract data about selected stations df_data_NV = extractNV_data(computer_data_path, NVfiledir, NVfilename) common = levels(factor(df_info_NV[df_info_NV$code %in% df_info_BH$code,]$code)) NVadd = levels(factor(df_info_NV[!(df_info_NV$code %in% df_info_BH$code),]$code)) df_info_NVadd = df_info_NV[df_info_NV$code %in% NVadd,] df_info = full_join(df_info_BH, df_info_NVadd, by=c("code", "nom", "L93X", "L93Y", "surface_km2", "file_path")) df_data_NVadd = df_data_NV[df_data_NV$code %in% NVadd,] df_data = full_join(df_data_BH, df_data_NVadd, by=c("Date", "Qm3s", "code")) # Plot time panel of debit by stations # panel(df_data, df_info, figdir, filedir) # panel(df_data, df_info, figdir, filedir, is_sqrt=TRUE) # Compute gap parameters for stations # df_lac = get_lacune(df_data, df_info)