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

Join BH and NV

parent b6a9422d
No related merge requests found
Showing with 72 additions and 26 deletions
+72 -26
...@@ -157,7 +157,7 @@ extractBH_info = function (computer_data_path, filedir, filename, verbose=TRUE) ...@@ -157,7 +157,7 @@ extractBH_info = function (computer_data_path, filedir, filename, verbose=TRUE)
# Print information if asked # Print information if asked
if (verbose) { if (verbose) {
print(paste("extraction of info for file :", filename)) print(paste("extraction of BH info for file :", filename))
} }
# Get the file path to the data # Get the file path to the data
...@@ -257,7 +257,7 @@ extractBH_data = function (computer_data_path, filedir, filename, verbose=TRUE) ...@@ -257,7 +257,7 @@ extractBH_data = function (computer_data_path, filedir, filename, verbose=TRUE)
# Print information if asked # Print information if asked
if (verbose) { if (verbose) {
print(paste("extraction of data for file :", filename)) print(paste("extraction of BH data for file :", filename))
} }
# Get the file path to the data # Get the file path to the data
......
...@@ -8,7 +8,7 @@ extractNVlist_info = function (computer_data_path, filedir, listdir, listname, v ...@@ -8,7 +8,7 @@ extractNVlist_info = function (computer_data_path, filedir, listdir, listname, v
# Print information if asked # Print information if asked
if (verbose) { if (verbose) {
print(paste("extraction of info for file :", listname)) print(paste("extraction of NV info for file :", listname))
} }
# Get the file path to the data # Get the file path to the data
...@@ -20,9 +20,11 @@ extractNVlist_info = function (computer_data_path, filedir, listdir, listname, v ...@@ -20,9 +20,11 @@ extractNVlist_info = function (computer_data_path, filedir, listdir, listname, v
# Create a filelist to store all the filename # Create a filelist to store all the filename
codelist = c() codelist = c()
dir_path = file.path(computer_data_path, filedir)
# Get all the filename in the data directory selected # Get all the filename in the data directory selected
filelist_tmp = list.files(file.path(computer_data_path, filelist_tmp = list.files(dir_path)
filedir))
# For all the filename in the directory selected # For all the filename in the directory selected
for (f in filelist_tmp) { for (f in filelist_tmp) {
...@@ -35,7 +37,7 @@ extractNVlist_info = function (computer_data_path, filedir, listdir, listname, v ...@@ -35,7 +37,7 @@ extractNVlist_info = function (computer_data_path, filedir, listdir, listname, v
exist = df_info$CODE %in% codelist exist = df_info$CODE %in% codelist
missing = codelist[!(codelist %in% df_info$CODE)] missing = codelist[!(codelist %in% df_info$CODE)]
print(paste('station missing :', missing)) print(paste('missing station info for :', missing))
df_info = df_info[exist,] df_info = df_info[exist,]
...@@ -47,18 +49,26 @@ extractNVlist_info = function (computer_data_path, filedir, listdir, listname, v ...@@ -47,18 +49,26 @@ extractNVlist_info = function (computer_data_path, filedir, listdir, listname, v
L93Y=df_info$Y_L2E, L93Y=df_info$Y_L2E,
surface_km2=df_info$S_km2, surface_km2=df_info$S_km2,
altitude_m=df_info$Alt, altitude_m=df_info$Alt,
file_path=paste(df_info$CODE, '.txt', sep='') file_path=file.path(dir_path,
paste(df_info$CODE, '.txt', sep=''))
) )
df_info = bind_rows(df_info,
data.frame(code=missing,
file_path=file.path(dir_path,
paste(missing,
'.txt',
sep=''))))
return (df_info) return (df_info)
} }
# Example # Example
# df_info = extractNVlist_info( df_info = extractNVlist_info(
# "/home/louis/Documents/bouleau/INRAE/CDD_stationnarite/data", "/home/louis/Documents/bouleau/INRAE/CDD_stationnarite/data",
# 'France207', 'France207',
# '', '',
# 'liste_bv_principaux_global.txt') 'liste_bv_principaux_global.txt')
# Extraction of data # Extraction of data
...@@ -115,7 +125,7 @@ extractNV_data = function (computer_data_path, filedir, filename, verbose=TRUE) ...@@ -115,7 +125,7 @@ extractNV_data = function (computer_data_path, filedir, filename, verbose=TRUE)
# Print information if asked # Print information if asked
if (verbose) { if (verbose) {
print(paste("extraction of data for file :", filename)) print(paste("extraction of NV data for file :", filename))
} }
# Get the file path to the data # Get the file path to the data
......
###### A MODIFIER ###### ###### A MODIFIER ######
# Path to the data # Path to the data
computer_data_path = computer_data_path =
"/home/louis/Documents/bouleau/INRAE/CDD_stationnarite/data" "/home/louis/Documents/bouleau/INRAE/CDD_stationnarite/data"
...@@ -11,32 +12,46 @@ computer_work_path = ...@@ -11,32 +12,46 @@ computer_work_path =
"/home/louis/Documents/bouleau/INRAE/CDD_stationnarite/ASH" "/home/louis/Documents/bouleau/INRAE/CDD_stationnarite/ASH"
# "C:\\Users\\louis.heraut\\Documents\\CDD_stationnarite\\ASH" # "C:\\Users\\louis.heraut\\Documents\\CDD_stationnarite\\ASH"
### BANQUE HYDRO ### ### BANQUE HYDRO ###
## Manual selection ## # Path to the directory where BH data is stored
# Path to data that will be analysed from the BanqueHydro
BHfiledir = BHfiledir =
FALSE
# "test" # "test"
# "BanqueHydro_Export2021" "BanqueHydro_Export2021"
## Manual selection ##
# Name of the file that will be analysed from the BH directory
BHfilename = BHfilename =
FALSE FALSE
# c("H5920011_HYDRO_QJM.txt", "K4470010_HYDRO_QJM.txt") # c("H5920011_HYDRO_QJM.txt", "K4470010_HYDRO_QJM.txt")
# "all" # "all"
## Or list selection ## ## Or list selection ##
# Path to the list file of station that will be analysed # Path to the list file of BH data that will be analysed
BHlistdir = BHlistdir =
# FALSE # FALSE
"" ""
BHlistname = BHlistname =
# FALSE # FALSE
"Liste-station_RRSE.docx" "Liste-station_RRSE.docx"
BHdatadir =
# FALSE
"BanqueHydro_Export2021"
### NIVALE ### ### 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"
######################## ########################
...@@ -69,8 +84,9 @@ if (!(file.exists(figdir))) { ...@@ -69,8 +84,9 @@ if (!(file.exists(figdir))) {
print(paste('figdir :', figdir)) print(paste('figdir :', figdir))
# BANQUE HYDRO #
# Get only the selected station from a list station file # Get only the selected station from a list station file
if (is.character(BHlistdir) & is.character(BHlistname) & is.character(BHdatadir)){ if (is.character(BHlistdir) & is.character(BHlistname) & is.character(BHfiledir)){
df_selec = get_selection(computer_data_path, df_selec = get_selection(computer_data_path,
BHlistdir, BHlistdir,
BHlistname, BHlistname,
...@@ -83,7 +99,7 @@ if (is.character(BHlistdir) & is.character(BHlistname) & is.character(BHdatadir) ...@@ -83,7 +99,7 @@ if (is.character(BHlistdir) & is.character(BHlistname) & is.character(BHdatadir)
'choix'), 'choix'),
c_num=c('BV_km2', c_num=c('BV_km2',
'longueur_serie')) 'longueur_serie'))
BHfiledir = BHdatadir
BHfilename = df_selec[df_selec$ok,]$filename BHfilename = df_selec[df_selec$ok,]$filename
} }
...@@ -93,9 +109,29 @@ df_info_BH = extractBH_info(computer_data_path, BHfiledir, BHfilename) ...@@ -93,9 +109,29 @@ df_info_BH = extractBH_info(computer_data_path, BHfiledir, BHfilename)
# Extract data about selected stations # Extract data about selected stations
df_data_BH = extractBH_data(computer_data_path, BHfiledir, BHfilename) 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 # Plot time panel of debit by stations
panel(df_data_BH, df_info_BH, figdir, BHfiledir) # panel(df_data, df_info, figdir, filedir)
# panel(df_data_BH, df_info_BH, figdir, BHfiledir, is_sqrt=TRUE) # panel(df_data, df_info, figdir, filedir, is_sqrt=TRUE)
# Compute gap parameters for stations # Compute gap parameters for stations
df_lac = get_lacune(df_data_BH, df_info_BH) # df_lac = get_lacune(df_data, df_info)
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