Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update syncGetters.R #29

Closed
wants to merge 30 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
4be668d
fix bug in getInpSync() - failed if sync_tag was only heard on own hydro
baktoft May 19, 2020
219682e
add function to fine tune sync_model
baktoft Jun 5, 2020
6c11c73
eliminate estimation of log_sigma_hydros_xy, replax priors on SS, ret…
baktoft Jun 7, 2020
e86c457
change version to 1.2.1.9000
baktoft Jul 2, 2020
6ba9673
add plots of temporal stability of sync_model
baktoft Oct 6, 2020
df77bff
adds bbox-constraint
baktoft Oct 8, 2020
16414be
fix bug in plotBbox()
baktoft Oct 8, 2020
d06acbc
fix global variables warnings in devtools::check()
baktoft Oct 8, 2020
1ba9169
add option to use recorded SS in sync
baktoft Oct 16, 2020
df633f3
updated NEWS.md
baktoft Oct 16, 2020
3890870
fix bug in getting sync_model when ss_data_what=est
baktoft Oct 16, 2020
811ca8d
fix bug in plotSyncModelResids()
baktoft Oct 17, 2020
4a2846d
fix bug in getInpSync() when ignoring specific hydros
baktoft Oct 17, 2020
989dcd1
fix bug if not enough data to produce toa
baktoft Oct 22, 2020
b093759
add checkInpSync()
baktoft Oct 28, 2020
edc9eb5
minor bug fixes according to check() and test()
baktoft Oct 29, 2020
f8ea546
Change from error to warning if sync_coverage$n <= 5
baktoft Oct 29, 2020
25cac5a
add better plot to getSyncCoverage() and include data in inp_sync$syn…
baktoft Oct 29, 2020
48ae72b
add option to use selective downsampling in getInpSync()
baktoft Oct 29, 2020
e3cd9aa
disable auto rerunning getSyncModel when extreme outliers identified
baktoft Oct 30, 2020
2580293
fix tiny bug in getDownsampledToaList()
baktoft Oct 30, 2020
ff6302c
fix bug in applySync() so it now can be applied to a matrix also
baktoft Nov 2, 2020
821d385
fix bug in getSyncCheckDat()
baktoft Nov 2, 2020
d8b7a2d
add plotSyncModelHydros()
baktoft Nov 2, 2020
792d877
fix potential bug in fineTuneSyncModel()
baktoft Nov 2, 2020
cf934fc
add estimation of Z
baktoft Nov 13, 2020
828e9e7
fix nasty bug in likelihood when using ping_type='rbi'
baktoft Jan 10, 2021
17584dc
update NEWS.md and update test ref data
baktoft Jan 10, 2021
052e793
Fix bug in getToaYaps() that allowed too short/too high BI to pass th…
baktoft Jan 10, 2021
39b4374
Update syncGetters.R
karlgjelland Jan 20, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix bug in applySync() so it now can be applied to a matrix also
baktoft committed Nov 2, 2020
commit ff6302c1f85687eaf1633b1bc6ff50fa9fccca1d
4 changes: 3 additions & 1 deletion R/applySync.R
Original file line number Diff line number Diff line change
@@ -14,7 +14,9 @@ applySync <- function(toa, hydros="", sync_model){


if(type=="toa_matrix"){
stop("USE OF LINEAR CORRECTION IS NOT IMPLEMENTED IN APPLYING SYNC TO A MATRIX YET!!!")
if(sum(inp_synced$inp_params$lin_corr_coeffs != 0)){
stop("ERROR: Use of linear correction is not yet implemented in applying sync to a matrix!\n If linear corrections are used in sync, these are ignored in this step and results will be wrong!\n")
}
offset_idx_mat <- matrix(findInterval(toa, ks), ncol=ncol(toa))
offset_level_mat <- matrix(inp_synced$inp_params$offset_levels[offset_idx_mat, 1], ncol=ncol(offset_idx_mat))

10 changes: 7 additions & 3 deletions R/syncGetters.R
Original file line number Diff line number Diff line change
@@ -195,7 +195,7 @@ getInpSyncToaList <- function(sync_dat, max_epo_diff, min_hydros, excl_self_dete
getDownsampledToaList <- function(inp_toa_list_all, offset_vals_all, keep_rate){
if(keep_rate > 0 & keep_rate <= 1){
toa_list_downsampled <- downsampleToaList_random(inp_toa_list_all, keep_rate)
} else if(keep_rate > 10){
} else if(keep_rate >= 10){
toa_list_downsampled <- downsampleToaList_selective(inp_toa_list_all, offset_vals_all, keep_rate)
}
return(toa_list_downsampled)
@@ -396,7 +396,7 @@ getEpsLong <- function(report, pl, inp_sync){
#' @param extreme_threshold Ignore delta values larger than this threshold.
#' @inheritParams getInpSync
#' @noRd
getSyncCheckDat <- function(sync_model, extreme_threshold=10000){
getSyncCheckDat <- function(sync_model, extreme_threshold=1000){
toa <- sync_model$inp_synced$inp_params$toa
toa_sync <- applySync(toa, sync_model=sync_model)

@@ -408,7 +408,11 @@ getSyncCheckDat <- function(sync_model, extreme_threshold=10000){
true_y <- sync_model$pl$TRUE_H[,2]
true_z <- sync_model$pl$TRUE_H[,3]

ss_long <- sync_model$pl$SS[ss_idx]
if(sync_model$inp_synced$dat_tmb_sync$dd_data_what == "est"){
ss_long <- sync_model$pl$SS[ss_idx]
} else {
ss_long <- sync_model$inp_synced$dat_tmb_sync$ss_data_vec[ss_idx]
}

toa_sync_long <- data.table::data.table(reshape2::melt(toa_sync))
colnames(toa_sync_long) <- c('ping_idx','hydro_idx', 'toa_sync')