7 Proportions Wet
Within each 2hr period we need to assess:
• Proportion wet or time wet ((Count wets in 2hr period * 30sec) / 72000sec)
Calculate proportions for downsampled data where the sum of wets was calculated in 2hr bins
7.1 Calclate Proportions
Function to calculate proportion of wet time on the downsampled data:
calc_prop <- function(deg_data, bin_time = bin_time) {
bird_id <- deg_data$bird_id[1]
#start by calculating metrics for a single 2hr bin
prop_data <- deg_data %>%
mutate(
bird_id = bird_id,
#proportion of time wet in bin_time period (wets*30 converts wetness level into secs spent wet)
# (600sec per 10min interval) / 20 = 30 seconds per unit
prop_wet = (wets * 30) / (bin_time * 3600) #convert wets to secs and divide by bin_length in secs
)
return(prop_data)
}Applying the function to our DEG files downsampled by 2hrs using sum of wets:
plan(multisession, workers = 4)
bin_time = 2
deg_props_2hrs <- future_map_dfr(deg_2hrs, calc_prop, bin_time = bin_time, .progress = TRUE)
deg_props_2hrs## # A tibble: 1,066,147 × 6
## bird_id date start_time end_time wets prop_wet
## <chr> <date> <chr> <chr> <dbl> <dbl>
## 1 BH584 2017-09-20 00:00:00 01:59:59 0 0
## 2 BH584 2017-09-20 02:00:00 03:59:59 0 0
## 3 BH584 2017-09-20 04:00:00 05:59:59 32 0.133
## 4 BH584 2017-09-20 06:00:00 07:59:59 78 0.325
## 5 BH584 2017-09-20 08:00:00 09:59:59 36 0.15
## 6 BH584 2017-09-20 10:00:00 11:59:59 18 0.075
## 7 BH584 2017-09-20 12:00:00 13:59:59 10 0.0417
## 8 BH584 2017-09-20 14:00:00 15:59:59 62 0.258
## 9 BH584 2017-09-20 16:00:00 17:59:59 49 0.204
## 10 BH584 2017-09-20 18:00:00 19:59:59 21 0.0875
## # ℹ 1,066,137 more rows
Add the colony and deployment_period values from metrics_md to deg_props_2hrs