diff --git a/man/add_distance.Rd b/man/add_distance.Rd
index 1da6642..2bdcf35 100644
--- a/man/add_distance.Rd
+++ b/man/add_distance.Rd
@@ -27,7 +27,9 @@ Find the distance between all sensors based on corridor and direction. Essential
It is best to call this function on the entire sensor configuration data table;
you can access the table with \code{pull_configuration()}. Non-station node types
will be
-\subsection{Interpolation}{\preformatted{Where upstream detector does not exist, or where distance is
+\subsection{Interpolation}{
+
+\if{html}{\out{
}}\preformatted{Where upstream detector does not exist, or where distance is
beyond 3 miles, interpolate so as not to assume large VMT
merely because vehicles crossed an isolated detector.
@@ -39,7 +41,7 @@ missing (i.e. NA for entire corridor), or distance attributed is
greater than 3 miles (want a conservative assumption for how
many miles of travel volume at a particular sensor depicts),
interpolate with metro-wide network median.
-}
+}\if{html}{\out{
}}
}
}
\examples{
diff --git a/man/add_weather.Rd b/man/add_weather.Rd
index bafd994..07e994c 100644
--- a/man/add_weather.Rd
+++ b/man/add_weather.Rd
@@ -48,7 +48,6 @@ For additional Minnesota station ID codes, see
the \href{http://mesonet.agron.iastate.edu/sites/networks.php?network=MN_ASOS}{Mesonet station directory}.
}
\examples{
-
\dontrun{
library(tc.sensors)
diff --git a/man/aggregate_sensor.Rd b/man/aggregate_sensor.Rd
index 1979171..a5ecc1f 100644
--- a/man/aggregate_sensor.Rd
+++ b/man/aggregate_sensor.Rd
@@ -51,7 +51,9 @@ values for the given measure
Aggregate raw sensor data to a chosen level
}
\details{
-\subsection{Calculating speed}{\preformatted{There are 60 scans per second, which means there are 60*60 = 1,800 scans per
+\subsection{Calculating speed}{
+
+\if{html}{\out{
}}\preformatted{There are 60 scans per second, which means there are 60*60 = 1,800 scans per
30-second interval. The occupancy value in the 30-second interval data
represents the number of scans that were occupied of the 1,800 scans in that
interval.
@@ -59,10 +61,12 @@ interval.
With 60 scans per second, 60 seconds per minute there are 3,600 scans per minute.
With 3,600 scans per minute, 60 minutes per hour there are 216,000 scans per hour.
To find the number of scans in 15 minutes, we can multiply 0.25 * 216000 = 54,000 scans.
-}
+}\if{html}{\out{
}}
}
-\subsection{Impossible values}{\preformatted{Any observation with a volume that exceeds 20 vehicles or an occupancy that exceeds 1,800 scans
+\subsection{Impossible values}{
+
+\if{html}{\out{
}}\preformatted{Any observation with a volume that exceeds 20 vehicles or an occupancy that exceeds 1,800 scans
will be replaced with `NA`. It is impossible for more than twenty vehicles to pass over a sensor
in only 30 seconds, and the maximum number of scans in 30 seconds is 1,800 (60 scans/second * 30 seconds).
@@ -72,7 +76,7 @@ in only 30 seconds, and the maximum number of scans in 30 seconds is 1,800 (60 s
at the raw data level. The interpolated value for a given observation is the mean of
the two observations on either side of the observation. This method preserves the variable's
overall distribution.
-}
+}\if{html}{\out{
}}
}
}
\examples{
diff --git a/man/pipe.Rd b/man/pipe.Rd
index 0eec752..a648c29 100644
--- a/man/pipe.Rd
+++ b/man/pipe.Rd
@@ -6,6 +6,14 @@
\usage{
lhs \%>\% rhs
}
+\arguments{
+\item{lhs}{A value or the magrittr placeholder.}
+
+\item{rhs}{A function call using the magrittr semantics.}
+}
+\value{
+The result of calling \code{rhs(lhs)}.
+}
\description{
See \code{magrittr::\link[magrittr:pipe]{\%>\%}} for details.
}
diff --git a/man/pull_sensor.Rd b/man/pull_sensor.Rd
index 644f083..1114a04 100644
--- a/man/pull_sensor.Rd
+++ b/man/pull_sensor.Rd
@@ -22,11 +22,14 @@ values. Default is \code{TRUE}}
data frame containing variables volume, occupancy, sensor, date, time.
}
\description{
-Create a tidy data frame, containing volume and occupancy, for a single date and sensor.
+Create a tidy data frame, containing volume and occupancy,
+for a single date and sensor.
Use \code{\link{pull_sensor_ids}} to obtain metro sensor IDs.
}
\details{
-\subsection{Output}{\preformatted{A complete year's worth of data for volume or occupancy for one sensor
+\subsection{Output}{
+
+\if{html}{\out{
}}\preformatted{A complete year's worth of data for volume or occupancy for one sensor
usually results in a file that is around ~30-31KB.
Approximate time to pull one sensor's and one extension's
@@ -35,12 +38,14 @@ Approximate time to pull one sensor's and one extension's
Also note that if you assign `pull_sensor()`'s output, the result is returned in-memory,
and there must be sufficient space in-memory to do so.
-}
+}\if{html}{\out{
}}
}
-\subsection{Missing data}{\preformatted{Occupancy *can* be missing while volume data exists and vice versa.
+\subsection{Missing data}{
+
+\if{html}{\out{
}}\preformatted{Occupancy *can* be missing while volume data exists and vice versa.
It is unknown how a loop could be monitoring volume and not occupancy.
-}
+}\if{html}{\out{
}}
}
}
\examples{
diff --git a/man/pull_sensor_ids.Rd b/man/pull_sensor_ids.Rd
index 21ede1b..9999128 100644
--- a/man/pull_sensor_ids.Rd
+++ b/man/pull_sensor_ids.Rd
@@ -2,9 +2,7 @@
% Please edit documentation in R/pull_sensor_ids.R
\name{pull_sensor_ids}
\alias{pull_sensor_ids}
-\title{Function to pull all sensor IDs in the Twin Cities metro
-
-Create a tidy dataframe containing sensor IDs for MnDOT metro district, mainly to be used with pull_sensor}
+\title{Function to pull all sensor IDs in the Twin Cities metro}
\usage{
pull_sensor_ids(.quiet = TRUE)
}
@@ -15,8 +13,6 @@ pull_sensor_ids(.quiet = TRUE)
dataframe containing variable "detector"
}
\description{
-Function to pull all sensor IDs in the Twin Cities metro
-
Create a tidy dataframe containing sensor IDs for MnDOT metro district, mainly to be used with pull_sensor
}
\examples{
diff --git a/man/replace_impossible.Rd b/man/replace_impossible.Rd
index e0e697f..ea120e4 100644
--- a/man/replace_impossible.Rd
+++ b/man/replace_impossible.Rd
@@ -22,14 +22,16 @@ replaced with \code{NA}.
Replace impossible volume and occupancy values with \code{NA} at given interval
}
\details{
-\subsection{Criteria}{\preformatted{- Hourly
+\subsection{Criteria}{
+
+\if{html}{\out{
}}\preformatted{- Hourly
- total hourly occupancy exceeds 216,000 scans
- total hourly volume exceeds 2,300 cars
- 30-sec
- total 30-second volume exceeds 20 cars
- total 30-second occupancy exceed 1,800 scans
- Percent nulls > 10.
-}
+}\if{html}{\out{
}}
}
}
\author{
diff --git a/man/tc.sensors-package.Rd b/man/tc.sensors-package.Rd
new file mode 100644
index 0000000..f82f88d
--- /dev/null
+++ b/man/tc.sensors-package.Rd
@@ -0,0 +1,33 @@
+% Generated by roxygen2: do not edit by hand
+% Please edit documentation in R/tc.sensors-package.R
+\docType{package}
+\name{tc.sensors-package}
+\alias{tc.sensors}
+\alias{tc.sensors-package}
+\title{tc.sensors: Retrieve Loop Detector Data from the MnDOT JSON Feed}
+\description{
+Process data collected from Minnesota Department of Transportation (MnDOT) loop detectors installed on the Minnesota Freeway system in 30-second interval measurements of occupancy and volume, data which are pushed daily to a public JSON feed. Occupancy and volume data can be used to calculate speed and delay.
+}
+\seealso{
+Useful links:
+\itemize{
+ \item Report bugs at \url{https://github.com/Metropolitan-Council/tc.sensors/issues}
+}
+
+}
+\author{
+\strong{Maintainer}: Liz Roten \email{liz.roten@metc.state.mn.us} (\href{https://orcid.org/0000-0002-5346-3549}{ORCID})
+
+Authors:
+\itemize{
+ \item Nicole Sullivan \email{nicole.sullivan@metc.state.mn.us}
+}
+
+Other contributors:
+\itemize{
+ \item Metropolitan Council [copyright holder]
+ \item Ashley Asmus \email{ashley.asmus@metc.state.mn.us} (\href{https://orcid.org/0000-0001-5505-1372}{ORCID}) [contributor]
+}
+
+}
+\keyword{internal}
diff --git a/tests/testthat/test-add_weather.R b/tests/testthat/test-add_weather.R
index 0eeced4..0314000 100644
--- a/tests/testthat/test-add_weather.R
+++ b/tests/testthat/test-add_weather.R
@@ -1,5 +1,6 @@
-testthat::skip_if_offline()
+testthat::skip_if_offline(host = "metrocouncil.org")
+testthat::skip_on_ci()
test_that("Weather data functions as expected", {
config <- pull_configuration()
diff --git a/tests/testthat/test-replace_impossible.R b/tests/testthat/test-replace_impossible.R
index 3c3ddd8..34f6b9d 100644
--- a/tests/testthat/test-replace_impossible.R
+++ b/tests/testthat/test-replace_impossible.R
@@ -1,6 +1,6 @@
-testthat::skip_if_offline()
+testthat::skip_if_offline("metrocouncil.org")
-test_that("Impossible values are replaced", {
+testthat::test_that("Impossible values are replaced", {
config <- pull_configuration()
yesterday <- as.Date(Sys.Date() - 3)
diff --git a/vignettes/pulling_sensors_in_parallel.Rmd b/vignettes/pulling_sensors_in_parallel.Rmd
index c2e4bfc..5e782a7 100644
--- a/vignettes/pulling_sensors_in_parallel.Rmd
+++ b/vignettes/pulling_sensors_in_parallel.Rmd
@@ -11,51 +11,42 @@ vignette: >
```{r, eval = FALSE}
library(tc.sensors)
-library(doParallel)
-library(foreach)
library(dplyr)
library(magrittr)
-library(tictoc) # If you want to benchmark - but you shouldn't have to; I already did (:
+library(furrr)
+library(tictoc)
+# pull sensor configuration and IDs
sensor_config <- pull_configuration()
sensor_ids <- pull_sensor_ids()
-cores <- detectCores()
-cl <- makeCluster(cores)
-registerDoParallel(cl)
tic() # Start the timer
-foreach(j = sensor_ids[[1]][633:714]) %dopar% {
- date_range <- seq(as.Date("2019/01/01"), as.Date("2019/12/31"), by = "days")
- n <- length(date_range)
- loops_ls <- vector("list", n)
-
- for (i in 1:n) {
- loops_ls[[i]] <- tc.sensors::pull_sensor(j, date_range[[i]])
- }
-
- loops_df <- data.table::rbindlist(loops_ls)
- data.table::fwrite(loops_df, paste0("../../MnDOT_Loop_Detectors/Volume-Occupancy/2019/Sensor ", j, ".csv"))
-}
-toc()
-stopCluster(cl)
-
-```
-
-## Save to Microsoft Access Database
-
-```{r, eval=FALSE}
-library(RODBC)
-
-test_conn <- odbcConnectAccess2007("../LoopDBTest.accdb")
-sqlTables(test_conn, tableType = "TABLE")$TABLE_NAME # Check available tables
-
-sqlSave(channel = test_conn,
- dat = loops_df,
- append = T,
- tablename = "testtable",
- rownames = F) # Prevents RStudio from crashing
-
-check <- RODBC::sqlQuery(test_conn, "SELECT * from testtable WHERE date = 20191231")
+# set up parallel processing
+future::plan(multisession)
+
+# define date range
+date_range <- seq(as.Date("2019/01/01"),
+ as.Date("2019/12/31"), by = "days")
+
+# iterate through each sensor
+sensor_data <- furrr::future_map_dfr(
+ sensor_ids[[1]][633:640],
+ function(x){
+
+ # iterate through each date
+ purrr::map_dfr(date_range,
+ function(d){
+ pull_sensor(
+ sensor = x,
+ pull_date = d
+ )
+ })
+
+ })
+
+tictoc::toc()
+
+head(sensor_data)
```