diff --git a/plotting/map.R b/plotting/map.R index 7b62fa990c2f2bcc168005d0381649dfd7a7fadb..257bc7abacac12dda2b94cb99e22c2c6a5b13069 100644 --- a/plotting/map.R +++ b/plotting/map.R @@ -277,7 +277,7 @@ map_panel = function (list_df2plot, df_meta, df_shapefile, idPer=1, outdirTmp='' # If there is a specified station code } else { # Same but with less graduation and smaller size - xmin = gpct(5, xlim, shift=TRUE) + xmin = gpct(2, xlim, shift=TRUE) xint = c(0, 100*1E3) ymin = gpct(1, ylim, shift=TRUE) ymax = ymin + gpct(3, ylim) diff --git a/processing/analyse.R b/processing/analyse.R index 6c429525f9d6cd670b973d4d9587714d1e732c9f..cda2470bdfec193ef759cccdfb51b0202d4da69b 100644 --- a/processing/analyse.R +++ b/processing/analyse.R @@ -327,13 +327,19 @@ get_tINItrend = function (df_data, df_meta, period, p_thresold) { # Get the data associated to the code df_data_roll_code = df_data_roll[df_data_roll$code == code,] - + # print('aa') + # Get the data associated to the code df_data_code = df_data[df_data$code == code,] + # print('bb') + # Prepare the data to fit the entry of extract.Var df_QNAlist_code = prepare(df_data_code, colnamegroup=c('code')) + + # print('cc') + # Compute the yearly mean over the data df_QNAEx_code = extract.Var(data.station=df_QNAlist_code, @@ -344,18 +350,17 @@ get_tINItrend = function (df_data, df_meta, period, p_thresold) { pos.datetime=1, na.rm=TRUE) - # print(code) - # print(df_QNAEx_code) + # print('dd') QNAmax = max(df_QNAEx_code$values, na.rm=TRUE) - # print(QNAmax) - # print(per.start) - - + # print('ee') + # Prepare the data to fit the entry of extract.Var df_tINIlist_code = prepare(df_data_roll_code, colnamegroup=c('code')) + + # print('ff') # Compute the yearly min over the averaged data df_tINIEx_code = extract.Var(data.station=df_tINIlist_code, @@ -366,28 +371,34 @@ get_tINItrend = function (df_data, df_meta, period, p_thresold) { pos.datetime=1, UpLim=QNAmax) + # print('gg') + # print(df_tINIEx_code) + + df_tINIEx_code$group1 = k df_tINIlist_code$data$group = k df_tINIlist_code$info$group = k + + # Converts index of the tINI to the julian date associated df_tINIEx_code = prepare_date(df_tINIEx_code, df_tINIlist_code, per.start=per.start) + + # print('hh') # 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(df_tINIEx) - # print(df_tINIlist) - # Compute the trend analysis df_tINItrend = Estimate.stats(data.extract=df_tINIEx, @@ -403,6 +414,8 @@ get_tINItrend = function (df_data, df_meta, period, p_thresold) { df_tINIExB = df_tINIEx } + print(per.start) + # Specify the period of analyse df_tINItrend = get_period(per, df_tINItrend, df_tINIEx, df_tINIlist) @@ -601,7 +614,8 @@ get_hydrograph = function (df_data, period=NULL, df_meta=NULL) { # Stores result of the hydrological regime df_meta$regime_hydro[df_meta$code == code] = classRegime # Computes the month of the max QM - maxMonth = which.max(df_QM$QM) + maxMonth = which.max(QM_code) + # Stores it as the start of the hydrological year df_meta$start_year[df_meta$code == code] = maxMonth # Otherwise diff --git a/processing/format.R b/processing/format.R index 84c928fa63bded3f2d411c7b6e5e95aed7f3ceba..fde65227d705f8194503192f024b2373cee39d10 100644 --- a/processing/format.R +++ b/processing/format.R @@ -285,19 +285,24 @@ get_period = function (per, df_Xtrend, df_XEx, df_Xlist) { # Computes index of the nearest accessible start and end date OkStart = df_XExtmp_code$Date >= as.Date(per[1]) OkEnd = df_XExtmp_code$Date <= as.Date(per[2]) + + # DateStart = df_XExtmp_code$Date[OkStart] + # DateEnd = df_XExtmp_code$Date[OkEnd] + DateStart = df_XExtmp_code$Date + DateEnd = df_XExtmp_code$Date - distStart = abs(df_XExtmp_code$Date[OkStart] - as.Date(per[1])) - distEnd = abs(df_XExtmp_code$Date[OkEnd] - as.Date(per[2])) - - iStart = which.min(distStart) - iEnd = which.min(distEnd) + 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])) # Stores the start and end of the trend analysis - df_Xtrend$period_start[id] = - as.Date(df_XExtmp_code$Date[iStart]) - df_Xtrend$period_end[id] = - as.Date(df_XExtmp_code$Date[iEnd]) + df_Xtrend$period_start[id] = as.Date(DateStart[iStart]) + df_Xtrend$period_end[id] = as.Date(DateEnd[iEnd]) } return (df_Xtrend) } diff --git a/script.R b/script.R index f478638708fdb5a5e885fad611550ecef3cd2927..8a1f5805f75ea37376a92e0af7d6f743483bcd9a 100644 --- a/script.R +++ b/script.R @@ -62,14 +62,12 @@ filename = # "P1712910_HYDRO_QJM.txt", # "P0885010_HYDRO_QJM.txt", # "O5055010_HYDRO_QJM.txt", - # "O0384010_HYDRO_QJM.txt", - # "S4214010_HYDRO_QJM.txt", - "Q7002910_HYDRO_QJM.txt" + "O0384010_HYDRO_QJM.txt" + # "S4214010_HYDRO_QJM.txt" + # "Q7002910_HYDRO_QJM.txt" ) - - ## AGENCE EAU ADOUR GARONNE SELECTION # Path to the 'docx' list file of station from the Agence de l'eau # Adour-Garonne that will be analysed