Thermal Regimes
Brian S. Yandell
03 August 2026
thermal.RmdThis document details the routines in the ewing
package for adjusting daily high/low temperatures and life stage
transition splines, as well as the refactoring details for
tempApp() and its Shinylive WebAssembly demo.
1. Core Spline & Temperature Routines
Interactive spline adjustment functions in ewing:
Temperature-Time Spline Adjustment
-
temp.design() in R/temp.design.R: Legacy interactive
console routine using
graphics::locator()to adjust daily high/low temperature knots.
General & Mean-Value Spline Adjustment
- spline.design() in R/spline.R: General prototype function for designing spline curves using the cursor, delegating to curve.plot().
- future.meanvalue() & spline.meanvalue() in R/future.meanvalue.R: Interactively design mean value curves for life stage transition events.
- five.plot() & five.show() in R/five.R: Interactive tools for studying 5-parameter relationships of time and mean value.
Shiny Applications & WebAssembly Demos
- fivePlotApp() & fiveShowApp(): Modern reactive Shiny apps for parameter sensitivity and target search.
- tempApp(): Interactive daily temperature spline and degree-day design explorer.
2. Refactoring Rationale for tempApp
Legacy Graphics Locator vs. Reactive Shiny UI
- Legacy
temp.design()relied ongraphics::locator()in a modal loop. While functional in desktop R console sessions,locator()blocks event dispatchers in web environments. -
tempApp()replaces this with a reactive Shiny interface built onbslib::page_sidebar. Node moves are captured viainput$temp_clickand immediately updated in reactive state (shiny::reactiveValues).
Dual Spline (High & Low Temperature) Management
- In ewing, daily thermal fluctuation is specified by
daily high and low cubic splines (
HighandLowelements ofcommunity$temp). -
tempApp()allows users to switch between editing High and Low temperature splines via radio buttons, maintaining separate node coordinate vectors.
Degree-Day Integration (activeTemp())
- Stage transition kinetics in the simulation depend on degree-days
(DD). Any adjustment to high/low daily temperatures triggers
activeTemp(community), which integrates degree-days usingtemp.repeat()andtemp.spline(). -
tempApp()displays side-by-side plots:-
Left (
plot_temp): Interactive daily high (red) and low (blue) temperature splines with click-to-move node editing. -
Right (
plot_degreeday): Real-time degree-day accumulation curve generated bytemp.plot(community).
-
Left (
3. Implementation Summary
Package Function (R/tempApp.R)
-
Signature:
tempApp(community = NULL, title = "Daily Temperature Design Explorer") -
Default Input: If
communityisNULL, automatically initializesmysim <- ewing::init.simulation(messages = FALSE). -
UI:
bslib::page_sidebarlayout featuring curve radio buttons, coordinate text inputs (x_coords,y_coords), minimum temperature input (min_temp), and side-by-side plots for temperature splines and degree-day accumulation. -
Server: Manages reactive state, bidirectional
synchronization between plot clicks and sidebar inputs, monotonicity
enforcement, and real-time
activeTemp()degree-day recalculations.
4. Verification
-
R Documentation & Package Export: Executed
devtools::document()anddevtools::load_all('.'). Verifiedman/tempApp.Rdcreation andNAMESPACEexport. -
Simulation Initialization Test: Verified default
initialization with
mysim <- init.simulation()and temperature spline extraction (getTemp(mysim, "High")&getTemp(mysim, "Low")). -
Degree-Day Recalculation Test: Verified that
calling
activeTemp()updatesDegreeDayandHoursplines without error andtemp.plot()renders cleanly.