Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
maeveupton committed Feb 12, 2024
1 parent c5e0e29 commit 1ad3961
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 10 deletions.
Binary file modified .DS_Store
Binary file not shown.
22 changes: 17 additions & 5 deletions R/internal_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,8 @@ clean_tidal_gauge_data <- function(data,
mat.distance_m <- as.matrix(mat.distance)
#--finding row mins & corresponding tidal gauge--
rownames(mat.distance) <- SL_proxy_unique$SiteName
colnames(mat.distance) <- SL_tide_unique$SiteName
# LongLat better than names as there were duplicate names
colnames(mat.distance) <- SL_tide_unique$LongLat#SL_tide_unique$SiteName
#--finding row mins & corresponding tidal gauge--
dist_TG_proxy <- t(sapply(seq(nrow(mat.distance)), function(z) {
js <- order((mat.distance[z, ]))[1:5]
Expand Down Expand Up @@ -512,12 +513,23 @@ clean_tidal_gauge_data <- function(data,
obs_sites <- SL_tide_unique %>%
dplyr::filter(SiteName %in% dist_TG_proxy_long_2$nearest_TG) %>%
dplyr::select(n_obs_by_site)
dist_TG_proxy_df_new <- data.frame(

dist_TG_proxy_df_no_sitename <- data.frame(
nearest_proxy_site = dist_TG_proxy_long_1$nearest_proxy_site,
nearest_TG = dist_TG_proxy_long_2$nearest_TG,
minimum_dist = as.numeric(dist_TG_proxy_long_1$minimum_distance)
)
) %>%
dplyr::rename(LongLat = nearest_TG)

# Matching the long and lat with name of TG
long_lat_name_match <- SL_tide_unique %>%
dplyr::select(SiteName,LongLat) %>%
dplyr::filter(LongLat %in% dist_TG_proxy_df_no_sitename$LongLat)

dist_TG_proxy_df_new <- dplyr::left_join(dist_TG_proxy_df_no_sitename,
long_lat_name_match, by = "LongLat",
relationship = "many-to-many") %>%
rename(nearest_TG = SiteName)

# Criteria 1: User provides a list of TGs------------------------
if (is.null(list_preferred_TGs) == FALSE) {
Expand Down Expand Up @@ -618,7 +630,7 @@ clean_tidal_gauge_data <- function(data,
}

# Criteria 4: All tide gauges within 1 degree away from proxy site & the preferred tide gauges listed by user
if (TG_minimum_dist_proxy == TRUE & is.null(list_preferred_TGs) == FALSE) {
if (all_TG_1deg == TRUE & is.null(list_preferred_TGs) == FALSE) {
# Check if TG exists in the list
check_TG <- all(list_preferred_TGs %in% unique(decadal_TG_df$SiteName))
if (check_TG == FALSE) {
Expand Down Expand Up @@ -661,7 +673,7 @@ clean_tidal_gauge_data <- function(data,
)
}
# Criteria 5: Closest tide gauges to the proxy site & the preferred tide gauges listed by user
if (all_TG_1deg == TRUE & is.null(list_preferred_TGs) == FALSE) {
if (TG_minimum_dist_proxy == TRUE & is.null(list_preferred_TGs) == FALSE) {
# Check if TG exists in the list
check_TG <- all(list_preferred_TGs %in% unique(decadal_TG_df$SiteName))
if (check_TG == FALSE) {
Expand Down
6 changes: 4 additions & 2 deletions R/reslr_load.R
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,11 @@ reslr_load <- function(data,
)
data_age_boundary_max <- data %>%
dplyr::group_by(SiteName) %>%
dplyr::slice_max(Age) %>%
#dplyr::slice_max(Age) %>%
dplyr::slice_max(Age,with_ties = FALSE) %>%
dplyr::reframe(
max_Age = Age + Age_err
#max_Age = Age + Age_err
max_Age = round(Age + Age_err, digits = 3)
)
data_age_boundary_min <- data %>%
dplyr::group_by(SiteName) %>%
Expand Down
6 changes: 3 additions & 3 deletions R/reslr_mcmc.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
#' @param igp_smooth This setting is focused on the Errors in Variables Integrated Gaussian Process model. It informs the prior for the smoothness (correlation) parameter if model = "igp" is chosen. Choose a value between 0 and 1. Closer to 1 will increase smoothness.
#' @param n_cp This setting is focused on the Errors in Variables Change Point model. The user can select the number of change points 1,2 or 3.
#' @param CI Size of the credible interval required by the user. The default is 0.95 corresponding to 95%.
#' @param spline_nseg This setting is focused on the Noisy Input Spline model. It provides the number of segments used to create basis functions.
#' @param spline_nseg_t This setting is focused on the Noisy Input Generalised Additive Model. It provides the number of segments used to create basis functions.
#' @param spline_nseg_st This setting is focused on the Noisy Input Generalised Additive Model. It provides the number of segments used to create basis functions.
#' @param spline_nseg This setting is focused on the Noisy Input Spline model. It provides the number of segments used to create basis functions. See Advanced vignette for more details.
#' @param spline_nseg_t This setting is focused on the Noisy Input Generalised Additive Model. It provides the number of segments used to create basis functions. See Advanced vignette for more details.
#' @param spline_nseg_st This setting is focused on the Noisy Input Generalised Additive Model. It provides the number of segments used to create basis functions. See Advanced vignette for more details.

#' @return A list containing the input data, the JAGS output and output dataframes used for final plots.
#' @export
Expand Down

0 comments on commit 1ad3961

Please sign in to comment.