From 82e35e88fbd76f6b8c88f560df2094d5934b10ac Mon Sep 17 00:00:00 2001 From: louis_heraut <louis@botan.home> Date: Tue, 9 Nov 2021 16:01:57 +0100 Subject: [PATCH] Remove useless files. --- init.R~ | 33 ------------ plotting/panel.R~ | 37 ------------- processing/#extract.R# | 118 ----------------------------------------- processing/extract.R~ | 90 ------------------------------- script_analyse.R~ | 24 --------- script_new_user.R~ | 45 ---------------- script_plot.R~ | 37 ------------- 7 files changed, 384 deletions(-) delete mode 100644 init.R~ delete mode 100644 plotting/panel.R~ delete mode 100644 processing/#extract.R# delete mode 100644 processing/extract.R~ delete mode 100644 script_analyse.R~ delete mode 100644 script_new_user.R~ delete mode 100644 script_plot.R~ diff --git a/init.R~ b/init.R~ deleted file mode 100644 index 4e25af4..0000000 --- a/init.R~ +++ /dev/null @@ -1,33 +0,0 @@ -#' Initialization of global environnemental variable -#' -#' @param x A number. -#' @param y A number. -#' @return The sum of \code{x} and \code{y}. -#' @examples -#' add(1, 1) -#' add(10, 1) - - -# Computer informations -data_path = c(louis="/home/louis/Documents/bouleau/INRAE/CDD_stationnarite/data", - other='...') -work_path = c(louis="/home/louis/Documents/bouleau/INRAE/CDD_stationnarite/ASH", - other='.../ASH') - -user = Sys.getenv('USER') - -# Path to the data -computer_data_path = data_path[user] -print(paste('computer_data_path :', computer_data_path, sep=' ')) - -# Work path -computer_work_path = work_path[user] -setwd(computer_work_path) -print(paste('computer_work_path :', computer_work_path, sep=' ')) - -# Output directory -res_dir = 'results/' -print(paste('res_dir : ', res_dir, sep='')) -fig_dir = 'figures/' -print(paste('fig_dir : ', fig_dir, sep='')) -print('') diff --git a/plotting/panel.R~ b/plotting/panel.R~ deleted file mode 100644 index ce776e6..0000000 --- a/plotting/panel.R~ +++ /dev/null @@ -1,37 +0,0 @@ -library(here) - -source(file.path(dirname(here()), 'init.R')) -source(file.path(dirname(here()), 'processing', 'extract.R')) - - -# Time panel -panel = function (filedirs, filenames, pan) { - - file_path = file.path(computer_data_path, filedirs, filenames) - - for (p in pan) { - # If there is not a dedicated figure directory it creats one - out_dir = file.path(res_dir, filedirs) - if (!(file.exists(out_dir))) { - dir.create(out_dir) - } - - # Get info - info = extract_info(filedirs, filenames) - - # Create name for the figure file - out_file = paste('Panel_', info$code, '.png', sep='') - - # Extract data - data = extract_data(filedirs, filenames) - - - - - - } - - return (NA) -} - -# panel('', 'H5920011_HYDRO_QJM.txt') diff --git a/processing/#extract.R# b/processing/#extract.R# deleted file mode 100644 index 057593d..0000000 --- a/processing/#extract.R# +++ /dev/null @@ -1,118 +0,0 @@ -library(here) -library(tools) -source(file.path(dirname(here()), 'init.R')) - - -# Extraction of data -extract_data = function (filedir, filename) { - - data_path = file.path(computer_data_path, filedir, filename) - - data = read.table(data_path, - header=TRUE, - na.strings=c('-99.000', '-99'), - sep=';', - skip=41)[,1:2] - - return (data=data) -} - -# data = extract_data('', 'H5920011_HYDRO_QJM.txt') - - -# Extraction of information -extract_info = function (filedir, filename) { - - data_path = file.path(computer_data_path, filedir, filename) - - # General information on station - iStatut = c('0'='inconnu', - '1'='station avec signification hydrologique', - '2'='station sans signification hydrologique', - '3'="station d'essai") - - iFinalite = c('0'='inconnue', - '1'="hydrométrie générale", - '2'='alerte de crue', - '3'="hydrométrie générale et alerte de crue", - '4'="gestion d'ouvrage", - '5'='police des eaux', - '6'="suivi d'étiage", - '7'='bassin expérimental', - '8'='drainage') - - iType = c('0'='inconnu', - '1'='une échelle', - '2'='deux échelles, station mère', - '3'='deux échelles, station fille', - '4'='débits mesurés', - '5'='virtuelle') - - iInfluence = c('0'='inconnue', - '1'='nulle ou faible', - '2'='en étiage seulement', - '3'='forte en toute saison') - - iDebit = c('0'='reconstitué', - '1'="réel (prise en compte de l'eau rajoutée ou retirée du bassin selon aménagements)", - '2'='naturel') - - iQBE = c('0'='qualité basses eaux inconnue', - '1'='qualité basses eaux bonne', - '2'='qualité basses eaux douteuse') - - iQME = c('0'='qualité moyennes eaux inconnue', - '1'='qualité moyennes eaux bonne', - '2'='qualité moyennes eaux douteuse') - - iQHE = c('0'='qualité hautes eaux inconnue', - '1'='qualité hautes eaux bonne', - '2'='qualité hautes eaux douteuse') - - data_path = file.path(computer_data_path, filedir, filename) - - infotxt = c(readLines(data_path, n=41)) - - info = list(code=trimws(substr(infotxt[11], 38, nchar(infotxt[11]))), - nom=trimws(substr(infotxt[12], 39, nchar(infotxt[12]))), - territoire=trimws(substr(infotxt[13], 39, nchar(infotxt[13]))), - L93X=as.numeric(substr(infotxt[16], 38, 50)), - L93Y=as.numeric(substr(infotxt[16], 52, 63)), - surface=as.numeric(substr(infotxt[19], 38, 50)), - statut=iStatut[trimws(substr(infotxt[26], 38, 50))], - finalite=iFinalite[trimws(substr(infotxt[26], 52, 56))], - type=iType[trimws(substr(infotxt[26], 58, 58))], - influence=iInfluence[trimws(substr(infotxt[26], 60, 60))], - debit=iDebit[trimws(substr(infotxt[26], 62, 62))], - QBE=iQBE[trimws(substr(infotxt[26], 72, 72))], - QME=iQME[trimws(substr(infotxt[26], 74, 74))], - QHE=iQHE[trimws(substr(infotxt[26], 76, 76))] - ) - - return (info=info) -} - -# info = extract_info('', 'H5920011_HYDRO_QJM.txt') - - -# Extraction and dataframing -extract_df = function (filedir, filename) { - - if (filename == 'all') { - filelist = c() - for (f in list.files(file.path(filedir))) { - if (file_ext(f) == 'txt') { - filelist = c(filelist, f) - } - - } - } - - data_path = file.path(computer_data_path, filedir, filename) - info = extract_info(filedir, filename) - df = data.frame(info, data_path=data_path) - - return (df) -} - -# df = extract_df('', 'H5920011_HYDRO_QJM.txt') diff --git a/processing/extract.R~ b/processing/extract.R~ deleted file mode 100644 index 39d69c6..0000000 --- a/processing/extract.R~ +++ /dev/null @@ -1,90 +0,0 @@ -library(here) -source(file.path(dirname(here()), 'init.R')) - - -# Extraction of data -extract_data = function (filedirs, filenames) { - file_path = file.path(computer_data_path, filedirs, filenames) - - data = read.table(file_path, - header=TRUE, - na.strings=c('-99.000', '-99'), - sep=';', - skip=41)[,1:2] - - return (data=data) -} - -# data = extract_data('', 'H5920011_HYDRO_QJM.txt') - - -# Extraction of information -extract_info = function (filedirs, filenames) { - # General information on station - iStatut = c('0'='inconnu', - '1'='station avec signification hydrologique', - '2'='station sans signification hydrologique', - '3'="station d'essai") - - iFinalite = c('0'='inconnue', - '1'="hydrométrie générale", - '2'='alerte de crue', - '3'="hydrométrie générale et alerte de crue", - '4'="gestion d'ouvrage", - '5'='police des eaux', - '6'="suivi d'étiage", - '7'='bassin expérimental', - '8'='drainage') - - iType = c('0'='inconnu', - '1'='une échelle', - '2'='deux échelles, station mère', - '3'='deux échelles, station fille', - '4'='débits mesurés', - '5'='virtuelle') - - iInfluence = c('0'='inconnue', - '1'='nulle ou faible', - '2'='en étiage seulement', - '3'='forte en toute saison') - - iDebit = c('0'='reconstitué', - '1'="réel (prise en compte de l'eau rajoutée ou retirée du bassin selon aménagements)", - '2'='naturel') - - iQBE = c('0'='qualité basses eaux inconnue', - '1'='qualité basses eaux bonne', - '2'='qualité basses eaux douteuse') - - iQME = c('0'='qualité moyennes eaux inconnue', - '1'='qualité moyennes eaux bonne', - '2'='qualité moyennes eaux douteuse') - - iQHE = c('0'='qualité hautes eaux inconnue', - '1'='qualité hautes eaux bonne', - '2'='qualité hautes eaux douteuse') - - file_path = file.path(computer_data_path, filedirs, filenames) - - infotxt = c(readLines(file_path, n=41)) - - info = list(code=trimws(substr(infotxt[11], 38, nchar(infotxt[11]))), - nom=trimws(substr(infotxt[12], 39, nchar(infotxt[12]))), - territoire=trimws(substr(infotxt[13], 39, nchar(infotxt[13]))), - L93X=as.numeric(substr(infotxt[16], 38, 50)), - L93Y=as.numeric(substr(infotxt[16], 52, 63)), - surface=as.numeric(substr(infotxt[19], 38, 50)), - statut=iStatut[trimws(substr(infotxt[26], 38, 50))], - finalite=iFinalite[trimws(substr(infotxt[26], 52, 56))], - type=iType[trimws(substr(infotxt[26], 58, 58))], - influence=iInfluence[trimws(substr(infotxt[26], 60, 60))], - debit=iDebit[trimws(substr(infotxt[26], 62, 62))], - QBE=iQBE[trimws(substr(infotxt[26], 72, 72))], - QME=iQME[trimws(substr(infotxt[26], 74, 74))], - QHE=iQHE[trimws(substr(infotxt[26], 76, 76))] - ) - - return (info=info) -} - -# info = extract_info('', 'H5920011_HYDRO_QJM.txt') diff --git a/script_analyse.R~ b/script_analyse.R~ deleted file mode 100644 index 60549a2..0000000 --- a/script_analyse.R~ +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env Rscript - -library(here) -library(argparser, quietly=TRUE) - -source(file.path(dirname(here()), 'init.R')) - -# Create a parser -p = arg_parser("Analyse data.") - -# Add command line arguments -p = add_argument(p, '--filedirs', - type="character", - help="Directory(ies) in the data directory to search for data.") - -p = add_argument(p, '--filenames', - type="character", - help="Filename(s) in the data directory to search for data. If 'all', the whole directory(ies) will used.") - - -# Parse the command line arguments -argv = parse_args(p) - -# Run approriate function diff --git a/script_new_user.R~ b/script_new_user.R~ deleted file mode 100644 index b80172d..0000000 --- a/script_new_user.R~ +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env Rscript - -library(here) -library(argparser, quietly=TRUE) -library(stringr) - -setwd(here()) - -# Create a parser -p = arg_parser("Add a new user to the environment with is work and data path.") - -# Add command line arguments -p = add_argument(p, '--data_dir', - type="character", - help="Data directory.") - -p = add_argument(p, '--work_dir', - type="character", - help="Working directory.") - -# Parse the command line arguments -argv = parse_args(p) - -# Create path file -user = Sys.getenv('USER') -computer_data_path = c(argv$data_dir) -computer_work_path = c(argv$work_dir) - -if (file.exists('path.txt')) { - computer_path = read.table('path.txt', sep=';') - if (!any(computer_path$user == user)) { - computer_path = rbind(computer_path, c(user, - computer_data_path, - computer_work_path)) - } else { - stop("User already register") - } -} else { - computer_path = data.frame(user=user, - computer_data_path=computer_data_path, - computer_work_path=computer_work_path) - print(paste('New user:', user, sep=' ')) -} - -write.table(computer_path, file='path.txt', sep=';') diff --git a/script_plot.R~ b/script_plot.R~ deleted file mode 100644 index 0528301..0000000 --- a/script_plot.R~ +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env Rscript - -library(here) -library(argparser, quietly=TRUE) - -source(file.path(here(), 'init.R')) - -# Create a parser -p = arg_parser("Plot data.") - -# Add command line arguments -p = add_argument(p, '--filedirs', - type="character", - help="Directory(ies) in the data directory to search for data.") - -p = add_argument(p, '--filenames', - type="character", - help="Filename(s) in the data directory to search for data. If 'all', the whole directory(ies) will used.") - -p = add_argument(p, '--panel', - type="numeric", - nargs=Inf, - help="Time span in day of simple time panel.") - -# Parse the command line arguments -argv = parse_args(p) - -# Run approriate function - -print(argv$panel) - -if (any(!is.na(argv$panel))) { - for (pan in argv$panel) { - print('aaa') - - } -} -- GitLab