Learn R Programming

puff (version 0.1.0)

single_emission_rate_plot: Plot Multiple Emission Rate Sensor Concentrations

Description

This function generates a faceted (if multiple sensors) bubble plot of sensor concentrations over time using precomputed sensor data (e.g., from `simulate_sensor_mode()`).

Usage

single_emission_rate_plot(sensor_concentrations, sensor_coords, text_size = 12)

Value

A ggplot object showing sensor concentrations over time, faceted by sensor.

Arguments

sensor_concentrations

Data frame. Output from a sensor simulation function, which must include a column named "Group.1" for timestamps and one or more columns named "Sensor_1", "Sensor_2", etc., for the sensor concentration values.

sensor_coords

Numeric vector or matrix. Coordinates (x, y, z) of the sensor(s).

text_size

Default at 12.

Examples

Run this code
set.seed(123)
sim_dt <- 10
puff_dt <- 10
output_dt <- 60
start_time <- "2024-01-01 12:00:00"
end_time <- "2024-01-01 13:00:00"
emission_rate <- 3.5
wind_data <- data.frame(
  wind_u = runif(3601, min = -3, max = 0.7),
  wind_v = runif(3601, min = -3, max = 1.5)
)
source_coords <- c(0, 0, 2.5)
sensor_coords <- matrix(c(-6.525403221327715e-15, -35.52264, 2.01775), ncol = 3, byrow = TRUE)

out <- simulate_sensor_mode(
  start_time, end_time, source_coords,
  emission_rate, wind_data, sensor_coords, sim_dt, puff_dt, output_dt, puff_duration = 1200
)

single_emission_rate_plot(out, sensor_coords)

Run the code above in your browser using DataLab