Software Description |
|
Corresponding author: Santosh Bhandari ( santoshbhandari4556@gmail.com ) Academic editor: Christopher John Topping
© 2026 Santosh Bhandari, Mahesh Ghimire, Lalit Kharel.
This is an open access article distributed under the terms of the Creative Commons Attribution License (CC BY 4.0), which permits unrestricted use, distribution, and reproduction in any medium, provided the original author and source are credited.
Citation:
Bhandari S, Ghimire M, Kharel L (2026) TrackTrap: An R-based computational tool for modeling pest phenology with automated weather integration. Agricultural and Environmental Modelling 8: e208963. https://doi.org/10.3897/aem.8.208963
|
Understanding pest phenology is fundamental to integrated pest management (IPM), as constant pest monitoring provides timely information needed for informed management decisions throughout the growing season. Conventional tools and techniques for pest phenology modeling rely on routine trap monitoring to identify the reference event (biofix) and on growing degree days (GDD) to track subsequent developmental progress since the biofix. Manual compilation, cleaning, and processing of weather data from multiple sources can be time-consuming, error-prone tasks that can further delay the development and application of phenology models. Several resources on CRAN (Comprehensive R Archive Network) provide only partial support for pest monitoring workflows, with limited integration of raw trap data processing, automated weather retrieval, GDD calculation, and pest phenology visualization within a single package. In this paper, we present TrackTrap, an open-source R package that automates this workflow by using two meteorological Application Programming Interfaces (APIs), namely Daymet and Open-Meteo, to retrieve location-specific weather information for a user-specified date. As an alternative, users may instead provide weather data manually as a CSV file downloaded from the California Irrigation Management Information System (CIMIS). Following the user’s inputs, TrackTrap then processes JSON responses from Open-Meteo, weather data retrieved via the daymetr package for Daymet, or CSV data manually downloaded from the CIMIS website. Using pest-specific developmental thresholds stored in the package’s built-in database or user-supplied values, TrackTrap computes cumulative GDD using the simple-average method with a horizontal upper-temperature cutoff when specified or without an upper cutoff when explicitly selected. TrackTrap provides researchers and pest control advisors (PCAs) with an automated, reproducible script to compute degree-days beginning the day after biofix and visualize trap catches against accumulated degree days. The software and resources for accessing TrackTrap are freely available in the Zenodo and GitHub repositories.
GDD, IPM, pest modelling, R package, TrackTrap, weather API
Growing degree day (GDD) models are crucial for integrated pest management (IPM) programs to translate temperature accumulation into standard estimates of insect development, generation intervals, and appropriate treatment timings. Despite being an important matter in applied entomology, the practical workflow for implementing GDD models is inconsistent. Acquiring up-to-date and historical weather parameters has recently become a major computational limitation for agricultural researchers and professionals who are constantly seeking to obtain data for calculating GDD. Manual weather data extraction involves accessing web-based meteorological databases, downloading the appropriate datasets in available formats, filtering out missing or incorrect sensor values, and performing threshold-specific mathematical calculations in spreadsheets. This manual data-processing pipeline is laborious, prone to human error, performs poorly in multi-year or multi-location studies, and lacks the programmatic reproducibility necessary for modern data-driven agriculture (
The economic benefits of precise pest phenology modeling are substantial. For instance, in California alone, the specialty crop industry generates approximately $50 billion in annual economic value and accounts for a significant share of the state’s agricultural output. Growers of high-value crops such as citrus, grapes, nuts, and vegetables face recurring pest management challenges, with expenditures for monitoring, biological control, and pesticide applications often representing 5–15% of annual production costs, depending on crop and pest pressure. Because pest populations are strongly influenced by temperature, precipitation, and other environmental factors, IPM programs must continually evolve by incorporating improved monitoring tools, phenology models, and sustainable management strategies to maintain effective and economically viable pest suppression.
A successful IPM strategy relies heavily on pest- and crop-informed decisions to optimize monitoring efforts, biocontrol release, and pesticide application timing. Insects are poikilothermic ectotherms, meaning their body temperature varies with environmental conditions and is largely determined by external heat sources (
Although GDD is simple to calculate, daily monitoring can be a tedious task (
To bridge this gap and enable effective decision-making in agriculture, this research proposes TrackTrap, a new open-source R package (
With user-configurable source selection and automated GDD calculations, TrackTrap makes an otherwise time-consuming, multi-step process efficient and repeatable. This document provides insight into the TrackTrap architecture, how data flows through it, and how it supports informed pest management.
TrackTrap uses the tidyverse-style package ‘dplyr’ to optimize data processing through efficient data manipulation techniques. In this architecture, complete data pipelines are handled from data ingestion to final visualization.
TrackTrap relies on the httr package in R to interact directly with the Open-Meteo API, handle secure communication via programmatic Hypertext Transfer Protocol Secure (HTTPS) requests, and convert the returned JSON into R data structures. In contrast, the daymetr package utilizes its own web resources to retrieve Daymet data secured via HTTPS communication. CIMIS data is imported manually via CSV import, not a programmatic API call. Users may also provide daily weather data directly. Together, these three pathways provide TrackTrap with high-resolution weather data from localized station records to broader grid-based or global geographic coverage.
CIMIS: CIMIS provides agricultural information by accessing weather station data from an extensive network managed by the California Department of Water Resources (
Daymet: The Daymet database is an open-source dataset of daily weather data developed by Oak Ridge National Laboratory, with 1 km resolution across North America and extensive historical records dating back to 1980 (
Open-Meteo: Open-Meteo helps maintain TrackTrap’s usability for global agricultural users by using open-source global weather APIs in real-time. It provides high-resolution models at 1–2 km resolution for Central Europe, France, Switzerland, the UK, and North America, while providing 9–11 km resolution for other global models (
Users are required to provide pest code and trap observation data containing date and trap_counts columns, with one observation per monitoring date. For a custom analysis, users assign pest = NULL and provide a lower temperature threshold. Latitude and longitude are also needed if weather is retrieved using Open-Meteo or Daymet but are not needed for CIMIS CSV input since the file provides temperature data directly, and location coordinates are not extracted from it. Coordinates provided by the user are retained as metadata for plot labelling.
TrackTrap defines biofix as the date of the first positive trap count in the provided monitoring series. This convention is applied consistently across all the listed pests; however, it does not imply that the first capture represents the starting point of every published developmental model. Since there may be instances earlier in the season when very few pests are detected in the trap followed by a sustained period of no pest detection, users are suggested to manually remove such instances and only consider the monitoring period shortly before or starting from the first sustained catch as the biofix. Based on user inputs, TrackTrap then generates an API query string and converts the API response into a standard data frame. Missing daily observations, invalid temperatures, and minimum temperatures exceeding maxima abort the calculation with an error.
Once the temperature data is compiled, TrackTrap calculates GDD using the standard simple average method with a horizontal upper-threshold cutoff (
Mathematically, daily GDDi are calculated using the horizontal cutoff (single-average) method as follows. Before calculation, the daily mean of minimum (Tmin,i and maximum (Tmax,i) temperatures are calculated, and then the horizontal cutoff is applied to the average.
where Ti and T'i are the daily average on day i and cutoff-adjusted daily mean temperature on day i, respectively. The lower threshold (Tlower) is then subtracted from the cutoff-adjusted mean temperature to yield the daily degree-day accumulation:
This implementation is limited by the daily mean temperature before the lower threshold is subtracted. Hence, the calculated daily thermal increment does not increase once the mean temperature exceeds the upper threshold. GDDi is set to zero whenever the result is negative. Cumulative growing degree-days (CDDn) from a biofix date (t0) through day n > t0 are then obtained by summation:
Temperatures are expressed in degrees Fahrenheit, and thermal heat accumulation is expressed in Fahrenheit degree-days.
Furthermore, a lazy-loaded reference database (pest_thresholds.rda) exists in the package that contains 90 pest records, including pest names, scientific names, available temperature thresholds, thermal reference values, and parameter sources. These values were compiled from online sources, including published literature and established degree-day resources from different U.S. universities such as UC IPM. Missing parameters for each variable are stored as ‘NA’. However, inclusion of a pest record does not indicate that a complete or validated phenology model is available for that pest. Users may provide custom values that are supported by documented sources and that are relevant to the developmental endpoint and computation methodology specified.
The thermal reference values correspond to different endpoints such as egg hatch, immature development, adult emergence, and intervals between successive flights or generations. Degree day calculation requires at least a finite value of the lower development threshold for calculation. If no upper threshold is available, the user must either provide custom values or configure upper_cutoff= “none”.
Custom thresholds can be used to override available database values for listed pests. If the pest is custom or not listed in the database, users are required to set pest as ‘NULL’, provide custom_lower and indicate the upper-cutoff selection. These threshold values are dynamically combined with the temperature data retrieved from the selected weather source (Daymet, Open-Meteo, or a manually supplied CIMIS CSV file) to compute the cumulative heat units accumulated by the target pest. An optional display label and custom_thermal_requirement may also be provided. Repeat markers need to be set to TRUE for repetition and are not generated automatically from the database.
Description of the three functions executed by TrackTrap (Table
| Function | Input | Output | Role |
|---|---|---|---|
| Weather Retrieval | Open-Meteo: lat, lon, start_date, end_date, timezone, and model | Data frame: date, tmin (°F), tmax (°F) | Access a daily min/max temperature from Open-Meteo (default; historical + live data), Daymet (gridded data, capped at most recent calendar year, conversion of °C→°F), or a user-provided CIMIS CSV |
| Daymet: lat, lon (year range derived from trap data; current year unsupported). | |||
| CIMIS CSV: cimis_csv_path (lat/lon not used for retrieval, but stored as attributes for plotting) | |||
| calc_pest_phenology() | trap_data containing date and trap_counts; optional pest; weather_source inputs; custom_lower, custom_upper, upper_cutoff, custom_thermal_requirement, and custom_pest_label. Optional database provides reference data. | Data frame: trap_data merged with tmax, tmin, avg_temp, daily DD, cumulative_dd, and cumulative_dd_from_biofix. Complete daily calculations and metadata are retained as attributes. | Calculates degree-days using the simple-average method, with an optional cap on the daily mean and a zero floor. A missing upper threshold requires a user-specified value or explicit upper_cutoff =”none”. Biofix is the first positive trap count; thermal accumulation begins the following day. |
| plot_trap_phenology() | pheno_data; optional pest, year, lat/lon, custom_thermal_requirement, repeat_markers, and custom_pest_label | ggplot object | Visualizes trap catch against accumulated degree-days since biofix. The plot includes a biofix line, and optionally (if a thermal reference value was provided or retained in calculation metadata) a thermal requirement marker. Multiple thermal requirement markers are drawn with repeat_markers = TRUE. |
TrackTrap architecture (Fig.
TrackTrap was employed to develop an example of phenology visualization for Fall Armyworm (Spodoptera frugiperda, FAW), a polyphagous pest affecting more than 80 crops worldwide. Data on FAW were retrieved from a publicly available insect monitoring repository from the Department of Entomology, University of Kentucky (UK, https://ipm.mgcafe.uky.edu/faw) and used as an example case study to illustrate visualization and analysis workflows implemented in the TrackTrap package (Table
Insect count data on FAW were randomly selected for the years 2017, 2019, 2020, and 2024 in the monitoring period (April-September) from the University of Kentucky Research Center, Princeton, KY (
| Year | Station | Coordinates |
|---|---|---|
| 2017 | Princeton, KY | 37.1009, -87.853 |
| 2019 | Princeton, KY | 37.1009, -87.853 |
| 2020 | Princeton, KY | 37.1009, -87.853 |
| 2024 | Princeton, KY | 37.1009, -87.853 |
The TrackTrap package was loaded in the R environment using library (TrackTrap), and trap observations were imported from CSV files. “Daymet” was specified as the weather source for GDD calculation because it provides higher-resolution, precise weather coverage for the user-specified latitude and longitude when real-time information is not available. On the backend, the calc_pest_phenology function (from the package) queries weather data from the initial date of monitoring for each year available in the dataset. For fall armyworm, the lower developmental threshold was set to 54.6 °F (12.57 °C). Because the selected parameter set did not provide a verified compatible upper threshold, calculations used upper_cutoff = “none”. The plot_trap_phenology function then visualized trap catches against cumulative degree-days since biofix. A thermal reference value of 704.8 °F DD was supplied through custom_thermal_requirement that represented the mean egg-to_adult requirement. Multiple lines were displayed using repeat_markers = TRUE.
Code script (Fig.
FAW Phenology Visualization (Fig.
FAW trap-catch patterns varied across monitoring years 2017, 2019, 2020, and 2024 (Fig.
In 2020, the largest reported trap-catch peak was above 400 individuals at approximately 1700 °F-days from first capture. Based on the thermal reference of 704.898 °F-days, the peak was between the second and third multiples of the reference value, about 1409.8 and 2114.7 °F-days, respectively. The thermal reference is the egg-to-adult development. In this case, the accumulation source is the first adult capture. Its repeated multiples thus provide reference positions along the thermal-time axis rather than independently determined generation limits. It shows the importance of continuous monitoring even after initial low catches; however, trap counts alone do not indicate crop infestation or damage.
To make a valid comparison among different weather sources, the calculation parameters must be consistent because differences in developmental thresholds, accumulation dates, and degree-day methods can be misinterpreted as differences in the weather inputs. For the revised comparison, the daily minimum and maximum temperatures from the University of Kentucky station, Open-Meteo, and Daymet should be computed using the identical simple-average calculation (Fig.
The upper temperature cutoff is not used in this configuration. Biofix is defined as first capture on 26 April 2024, at which point cumulative degree-days are set to zero, and accumulation begins on 27 April. Station-specific accumulated values should be calculated from daily station temperatures, not adjusted from an existing cumulative degree-day interval. Cumulative accumulation from the station on 27 September 2024 was 2995.6 °F-days. Open-Meteo and Daymet exceeded this amount, with 228.1 °F-days (7.61%) and 213.9 °F-days (7.14%), respectively (Table
Comparison of Fall Armyworm (Spodoptera frugiperda) degree-day accumulation across on-site station observations (University of Kentucky) and gridded meteorological sources (Open-Meteo and Daymet) at Princeton, KY (2024).
| Date | Trap Catch | Kentucky Station Min/Max (°F) | Kentucky Station SUMDD | Open-Meteo DD | Daymet DD | Δ (Open-Meteo – Kentucky) | Δ (Daymet – Kentucky) |
|---|---|---|---|---|---|---|---|
| 2024-04-05 | 0 | 30.0 / 49.0 | 0 | 0 | 0 | – | – |
| 2024-04-12 | 0 | 43.0 / 66.0 | 0 | 0 | 0 | – | – |
| 2024-04-19 | 0 | 52.0 / 69.0 | 0 | 0 | 0 | – | – |
| 2024-04-26 (Biofix) | 3 | 52.0 / 81.0 | 0 | 0 | 0 | – | – |
| 2024-05-03 | 9 | 64.0 / 75.0 | 111.8 | 117.8 | 119.2 | 6.0 | 7.4 |
| 2024-05-10 | 4 | 53.0 / 68.0 | 218.6 | 229.0 | 235.0 | 10.4 | 16.4 |
| 2024-05-17 | 1 | 63.0 / 75.0 | 292.4 | 314.3 | 321.1 | 21.9 | 28.7 |
| 2024-05-24 | 0 | 66.0 / 76.0 | 420.2 | 445.5 | 456.1 | 25.3 | 35.9 |
| 2024-05-31 | 22 | 61.0 / 81.0 | 528.0 | 556.8 | 567.3 | 28.8 | 39.3 |
| 2024-06-07 | 6 | 56.0 / 85.0 | 655.8 | 688.4 | 703.5 | 32.6 | 47.7 |
| 2024-06-14 | 23 | 62.0 / 90.0 | 752.6 | 795.3 | 815.5 | 42.7 | 62.9 |
| 2024-06-21 | 0 | 68.0 / 91.0 | 921.4 | 978.7 | 994.9 | 57.3 | 73.5 |
| 2024-06-28 | 9 | 68.0 / 90.0 | 1088.2 | 1160.4 | 1172.9 | 72.2 | 84.7 |
| 2024-07-05 | 2 | 69.0 / 86.0 | 1253.0 | 1335.9 | 1347.5 | 82.9 | 94.5 |
| 2024-07-12 | 18 | 68.0 / 88.0 | 1407.8 | 1500.9 | 1513.3 | 93.1 | 105.5 |
| 2024-07-19 | 8 | 60.0 / 81.3 | 1564.2 | 1671.5 | 1680.7 | 107.3 | 116.5 |
| 2024-07-26 | 27 | 69.6 / 84.3 | 1716.4 | 1831.6 | 1840.8 | 115.2 | 124.4 |
| 2024-08-02 | 2 | 70.0 / 87.0 | 1890.2 | 2018.7 | 2028.9 | 128.5 | 138.7 |
| 2024-08-09 | 14 | 63.0 / 83.0 | 2045.0 | 2190.6 | 2197.4 | 145.6 | 152.4 |
| 2024-08-16 | 17 | 70.0 / 90.0 | 2179.8 | 2342.6 | 2341.6 | 162.8 | 161.8 |
| 2024-08-23 | 4 | 62.0 / 89.0 | 2307.6 | 2480.8 | 2477.0 | 173.2 | 169.4 |
| 2024-08-30 | 0 | 70.0 / 94.0 | 2483.4 | 2678.9 | 2673.3 | 195.5 | 189.9 |
| 2024-09-06 | 2 | 60.0 / 93.0 | 2630.2 | 2841.7 | 2829.8 | 211.5 | 199.6 |
| 2024-09-13 | 62 | 65.0 / 84.0 | 2720.0 | 2947.8 | 2927.3 | 227.8 | 207.3 |
| 2024-09-20 | 28 | 62.0 / 91.0 | 2862.8 | 3093.6 | 3078.7 | 230.8 | 215.9 |
| 2024-09-27 | 22 | 62.0 / 70.0 | 2995.6 | 3223.7 | 3209.5 | 228.1 | 213.9 |
Existing degree-day tools fall broadly into two categories: (1) integrated web platforms that provide pre-built species models (e.g., USPEST.org, which hosts over 130 phenology models) and regional extension tools (e.g., WSU and UC IPM degree-day calculators), and (2) R libraries that compute degree-days from user-provided temperature and threshold inputs without broader pipeline integration (e.g., the R package degday, which implements the simple average, triangle and sine methods (
TrackTrap (version 1.1.0) is distributed under the MIT + file license and is openly available on GitHub, with a permanent, citable archive on Zenodo. The package will also be installable directly via install.packages (“TrackTrap”) in R. Researchers are encouraged to submit issues or feature requests in the repository’s issue tracker.
GitHub: https://github.com/Santosh4355/TrackTrap
Zenodo URL: https://doi.org/10.5281/zenodo.23446360
Dependencies
Name: TrackTrap
Version: 1.1.0
Repository: Archived via Zenodo (doi: [https://doi.org/10.5281/zenodo.23446360]); development version on GitHub ([https://github.com/Santosh4355/TrackTrap]);
License: MIT + file License (open source)
Encoding: UTF-8
Programming Language: R (>=3.5.0)
Key dependencies: daymetr, ggplot2, httr, utils
As agricultural datasets increase in size and complexity, entomologists require optimized computational tools to assist in pest monitoring. TrackTrap addresses the challenge of manual weather data collection and degree-day calculation by integrating API data querying and GDD modeling directly into the R environment. It enables researchers to perform rapid, reproducible phenological modeling to support modern IPM strategies.
Biofix is the date when there is the first sustained occurrence of a pest earlier in the season. Often, the biofix determination is left to growers. There are instances when there is initial detection of a pest followed by a prolonged period of no pest detection. More recently, researchers have proposed using the first sustained catch as the biofix rather than relying on the first single positive catch. This package expects users to determine the first sustained catches of the targeted pest and format the dataset accordingly before feeding it for analysis. In the use case example, no trimming was done to adjust for zero counts of FAW from the University of Kentucky dataset across the monitoring dates preceding the biofix.
TrackTrap was built independently by the authors and did not rely on institutional funds or time. We thank the California Irrigation Management Information System (CIMIS), Open-Meteo, and NASA Daymet for the free access to weather data used for growing degree day calculations and pest phenology modeling in TrackTrap. We are deeply grateful to the developers and maintainers of the R packages that this work depends on, such as dplyr, ggplot2, and httr, which enabled us to process data, integrate API, and visualize information.
A premium subscription to Grammarly was used to improve the standard of writing intended for academic journals.
The authors have declared that no competing interests exist.
No ethical statement was reported.
The authors accept full responsibility for the content of the manuscript, including the disclosure of any use of AI.
No AI tools were used in the preparation of this manuscript.
No funding was reported.
SB: Conceptualization, Methodology, Software, Formal analysis, Investigation, Resources, Data Curation, Writing – Original draft. MG: Methodology, Validation, Formal analysis, Writing – Review and Editing. LK: Methodology, Software, Validation, Formal analysis, Data Curation, Writing – Review and Editing, Visualization
S. Bhandari https://orcid.org/0000-0001-9991-474X
M. Ghimire https://orcid.org/0009-0005-6295-0954
L. Kharel https://orcid.org/0009-0002-0699-546X
All of the data that support the findings of this study are available in the main text or Supplementary Information.
Input data format
Data type: pdf