Skip to content

Commit

Permalink
adapt timelag class
Browse files Browse the repository at this point in the history
  • Loading branch information
andreakoelzsch committed Mar 21, 2023
1 parent 1f1cd73 commit e8ed894
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions RFunction.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ rFunction <- function(data,adapt_alt=FALSE,height_props=NULL,ellipsoid=FALSE)

} else
{
if (is.null(data@data[,"timelag"])) logger.info("The variable 'timelag/2' is missing in your data set. Please make sure to run the Time Lag Between Locations App (and Adapt Time Lag for Regular Gaps App) before in your Workflow. Duration weighted height statistics cannot be provided.")
if (is.null(data@data[,"timelag"])) logger.info("The variable 'timelag' is missing in your data set. Please make sure to run the Time Lag Between Locations App (and Adapt Time Lag for Regular Gaps App) before in your Workflow. Duration weighted height statistics cannot be provided.")

hei_props <- sort(as.numeric(trimws(strsplit(as.character(height_props),",")[[1]])),decreasing=FALSE)
n.prop <- length(hei_props)
Expand Down Expand Up @@ -140,7 +140,7 @@ rFunction <- function(data,adapt_alt=FALSE,height_props=NULL,ellipsoid=FALSE)
hei_adap_i <- datai@data[,adap_name]
alt_table$mean.pts.height.adapted[ix] <- mean(hei_adap_i,na.rm=TRUE)
alt_table$sd.pts.height.adapted[ix] <- sd(hei_adap_i,na.rm=TRUE)
dur_i <- datai@data[,"timelag"] # from TimeLag App, if night gaps then last day locs adaped above
dur_i <- as.numeric(datai@data[,"timelag"]) # from TimeLag App
mu_i <- sum(hei_adap_i*dur_i,na.rm=TRUE)/sum(dur_i,na.rm=TRUE)
alt_table$mean.dur.height.adapted[ix] <- mu_i
alt_table$sd.dur.height.adapted[ix] <- sqrt(sum((hei_adap_i-mu_i)*(hei_adap_i-mu_i)*dur_i,na.rm=TRUE)/sum(dur_i,na.rm=TRUE)) #sqrt(weighted variance)
Expand All @@ -149,7 +149,7 @@ rFunction <- function(data,adapt_alt=FALSE,height_props=NULL,ellipsoid=FALSE)

alt_table$mean.pts.height.adapted[n+1] <- mean(hei_adap,na.rm=TRUE)
alt_table$sd.pts.height.adapted[n+1] <- sd(hei_adap,na.rm=TRUE)
dur <- data@data[,"timelag"]
dur <- as.numeric(data@data[,"timelag"])
mu <- sum(hei_adap*dur,na.rm=TRUE)/sum(dur,na.rm=TRUE)
alt_table$mean.dur.height.adapted[n+1] <- mu
alt_table$sd.dur.height.adapted[n+1] <- sqrt(sum((hei_adap-mu)*(hei_adap-mu)*dur,na.rm=TRUE)/sum(dur,na.rm=TRUE))
Expand Down
2 changes: 1 addition & 1 deletion co-pilot-sdk.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
## Provided testing datasets in `./data/raw`:
## "input1_pigeons.rds", "input2_geese.rds", "input3_stork.rds", "input4_goat.rds"
## for own data: file saved as a .rds containing a object of class MoveStack
inputFileName = "App-Output 2_Life_Track_White_Stork_Bavaria__Segment_Data_by_Speed__2022-07-13_10-06-20.rds"
inputFileName = "Workflow_Instance_001__Time_Lag_Between_Locations__2023-03-21_07-18-51.rds"

## optionally change the output file name
unlink("./data/output/", recursive = TRUE)
Expand Down

0 comments on commit e8ed894

Please sign in to comment.