-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adding_1s_input_option_shiny.R Adding_input_duration_1s in shiny.R * Flag_duration_change_in_criteria change in criteria in "flag_duration_for_updating_if_value_non_standard_and_calced_interval_is_5s" function for the definition of flag duration. * "Adding_1s_input_option_shiny.R" 1s input option is added in shiny.R * remove NAs in UFLS_detection_voltage NAs are removed during the mean voltage calculations. * ignore_downsampling_for_1s_in_ideal_response down-sampling of "ideal response" is ignored while analyzing 1s data because "ideal response" is already with 1s duration. Only column name "time_group" is changes to match with the existing data-frame. * Suggested modification to "Ideal Response Curve" Potential modification for "Ideal Response Curve" is suggested in "Assumptions and Methodology" tab of GUI * Documenting minor discrepancies in the definition of "Reconnection Compliance Status" Minor discrepancies in the definition of "Reconnection Compliance Status" is identified and mentioned in the documentation for future reference. * downsampling "post event response" to 5s during 1s data analysis "post event response" is down-sampled to 5s, only for 1s data analysis, for the definition of "reconnection status". * Typo corrected in "Ideal Response function" * Typo "duration" is corrected * "d" duration is updated from the "reconnection data" * spacing after "if" statement is corrected * remove NAs during minimum and maximum f and v calculations * adding if condition for downsampling from 1s to 5s Down-sampling is done for data with 1s duration to 5s for "post_event_response" and the other duration are allowed with the previous "post_event_response" calculations. * fixed indenting * downsampling from 1s to 5s for reconnection Calculation of "post_event_response" is downsampled from 1s to 5s. Test file is created for dwonsampling. * Spacing issue is fixed Spacing in the added lines of codes in "island_assessment_function.R" and "ufls_detection_voltage.R" are resolved. * Changes in documentation_tab regarding "reconnection_compliance_status" * Spacing in "thicken" argument in "ideal_response_function.R" * spacing inside if condition is fixed * tidying unintended changes * tidy up downsampling --------- Co-authored-by: Phoebe <[email protected]>
- Loading branch information
1 parent
7456c39
commit ea8e6cb
Showing
12 changed files
with
140 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
downsample_for_reconnection <- function(post_event_response) { | ||
post_event_response_5s_ds <- post_event_response %>% | ||
group_by(c_id) %>% | ||
do(downsample_post_event_response(.)) %>% | ||
data.frame() | ||
|
||
return(post_event_response_5s_ds) | ||
} | ||
|
||
downsample_post_event_response <- function(post_event_response) { | ||
time_intervals <- seq(min(post_event_response$ts), max(post_event_response$ts), by = 5) | ||
avg_power <- sapply(time_intervals, function(interval) { | ||
mean(post_event_response$c_id_daily_norm_power[post_event_response$ts >= interval & | ||
post_event_response$ts < interval + 5], | ||
na.rm = TRUE) | ||
}) | ||
|
||
post_event_response_5S <- data.frame( | ||
c_id = unique(post_event_response$c_id)[1], | ||
ts = time_intervals, | ||
c_id_daily_norm_power = avg_power, | ||
pre_event_norm_power = unique(post_event_response$pre_event_norm_power)[1] | ||
) | ||
return(post_event_response_5S) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
testthat::context("Testing downsampling from 1s to 5s for reconnection compliance calculations.") | ||
|
||
load_test_df <- function(text) { | ||
df <- read.table(text = gsub(" ", "", text), sep = ",", header = TRUE, stringsAsFactors = FALSE) | ||
return(df) | ||
} | ||
|
||
testthat::test_that("Downsampling 1s to 5s works", { | ||
post_event_response <- " ts, c_id, c_id_daily_norm_power, pre_event_norm_power, d | ||
2018-01-01 00:01:00, 1, NA, 0.1, 1 | ||
2018-01-01 00:01:01, 1, 0.0020, 0.1, 1 | ||
2018-01-01 00:01:02, 1, 0.0025, 0.1, 1 | ||
2018-01-01 00:01:03, 1, 0.0020, 0.1, 1 | ||
2018-01-01 00:01:04, 1, 0.0021, 0.1, 1 | ||
2018-01-01 00:01:05, 1, 0.0023, 0.1, 1 | ||
2018-01-01 00:01:06, 1, 0.0024, 0.1, 1 | ||
2018-01-01 00:01:07, 1, 0.0023, 0.1, 1 | ||
2018-01-01 00:01:08, 1, 0.0022, 0.1, 1 | ||
2018-01-01 00:01:09, 1, 0.0020, 0.1, 1 | ||
2018-01-01 00:01:10, 1, 0.0023, 0.1, 1 | ||
2018-01-01 00:01:11, 1, 0.0024, 0.1, 1 | ||
2018-01-01 00:01:12, 1, 0.0024, 0.1, 1 | ||
2018-01-01 00:01:13, 1, 0.0022, 0.1, 1 | ||
2018-01-01 00:01:14, 1, 0.0025, 0.1, 1 | ||
2018-01-01 00:01:15, 1, 0.0026, 0.1, 1 | ||
2018-01-01 00:01:16, 1, 0.0030, 0.1, 1 | ||
2018-01-01 00:01:17, 1, 0.0032, 0.1, 1 | ||
2018-01-01 00:01:19, 1, 0.0030, 0.1, 1" | ||
|
||
# first time interval (2018-01-01 00:01:00) to test downsampling with NAs | ||
# last time interval (2018-01-01 00:01:15) to test downsampling with a missing time step | ||
|
||
post_event_response <- load_test_df(post_event_response) | ||
post_event_response <- dplyr::mutate(post_event_response, ts = as.POSIXct(ts, tz = "Australia/Brisbane")) | ||
|
||
post_event_response_new <- " ts, c_id, c_id_daily_norm_power, pre_event_norm_power | ||
2018-01-01 00:01:00, 1, 0.00215, 0.1 | ||
2018-01-01 00:01:05, 1, 0.00224, 0.1 | ||
2018-01-01 00:01:10, 1, 0.00236, 0.1 | ||
2018-01-01 00:01:15, 1, 0.00295, 0.1" | ||
|
||
post_event_response_new <- load_test_df(post_event_response_new) | ||
post_event_response_new <- dplyr::mutate(post_event_response_new, ts = as.POSIXct(ts, tz = "Australia/Brisbane")) | ||
post_event_response_new <- post_event_response_new %>% relocate(c_id) | ||
|
||
calculated_downsampled_post_event_response <- downsample_for_reconnection(post_event_response) | ||
|
||
testthat::expect_equal(calculated_downsampled_post_event_response, post_event_response_new, tolerance = 1e-4) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters