Commit 1eb93e74 authored by Heraut Louis's avatar Heraut Louis
Browse files

INI variable

parent f44db780
No related merge requests found
Showing with 133 additions and 99 deletions
+133 -99
......@@ -69,46 +69,53 @@ map_panel = function (list_df2plot, df_meta, df_shapefile, idPer=1, outdirTmp=''
}
}
# Blank list to store time info by station code
Start_code = vector(mode='list', length=nCode)
End_code = vector(mode='list', length=nCode)
Code_code = vector(mode='list', length=nCode)
Periods_code = vector(mode='list', length=nCode)
# For all the code
for (j in 1:nCode) {
tab_Start = array(rep('', nCode*nbp*nPeriod_max),
dim=c(nCode, nbp, nPeriod_max))
tab_End = array(rep('', nCode*nbp*nPeriod_max),
dim=c(nCode, nbp, nPeriod_max))
tab_Code = array(rep('', nCode*nbp*nPeriod_max),
dim=c(nCode, nbp, nPeriod_max))
tab_Periods = array(rep('', nCode*nbp*nPeriod_max),
dim=c(nCode, nbp, nPeriod_max))
# For all code
for (k in 1:nCode) {
# Gets the code
code = Code[j]
# Extracts the trend corresponding to the code
df_trend_code = df_trend[df_trend$code == code,]
code = Code[k]
# Extract start and end of trend periods
Start = df_trend_code$period_start
End = df_trend_code$period_end
# Get the name of the different period
UStart = levels(factor(Start))
UEnd = levels(factor(End))
# Compute the max of different start and end
# so the number of different period
nPeriod = max(length(UStart), length(UEnd))
# Vector to store trend period
Periods = c()
# For all the period
for (i in 1:nPeriod_max) {
# Stocks period
Periods = append(Periods,
paste(substr(Start[i], 1, 4),
substr(End[i], 1, 4),
sep=' / '))
for (i in 1:nbp) {
df_trend = list_df2plot[[i]]$trend
# Extracts the trend corresponding to the code
df_trend_code = df_trend[df_trend$code == code,]
# Extract start and end of trend periods
Start = df_trend_code$period_start
End = df_trend_code$period_end
# Get the name of the different period
UStart = levels(factor(Start))
UEnd = levels(factor(End))
# Compute the max of different start and end
# so the number of different period
nPeriod = max(length(UStart), length(UEnd))
# For all the period
for (j in 1:nPeriod_max) {
# Stocks period
Periods = paste(Start[j],
End[j],
sep=' / ')
tab_Start[k, i, j] = as.character(Start[j])
tab_End[k, i, j] = as.character(End[j])
tab_Code[k, i, j] = code
tab_Periods[k, i, j] = Periods
}
}
# Stores time info by station
Start_code[[j]] = Start
End_code[[j]] = End
Code_code[[j]] = code
Periods_code[[j]] = Periods
}
# Blank array to store mean of the trend for each
# station, perdiod and variable
TrendMean_code = array(rep(1, nPeriod_max*nbp*nCode),
......@@ -134,9 +141,9 @@ map_panel = function (list_df2plot, df_meta, df_shapefile, idPer=1, outdirTmp=''
df_trend_code = df_trend[df_trend$code == code,]
# Gets the associated time info
Start = Start_code[Code_code == code][[1]][j]
End = End_code[Code_code == code][[1]][j]
Periods = Periods_code[Code_code == code][[1]][j]
Start = tab_Start[k, i, j]
End = tab_End[k, i, j]
Periods = tab_Periods[k, i, j]
# Extracts the corresponding data for the period
df_data_code_per =
......@@ -334,7 +341,9 @@ map_panel = function (list_df2plot, df_meta, df_shapefile, idPer=1, outdirTmp=''
trend = c()
p_threshold_Ok = c()
# For all code
for (code in Code) {
for (k in 1:nCode) {
# Gets the code
code = Code[k]
# Extracts the data corresponding to the current variable
df_data = list_df2plot[[i]]$data
# Extracts the trend corresponding to the
......@@ -347,8 +356,13 @@ map_panel = function (list_df2plot, df_meta, df_shapefile, idPer=1, outdirTmp=''
df_trend_code = df_trend[df_trend$code == code,]
# Gets the associated time info
Start = Start_code[Code_code == code][[1]][idPer]
End = End_code[Code_code == code][[1]][idPer]
# Start = Start_code[Code_code == code][[1]][idPer]
# End = End_code[Code_code == code][[1]][idPer]
# Gets the associated time info
Start = tab_Start[k, i, idPer]
End = tab_End[k, i, idPer]
Periods = tab_Periods[k, i, idPer]
# Extracts the corresponding data for the period
df_data_code_per =
......
......@@ -70,44 +70,53 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice
}
}
# Blank list to store time info by station code
Start_code = vector(mode='list', length=nCode)
End_code = vector(mode='list', length=nCode)
Code_code = vector(mode='list', length=nCode)
Periods_code = vector(mode='list', length=nCode)
# For all the code
for (j in 1:nCode) {
tab_Start = array(rep('', nCode*nbp*nPeriod_max),
dim=c(nCode, nbp, nPeriod_max))
tab_End = array(rep('', nCode*nbp*nPeriod_max),
dim=c(nCode, nbp, nPeriod_max))
tab_Code = array(rep('', nCode*nbp*nPeriod_max),
dim=c(nCode, nbp, nPeriod_max))
tab_Periods = array(rep('', nCode*nbp*nPeriod_max),
dim=c(nCode, nbp, nPeriod_max))
# For all code
for (k in 1:nCode) {
# Gets the code
code = Code[j]
# Extracts the trend corresponding to the code
df_trend_code = df_trend[df_trend$code == code,]
# Extract start and end of trend periods
Start = df_trend_code$period_start
End = df_trend_code$period_end
# Get the name of the different period
UStart = levels(factor(Start))
UEnd = levels(factor(End))
# Compute the max of different start and end
# so the number of different period
nPeriod = max(length(UStart), length(UEnd))
# Vector to store trend period
Periods = c()
# For all the trend period
for (i in 1:nPeriod_trend) {
# Stocks period
Periods = append(Periods,
paste(Start[i],
End[i],
sep=' / '))
code = Code[k]
for (i in 1:nbp) {
df_trend = list_df2plot[[i]]$trend
# Extracts the trend corresponding to the code
df_trend_code = df_trend[df_trend$code == code,]
# Extract start and end of trend periods
Start = df_trend_code$period_start
End = df_trend_code$period_end
# Get the name of the different period
UStart = levels(factor(Start))
UEnd = levels(factor(End))
# Compute the max of different start and end
# so the number of different period
nPeriod = max(length(UStart), length(UEnd))
# For all the period
for (j in 1:nPeriod_max) {
# Stocks period
Periods = paste(Start[j],
End[j],
sep=' / ')
tab_Start[k, i, j] = as.character(Start[j])
tab_End[k, i, j] = as.character(End[j])
tab_Code[k, i, j] = code
tab_Periods[k, i, j] = Periods
}
}
# Stores time info by station
Start_code[[j]] = Start
End_code[[j]] = End
Code_code[[j]] = code
Periods_code[[j]] = Periods
}
# Blank array to store mean of the trend for each
# station, perdiod and variable
......@@ -134,9 +143,9 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice
df_trend_code = df_trend[df_trend$code == code,]
# Gets the associated time info
Start = Start_code[Code_code == code][[1]][j]
End = End_code[Code_code == code][[1]][j]
Periods = Periods_code[Code_code == code][[1]][j]
Start = tab_Start[k, i, j]
End = tab_End[k, i, j]
Periods = tab_Periods[k, i, j]
# Extracts the corresponding data for the period
df_data_code_per =
......@@ -191,7 +200,9 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice
# For all the trend period
for (j in 1:nPeriod_trend) {
# For all code
for (code in Code) {
for (k in 1:nCode) {
# Gets the code
code = Code[k]
# For all variable
for (i in 1:nbp) {
# Extracts the data corresponding to the current variable
......@@ -210,9 +221,9 @@ matrix_panel = function (list_df2plot, df_meta, trend_period, mean_period, slice
df_trend_code = df_trend[df_trend$code == code,]
# Gets the associated time info
Start = Start_code[Code_code == code][[1]][j]
End = End_code[Code_code == code][[1]][j]
Periods = Periods_code[Code_code == code][[1]][j]
Start = tab_Start[k, i, j]
End = tab_End[k, i, j]
Periods = tab_Periods[k, i, j]
# Extracts the corresponding data for the period
df_data_code_per =
......
......@@ -320,6 +320,7 @@ get_tINItrend = function (df_data, df_meta, period, p_thresold) {
for (k in 1:nCode) {
# Gets the code
code = Code[k]
# print(code)
per.start = df_meta$start_year[df_meta$code == code]
per.start = paste(sprintf("%02d", per.start), '-01', sep='')
......@@ -387,18 +388,22 @@ get_tINItrend = function (df_data, df_meta, period, p_thresold) {
per.start=per.start)
# print('hh')
# print(df_tINIEx_code)
# Store the results
df_tINIEx = bind_rows(df_tINIEx, df_tINIEx_code)
df_tINIEx = bind_rows(df_tINIEx, df_tINIEx_code)
df_tINIlist$data = bind_rows(df_tINIlist$data,
df_tINIlist_code$data)
df_tINIlist$info = bind_rows(df_tINIlist$info,
df_tINIlist_code$info)
# print('ii')
}
# print('11')
# Compute the trend analysis
df_tINItrend = Estimate.stats(data.extract=df_tINIEx,
......@@ -414,7 +419,7 @@ get_tINItrend = function (df_data, df_meta, period, p_thresold) {
df_tINIExB = df_tINIEx
}
print(per.start)
# print(per.start)
# Specify the period of analyse
df_tINItrend = get_period(per, df_tINItrend, df_tINIEx,
......
......@@ -169,6 +169,8 @@ prepare_date = function(df_XEx, df_Xlist, per.start="01-01") {
df_XEx$values[OkXEx_code] = XEx_code
}
df_XEx$datetime = as.double(df_XEx$datetime)
return (df_XEx)
}
......@@ -294,11 +296,11 @@ get_period = function (per, df_Xtrend, df_XEx, df_Xlist) {
iStart = which.min(abs(DateStart - as.Date(per[1])))
iEnd = which.min(abs(DateEnd - as.Date(per[2])))
print(nrow(df_XEx))
print(as.Date(DateStart[iStart]))
print(head(df_XEx))
print(tail(df_XEx))
print(as.Date(DateEnd[iEnd]))
# print(nrow(df_XEx))
# print(as.Date(DateStart[iStart]))
# print(head(df_XEx))
# print(tail(df_XEx))
# print(as.Date(DateEnd[iEnd]))
# Stores the start and end of the trend analysis
df_Xtrend$period_start[id] = as.Date(DateStart[iStart])
......
......@@ -58,13 +58,15 @@ filename =
# ""
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"
# "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",
"O3035210_HYDRO_QJM.txt",
"O3121010_HYDRO_QJM.txt"
)
......@@ -286,8 +288,8 @@ df_shapefile = ini_shapefile(computer_data_path,
### 4.2. Analysis layout
datasheet_layout(toplot=c(
'datasheet'
# 'matrix',
# 'datasheet',
'matrix',
# 'map'
),
df_meta=df_meta,
......
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