-
Notifications
You must be signed in to change notification settings - Fork 5
ArticleQuickStart
Tim Lam edited this page Sep 30, 2021
·
23 revisions
-
Please understand that R is being very rapidly developed and geolocation packages may sometimes lag in catching up with the fundamental changes made in R.
-
We just completed updates to support ncdf4 and R.4.1.1. Let us know if you have experienced any issues.
- To make installation a bit easier, a script has been prepared to set up all required packages. To run it, fire up R and type (or paste) the following:
if (!any('devtools' == installed.packages()[,"Package"])){
install.packages('devtools', repos="http://cran.rstudio.com/")}
require(devtools)
source_url("https://raw.githubusercontent.com/positioning/kalmanfilter/master/install.r")
### Optional install analyzepsat as well
# devtools::install_github('galuardi/analyzepsat', dep = T, ref = 'v4.0')
- Inform yourself with an overview of the geolocation methods:
- Refer to PFRP Trackit Workshop materials for more detailed tutorials
-
Start up R, copy-and-paste lines or block of code to run the commands
# Note: delete the hash sign (#) at the beginning to uncomment a line
library(kftrack)
data(big.241) # load packaged example data
track <- big.241
#track<-read.table("datafile.dat", header=TRUE) # change file name and path for your own file
fit1 <-kftrack(track)
fit1 # inspect model parameters
plot(fit1, map=FALSE, ci=TRUE)
save(fit1, file="kf-example.Rdata")
# Note: delete the hash sign (#) at the beginning to uncomment a line
library(ukfsst)
#library(kfsst)
data(blue.shark) # load packaged example data
#track<-read.table("datafile.dat", header=TRUE) # change file name and path for your own file
sst.path<- suppressWarnings(get.sst.from.server(blue.shark))
#sst.file<-write.sst.field(sst.path) # only used in kfsst
track <- blue.shark # delete this line when you use your own data
fit2<- kfsst(track, bx.a=F, bsst.a=F)
fit2 # inspect model parameters
plot(fit2, map=FALSE, ci=TRUE)
save(fit2, file="kf-example.Rdata")
# Note: delete the hash sign (#) at the beginning to uncomment a line
library(trackit)
data(gmt3); data(deltat); deltat$JDE = with(deltat,JDE(year,month,day))
data(drifter) # load packaged example data
#track<-read.table("datafile.dat", header=TRUE) # change file name and path for your own file
prep.track<-prepit(drifter, fix.first=c(360-161.45,22.85,2002,9,10,0,0,0),
fix.last=c(360-159.87,21.95,2003,5,21,0,0,0), scan=FALSE)
fit3<-trackit(prep.track, D.ph=2)
print.trackit(fit3) # inspect model parameters
plot.trackit(fit3)
fitmap(fit3, ci=T)
points(fit3$most.prob.track, pch=20)
save(fit3, file="kf-example.Rdata")
Assume we have run our tracks successfully, and everything is in an active R session, we can output the tracks for other programs.
-
Download the export script for R, fit2csv (Right-click to "save link/ file as")
-
Make sure you note where you save the downloaded file. Drag-and-drop the file into the main R window, or use the function,
source
# Note: delete the hash sign (#) to uncomment a line
# Preparation; find out/ define your working directory:
getwd()
# setwd("C:/Test") # give path to your desired output directory
# Main code:
source("fit2csv.R") # make sure R knows where the file is located,
# or move fit2csv.R to the working directory, as shown above
fit2csv(fit1)
fit2csv(fit2)
- A set of output files (e.g
fit1a.csv
,fit1b.csv
,fit1c.csv
) will be generated for each tag. The output files are:-
-a.csv
- track points -
-b.csv
- model parameters -
-c.csv
- initialization values to model
-
Starter
Fundamentals
R-basics
Essentials
- Overview of KF geolocation packages
- Package details - Kftrack
- Kftrack parameters
- Package details - Kfsst
- Package details - Ukfsst
- Ukfsst parameters
- Package details - Trackit
- Trackit Parameters
Extras
- Extracting confidence intervals and regions
- Bathymetric correction with Analyzepsat
- Generating Utilization Distribution (UD)
- Feeding model results to a remote sensing data extraction routine
Others
Reference