Skip to content

Commit

Permalink
andrea code edits
Browse files Browse the repository at this point in the history
  • Loading branch information
nilanjanchatterjee committed Apr 20, 2022
1 parent 0625c71 commit 8b7c606
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ Github repository: https://github.com/nilanjanchatterjee/parturition

## Description

The app predicts time, location and length of parturition events from radio-telemetry data. It uses the input as *move/movestack* as the output is given in the form of step-length plots with the marked threshold (red-dashed line) and the parturition time (blue-dotted line) and csv with the individual id, parturition time and the lat-long of the parturition event.
The app predicts time, location and length of parturition events from tracking data. It uses the input as *move/movestack* as the output is given in the form of step-length plots with the marked threshold (red-dashed line) and the parturition time (blue-dotted line) and csv with the individual id, parturition time and the lat-long of the parturition event.

## Documentation

The app should be ran with the app *Filter data by season* and *Distance between locations* for convenience. It uses the input of step-length calculated from the *Distance between locations* app. This app uses an individual filter and calculates the step-wise speed for each relocation. Then it filters the location based on the threshold provided by the user or calculates using the average from the dataset. There are pros and cons for both the choices and user discretion and knowledge should be used.
The app must be ran in a workflow with the app *Distance between locations* preceding it, becuase it uses the input of step-length calculated by this App. Furthermore, the App *Filter data by season* allows filtering to the parturition season before. This app uses an individual filter and calculates the step-wise speed for each relocation. Then it filters the location based on the threshold provided by the user or calculates using the average from the dataset. There are pros and cons for both the choices and user discretion and knowledge should be used.
Based on the filter it calculates the parturition interval, location of the parturition and number of relocations in the parturition interval. We used the maximum interval from the data that satisfies the threshold condition.

## Input data
Expand All @@ -21,10 +21,12 @@ Based on the filter it calculates the parturition interval, location of the part
*move/moveStack* in Movebank format

### Artefacts
- Parturition_vel.pdf: pdf with the distance/time_interval plots with the marked threshold (red-dashed line) and parturition interval (blue-dotted line)
- Parturition_vel.pdf: pdf with the distance/time_interval plots with the marked threshold (red-dashed line) and parturition interval (blue-dotted line)

- Parturition_date_output.csv: csv with the individual id, parturition time and parturition lat-long

## Parameters

*threshold*: A speed threshold (user specified) or average calculated using input dataset

*window*: A window specified by user for calculation of moving average or **72 hours** used as default
10 changes: 7 additions & 3 deletions RFunction.R
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
library(move)
library(zoo)
library(tidyverse)
library(readr)
library(sf)
library(rgeos)

rFunction <-function(data, threshold=NULL, window=72){

data_df <-as.data.frame(data)
uid <-unique(data_df$tag_local_identifier)

dat_output <-as.data.frame(uid) ## Save the different individuals
plot.new()
#plot.new()

pdf("Parturition_vel.pdf", width = 8, height = 12)
pdf(paste0(Sys.getenv(x = "APP_ARTIFACTS_DIR", "/tmp/"),"Parturition_vel.pdf"), width = 8, height = 12)
par(mfrow=c(4,3), mar=c(4,4,3,1))

## if no values are specified as threshold then use the mean as the threshold
Expand Down Expand Up @@ -115,12 +118,13 @@ rFunction <-function(data, threshold=NULL, window=72){
dev.off()

dat_final <-do.call(rbind,dat_updt)
names(dat_final) <- make.names(names(dat_final),allow_=FALSE)

###Converting the data.frame output into move-stack object
data_move <- move(x=dat_final$location.long, y=dat_final$location.lat,
time=as.POSIXct(dat_final$timestamp,format="%Y-%m-%d %H:%M:%S"),
data=dat_final, proj=CRS("+proj=longlat +ellps=WGS84"),
animal=dat_final$tag_local_identifier)
animal=dat_final$trackId)

return(data_move)

Expand Down
6 changes: 3 additions & 3 deletions copilot-sdk.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ args<-list()
#################################################################
########################### Arguments ###########################

args[["data"]]
args[["threshold"]]
args[["threshold"]] <- NULL
args[["window"]] <- 72

#################################################################
#################################################################

Expand Down

0 comments on commit 8b7c606

Please sign in to comment.