From ef8d78d5941ddf7c6ecbc6f20b0fff992789c4ff Mon Sep 17 00:00:00 2001 From: Ashish Manoj J <122615401+Ash-Manoj@users.noreply.github.com> Date: Tue, 5 Nov 2024 10:10:19 +0100 Subject: [PATCH] changes from alex #PR4 --- src/{ => depreceted}/catlib_old.R | 0 src/{ => depreceted}/lib_old.R | 0 src/{ => depreceted}/plot_old.R | 0 src/{ => depreceted}/run_old.R | 0 src/{ => depreceted}/tool_old.yml | 0 src/hillslope_method.R | 4 +-- src/plot.R | 50 +++++++++++++++++++++++++++++++ 7 files changed, 52 insertions(+), 2 deletions(-) rename src/{ => depreceted}/catlib_old.R (100%) rename src/{ => depreceted}/lib_old.R (100%) rename src/{ => depreceted}/plot_old.R (100%) rename src/{ => depreceted}/run_old.R (100%) rename src/{ => depreceted}/tool_old.yml (100%) create mode 100644 src/plot.R diff --git a/src/catlib_old.R b/src/depreceted/catlib_old.R similarity index 100% rename from src/catlib_old.R rename to src/depreceted/catlib_old.R diff --git a/src/lib_old.R b/src/depreceted/lib_old.R similarity index 100% rename from src/lib_old.R rename to src/depreceted/lib_old.R diff --git a/src/plot_old.R b/src/depreceted/plot_old.R similarity index 100% rename from src/plot_old.R rename to src/depreceted/plot_old.R diff --git a/src/run_old.R b/src/depreceted/run_old.R similarity index 100% rename from src/run_old.R rename to src/depreceted/run_old.R diff --git a/src/tool_old.yml b/src/depreceted/tool_old.yml similarity index 100% rename from src/tool_old.yml rename to src/depreceted/tool_old.yml diff --git a/src/hillslope_method.R b/src/hillslope_method.R index 75e07a1..7773ceb 100644 --- a/src/hillslope_method.R +++ b/src/hillslope_method.R @@ -16,7 +16,7 @@ library('rgdal') #-------------------------------------------------------------------------------------- # Own packages -source("plot_old.R") +source("plot.R") #-------------------------------------------------------------------------------------- # Start hillslope method @@ -35,7 +35,7 @@ hillslope_tool <- function(hillslope_nr, li_spatial, plot_2d_catena=FALSE, plot_ # safty check if hillslope_nr is set to zero if(hillslope_nr == 0) stop("---Do not use hillslope_nr = 0---") - if(hillslope_nr == -1) hill <- hillslope_as_pts # Untested - Ashish 06.08.2024 + if(hillslope_nr == -1) hill <- hillslope_as_pts # hillslope_nr = -1 means that the entire hillslope is used else hill <- hillslope_as_pts[hillslope_as_pts[,3]==hillslope_nr,] #extract number of cells and area of hillslope diff --git a/src/plot.R b/src/plot.R new file mode 100644 index 0000000..475368c --- /dev/null +++ b/src/plot.R @@ -0,0 +1,50 @@ +### +# +plot_profile_geo <- function() + { +plot(hill$short_rep_hill$short_dist, hill$short_rep_hill$short_elev, col=as.factor(hill$short_rep_hill$geo)) + } + + +### +# plot representiv hillslope +plot_rep_hill <- function(hillslope_dist, hillslope_width, rect_col=NA){ + + + delta_d <- (diff(hillslope_width, lag=1)*-1)/2 + plot(1, type="n", axes=T, xlab="", ylab="", xlim=c(max(hillslope_width)*-0.5, + max(hillslope_width)), + ylim=c(0, max(hillslope_dist)), bty='n') + + rect(delta_d[1], 0, hillslope_width[1] - delta_d[1], hillslope_dist[1], col=rect_col) + + for(x in 2:length(delta_d)) + { + rect(sum(delta_d[1:x-1]) + delta_d[x], hillslope_dist[x-1], + hillslope_width[1] - (sum(delta_d[1:x-1]) + delta_d[x]), + hillslope_dist[x], col=rect_col) + } +} + + +### +# +plot_2d_profile <- function(rep_hill, sp_elev, short_dist, short_elev, hillslope_nr) + { + plot(rep_hill$mean_dist, rep_hill$mean_elev, xlab='distance to river [m]', ylab='elevation above river [m]', main=hillslope_nr) + lines(sp_elev, lwd=2, col='blue') + points(short_dist, short_elev, pch=20, col='green') + abline(v=max(short_dist), col='red', lwd=2) + } + + +### +# +plot_hillslope_width <- function(rep_hill, short_dist, short_width, short_width_area_corr, sm_spline) + { + plot(rep_hill$mean_dist, rep_hill$width, pch=1, , xlab='distance to river [m]', ylab='hillslope width [m]') + lines(sm_spline, lwd=2, col='blue') + abline(h=quantile(rep_hill$width, 0.1), lwd=2, col='black', pch=2) + points(short_dist, short_width, pch=20, col='darkgreen') + points(short_dist, short_width_area_corr, pch=5, col='red') + } \ No newline at end of file