Title: | Reconstruct Animal Paths from Solar Geolocation Loggers Data |
---|---|
Description: | Spatio-temporal locations of an animal are computed from annotated data with a hidden Markov model via particle filter algorithm. The package is relatively robust to varying degrees of shading. The hidden Markov model is described in Movement Ecology - Rakhimberdiev et al. (2015) <doi:10.1186/s40462-015-0062-5>, general package description is in the Methods in Ecology and Evolution - Rakhimberdiev et al. (2017) <doi:10.1111/2041-210X.12765> and package accuracy assessed in the Journal of Avian Biology - Rakhimberdiev et al. (2016) <doi:10.1111/jav.00891>. |
Authors: | Eldar Rakhimberdiev [aut, cre], Anatoly Saveliev [aut], Julia Karagicheva [aut], Simeon Lisovski [ctb], Johannes de Groeve [ctb] |
Maintainer: | Eldar Rakhimberdiev <[email protected]> |
License: | GPL-3 |
Version: | 0.5.6 |
Built: | 2025-02-24 05:50:25 UTC |
Source: | https://github.com/eldarrak/flightr |
this function converts combines twilights detected in BAStag with raw data and writes them down in TAGS format that can be easily read by get.tags.data
BAStag2TAGS(raw, twl, threshold, filename = NULL)
BAStag2TAGS(raw, twl, threshold, filename = NULL)
raw |
original data - dataframe with two columns first column must contain time and second measured light levels |
twl |
twilights object from |
threshold |
threshold value used for twilight definition in |
filename |
if NULL data.frame in TAGS format will be returned otherwise .csv file in TAGS format will be written |
TAGS format returned or written as .csv by this function is a dataframe with columns
datetime
date and time in ISO 8601 format e.g. 2013-06-16T00:00:11.000Z
light
light value measured by tag
twilight
assigned by the software numeric indication of whether the record belongs to sunrise (1), sunset (2) or none of those (0)
excluded
indication of whether a twilight was excluded during manual inspection (logical, TRUE | FALSE
)
interp
indication of whether the light value at twilight was interpolated (logical, TRUE | FALSE
)
The fields excluded
and interp
may have values of TRUE
only for twilight > 0
.
NULL
if filename
is provided or TAGS formatted dataframe.
Eldar Rakhimberdiev & Simeon Lisovski
Functions attempts to find a location where The function attempts to find a location for a time period assuming animal was not moving. Does not work well will shaded data!
find.stationary.location( Proc.data, calibration.start, calibration.stop, plot = TRUE, initial.coords = NULL, print.optimization = TRUE, reltol = 1e-04 )
find.stationary.location( Proc.data, calibration.start, calibration.stop, plot = TRUE, initial.coords = NULL, print.optimization = TRUE, reltol = 1e-04 )
Proc.data |
processed data object generated by |
calibration.start |
POSIXct time when stationary period started |
calibration.stop |
POSIXct time when stationary period ended |
plot |
plots every iteration |
initial.coords |
location vector with initial values for location (longitude and latitude). Should be close (+-2000 km from the real location) |
print.optimization |
do you want every optimization iteration to be printed? If TRUE - Lon, Lat, calibration mean and calibration sd are being printed. Optimization tries to minimize the latter. |
reltol |
tolerance for optimization, see |
The idea behind the function is that it tries to minimize variance between slopes for the whole period by optimizing location. It can be seen as an extension of Hill-Ekstrom calibration idea.
vector with coordinates - longitude and latitude.
Eldar Rakhimberdiev
#this example takes about 15 minutes to run File<-system.file("extdata", "Godwit_TAGS_format.csv", package = "FLightR") Proc.data<-get.tags.data(File) plot_slopes_by_location(Proc.data=Proc.data, location=c(5.43, 52.93)) abline(v=as.POSIXct("2013-08-20", tz='GMT')) # end of first calibration period abline(v=as.POSIXct("2014-05-05", tz='GMT')) # start of the second calibration period Location<-find.stationary.location(Proc.data, '2013-07-20', '2013-08-20', initial.coords=c(10, 50))
#this example takes about 15 minutes to run File<-system.file("extdata", "Godwit_TAGS_format.csv", package = "FLightR") Proc.data<-get.tags.data(File) plot_slopes_by_location(Proc.data=Proc.data, location=c(5.43, 52.93)) abline(v=as.POSIXct("2013-08-20", tz='GMT')) # end of first calibration period abline(v=as.POSIXct("2014-05-05", tz='GMT')) # start of the second calibration period Location<-find.stationary.location(Proc.data, '2013-07-20', '2013-08-20', initial.coords=c(10, 50))
Idea of this functions is to extract schedules for known location
find.times.distribution(Result, Spatial.Index)
find.times.distribution(Result, Spatial.Index)
Result |
FLightR result object obtained from |
Spatial.Index |
Row numbers for spatial grid ( |
dataframe with columns for 0.025, 0.25, 0.5, 0.75, 0.975 probability of line crossing and rows for every crossing.
Eldar Rakhimberdiev
Summarize result object in the format required for upload to Movebank
FLightR2Movebank(Result, alpha = 0.5, filename = NULL)
FLightR2Movebank(Result, alpha = 0.5, filename = NULL)
Result |
FLightR result object obtained from |
alpha |
coverage of the credible intervals for now only two options: 0.95 or 0.5. |
filename |
if NULL data.frame in TAGS format will be returned otherwise .csv file in TAGS format will be written |
This function accepts FLightR results object.
NULL
if filename
is provided or Movebank formatted dataframe.
Eldar Rakhimberdiev
this function converts combines twilights detected in BAStag to twGeos with raw data and writes them down in TAGS format that can be easily read by get.tags.data
GeoLight2TAGS(raw, gl_twl, threshold, filename = NULL)
GeoLight2TAGS(raw, gl_twl, threshold, filename = NULL)
raw |
original data - dataframe with two columns first column must contain time and second measured light levels |
gl_twl |
twilights object from GeoLight |
threshold |
threshold value used for twilight definition in GeoLight |
filename |
if NULL data.frame in TAGS format will be returned otherwise .csv file in TAGS format will be written |
TAGS format returned or written as .csv by this function is a dataframe with columns
datetime
date and time in ISO 8601 format e.g. 2013-06-16T00:00:11.000Z
light
light value measured by tag
twilight
assigned by the software numeric indication of whether the record belongs to sunrise (1), sunset (2) or none of those (0)
excluded
indication of whether a twilight was excluded during manual inspection (logical, TRUE | FALSE
)
interp
indication of whether the light value at twilight was interpolated (logical, TRUE | FALSE
)
The fields excluded
and interp
may have values of TRUE
only for twilight > 0
.
NULL
if filename
is provided or TAGS formatted dataframe.
Eldar Rakhimberdiev & Simeon Lisovski
This function estimate distances with all zeros from stationary periods. This means many of the resulting movements will have 0 as the distance
get_ZI_distances(Result)
get_ZI_distances(Result)
Result |
An object created by |
a data frame containing median and quartiles for the distances and also departure and arrival time
Eldar Rakhimberdiev
Reads the data frame with detected twilight events into the FLightR
get.tags.data( filename = NULL, start.date = NULL, end.date = NULL, log.light.borders = "auto", log.irrad.borders = "auto", saves = c("auto", "max", "mean"), measurement.period = NULL, impute.on.boundaries = FALSE )
get.tags.data( filename = NULL, start.date = NULL, end.date = NULL, log.light.borders = "auto", log.irrad.borders = "auto", saves = c("auto", "max", "mean"), measurement.period = NULL, impute.on.boundaries = FALSE )
filename |
the name of the file which the data are to be read from. File is supposed to be comma separated file of TAGS format. If it does not contain an absolute path, the file name is relative to the current working directory, getwd(). Tilde-expansion is performed where supported. This can be a compressed file (see |
start.date |
date of beginning of relevant data collection in |
end.date |
date of end of relevant data collection in |
log.light.borders |
Numeric vector with length of 2 for minimum and maximum log(light) levels to use. Alternatively character value 'auto', that will allow FLightR to assign these values according to detected tag type. |
log.irrad.borders |
Numeric vector with length of 2 for minimum and maximum log(irradiance) values to use. Alternatively character value 'auto', that will allow FLightR to assign these values according to detected tag type. |
saves |
character values informing FLightR if min or max values were used by logger. |
measurement.period |
Value in seconds defining how often tag was measuring light levels. If NULL value will be taken from known values for detected tag type. |
impute.on.boundaries |
logical, if FLightR should approximate values at boundaries. Set it to TRUE only if you have vary few active points at each twilight, e.g if tag was saving every 10 minutes or so. |
The returned object has many parts, the important are: (1) the recorded light data, (2) the detected twilight events, (3) light level data at the moment of each determined sunrise and sunset and around them (24 fixes before and 24 after), and (4) technical parameters of the tag, i. e. its type, saving and measuring period (the periodicity, in seconds, at which a tag measures and saves data).
list, which is to be further processed with the FLightR.
File<-system.file("extdata", "Godwit_TAGS_format.csv", package = "FLightR") Proc.data<-get.tags.data(File)
File<-system.file("extdata", "Godwit_TAGS_format.csv", package = "FLightR") Proc.data<-get.tags.data(File)
run.particle.filter
.Function estimates all necessary parameters from the calibration data logged in a known location or locations.
make.calibration( Proc.data, Calibration.periods, model.ageing = FALSE, plot.each = FALSE, plot.final = FALSE, likelihood.correction = "auto", fixed.logSlope = c(NA, NA), suggest.irrad.borders = FALSE, return.slopes = FALSE )
make.calibration( Proc.data, Calibration.periods, model.ageing = FALSE, plot.each = FALSE, plot.final = FALSE, likelihood.correction = "auto", fixed.logSlope = c(NA, NA), suggest.irrad.borders = FALSE, return.slopes = FALSE )
Proc.data |
processed data object generated by |
Calibration.periods |
a data frame containing start and end dates of all the calibration periods (POSIXct) and geographic coordinates of the corresponding calibration locations. |
model.ageing |
if set to TRUE, accounts for the tag ageing (with opacification of its transparent shell of a light sensor), resulting into decreasing sensitivity of the device. This option is useful only if there were several calibration periods or if calibration period was very long (~ longer than a month). |
plot.each |
Do you want every twilight to be plotted while processing |
plot.final |
Do you want final calibration graph to be plotted. On the graph you can see all the observed versus expected light levels. All slopes should be similar. |
likelihood.correction |
will estimate correction of likelihood for the current calibration parameters. Highly recommended not to be change from 'auto'. In this case FLightR will switch it to FALSE in case tag saved data on 10 minutes or longer period. |
fixed.logSlope |
these are mean (1) and SD (2) for distribution of slopes. Should normally be estimated from the data (and thus default is c(NA, NA)). Change any of these two finite values if you want them to be predetermined and not estimated from the calibration data. |
suggest.irrad.borders |
experimental parameter! If set to TRUE function will try to find the best values for the log.irrad.borders |
return.slopes |
if true function will return estimated individual twilight slopes. |
calibration object to be uses in the make.prerun.object
Eldar Rakhimberdiev
File<-system.file("extdata", "Godwit_TAGS_format.csv", package = "FLightR") Proc.data<-get.tags.data(File, end.date=as.POSIXct('2013-08-20', tz='GMT')) Calibration.periods<-data.frame( calibration.start=NA, calibration.stop=as.POSIXct("2013-08-20", tz='GMT'), lon=5.43, lat=52.93) #use c() also for the geographic coordinates, if you have more than one calibration location # (e. g., lon=c(5.43, 6.00), lat=c(52.93,52.94)) print(Calibration.periods) # NB Below likelihood.correction is set to FALSE for fast run! # Leave it as default 'auto' for real examples Calibration<-make.calibration(Proc.data, Calibration.periods, likelihood.correction=FALSE)
File<-system.file("extdata", "Godwit_TAGS_format.csv", package = "FLightR") Proc.data<-get.tags.data(File, end.date=as.POSIXct('2013-08-20', tz='GMT')) Calibration.periods<-data.frame( calibration.start=NA, calibration.stop=as.POSIXct("2013-08-20", tz='GMT'), lon=5.43, lat=52.93) #use c() also for the geographic coordinates, if you have more than one calibration location # (e. g., lon=c(5.43, 6.00), lat=c(52.93,52.94)) print(Calibration.periods) # NB Below likelihood.correction is set to FALSE for fast run! # Leave it as default 'auto' for real examples Calibration<-make.calibration(Proc.data, Calibration.periods, likelihood.correction=FALSE)
This function makes a rectangular grid with use defined boundaries and probabilities of being stationary.
make.grid( left = -180, bottom = -90, right = 180, top = 90, distance.from.land.allowed.to.use = c(-Inf, Inf), distance.from.land.allowed.to.stay = c(-Inf, Inf), plot = TRUE, return.distances = FALSE, probability.of.staying = 0.5 )
make.grid( left = -180, bottom = -90, right = 180, top = 90, distance.from.land.allowed.to.use = c(-Inf, Inf), distance.from.land.allowed.to.stay = c(-Inf, Inf), plot = TRUE, return.distances = FALSE, probability.of.staying = 0.5 )
left |
- left boundary in degrees (-180 <= left <= 180) |
bottom |
- lower boundary in degrees (-90 <= bottom <= 90) |
right |
- right boundary in degrees (-180 <= right <= 180) |
top |
- top boundary in degrees (-90 <= right <= 90) |
distance.from.land.allowed.to.use |
- define how far from the shore animal could occur. Unit - km, negative values are for inland and positive for offshore directions. |
distance.from.land.allowed.to.stay |
- define how far from the shore animal could stay stationary between twilights. Unit - km, negative values are for inland and positive for offshore directions. |
plot |
show a plot of final grid. |
return.distances |
- return distances to the shoreline |
probability.of.staying |
- assigned probability value for grid cells that do not satisfy |
dataframe with coordinates(lon and lat) and probability.of.staying
Eldar Rakhimberdiev
Grid<-make.grid(left=-14, bottom=30, right=13, top=57, distance.from.land.allowed.to.use=c(-Inf, Inf), distance.from.land.allowed.to.stay=c(-Inf, Inf))
Grid<-make.grid(left=-14, bottom=30, right=13, top=57, distance.from.land.allowed.to.use=c(-Inf, Inf), distance.from.land.allowed.to.stay=c(-Inf, Inf))
This function is one step before run.particle.filter
. It combines data, calibration, spatial extent and movement priors and estimates spatial likelihoods that used later in the particle filter.
make.prerun.object( Proc.data, Grid, start, end = start, Calibration, threads = -1, Decision = 0.05, Direction = 0, Kappa = 0, M.mean = 300, M.sd = 500, likelihood.correction = TRUE )
make.prerun.object( Proc.data, Grid, start, end = start, Calibration, threads = -1, Decision = 0.05, Direction = 0, Kappa = 0, M.mean = 300, M.sd = 500, likelihood.correction = TRUE )
Proc.data |
Processed data object created by |
Grid |
Spatial grid created by |
start |
release location (lat, lon). |
end |
end of the track location. Will use |
Calibration |
Calibration object created by |
threads |
number of parallel threads to use. default is -1, which means FLightR will use all available threads except 1. Value 1 will force sequential evaluation |
Decision |
prior for migration probability values from 0 to 1 are allowed |
Direction |
Direction prior for direction of migration (in degrees) with 0 pointing to the North |
Kappa |
concentration parameter for vonMises distribution, 0 means uniform or even distribution. Will set some prior for direction for all the track, so is not recommended to be changed |
M.mean |
Prior for mean distance travelled between consecutive twilights, km |
M.sd |
Prior for sd of distance travelled between consecutive twilights, the higher the value is the wider is the the distribution |
likelihood.correction |
Should likelihood correction estimated during |
Object to be uses in the run.particle.filter
Eldar Rakhimberdiev
File<-system.file("extdata", "Godwit_TAGS_format.csv", package = "FLightR") # to run example fast we will cut the real data file by 2013 Aug 20 Proc.data<-get.tags.data(File, end.date=as.POSIXct('2013-07-02', tz='GMT')) Calibration.periods<-data.frame( calibration.start=NA, calibration.stop=as.POSIXct("2013-08-20", tz='GMT'), lon=5.43, lat=52.93) #use c() also for the geographic coordinates, if you have more than one calibration location # (e. g., lon=c(5.43, 6.00), lat=c(52.93,52.94)) print(Calibration.periods) # NB Below likelihood.correction is set to FALSE for fast run! # Leave it as default TRUE for real examples Calibration<-make.calibration(Proc.data, Calibration.periods, likelihood.correction=FALSE) Grid<-make.grid(left=0, bottom=50, right=10, top=56, distance.from.land.allowed.to.use=c(-Inf, Inf), distance.from.land.allowed.to.stay=c(-Inf, Inf)) all.in<-make.prerun.object(Proc.data, Grid, start=c(5.43, 52.93), Calibration=Calibration, threads=2)
File<-system.file("extdata", "Godwit_TAGS_format.csv", package = "FLightR") # to run example fast we will cut the real data file by 2013 Aug 20 Proc.data<-get.tags.data(File, end.date=as.POSIXct('2013-07-02', tz='GMT')) Calibration.periods<-data.frame( calibration.start=NA, calibration.stop=as.POSIXct("2013-08-20", tz='GMT'), lon=5.43, lat=52.93) #use c() also for the geographic coordinates, if you have more than one calibration location # (e. g., lon=c(5.43, 6.00), lat=c(52.93,52.94)) print(Calibration.periods) # NB Below likelihood.correction is set to FALSE for fast run! # Leave it as default TRUE for real examples Calibration<-make.calibration(Proc.data, Calibration.periods, likelihood.correction=FALSE) Grid<-make.grid(left=0, bottom=50, right=10, top=56, distance.from.land.allowed.to.use=c(-Inf, Inf), distance.from.land.allowed.to.stay=c(-Inf, Inf)) all.in<-make.prerun.object(Proc.data, Grid, start=c(5.43, 52.93), Calibration=Calibration, threads=2)
plots track over map with probability cloud. Can plot only part of the track if dates are specified. Note that you can use it only after obtaining and registering in you current session Google Api Key. For details on the API key check [here](http://ornithologyexchange.org/forums/topic/38315-mapflightrggmap-error).
map.FLightR.ggmap( Result, dates = NULL, plot.cloud = TRUE, map.options = NULL, plot.options = NULL, save.options = NULL, zoom = "auto", return.ggobj = FALSE, seasonal.colors = TRUE, seasonal.donut.location = "topleft", seasonal.donut.proportion = 0.5, save = TRUE )
map.FLightR.ggmap( Result, dates = NULL, plot.cloud = TRUE, map.options = NULL, plot.options = NULL, save.options = NULL, zoom = "auto", return.ggobj = FALSE, seasonal.colors = TRUE, seasonal.donut.location = "topleft", seasonal.donut.proportion = 0.5, save = TRUE )
Result |
FLightR result object obtained from |
dates |
either NULL if all twilights should be included or data.frame with first column - start of the period and second end of the period. Each line represents a new period |
plot.cloud |
Should probability cloud be plotted? If TRUE cloud is estimated by |
map.options |
options passed to |
plot.options |
plotting options. Not defined yet! |
save.options |
options passed to |
zoom |
Zoom for map. If 'auto' FLightR will try to find optimal zoom level by downloading different size maps and checking whether all the points fit the map. |
return.ggobj |
Should ggobj be returned for subsequent checks and/or replotting |
seasonal.colors |
if true points of the track will have seasonal colors |
seasonal.donut.location |
if NULL - no color wheel placed, otherwise select one of 'bottomleft', 'bottomright', 'topleft' |
seasonal.donut.proportion |
how much of X axis should color wheel occupy. return either NULL or ggplot2 class object |
save |
should function save results with |
if 'return.ggobj=TRUE' return ggplot object otherwise returns 'NULL'.
Eldar Rakhimberdiev
File<-system.file("extdata", "Godwit_TAGS_format.csv", package = "FLightR") # to run example fast we will cut the real data file by 2013 Aug 20 Proc.data<-get.tags.data(File, end.date=as.POSIXct('2013-06-25', tz='GMT')) Calibration.periods<-data.frame( calibration.start=as.POSIXct(c(NA, "2014-05-05"), tz='GMT'), calibration.stop=as.POSIXct(c("2013-08-20", NA), tz='GMT'), lon=5.43, lat=52.93) #use c() also for the geographic coordinates, if you have more than one calibration location # (e. g., lon=c(5.43, 6.00), lat=c(52.93,52.94)) # NB Below likelihood.correction is set to FALSE for fast run! # Leave it as default TRUE for real examples Calibration<-make.calibration(Proc.data, Calibration.periods, likelihood.correction=FALSE) Grid<-make.grid(left=0, bottom=50, right=10, top=56, distance.from.land.allowed.to.use=c(-Inf, Inf), distance.from.land.allowed.to.stay=c(-Inf, Inf)) all.in<-make.prerun.object(Proc.data, Grid, start=c(5.43, 52.93), Calibration=Calibration, threads=2) # here we will run only 1e4 partilces for a very short track. # One should use 1e6 particles for the full run Result<-run.particle.filter(all.in, threads=1, nParticles=1e3, known.last=TRUE, precision.sd=25, check.outliers=FALSE) ## Not run: map.FLightR.ggmap(Result, seasonal.donut.location=NULL, zoom=6, save=FALSE) ## End(Not run) # for this short track without variance seasonal donut does not work, # but for normall track it will.
File<-system.file("extdata", "Godwit_TAGS_format.csv", package = "FLightR") # to run example fast we will cut the real data file by 2013 Aug 20 Proc.data<-get.tags.data(File, end.date=as.POSIXct('2013-06-25', tz='GMT')) Calibration.periods<-data.frame( calibration.start=as.POSIXct(c(NA, "2014-05-05"), tz='GMT'), calibration.stop=as.POSIXct(c("2013-08-20", NA), tz='GMT'), lon=5.43, lat=52.93) #use c() also for the geographic coordinates, if you have more than one calibration location # (e. g., lon=c(5.43, 6.00), lat=c(52.93,52.94)) # NB Below likelihood.correction is set to FALSE for fast run! # Leave it as default TRUE for real examples Calibration<-make.calibration(Proc.data, Calibration.periods, likelihood.correction=FALSE) Grid<-make.grid(left=0, bottom=50, right=10, top=56, distance.from.land.allowed.to.use=c(-Inf, Inf), distance.from.land.allowed.to.stay=c(-Inf, Inf)) all.in<-make.prerun.object(Proc.data, Grid, start=c(5.43, 52.93), Calibration=Calibration, threads=2) # here we will run only 1e4 partilces for a very short track. # One should use 1e6 particles for the full run Result<-run.particle.filter(all.in, threads=1, nParticles=1e3, known.last=TRUE, precision.sd=25, check.outliers=FALSE) ## Not run: map.FLightR.ggmap(Result, seasonal.donut.location=NULL, zoom=6, save=FALSE) ## End(Not run) # for this short track without variance seasonal donut does not work, # but for normall track it will.
plots specific likelihood surface over map
plot_likelihood(object, date = NULL, twilight.index = NULL)
plot_likelihood(object, date = NULL, twilight.index = NULL)
object |
either output from |
date |
either NULL or a date (possibly with time) closest to the twilight you wan to be plotted |
twilight.index |
number of likelihood surface to be plotted |
function plots likelihoods before particle filter run, so these are pure results of calibrations without any movement model
'NULL'
Eldar Rakhimberdiev
File<-system.file("extdata", "Godwit_TAGS_format.csv", package = "FLightR") # to run example fast we will cut the real data file by 2013 Aug 20 Proc.data<-get.tags.data(File, end.date=as.POSIXct('2013-07-02', tz='GMT')) Calibration.periods<-data.frame( calibration.start=as.POSIXct(c(NA, "2014-05-05"), tz='GMT'), calibration.stop=as.POSIXct(c("2013-08-20", NA), tz='GMT'), lon=5.43, lat=52.93) #use c() also for the geographic coordinates, if you have more than one calibration location # (e. g., lon=c(5.43, 6.00), lat=c(52.93,52.94)) # NB Below likelihood.correction is set to FALSE for fast run! # Leave it as default TRUE for real examples Calibration<-make.calibration(Proc.data, Calibration.periods, likelihood.correction=FALSE) Grid<-make.grid(left=0, bottom=50, right=10, top=56, distance.from.land.allowed.to.use=c(-Inf, Inf), distance.from.land.allowed.to.stay=c(-Inf, Inf)) all.in<-make.prerun.object(Proc.data, Grid, start=c(5.43, 52.93), Calibration=Calibration, threads=2) plot_likelihood(all.in, twilight.index=10)
File<-system.file("extdata", "Godwit_TAGS_format.csv", package = "FLightR") # to run example fast we will cut the real data file by 2013 Aug 20 Proc.data<-get.tags.data(File, end.date=as.POSIXct('2013-07-02', tz='GMT')) Calibration.periods<-data.frame( calibration.start=as.POSIXct(c(NA, "2014-05-05"), tz='GMT'), calibration.stop=as.POSIXct(c("2013-08-20", NA), tz='GMT'), lon=5.43, lat=52.93) #use c() also for the geographic coordinates, if you have more than one calibration location # (e. g., lon=c(5.43, 6.00), lat=c(52.93,52.94)) # NB Below likelihood.correction is set to FALSE for fast run! # Leave it as default TRUE for real examples Calibration<-make.calibration(Proc.data, Calibration.periods, likelihood.correction=FALSE) Grid<-make.grid(left=0, bottom=50, right=10, top=56, distance.from.land.allowed.to.use=c(-Inf, Inf), distance.from.land.allowed.to.stay=c(-Inf, Inf)) all.in<-make.prerun.object(Proc.data, Grid, start=c(5.43, 52.93), Calibration=Calibration, threads=2) plot_likelihood(all.in, twilight.index=10)
This function plots result by latitude and longitude in either vertical or horizontal layout.
plot_lon_lat(Result, scheme = c("vertical", "horizontal"))
plot_lon_lat(Result, scheme = c("vertical", "horizontal"))
Result |
FLightR result object obtained from |
scheme |
either 'vertical' or 'horizontal' layouts |
'NULL'
Eldar Rakhimberdiev
File<-system.file("extdata", "Godwit_TAGS_format.csv", package = "FLightR") # to run example fast we will cut the real data file by 2013 Aug 20 Proc.data<-get.tags.data(File, end.date=as.POSIXct('2013-07-02', tz='GMT')) Calibration.periods<-data.frame( calibration.start=as.POSIXct(c(NA, "2014-05-05"), tz='GMT'), calibration.stop=as.POSIXct(c("2013-08-20", NA), tz='GMT'), lon=5.43, lat=52.93) #use c() also for the geographic coordinates, if you have more than one calibration location # (e. g., lon=c(5.43, 6.00), lat=c(52.93,52.94)) # NB Below likelihood.correction is set to FALSE for fast run! # Leave it as default TRUE for real examples Calibration<-make.calibration(Proc.data, Calibration.periods, likelihood.correction=FALSE) Grid<-make.grid(left=0, bottom=50, right=10, top=56, distance.from.land.allowed.to.use=c(-Inf, Inf), distance.from.land.allowed.to.stay=c(-Inf, Inf)) all.in<-make.prerun.object(Proc.data, Grid, start=c(5.43, 52.93), Calibration=Calibration, threads=2) # here we will run only 1e4 partilces for a very short track. # One should use 1e6 particles for the full run Result<-run.particle.filter(all.in, threads=1, nParticles=1e3, known.last=TRUE, precision.sd=25, check.outliers=FALSE) plot_lon_lat(Result)
File<-system.file("extdata", "Godwit_TAGS_format.csv", package = "FLightR") # to run example fast we will cut the real data file by 2013 Aug 20 Proc.data<-get.tags.data(File, end.date=as.POSIXct('2013-07-02', tz='GMT')) Calibration.periods<-data.frame( calibration.start=as.POSIXct(c(NA, "2014-05-05"), tz='GMT'), calibration.stop=as.POSIXct(c("2013-08-20", NA), tz='GMT'), lon=5.43, lat=52.93) #use c() also for the geographic coordinates, if you have more than one calibration location # (e. g., lon=c(5.43, 6.00), lat=c(52.93,52.94)) # NB Below likelihood.correction is set to FALSE for fast run! # Leave it as default TRUE for real examples Calibration<-make.calibration(Proc.data, Calibration.periods, likelihood.correction=FALSE) Grid<-make.grid(left=0, bottom=50, right=10, top=56, distance.from.land.allowed.to.use=c(-Inf, Inf), distance.from.land.allowed.to.stay=c(-Inf, Inf)) all.in<-make.prerun.object(Proc.data, Grid, start=c(5.43, 52.93), Calibration=Calibration, threads=2) # here we will run only 1e4 partilces for a very short track. # One should use 1e6 particles for the full run Result<-run.particle.filter(all.in, threads=1, nParticles=1e3, known.last=TRUE, precision.sd=25, check.outliers=FALSE) plot_lon_lat(Result)
The function calculates and plots calibration slopes for sunsets and sunrises for every day of the tracking period, based on the assumption that the tag remained in the same (calibration) location all the time.
plot_slopes_by_location( Proc.data, location, log.light.borders = "auto", log.irrad.borders = "auto", ylim = NULL, xlim = NULL )
plot_slopes_by_location( Proc.data, location, log.light.borders = "auto", log.irrad.borders = "auto", ylim = NULL, xlim = NULL )
Proc.data |
processed data object generated by |
location |
vector with longitude and latitude of calibration location (degrees). |
log.light.borders |
numeric vector with length of 2 for minimum and maximum log(light) levels to use. Default value 'auto', will take these values from the Proc.data object. |
log.irrad.borders |
numeric vector with length of 2 for minimum and maximum log(irradiance) values to use. Default value 'auto', will take these values from the Proc.data object. |
ylim |
the y limits of the plot. The default value, NULL, indicates that the range of the finite values to be plotted should be used. |
xlim |
the x limits of the plot. The default value, NULL, otherwise can be POSIXct or character in a form readable by |
The plot of calibration slopes is used for finding start and end dates of a calibration period (the time period, during which the tag remained in the calibration location with coordinates (x,y)). During the calibration period, the calibration slopes vary little both, between the twilight events (sunrises and sunsets) and in time. When the tag changes location, the slopes for sunrises and sunsets start to deviate. There may potentially be several calibration periods for the same location (if the bird returned to the same location several times). The boundaries (start and end dates) of each of these periods are captured visually. If there were more than one calibration location, the procedure is repeated, once for each location. All the obtained calibration periods can be entered in a data frame 'Calibration.periods', for further analysis. Each line of the data frame contains start and end dates (if applicable) of the calibration period and geographic coordinates of the location.
'NULL'
Eldar Rakhimberdiev
File<-system.file("extdata", "Godwit_TAGS_format.csv", package = "FLightR") Proc.data<-get.tags.data(File) plot_slopes_by_location(Proc.data=Proc.data, location=c(5.43, 52.93)) abline(v=as.POSIXct("2013-08-20", tz='GMT')) # end of first calibration period abline(v=as.POSIXct("2014-05-05", tz='GMT')) # start of the second calibration period
File<-system.file("extdata", "Godwit_TAGS_format.csv", package = "FLightR") Proc.data<-get.tags.data(File) plot_slopes_by_location(Proc.data=Proc.data, location=c(5.43, 52.93)) abline(v=as.POSIXct("2013-08-20", tz='GMT')) # end of first calibration period abline(v=as.POSIXct("2014-05-05", tz='GMT')) # start of the second calibration period
May be use not only for the whole track but for a set of specific dates, e.g. to show spatial uncertainty during migration. Note that you can use it only after obtaining and registering in you current session Google Api Key. For details on the API key check [here](http://ornithologyexchange.org/forums/topic/38315-mapflightrggmap-error).
plot_util_distr( Result, dates = NULL, map.options = NULL, percentiles = c(0.4, 0.6, 0.8), zoom = "auto", geom_polygon.options = NULL, save.options = NULL, color.palette = NULL, use.palette = TRUE, background = NULL, plot = TRUE, save = TRUE )
plot_util_distr( Result, dates = NULL, map.options = NULL, percentiles = c(0.4, 0.6, 0.8), zoom = "auto", geom_polygon.options = NULL, save.options = NULL, color.palette = NULL, use.palette = TRUE, background = NULL, plot = TRUE, save = TRUE )
Result |
FLightR result object obtained from |
dates |
Use NULL if all twilights will be used for plotting, one integer if specific twilight should be plotted (line number in Result$Results$Quantiles). Use data.frame with first column - start of the period and second - end of the period and each line represents a new period to plot specific periods, e.g. wintering or migration. |
map.options |
options passed to |
percentiles |
Probability breaks for utilisation distribution |
zoom |
Zoom for map. If 'auto' FLightR will try to find optimal zoom level by downloading different size maps and checking whether all the points fit the map. |
geom_polygon.options |
options passed to |
save.options |
options passed to |
color.palette |
colors for probability contours. Either NULL or |
use.palette |
should the same colors be used for polygon boundaries as for polygon filling? |
background |
if provided will be used as a background. Must be created by |
plot |
should function produce a plot? |
save |
should function save results with |
list with two parts
res_buffers |
spatial buffers for defined probability values |
p |
|
Eldar Rakhimberdiev
File<-system.file("extdata", "Godwit_TAGS_format.csv", package = "FLightR") # to run example fast we will cut the real data file by 2013 Aug 20 Proc.data<-get.tags.data(File, end.date=as.POSIXct('2013-06-25', tz='GMT')) Calibration.periods<-data.frame( calibration.start=as.POSIXct(c(NA, "2014-05-05"), tz='GMT'), calibration.stop=as.POSIXct(c("2013-08-20", NA), tz='GMT'), lon=5.43, lat=52.93) #use c() also for the geographic coordinates, if you have more than one calibration location # (e. g., lon=c(5.43, 6.00), lat=c(52.93,52.94)) # NB Below likelihood.correction is set to FALSE for fast run! # Leave it as default TRUE for real examples Calibration<-make.calibration(Proc.data, Calibration.periods, likelihood.correction=FALSE) Grid<-make.grid(left=0, bottom=50, right=10, top=56, distance.from.land.allowed.to.use=c(-Inf, Inf), distance.from.land.allowed.to.stay=c(-Inf, Inf)) all.in<-make.prerun.object(Proc.data, Grid, start=c(5.43, 52.93), Calibration=Calibration, threads=1) # here we will run only 1e4 partilces for a very short track. # One should use 1e6 particles for the full run Result<-run.particle.filter(all.in, threads=1, nParticles=1e3, known.last=TRUE, precision.sd=25, check.outliers=FALSE) ## Not run: plot_util_distr(Result, zoom=6, save=FALSE) ## End(Not run)
File<-system.file("extdata", "Godwit_TAGS_format.csv", package = "FLightR") # to run example fast we will cut the real data file by 2013 Aug 20 Proc.data<-get.tags.data(File, end.date=as.POSIXct('2013-06-25', tz='GMT')) Calibration.periods<-data.frame( calibration.start=as.POSIXct(c(NA, "2014-05-05"), tz='GMT'), calibration.stop=as.POSIXct(c("2013-08-20", NA), tz='GMT'), lon=5.43, lat=52.93) #use c() also for the geographic coordinates, if you have more than one calibration location # (e. g., lon=c(5.43, 6.00), lat=c(52.93,52.94)) # NB Below likelihood.correction is set to FALSE for fast run! # Leave it as default TRUE for real examples Calibration<-make.calibration(Proc.data, Calibration.periods, likelihood.correction=FALSE) Grid<-make.grid(left=0, bottom=50, right=10, top=56, distance.from.land.allowed.to.use=c(-Inf, Inf), distance.from.land.allowed.to.stay=c(-Inf, Inf)) all.in<-make.prerun.object(Proc.data, Grid, start=c(5.43, 52.93), Calibration=Calibration, threads=1) # here we will run only 1e4 partilces for a very short track. # One should use 1e6 particles for the full run Result<-run.particle.filter(all.in, threads=1, nParticles=1e3, known.last=TRUE, precision.sd=25, check.outliers=FALSE) ## Not run: plot_util_distr(Result, zoom=6, save=FALSE) ## End(Not run)
Main function of FLightR, it takes fully prepared object created by make.prerun.object
and produces a result object that can be used for plotting etc.
run.particle.filter( all.out, cpus = NULL, threads = -1, nParticles = 1e+06, known.last = TRUE, precision.sd = 25, behav.mask.low.value = 0, k = NA, plot = TRUE, cluster.type = "PSOCK", a = 45, b = 1500, L = 90, adaptive.resampling = 0.99, check.outliers = FALSE, sink2file = FALSE, add.jitter = FALSE )
run.particle.filter( all.out, cpus = NULL, threads = -1, nParticles = 1e+06, known.last = TRUE, precision.sd = 25, behav.mask.low.value = 0, k = NA, plot = TRUE, cluster.type = "PSOCK", a = 45, b = 1500, L = 90, adaptive.resampling = 0.99, check.outliers = FALSE, sink2file = FALSE, add.jitter = FALSE )
all.out |
An object created by |
cpus |
another way to specify |
threads |
An amount of threads to use while running in parallel. default is -1. if value 1 submitted package will run sequentially |
nParticles |
total amount of particles to be used with the run. 10 000 (1e4) is recommended for the preliminary run and 1 000 000 (1e6) for the final |
known.last |
Set to FALSE if your bird was not at a known place during last twilight in the data |
precision.sd |
if |
behav.mask.low.value |
Probability value that will be used instead of 0 in the behavioural mask. If set to 1 behavioural mask will not be active anymore |
k |
Kappa parameter from vonMises distribution. Default is NA, otherwise will generate particles in a direction of a previous transitions with kappa = k |
plot |
Should function plot preliminary map in the end of the run? |
cluster.type |
see help to package parallel for details |
a |
minimum distance that is used in the movement model - left boundary for truncated normal distribution of distances moved between twilights. Default is 45 for as default grid has a minimum distance of 50 km. |
b |
Maximum distance allowed to fly between two consecutive twilights |
L |
how many consecutive particles to resample |
adaptive.resampling |
Above what level of ESS resampling should be skipped |
check.outliers |
switches ON the online outlier routine |
sink2file |
will write run details in a file instead of showing on the screen |
add.jitter |
will add spatial jitter inside a grid cell for the median estimates |
FLightR object, containing output and extracted results. It is a list with the following elements
Indices |
List with prior information and indices |
Spatial |
Spatial data - Grid, Mask, spatial likelihood |
Calibration |
all calibration parameters |
Data |
original data |
Results |
The main results object. Main components of it are
|
Eldar Rakhimberdiev
File<-system.file("extdata", "Godwit_TAGS_format.csv", package = "FLightR") # to run example fast we will cut the real data file by 2013 Aug 20 Proc.data<-get.tags.data(File, end.date=as.POSIXct('2013-07-02', tz='GMT')) Calibration.periods<-data.frame( calibration.start=NA, calibration.stop=as.POSIXct("2013-08-20", tz='GMT'), lon=5.43, lat=52.93) #use c() also for the geographic coordinates, if you have more than one calibration location # (e. g., lon=c(5.43, 6.00), lat=c(52.93,52.94)) print(Calibration.periods) # NB Below likelihood.correction is set to FALSE for fast run! # Leave it as default TRUE for real examples Calibration<-make.calibration(Proc.data, Calibration.periods, likelihood.correction=FALSE) Grid<-make.grid(left=0, bottom=50, right=10, top=56, distance.from.land.allowed.to.use=c(-Inf, Inf), distance.from.land.allowed.to.stay=c(-Inf, Inf)) all.in<-make.prerun.object(Proc.data, Grid, start=c(5.43, 52.93), Calibration=Calibration, threads=2) # here we will run only 1e4 partilces for a very short track. # One should use 1e6 particles for the full run. Result<-run.particle.filter(all.in, threads=1, nParticles=1e3, known.last=TRUE, precision.sd=25, check.outliers=FALSE)
File<-system.file("extdata", "Godwit_TAGS_format.csv", package = "FLightR") # to run example fast we will cut the real data file by 2013 Aug 20 Proc.data<-get.tags.data(File, end.date=as.POSIXct('2013-07-02', tz='GMT')) Calibration.periods<-data.frame( calibration.start=NA, calibration.stop=as.POSIXct("2013-08-20", tz='GMT'), lon=5.43, lat=52.93) #use c() also for the geographic coordinates, if you have more than one calibration location # (e. g., lon=c(5.43, 6.00), lat=c(52.93,52.94)) print(Calibration.periods) # NB Below likelihood.correction is set to FALSE for fast run! # Leave it as default TRUE for real examples Calibration<-make.calibration(Proc.data, Calibration.periods, likelihood.correction=FALSE) Grid<-make.grid(left=0, bottom=50, right=10, top=56, distance.from.land.allowed.to.use=c(-Inf, Inf), distance.from.land.allowed.to.stay=c(-Inf, Inf)) all.in<-make.prerun.object(Proc.data, Grid, start=c(5.43, 52.93), Calibration=Calibration, threads=2) # here we will run only 1e4 partilces for a very short track. # One should use 1e6 particles for the full run. Result<-run.particle.filter(all.in, threads=1, nParticles=1e3, known.last=TRUE, precision.sd=25, check.outliers=FALSE)
This function will find any sites where birds stayed longer than min.stay
. Potential movement is detected by the minimum probability of movement prob.cutoff
.
stationary.migration.summary(Result, prob.cutoff = 0.1, min.stay = 3)
stationary.migration.summary(Result, prob.cutoff = 0.1, min.stay = 3)
Result |
FLightR result object obtained from |
prob.cutoff |
Minimum probability that defines movement |
min.stay |
Minimum duration of stationary period (in twilights) |
list with stationary and movement statistics
Eldar Rakhimberdiev
File<-system.file("extdata", "Godwit_TAGS_format.csv", package = "FLightR") # to run example fast we will cut the real data file by 2013 Aug 20 Proc.data<-get.tags.data(File, end.date=as.POSIXct('2013-06-25', tz='GMT')) Calibration.periods<-data.frame( calibration.start=as.POSIXct(c(NA, "2014-05-05"), tz='GMT'), calibration.stop=as.POSIXct(c("2013-08-20", NA), tz='GMT'), lon=5.43, lat=52.93) #use c() also for the geographic coordinates, if you have more than one calibration location # (e. g., lon=c(5.43, 6.00), lat=c(52.93,52.94)) # NB Below likelihood.correction is set to FALSE for fast run! # Leave it as default TRUE for real examples Calibration<-make.calibration(Proc.data, Calibration.periods, likelihood.correction=FALSE) Grid<-make.grid(left=0, bottom=50, right=10, top=56, distance.from.land.allowed.to.use=c(-Inf, Inf), distance.from.land.allowed.to.stay=c(-Inf, Inf)) all.in<-make.prerun.object(Proc.data, Grid, start=c(5.43, 52.93), Calibration=Calibration, threads=1) # here we will run only 1e4 partilces for a very short track. # One should use 1e6 particles for the full run. Result<-run.particle.filter(all.in, threads=1, nParticles=1e3, known.last=TRUE, precision.sd=25, check.outliers=FALSE) Summary<-stationary.migration.summary(Result, prob.cutoff=1) # Use lower cut offs for real runs!
File<-system.file("extdata", "Godwit_TAGS_format.csv", package = "FLightR") # to run example fast we will cut the real data file by 2013 Aug 20 Proc.data<-get.tags.data(File, end.date=as.POSIXct('2013-06-25', tz='GMT')) Calibration.periods<-data.frame( calibration.start=as.POSIXct(c(NA, "2014-05-05"), tz='GMT'), calibration.stop=as.POSIXct(c("2013-08-20", NA), tz='GMT'), lon=5.43, lat=52.93) #use c() also for the geographic coordinates, if you have more than one calibration location # (e. g., lon=c(5.43, 6.00), lat=c(52.93,52.94)) # NB Below likelihood.correction is set to FALSE for fast run! # Leave it as default TRUE for real examples Calibration<-make.calibration(Proc.data, Calibration.periods, likelihood.correction=FALSE) Grid<-make.grid(left=0, bottom=50, right=10, top=56, distance.from.land.allowed.to.use=c(-Inf, Inf), distance.from.land.allowed.to.stay=c(-Inf, Inf)) all.in<-make.prerun.object(Proc.data, Grid, start=c(5.43, 52.93), Calibration=Calibration, threads=1) # here we will run only 1e4 partilces for a very short track. # One should use 1e6 particles for the full run. Result<-run.particle.filter(all.in, threads=1, nParticles=1e3, known.last=TRUE, precision.sd=25, check.outliers=FALSE) Summary<-stationary.migration.summary(Result, prob.cutoff=1) # Use lower cut offs for real runs!
this function converts combines twilights detected in twGeos with raw data and writes them down in TAGS format that can be easily read by get.tags.data
twGeos2TAGS(raw, twl, threshold, filename = NULL)
twGeos2TAGS(raw, twl, threshold, filename = NULL)
raw |
original data - dataframe with two columns first column must contain time and second measured light levels |
twl |
twilights object from |
threshold |
threshold value used for twilight definition in |
filename |
if NULL data.frame in TAGS format will be returned otherwise .csv file in TAGS format will be written |
TAGS format returned or written as .csv by this function is a dataframe with columns
datetime
date and time in ISO 8601 format e.g. 2013-06-16T00:00:11.000Z
light
light value measured by tag
twilight
assigned by the software numeric indication of whether the record belongs to sunrise (1), sunset (2) or none of those (0)
excluded
indication of whether a twilight was excluded during manual inspection (logical, TRUE | FALSE
)
interp
indication of whether the light value at twilight was interpolated (logical, TRUE | FALSE
)
The fields excluded
and interp
may have values of TRUE
only for twilight > 0
.
NULL
if filename
is provided or TAGS formatted dataframe.
Eldar Rakhimberdiev & Simeon Lisovski