Title: | Geospatial Regression Equation for European Nutrient Losses (GREEN) |
---|---|
Description: | Tools and methods to apply the model Geospatial Regression Equation for European Nutrient losses (GREEN); Grizzetti et al. (2005) <doi:10.1016/j.jhydrol.2004.07.036>; Grizzetti et al. (2008); Grizzetti et al. (2012) <doi:10.1111/j.1365-2486.2011.02576.x>; Grizzetti et al. (2021) <doi:10.1016/j.gloenvcha.2021.102281>. |
Authors: | A. Udias [aut], B. Grizzetti [aut], O. Vigiak [aut], J. Gomez [aut], C. Alfaro [aut, cre], A. Aloe [aut] |
Maintainer: | C. Alfaro <[email protected]> |
License: | GPL-3 |
Version: | 1.0.0 |
Built: | 2025-03-01 04:37:48 UTC |
Source: | https://github.com/calfarog/greener |
Defines the sources of nutrient (nitrogen) for each year and catchments.
annual_data_TN
annual_data_TN
A data frame with 14 variables:
BasinID
integer. The basin unique identifier.
YearValue
integer. The year for which data are defined.
HydroID
integer positive. Unique catchment identifier.
NextDownID
integer. Unique identifier of the catchment to which the catchment goes.
Atm
double. Annual nitrogen deposition from atmosphere (ton/yr).
Min
double. Annual amount of nitrogen from mineral fertilisers (ton/yr).
Man
double. Annual amount of nitrogen in manure fertilisers (ton/yr).
Fix
double. Annual amount of nitrogen fixation by leguminous crops and fodder (ton/yr).
Soil
double. Annual amount of nitrogen fixation by bacteria in soils (ton/yr).
Sd
double. Nitrogen input from scattered dwellings (ton/yr).
Ps
double. Nitrogen input from point sources (ton/yr).
YearlyMass
double. Observed annual total nitrogen load (TN ton/yr) from monitoring station data.
ForestFraction
double. Non-agricultural land cover in the catchment (fraction).
InvNrmRain
double. Inverse of normalized rainfall.
Defines the sources of nutrient (phosphorus) for each year and catchments.
annual_data_TP
annual_data_TP
A data frame with 12 variables:
BasinID
integer. The basin unique identifier.
YearValue
integer. The year for which data are defined.
HydroID
integer positive. Unique catchment identifier.
NextDownID
integer. Unique identifier of the catchment to which the catchment goes.
Bg
double. Annual amount of phosphorus background losses (ton/yr).
Min
double. Annual amount of phosphorus mineral fertilisers (ton/yr).
Man
double. Annual amount of phosphorus in manure fertilisers (ton/yr).
Sd
double. Phosphorus input from scattered dwellings (ton/yr).
Ps
double. Phosphorus input from point sources (ton/yr).
YearlyMass
double. Observed annual total phosphorus load (TP ton/yr) from monitoring station data.
ForestFraction
double. Non-agricultural land cover in the catchment (fraction).
InvNrmRain
double. Inverse of normalized rainfall.
Returns boxplots of best model parameters ranked according to different goodness-of-fit measures, and also boxplot with the distribution of the parameters values.
calib_boxplot(df_cb, rate_bs)
calib_boxplot(df_cb, rate_bs)
df_cb |
data frame. Table with the result of the calibration process. |
rate_bs |
numeric. Rate (%) of parameters selected from the whole set produced in the calibration. |
Multiple boxplots
# the data of the TN scenario data(catch_data_TP) data(annual_data_TP) # the parameter for the calibration of the model n_iter <- 2 # number of iterations # the lower limits for all params (alpha_P, alpha_L, sd_coef) low <- c(10, 0.000, 0.1) # the upper limits for all params (alpha_P, alpha_L, sd_coef) upp <- c(70, 0.3, 0.9) # years in which the model should be executed years <- 1990:2018 # execution of the calibration df_calib <- calib_green(catch_data_TP, annual_data_TP, n_iter, low, upp, years) # Generating the box plots rateBS <- 5 # rate of best set of parameter to include in the plots calib_boxplot(df_calib, rateBS)
# the data of the TN scenario data(catch_data_TP) data(annual_data_TP) # the parameter for the calibration of the model n_iter <- 2 # number of iterations # the lower limits for all params (alpha_P, alpha_L, sd_coef) low <- c(10, 0.000, 0.1) # the upper limits for all params (alpha_P, alpha_L, sd_coef) upp <- c(70, 0.3, 0.9) # years in which the model should be executed years <- 1990:2018 # execution of the calibration df_calib <- calib_green(catch_data_TP, annual_data_TP, n_iter, low, upp, years) # Generating the box plots rateBS <- 5 # rate of best set of parameter to include in the plots calib_boxplot(df_calib, rateBS)
Dot plot of goodness-of-fit metric vs parameters value
calib_dot(df_cb, param)
calib_dot(df_cb, param)
df_cb |
data frame. A table with the result of the calibration process. |
param |
character. Goodness of fit measures. See alternatives link "NSE" "rNSE", "NSE", "mNSE", "MAE", "PBIAS", "cp", "R2". |
Multiple dot plots
# the data of the TN scenario data(catch_data_TN) data(annual_data_TN) # the parameter for the calibration of the model n_iter <- 2 # number of iterations # the lower limits for all params (alpha_P, alpha_L, sd_coef) low <- c(10, 0.000, 0.1) # the upper limits for all params (alpha_P, alpha_L, sd_coef) upp <- c(70, 0.3, 0.9) # years in which the model should be executed years <- 1990:2018 # execution of the calibration df_calib <- calib_green(catch_data_TN, annual_data_TN, n_iter, low, upp, years) # Generating the dot plots gof_mes <- "NSE" calib_dot(df_calib, gof_mes)
# the data of the TN scenario data(catch_data_TN) data(annual_data_TN) # the parameter for the calibration of the model n_iter <- 2 # number of iterations # the lower limits for all params (alpha_P, alpha_L, sd_coef) low <- c(10, 0.000, 0.1) # the upper limits for all params (alpha_P, alpha_L, sd_coef) upp <- c(70, 0.3, 0.9) # years in which the model should be executed years <- 1990:2018 # execution of the calibration df_calib <- calib_green(catch_data_TN, annual_data_TN, n_iter, low, upp, years) # Generating the dot plots gof_mes <- "NSE" calib_dot(df_calib, gof_mes)
Runs GREEN model calibration
calib_green(catch_data, annual_data, n_iter, low, upp, years)
calib_green(catch_data, annual_data, n_iter, low, upp, years)
catch_data |
data frame. Definition of the topological sequence of catchments. |
annual_data |
data frame. Sources of nutrient for each year and catchments. |
n_iter |
numeric. Number of iterations for the calibration process. |
low |
numeric. Lower bounds of the calibration parameters. |
upp |
numeric. Upper bounds of the calibration parameters. |
years |
integer. Years to be used in the calibration. For sequences use c(yearini:yearend). |
One object, a data frame with the model calibration
# the data of the TN scenario data(catch_data_TN) data(annual_data_TN) # the parameter for the calibration of the model n_iter <- 2 # number of iterations # the lower limits for all params (alpha_P, alpha_L, sd_coef) low <- c(10, 0.000, 0.1) # the upper limits for all params (alpha_P, alpha_L, sd_coef) upp <- c(70, 0.3, 0.9) # years in which the model should be executed years <- 1990:2018 # execution of the calibration dF_calib <- calib_green(catch_data_TN, annual_data_TN, n_iter, low, upp, years)
# the data of the TN scenario data(catch_data_TN) data(annual_data_TN) # the parameter for the calibration of the model n_iter <- 2 # number of iterations # the lower limits for all params (alpha_P, alpha_L, sd_coef) low <- c(10, 0.000, 0.1) # the upper limits for all params (alpha_P, alpha_L, sd_coef) upp <- c(70, 0.3, 0.9) # years in which the model should be executed years <- 1990:2018 # execution of the calibration dF_calib <- calib_green(catch_data_TN, annual_data_TN, n_iter, low, upp, years)
Defines the topological sequence of catchments for nitrogen.
catch_data_TN
catch_data_TN
A data frame with 5 variables:
HydroID
integer positive. Unique catchment identifier.
To_catch
integer. Unique identifier of the catchment to which the catchment goes. Note that for the outlet To_catch== -1.
Shreve
integer. this indicates the Shreve order of the topological sequence in the stream network.
LakeFrRet
fraction, 0-1. Lake retention fraction.
NrmLengthKm
double. Normalized length of catchment reach.
Defines the topological sequence of catchments for phosphorus.
catch_data_TP
catch_data_TP
A data frame with 5 variables:
HydroID
integer positive. Unique catchment identifier.
To_catch
integer. Unique identifier of the catchment to which the catchment goes. Note that for the outlet To_catch== -1.
Shreve
integer. this indicates the Shreve order of the topological sequence in the stream network.
LakeFrRet
fraction, 0-1. Lake retention fraction.
NrmLengthKm
double. Normalized length of catchment reach.
Returns a scatter plot comparing observed versus modeled loads obtained with two model parameter sets
compare_calib( catch_data, annual_data, alpha_p1, alpha_l1, sd_coef1, alpha_p2, alpha_l2, sd_coef2, years, name_basin, setPlabels )
compare_calib( catch_data, annual_data, alpha_p1, alpha_l1, sd_coef1, alpha_p2, alpha_l2, sd_coef2, years, name_basin, setPlabels )
catch_data |
data frame. Definition of the topological sequence of catchments. |
annual_data |
data frame. Sources of nutrient for each year and catchments. |
alpha_p1 |
numeric. The basin retention coefficient of the first set of parameters. |
alpha_l1 |
numeric. The river retention coefficient of the first set of parameters. |
sd_coef1 |
numeric. Fraction of domestic diffuse sources that reaches the stream network of the first set of parameters. |
alpha_p2 |
numeric. The basin retention coefficient of the second set of parameters. |
alpha_l2 |
numeric. The river retention coefficient of the second set of parameters. |
sd_coef2 |
numeric. Fraction of domestic diffuse sources that reaches the stream network of the second set of parameters. |
years |
numeric. Years to be shown in the plot. |
name_basin |
character. Name of the basin (title of the plot). |
setPlabels |
character. Labels identifying each set of parameter. |
A scatter plot and a list with two data frames with model GREEN applied to two model parameter sets
# the data of the TN scenario data(catch_data_TN) data(annual_data_TN) # the first set of parameters to assess the basin model alpha_p <- 35.09 alpha_l <- 0.02 sd_coef <- 0.2 # the second set of parameters to assess the basin model alpha_p2 <- 41.23 alpha_l2 <- 0.0015 sd_coef2 <- 0.6 # years in which the plot will we shown years <- 1990:2018 nameBasin <- "Lay" # generating the scatter plot comparing two set of parameters observed # versus modeled loads by year setPlabels <- c("bestNSE","bestR2") compare_calib(catch_data_TN, annual_data_TN, alpha_p , alpha_l, sd_coef, alpha_p2, alpha_l2, sd_coef2, years, nameBasin, setPlabels)
# the data of the TN scenario data(catch_data_TN) data(annual_data_TN) # the first set of parameters to assess the basin model alpha_p <- 35.09 alpha_l <- 0.02 sd_coef <- 0.2 # the second set of parameters to assess the basin model alpha_p2 <- 41.23 alpha_l2 <- 0.0015 sd_coef2 <- 0.6 # years in which the plot will we shown years <- 1990:2018 nameBasin <- "Lay" # generating the scatter plot comparing two set of parameters observed # versus modeled loads by year setPlabels <- c("bestNSE","bestR2") compare_calib(catch_data_TN, annual_data_TN, alpha_p , alpha_l, sd_coef, alpha_p2, alpha_l2, sd_coef2, years, nameBasin, setPlabels)
Map showing the mean load input by source
input_maps( catch_data, annual_data, sh_file, plot.type, style_map = "fisher", scale_barTextS = 0.7, legend_position = 1 )
input_maps( catch_data, annual_data, sh_file, plot.type, style_map = "fisher", scale_barTextS = 0.7, legend_position = 1 )
catch_data |
data frame. Definition of the topological sequence of catchments. |
annual_data |
data frame. Sources of nutrient for each year and catchments. |
sh_file |
sf object. The spatial information. |
plot.type |
character. Alternatives of the map: input load (kt) by type divided by year and catchment. “gr1”: by km2; “gr2”: by year/km2. |
style_map |
character. Alternatives to create the intervals in the maps. Chosen style: one of "fixed", "sd", "equal", "pretty", "quantile", "kmeans", "hclust", "bclust", "fisher", "jenks". |
scale_barTextS |
numeric. To modify the size of the text in the legend. |
legend_position |
numeric. Legend position: 1 (default): "right", "bottom"; 2: "left", "up"; 3: "right", "bottom"; 4: "right", "up". |
No return value, called for the side effect of drawing a plot
# the data of the TN scenario data(catch_data_TN) data(annual_data_TN) data(sh_file) # the Input Load Map by source type 1 (lines) input_maps(catch_data_TN, annual_data_TN, sh_file, plot.type = "gr1", legend_position = 2) # the Input Load Map by source type 2 (lines & area) input_maps(catch_data_TN, annual_data_TN, sh_file, plot.type = "gr2", legend_position = 2)
# the data of the TN scenario data(catch_data_TN) data(annual_data_TN) data(sh_file) # the Input Load Map by source type 1 (lines) input_maps(catch_data_TN, annual_data_TN, sh_file, plot.type = "gr1", legend_position = 2) # the Input Load Map by source type 2 (lines & area) input_maps(catch_data_TN, annual_data_TN, sh_file, plot.type = "gr2", legend_position = 2)
A grouped barplot representing the average input load by source for the whole basin or a three density plots showing the distribution of nutrient sources (7 for nitrogen, 5 for phosphorous).
input_plot(annual_data, sh_file, basin_name, plot.type, coef_SD = 1)
input_plot(annual_data, sh_file, basin_name, plot.type, coef_SD = 1)
annual_data |
data frame. Sources of nutrient for each year and catchments. |
sh_file |
sf object. The spatial information. |
basin_name |
character. The title of the plot. |
plot.type |
character. Possible values: Bar plot ("B") or Density plot (“D”). |
coef_SD |
numeric. The standard deviation coefficient. |
No return value, called for the side effect of drawing a plot
# the data of the TN scenario data(annual_data_TN) data(sh_file) # The name of the basin basin_name <- "Lay" # the barplot input_plot(annual_data = annual_data_TN, basin_name = basin_name, plot.type = "B") # the density plots input_plot(annual_data_TN, sh_file, basin_name, "D")
# the data of the TN scenario data(annual_data_TN) data(sh_file) # The name of the basin basin_name <- "Lay" # the barplot input_plot(annual_data = annual_data_TN, basin_name = basin_name, plot.type = "B") # the density plots input_plot(annual_data_TN, sh_file, basin_name, "D")
Creates a time series plot showing basin inputs by source
input_Tserie(catch_data, annual_data, sh_file, basin_name, plot.type)
input_Tserie(catch_data, annual_data, sh_file, basin_name, plot.type)
catch_data |
data frame. Definition of the topological sequence of catchments. |
annual_data |
data frame. Sources of nutrient for each year and catchments. |
sh_file |
sf object. The spatial information. |
basin_name |
character. The title of the plot |
plot.type |
character. Alternative of the plot: “gr1”: stacked area; “gr2”: lines & area. |
A time-series plot
# the data of the TN scenario data(catch_data_TN) data(annual_data_TN) data(sh_file) # The title of the plot plotTitle <- "Time series for the Lay Basin" # the time serie plot 1 (lines) input_Tserie(catch_data_TN, annual_data_TN, sh_file, plotTitle, "gr1") # the time serie plot 2 (lines & area) input_Tserie(catch_data_TN, annual_data_TN, sh_file, plotTitle, "gr2")
# the data of the TN scenario data(catch_data_TN) data(annual_data_TN) data(sh_file) # The title of the plot plotTitle <- "Time series for the Lay Basin" # the time serie plot 1 (lines) input_Tserie(catch_data_TN, annual_data_TN, sh_file, plotTitle, "gr1") # the time serie plot 2 (lines & area) input_Tserie(catch_data_TN, annual_data_TN, sh_file, plotTitle, "gr2")
Creates a time series plot showing basin inputs by source
input_Tserie_area(catch_data, annual_data, sh_file, basin_name, plot.type)
input_Tserie_area(catch_data, annual_data, sh_file, basin_name, plot.type)
catch_data |
data frame. Definition of the topological sequence of catchments. |
annual_data |
data frame. Sources of nutrient for each year and catchments. |
sh_file |
sf object. The spatial information. |
basin_name |
character. The title of the plot |
plot.type |
character. Alternative of the plot: “gr1”: stacked area by km2; “gr2” lines & area by km2 and Shreve. |
A time-series plot
# the data of the TN scenario data(catch_data_TN) data(annual_data_TN) data(sh_file) # The title of the plot plotTitle <- "Time series for the Lay Basin" # the time serie plot 1 (by km2) input_Tserie(catch_data_TN, annual_data_TN, sh_file, plotTitle, "gr1") # the time serie plot 2 (by km2 and Shreve) input_Tserie(catch_data_TN, annual_data_TN, sh_file, plotTitle, "gr2") # catch_data <- The_Scen[[1]] # annual_data <- The_Scen[[2]] # sh_file <- The_Sf_shape
# the data of the TN scenario data(catch_data_TN) data(annual_data_TN) data(sh_file) # The title of the plot plotTitle <- "Time series for the Lay Basin" # the time serie plot 1 (by km2) input_Tserie(catch_data_TN, annual_data_TN, sh_file, plotTitle, "gr1") # the time serie plot 2 (by km2 and Shreve) input_Tserie(catch_data_TN, annual_data_TN, sh_file, plotTitle, "gr2") # catch_data <- The_Scen[[1]] # annual_data <- The_Scen[[2]] # sh_file <- The_Sf_shape
Summary of the reference values in the stations
LakeRetent_plot(catch_data_TN)
LakeRetent_plot(catch_data_TN)
catch_data_TN |
data frame. Sources of nutrient for each year and catchments. |
barplot & histogram-density
# the data of the TN scenario data(catch_data_TN) LakeRetent_plot(catch_data_TN)
# the data of the TN scenario data(catch_data_TN) LakeRetent_plot(catch_data_TN)
Nutrient balance flow in Sankey plot
N4_sankey(Nbalance_out)
N4_sankey(Nbalance_out)
Nbalance_out |
data frame. Nutrient balance result from the Nutbalance() function |
A Sankey diagram and a data frame with the some variable values
# the data of the TN scenario data(catch_data_TN) data(annual_data_TN) # the parameter to assess the basin model alpha_p <- 35.09 alpha_l <- 0.02 sd_coef <- 0.2 # years in which the model should be executed loc_years <- 1990:2018 # Computing the nutrient balance nut_bal <- region_nut_balance(catch_data_TN, annual_data_TN, alpha_p, alpha_l, sd_coef, loc_years) # Plot the sankey plot with the result of the balance sank <- N4_sankey(nut_bal)
# the data of the TN scenario data(catch_data_TN) data(annual_data_TN) # the parameter to assess the basin model alpha_p <- 35.09 alpha_l <- 0.02 sd_coef <- 0.2 # years in which the model should be executed loc_years <- 1990:2018 # Computing the nutrient balance nut_bal <- region_nut_balance(catch_data_TN, annual_data_TN, alpha_p, alpha_l, sd_coef, loc_years) # Plot the sankey plot with the result of the balance sank <- N4_sankey(nut_bal)
Creates maps showing basin output total or by source loads
nutrient_maps(green_file, sh_file, plot.type, style, legend_position = 1)
nutrient_maps(green_file, sh_file, plot.type, style, legend_position = 1)
green_file |
data frame of GREEN model results from green_shares() function. Nutrient Load by source apportionment of nutrient for each year and catchments. |
sh_file |
sf object. The spatial information of the basin. |
plot.type |
character. Alternatives of the map: “gr1”: output load (kt/y) by source; “gr2”: Total Load, log10 (kt/y); “gr3”: Total Load by km2 (kt/year/km2). |
style |
character. The style of the plot. |
legend_position |
numeric. Legend position: 1 (default): "right", "bottom"; 2: "left", "up"; 3: "right", "bottom"; 4: "right", "up". |
No return value, called for the side effect of drawing a plot
# the data of the TN scenario data(catch_data_TN) data(annual_data_TN) data(sh_file) # the parameter to assess the basin model alpha_p <- 35.09 alpha_l <- 0.02 sd_coef <- 0.2 # years in which the model should be executed loc_years <- 1990:2018 # Computing the source apportionment basin_sa <- green_shares(catch_data_TN, annual_data_TN, alpha_p, alpha_l, sd_coef, loc_years) # Basin Output Load Maps by source Lpos <- 1 nutrient_maps(basin_sa, sh_file, plot.type = "gr1", style = "log10", legend_position = Lpos) # Basin Output Specific Load Maps Lpos <- 1 nutrient_maps(basin_sa, sh_file, plot.type = "gr2", style = "log10", legend_position = Lpos) # Basin Output Specific Load by km2 Maps Lpos <- 1 nutrient_maps(basin_sa, sh_file, plot.type = "gr3", style = "fisher", legend_position = Lpos)
# the data of the TN scenario data(catch_data_TN) data(annual_data_TN) data(sh_file) # the parameter to assess the basin model alpha_p <- 35.09 alpha_l <- 0.02 sd_coef <- 0.2 # years in which the model should be executed loc_years <- 1990:2018 # Computing the source apportionment basin_sa <- green_shares(catch_data_TN, annual_data_TN, alpha_p, alpha_l, sd_coef, loc_years) # Basin Output Load Maps by source Lpos <- 1 nutrient_maps(basin_sa, sh_file, plot.type = "gr1", style = "log10", legend_position = Lpos) # Basin Output Specific Load Maps Lpos <- 1 nutrient_maps(basin_sa, sh_file, plot.type = "gr2", style = "log10", legend_position = Lpos) # Basin Output Specific Load by km2 Maps Lpos <- 1 nutrient_maps(basin_sa, sh_file, plot.type = "gr3", style = "fisher", legend_position = Lpos)
Creates a time series plot showing basin model results
nutrient_tserie(green_file, basin_name, plot.type, file_path = NULL)
nutrient_tserie(green_file, basin_name, plot.type, file_path = NULL)
green_file |
data frame. Nutrient Load by source apportionment of nutrient for each year and catchments. |
basin_name |
character. The title of the plot. |
plot.type |
character. Alternative of the plot: output load (t) by source; gr1: Basin average by Shreve (t/y/km2); gr2: Outlet total (kt/y). |
file_path |
character. The path to save the csv. |
No return value, called for the side effect of drawing a plot
# the data of the TN scenario data(catch_data_TN) data(annual_data_TN) data(sh_file) # the parameter to assess the basin model alpha_p <- 35.09 alpha_l <- 0.02 sd_coef <- 0.2 # years in which the model should be executed loc_years <- 1990:2018 # Computing the source apportionment basin_sa <- green_shares(catch_data_TN, annual_data_TN, alpha_p, alpha_l, sd_coef, loc_years) # The title of the plot plotTitle <- "Time series Load Output for the Lay Basin" # Output Load Basin average time series (lines) nutrient_tserie(basin_sa, basin_name = plotTitle, plot.type = "gr1") # Total Load in the Basin Outlet time series (lines) nutrient_tserie(basin_sa, basin_name = plotTitle, plot.type = "gr2")
# the data of the TN scenario data(catch_data_TN) data(annual_data_TN) data(sh_file) # the parameter to assess the basin model alpha_p <- 35.09 alpha_l <- 0.02 sd_coef <- 0.2 # years in which the model should be executed loc_years <- 1990:2018 # Computing the source apportionment basin_sa <- green_shares(catch_data_TN, annual_data_TN, alpha_p, alpha_l, sd_coef, loc_years) # The title of the plot plotTitle <- "Time series Load Output for the Lay Basin" # Output Load Basin average time series (lines) nutrient_tserie(basin_sa, basin_name = plotTitle, plot.type = "gr1") # Total Load in the Basin Outlet time series (lines) nutrient_tserie(basin_sa, basin_name = plotTitle, plot.type = "gr2")
Creates a time series plot showing basin model results
nutrient_tserie_darea(green_file, sh_file, basin_name)
nutrient_tserie_darea(green_file, sh_file, basin_name)
green_file |
data frame. Nutrient Load by source apportionment of nutrient for each year and catchments. |
sh_file |
sf object. The spatial information. |
basin_name |
character. The title of the plot. |
No return value, called for the side effect of drawing a plot
# the data of the TN scenario data(catch_data_TN) data(annual_data_TN) data(sh_file) # the parameter to assess the basin model alpha_p <- 35.09 alpha_l <- 0.02 sd_coef <- 0.2 # years in which the model should be executed loc_years <- 1990:2018 # Computing the source apportionment basin_sa <- green_shares(catch_data_TN, annual_data_TN, alpha_p, alpha_l, sd_coef, loc_years) basin_name <- "Visla Basin" nutrient_tserie_darea(basin_sa, sh_file, basin_name)
# the data of the TN scenario data(catch_data_TN) data(annual_data_TN) data(sh_file) # the parameter to assess the basin model alpha_p <- 35.09 alpha_l <- 0.02 sd_coef <- 0.2 # years in which the model should be executed loc_years <- 1990:2018 # Computing the source apportionment basin_sa <- green_shares(catch_data_TN, annual_data_TN, alpha_p, alpha_l, sd_coef, loc_years) basin_name <- "Visla Basin" nutrient_tserie_darea(basin_sa, sh_file, basin_name)
Function to read the geometry file.
read_geometry(file)
read_geometry(file)
file |
string. A string with the name and extension of the geometry file. |
One object, a sf file.
Function to read the data and return the data frame for GREEN execution.
read_NSdata(path, tsn, obs, ff, rain, topo, lr, length)
read_NSdata(path, tsn, obs, ff, rain, topo, lr, length)
path |
string. A string with the path of the CSV files. |
tsn |
file. A CSV file with nine variables YearValue (integer), HydroID (integer), Atm (float), Min (float), Man (float), Fix (float), Soil (float), Sd (float) and Ps (float). |
obs |
file. A CSV file with three variables YearValue (integer), HydroID (integer) and YearlyMass (float). |
ff |
file. A CSV file with three variables YearValue (integer), HydroID (integer) and ForestFraction (float). |
rain |
file. A CSV file with three variables YearValue (integer), HydroID (integer) and Rain (float). |
topo |
file. A CSV file with two variables HydroID (integer) and Next_HydroID (integer). |
lr |
file. A CSV file with three variables HydroID (integer), AvgDepth (float) and ResTime (float). |
length |
file. A CSV file with two variables HydroID (integer) and LengthKm (float). |
One object, a list with two data frame. First position of the list contains the catch data and the second one the annual data.
path <- "https://raw.githubusercontent.com/calfarog/GREENeR_data/main/data/csv/" ns_data <- read_NSdata(path, "TS_nutrients.csv", "Obs_monitoring.csv", "ForestFr.csv", "Precipitation.csv", "Topology.csv", "LakeProperties.csv", "Length.csv")
path <- "https://raw.githubusercontent.com/calfarog/GREENeR_data/main/data/csv/" ns_data <- read_NSdata(path, "TS_nutrients.csv", "Obs_monitoring.csv", "ForestFr.csv", "Precipitation.csv", "Topology.csv", "LakeProperties.csv", "Length.csv")
Summary of the reference values in the stations
references_plot(annual_data)
references_plot(annual_data)
annual_data |
data frame. Sources of nutrient for each year and catchments. |
A barplot, a histogram-density and a boxplot
# the data of the TN scenario data(annual_data_TN) references_plot(annual_data_TN)
# the data of the TN scenario data(annual_data_TN) references_plot(annual_data_TN)
Computes the basin nutrient balance.
region_nut_balance( catch_data, annual_data, alpha_p, alpha_l, sd_coef, loc_years, atm_coeff = 0.38 )
region_nut_balance( catch_data, annual_data, alpha_p, alpha_l, sd_coef, loc_years, atm_coeff = 0.38 )
catch_data |
data frame. Definition of the topological sequence of catchments. |
annual_data |
data frame. Sources of nutrient for each year and catchments. |
alpha_p |
numeric. First model parameter, the basin retention coefficient. |
alpha_l |
numeric. Second model parameter, the river retention coefficient. |
sd_coef |
numeric. Third model parameter, fraction of domestic diffuse sources that reaches the stream network. |
loc_years |
integer. Years in which the model should be executed. |
atm_coeff |
numeric. A value for atmospheric attenuation coefficient. |
One object, a data frame with the basin nutrient balance
# the data of the TN scenario data(catch_data_TN) data(annual_data_TN) # the parameter to assess the basin model alpha_p <- 35.09 alpha_l <- 0.02 sd_coef <- 0.2 # year in which the model should be executed loc_years <- 1990:2018 # Computing the nutrient balance basin_loads_b <- region_nut_balance(catch_data_TN, annual_data_TN, alpha_p, alpha_l, sd_coef, loc_years)
# the data of the TN scenario data(catch_data_TN) data(annual_data_TN) # the parameter to assess the basin model alpha_p <- 35.09 alpha_l <- 0.02 sd_coef <- 0.2 # year in which the model should be executed loc_years <- 1990:2018 # Computing the nutrient balance basin_loads_b <- region_nut_balance(catch_data_TN, annual_data_TN, alpha_p, alpha_l, sd_coef, loc_years)
Scatter plot of goodness-of-fit metric vs parameters
scatter_plot(df_cb, param)
scatter_plot(df_cb, param)
df_cb |
data frame. A table with the result of the calibration process. |
param |
character. Goodness of fit metric:"NSE", "rNSE", "NSE", "mNSE", "MAE", "PBIAS", "cp", "R2",... |
Multiple scatter plot
# the data of the TN scenario data(catch_data_TN) data(annual_data_TN) # the parameter for the calibration of the model n_iter <- 2 # number of iterations # the lower limits for all params (alpha_P, alpha_L, sd_coef) low <- c(10, 0.000, 0.1) # the upper limits for all params (alpha_P, alpha_L, sd_coef) upp <- c(70, 0.3, 0.9) # years in which the model should be executed years <- 1990:2018 # execution of the calibration df_calib <- calib_green(catch_data_TN, annual_data_TN, n_iter, low, upp, years) gof_mes <- "NSE" scatter_plot(df_calib, gof_mes)
# the data of the TN scenario data(catch_data_TN) data(annual_data_TN) # the parameter for the calibration of the model n_iter <- 2 # number of iterations # the lower limits for all params (alpha_P, alpha_L, sd_coef) low <- c(10, 0.000, 0.1) # the upper limits for all params (alpha_P, alpha_L, sd_coef) upp <- c(70, 0.3, 0.9) # years in which the model should be executed years <- 1990:2018 # execution of the calibration df_calib <- calib_green(catch_data_TN, annual_data_TN, n_iter, low, upp, years) gof_mes <- "NSE" scatter_plot(df_calib, gof_mes)
Return the best calibration parameter set according to one goodness-of-fit metric
select_params(df_cb, param)
select_params(df_cb, param)
df_cb |
data frame. The result of the calibration process. |
param |
numeric. Goodness-of-fit measures. "NSE", "rNSE", "NSE", "mNSE", "MAE", "PBIAS", "cp", "R2",... |
A vector with the 3 parameters
# the data of the TN scenario data(catch_data_TN) data(annual_data_TN) # the parameter for the calibration of the model n_iter <- 2 # number of iterations # the lower limits for all params (alpha_P, alpha_L, sd_coef) low <- c(10, 0.000, 0.1) # the upper limits for all params (alpha_P, alpha_L, sd_coef) upp <- c(70, 0.3, 0.9) # years in which the model should be executed years <- 1990:2018 # execution of the calibration df_calib <- calib_green(catch_data_TN, annual_data_TN, n_iter, low, upp, years) # Extract the best set of parameter according to a Goodnes of fit metric gof_mes <- "NSE" NSE_bestParams <- select_params(df_calib, gof_mes)
# the data of the TN scenario data(catch_data_TN) data(annual_data_TN) # the parameter for the calibration of the model n_iter <- 2 # number of iterations # the lower limits for all params (alpha_P, alpha_L, sd_coef) low <- c(10, 0.000, 0.1) # the upper limits for all params (alpha_P, alpha_L, sd_coef) upp <- c(70, 0.3, 0.9) # years in which the model should be executed years <- 1990:2018 # execution of the calibration df_calib <- calib_green(catch_data_TN, annual_data_TN, n_iter, low, upp, years) # Extract the best set of parameter according to a Goodnes of fit metric gof_mes <- "NSE" NSE_bestParams <- select_params(df_calib, gof_mes)
Function to read the data and return the data frame for GREEN execution.
shreve(the_SC)
shreve(the_SC)
the_SC |
table. A table with topology data. |
One object, a data frame with the shreve.
This function blah, blah, blah....
simobs_annual_plot( catch_data, annual_data, alpha_p, alpha_l, sd_coef, years, name_basin, maxvalue )
simobs_annual_plot( catch_data, annual_data, alpha_p, alpha_l, sd_coef, years, name_basin, maxvalue )
catch_data |
data frame. Definition of the topological sequence of catchments. |
annual_data |
data frame. Sources of nutrient for each year and catchments. |
alpha_p |
numeric. First model parameter, the basin retention coefficient. |
alpha_l |
numeric. Second model parameter, the river retention coefficient. |
sd_coef |
numeric. Third model parameter, fraction of domestic diffuse sources that reaches the stream network. |
years |
integer. Years to be used in the calibration. For sequences use c(yearini:yearend). |
name_basin |
character. The name of the basin |
maxvalue |
numeric. The maximum value |
One object, a data frame