plot_sensorimage: sensor image

plot_sensorimageR Documentation

sensor image

Description

This function plots sensor data as an image. An actogram for instance is a type of sensor image.

Usage

plot_sensorimage(
  date,
  sensor_data,
  tz = "UTC",
  plotx = TRUE,
  ploty = TRUE,
  labelx = TRUE,
  labely = TRUE,
  offset = 0,
  dt = NA,
  xlab = "Hour",
  ylab = "Date",
  cex = 2,
  na.col = "white",
  col = c("black", viridis::magma(90)),
  ...
)

Arguments

date

Date data in POSIXct format, most commonly PAM_data$acceleration$date

sensor_data

sensor data, for example look at PAM_data$acceleration$act

tz

Time zone for POSIXct, default set to "UTC"

plotx

wherether or not to plot the x axis ticks + labels (for instance when compiling multifigures)

ploty

wherether or not to plot the y axis ticks + labels (for instance when compiling multifigures)

labelx

wherether or not to write the name of the x axis (for instance when compiling multifigures)

labely

wherether or not to write the name of the y axis (for instance when compiling multifigures)

offset

This parameter determines where the center of the graph is. When offset = 0, then midday is at the center of the graph. when offset=12 midnight'

dt

the time interval to which the data are resampled (secs). Default is NA

xlab

label for x-axis (as a character string)

ylab

label for y axis (as a character string)

cex

size of labels

na.col

colour given to NA values, default is "white"

col

Colour scheme of plot. Default col = c("black",viridis::magma(90))

...

Any additional parameters used by graphics::image

Value

an image of the sensor data, for instance with activity it would produce an actogram

Examples

## Not run: 
#specify the data location
data(hoopoe)
start = as.POSIXct("2016-07-01","%Y-%m-%d", tz="UTC")
end = as.POSIXct("2017-06-01","%Y-%m-%d", tz="UTC")
PAM_data = create_crop(hoopoe,start,end)

# Create plots with 3 together (mfrow)
par( mfrow= c(1,3), oma=c(0,2,0,6))

par(mar =  c(4,2,4,2))
plot_sensorimage(PAM_data$acceleration$date, ploty=FALSE,
          PAM_data$acceleration$act, main = "Activity",
          col=c("black",viridis::cividis(90)), cex=1.2, cex.main = 2)

par(mar =  c(4,2,4,2))
plot_sensorimage(PAM_data$pressure$date, plotx=TRUE, ploty=FALSE, labely=FALSE,
          PAM_data$pressure$obs,  main="Pressure",
          col=c("black",viridis::cividis(90)), cex=1.2, cex.main = 2)

par(mar =  c(4,2,4,2))
plot_sensorimage(PAM_data$temperature$date, labely=FALSE,
          PAM_data$temperature$obs,  main="Temperature",
          col=c("black",viridis::cividis(90)), cex=1.2, cex.main = 2)

######################################################
# Look at a classification output
######################################################

# Classification
classification  =  classify_flap(dta = PAM_data$acceleration, period = 10, to_plot=FALSE)

par( mfrow= c(1,3), oma=c(0,2,0,6),mar =  c(4,2,4,2))

plot_sensorimage(PAM_data$pressure$date, c(0,abs(diff(PAM_data$pressure$obs))),
          main="Pressure  difference",
          ploty=FALSE,
          col=c("black",viridis::cividis(90)), cex=1.2, cex.main = 2)

plot_sensorimage(PAM_data$acceleration$date, PAM_data$acceleration$act,  main="Activity",
          ploty=FALSE, labely=FALSE,
          col=c(viridis::cividis(90)), cex=1.2, cex.main = 2)

plot_sensorimage(PAM_data$acceleration$date,
          ifelse(classification$classification == classification$migration, 1,2),
          main="Migration Classification",
          labely=FALSE,
          na.col="white",
          col = c("orange","black"),
          cex=1.2, cex.main = 2)


twilights <- GeoLight::twilightCalc(PAM_data$light$date,
                                    PAM_data$light$obs,
                                    LightThreshold = 2,
                                    ask = FALSE)

plot_sensorimage_twilight(twilights$tFirst, offset=0,
       col= ifelse(twilights$type == 1,
                   "goldenrod","cornflowerblue"),
       pch=16, cex=0.5)


## End(Not run)

KiranLDA/PAMLr documentation built on March 6, 2023, 1:40 p.m.