How to generate accurate continuous thermal regimes from sparse but regular temperature measurements

In ecology, there is an emerging emphasis on the importance of capturing temperature variation at relevant scales. Temperature fluctuates continuously in nature but is sampled at discrete time points, so how often should ecologists measure temperature to capture its variation? A recent development in thermal ecology is the use of spectral analysis of temperature time series to determine at what frequencies important temperature fluctuations occur. Building on this, I borrow from signal processing theory to show how continuous thermal regimes can be effectively reconstructed from discrete, regular, measurements, and provide a rule of thumb for designing temperature sampling schemes that capture ecologically relevant temporal variation. I introduce sinc interpolation, a method for reconstructing continuous waveforms from discrete samples. Furthermore, I introduce the Nyquist–Shannon sampling theorem, which states that continuous complex waveforms can be perfectly sinc‐interpolated from discrete, regular, samples if sampling intervals are sufficiently short. To demonstrate the power of these concepts in an ecological context, I apply them to several published high‐resolved (15‐min intervals) temperature time series used for ecological predictions of insect development times. First, I use spectral analysis to illuminate the fluctuation frequencies that dominate the temperature data. Second, I employ sinc interpolation over artificially thinned versions of the temperature time series. Third, I compare interpolated temperatures with observed temperatures to demonstrate the Nyquist–Shannon sampling theorem and its relation to spectral analysis. Last, I repeat the ecological predictions using sinc‐interpolated temperatures. Daily, and less frequent, fluctuations dominated the variation in all the temperature time series. Therefore, in accordance with the Nyquist–Shannon sampling theorem, 11‐h measurement intervals consistently retrieved most 15‐min temperature variation. Moreover, previous predictions of insect development times were improved by using sinc‐interpolated, rather than averaged, temperatures. By identifying the highest frequency at which ecologically (or otherwise) relevant temperature fluctuations occur and applying the Nyquist–Shannon sampling theorem, ecologists (or others doing climate‐related research) can use sinc interpolation to produce remarkably accurate continuous thermal regimes from sparse but regular temperature measurements. Surprisingly, these concepts have remained largely unexplored in ecology despite their applicability, not least in thermal ecology.


| INTRODUC TI ON
Temperature's influence on life has long been of major interest to biologists, and is now particularly relevant given the rapid rate of anthropogenic climate change (de Réaumur, 1734;Lenoir et al., 2020;Pörtner et al., 2022). To make ecological predictions and projections, we must not only know the functional form of the biological response but also capture relevant variation in its environmental drivers. Thermal ecologists are therefore increasingly aware of the importance of considering temperature variation at relevant scales, as evident by a rapidly growing body of literature (e.g. Bernhardt et al., 2020;Bramer et al., 2018;Kefford et al., 2022;Ma et al., 2021).
For spatial dimensions, this trend is best represented in microclimate research (Lembrechts & Nijs, 2020;Pincebourde et al., 2016;Zellweger et al., 2020). For temporal temperature variation, the most important realization has perhaps been that average temperatures are often ecologically uninformative since most biological processes respond nonlinearly to temperature, owing to the mathematical fact now known widely in ecology as 'Jensen's inequality' (Denny, 2015;Ruel & Ayres, 1999;Vasseur et al., 2014). Consequently, environmental sampling must adequately capture ecologically relevant variation in temperature over time. But even though temperature fluctuates continuously in nature, it is sampled at discrete time points by ecologists. How often should ecologists measure temperature in nature to capture its variation?
A recent development in thermal ecology is the use of spectral analysis of temperature time series Denny, 2015;Dillon et al., 2016). Through discrete Fourier transformation, temperature time series (i.e. temperature data in the time domain) can be decomposed into sinusoids of the constituent frequencies and analysed in the frequency domain. Graphically, this changes the unit on the x-axis from one of time to one of frequency, illuminating the separate contributions to the total temperature variation from sinusoidal fluctuations of different frequencies. Since the discrete Fourier transform can help distinguish the time-scales on which meaningful variation occurs, it can be a powerful tool for ecologists dealing with temperature time series. For example, temperature variation within and among generations can have different implications for thermal adaptation (Angilletta, 2009;Kefford et al., 2022). What is less known in ecology, however, is that the frequency domain can be used to determine at what frequency environmental temperatures should be sampled in the future. This is because (1) continuous thermal regimes can be effectively interpolated from discrete temperature measurements using a method called sinc interpolation if (2) regular sampling is done frequently enough relative to the highest ecologically relevant fluctuation frequency (which can be identified in the frequency domain), as shown by the Nyquist-Shannon sampling theorem (Nyquist, 1928;Shannon, 1948Shannon, , 1949Whittaker, 1915). Both sinc interpolation and the Nyquist-Shannon sampling theorem are well known in the field of signal processing (Oppenheim & Schafer, 2014), but remain largely unexplored in ecology despite being broadly applicable in many ecological scenarios.
Here, I introduce these concepts in the context of thermal ecology, and apply them to published data to demonstrate their utility.

| The Nyquist-Shannon sampling theorem and sinc interpolation
The Nyquist-Shannon sampling theorem (Nyquist, 1928;Shannon, 1949) states that any sinusoidal waveform can be reconstructed using discrete data sampled at even intervals of at least half the wavelength of the waveform, or inversely, sampled at least with twice the waveform's frequency (i.e. the Nyquist rate). This holds true for complex waveforms too, since they can be decomposed into separate sinusoids of the constituent frequencies using a discrete Fourier transform. The reconstruction is often performed through sinc interpolation (also known as Whittaker-Shannon interpolation; Shannon, 1948;Whittaker, 1915). In sinc interpolation, normalized sinc functions (Equation 1) are fitted to each measured data pointshifted on the x-axis and scaled by the y-value-and summed to generate the interpolation function (Equation 2).
In the case of a thermal regime, f(t) describes the temperature at time t, where T is the sampling interval (time between temperature temperature should be measured to retrieve most variation seen in the 15-min resolution data. To validate this prediction, I artificially thinned the temperature time series data at different even intervals to represent different temperature sampling schemes. Additionally, for each thinning interval, I thinned the data in all possible combinations to represent different starting times for the sampling. For each artificial sampling scheme, I generated sinc-interpolated 15-min temperatures (Equation 2), which I compared to the observed 15min temperatures. First, I calculated the residual sums of squares (SS) for models where observed temperature was a linear function of interpolated temperature with a forced intercept of zero and a forced slope of one (equivalent to a belief that interpolations represent reality). I then calculated R 2 as 1 − SS residual ∕ SS total . Thus, the R 2 represents how much information is retrieved through sinc interpolation relative to how much information is retrieved by just fitting a mean to the observed temperatures. This was done for all artificial sampling schemes and temperature time series in a factorial manner can also be observed in Figure 2b is that fluctuation amplitudes generally decrease with frequency, indicating that relatively slow fluctuations contribute most to the total temperature variation (this is sometimes called a 'reddened' spectrum; Bernhardt et al., 2020;Denny, 2015;Dillon et al., 2016). Therefore, in the scenario presented here, the Nyquist-Shannon sampling theorem states that most of the observed temperature variation can be reproduced simply by reconstructing the daily (and by extension less frequent) fluctuations through sinc interpolation.
Thus, for most ecological applications, temperature should be measured at least every 12 h in all eight thermal regimes. This is confirmed by the comparisons of observed and interpolated 15-min temperatures (Figure 3), where most 15-min temperature variation is retrieved from measurements taken at 11-h intervals or shorter.
When sampling intervals are 13 hrs or longer, interpolated thermal regimes become nonsensical, describing less time-specific temperature variation than just fitting a mean to the 15-min data ( Figure 3).
However, over 12-h sampling intervals, sinc interpolation accuracy is highly variable and depends on the time points of the sampling ( Figure 3). As seen in Figure 4b, if daily temperature highs and lows are captured in the sampling, interpolation is highly effective. If sampling does not capture these highs and lows, interpolation fails.
Note also that even the worst starting time retains most 15-min temperature variation if sampling is done at 11-h intervals (Figure 4a), and outperforms even the best-timed sampling scheme that uses 13-h intervals (Figure 4c).
When predictions of insect development times were repeated using the same methodology and data as in von Schmalensee et al.
(2021), but with sinc-interpolated instead of averaged temperatures, a higher predictive accuracy was achieved ( Figure 5). At 4-h sampling intervals or shorter, average prediction error was close to zero regardless of starting time. In other words, temperature sampling could have been performed 16 times less frequently than in the original study without compromising predictive accuracy. Note that at F I G U R E 3 How sinc interpolation captures real temperature variation. The y-axis shows R 2 -how well interpolated 15-min temperatures correspond to observed 15-min temperatures. The x-axis shows sampling interval. The light grey area represents sampling below the Nyquist rate for daily fluctuations. R 2 < 0 means that interpolated temperatures describe temperature at a given time worse than just a mean fitted to the data. Each colour represents one of eight microclimate thermal regimes, coloured by its temperature variance (blue = low, red = high). Error bars represent the range of R 2 -values resulting from different starting times of the sampling, and points represent average R 2values across all starting times. Points and error bars have been slightly offset on the x-axis to avoid cluttering.  (Figures 3 and 4).

Temperature sampling intervals (hours)
In the Supporting Information, the results are compared with results obtained using spline interpolation (see Kearney et al., 2020) and linear interpolation. The comparisons reveal that sinc interpolation either outperforms or equals the other interpolation methods in the vast majority of cases ( Figure S1-S5).

| DISCUSS ION
The Nyquist-Shannon sampling theorem and sinc interpolation are broadly applicable in thermal ecology since temperature fluctuates continuously and periodically but is measured at discrete time points. The Nyquist-Shannon sampling theorem can be used to plan resource-efficient temperature sampling schemes, and sinc interpolation can be used to generate remarkably accurate high-resolution thermal regimes from sparse data. Granted, not all temperature variation is sinusoidal (e.g. noise, or a directional increase in mean temperature from climate change; Pörtner et al., 2022), and thus cannot be perfectly reproduced using sinc interpolation. Still, as seen in Figure 3, most (15-min) temperature variation can be captured using much sparser temperature data. These concepts are widely known in signal processing theory and have many practical applications, for example, in the field of digital audio (Oppenheim & Schafer, 2014 (Figures 3 and   4). Still, it should be mentioned that sampling at a higher rate always increases accuracy (Figures 3 and 5); it is a question of costs versus benefits-less frequent sampling consumes less temperature logger memory space and battery power, potentially reducing maintenance (particularly for large logger networks). Furthermore, sampling should extend some sampling intervals beyond the time period of interest because interpolation error is highest at the ends of the sampling scheme (Figure 1). In a diurnally fluctuating environment, it would be prudent to start the sampling a few days before the period of interest and extend it a few days after.
As a final caveat, not all temperature variation is created equal in the eyes of a biological thermal reaction norm. Jensen's inequality (Denny, 2015;Ruel & Ayres, 1999;Vasseur et al., 2014) Figure 5).
Perhaps counterintuitively, average insect development time prediction error was sometimes low even when temperatures were sampled well below the Nyquist rate (e.g. every 23 h; Figure 5). Thus, in this particular system, erroneous thermal regimes sometimes resulted in similar thermal sums as the true thermal regimes. A reason for this is the phenomenon known as aliasing, when sampling is unable to capture high-frequency fluctuations whose power is then wrongly assigned to lower frequencies (Oppenheim & Schafer, 2014). Even though this causes distortion, the magnitude of the high-frequency fluctuations can still be retained at lower frequencies. Aliasing can be observed in Figure 4c, where interpolation sometimes leads to night temperatures in the middle of the day, and vice versa. I emphasize, however, that while measuring below the Nyquist rate (for daily temperature fluctuations) can lead to similar conclusions as highfrequency sampling, most of the time it does not (as evident by large standard deviations in Figure 5). Also, the ecological consequences of aliasing in temperature time series depend strongly on the time-scales of interest. For example, if interpolation results in winter-like temperatures during summer, season-specific organism performance will be substantially miscalculated. Since significant aliasing cause distorted, unrealistic, temperature time series, it should be avoided by sampling at a sufficient frequency.

| General applications in climate-related research
Because sinc interpolation can increase the temporal resolution of temperature time series, it has several general applications beyond ecological prediction making. One use case is to synchronize different temperature time series at comparable time points. For example, many Swedish weather stations measure temperature hourly, but some only every 3rd, 6th or 12th hour (SMHI, 2023). Thus, sinc interpolation can be used to increase the temporal resolution of sparsely sampled Swedish weather station data so all time series can be compared at hourly intervals.
Another use case for sinc interpolation is temporal downscaling of macroclimate data used to feed climate models (a common procedure; Bramer et al., 2018;Kearney et al., 2020;Lembrechts et al., 2019).
For example, a recent study linked microclimate and macroclimate temperatures through two site-specific parameters (Gril et al., 2023).
Given the values of these parameters, it should in theory be possible to model microclimate temperatures at any time-scale, only limited by the temporal resolution of the input macroclimate data. However, as mentioned above, some weather stations go several hours between temperature measurements. If a microclimate site, perhaps because of its remote location, is limited to such temporally coarse macroclimate data, temporally high-resolved microclimate data could potentially still be generated by using sinc interpolation for temporal downscaling (note that spline interpolation over 6-h intervals has also been successfully used for this purpose, Kearney et al., 2020).
Yet another potential use case for sinc interpolation is temperature data imputation under certain circumstances. Because the sinc function is normalized on the x-axis to match the sampling interval (Equation 1, Figure 1), missing data points will cause erroneous interpolation. However, in situations where sampling has been performed at double the Nyquist rate or more often, this can be salvaged by artificially thinning the data and extracting the sinc-interpolated temperature at the time of the missing measurement. By substituting the missing measurement with the interpolated temperature, sinc interpolation can be performed using the original temporal resolution even in the absence of some data points (see code at https://doi.org/10.5281/zenodo.7687975 for an example). If missing data are misaligned so that imputation cannot be performed using a single thinned dataset, imputation might potentially still be performed locally by subsetting the temperature time series.

| Signal processing theory's future in ecology
I have demonstrated the ecological utility of two basic (and frankly, quite old) signal processing concepts: sinc interpolation and the Nyquist-Shannon sampling theorem. Yet, these concepts have remained largely unexplored in ecology research, perhaps due to cross-disciplinary research barriers such as disciplinary jargon or biases towards field-specific literature. Therefore, I encourage more ecologists to make cross-disciplinary ventures into the field of signal processing. Indeed, since ecology often relies on discrete sampling of continuous natural processes, usually with nonlinear biological effects, it is likely that many more ecological applications of signal processing theory remain undiscovered. For example, under certain conditions, there are ways to reconstruct signals from non-uniform samples, and even from samples taken below the Nyquist rate (Candès et al., 2006a(Candès et al., , 2006bDonoho, 2006;Maymon & Oppenheim, 2011). The latter (often called 'compressed sensing'; Donoho, 2006) relies on signals being sparse-that there is a structure to how their information content is distributed. If a signal has a large proportion of frequency components with amplitudes of zero or close to zero (which is common), it allows for constraining the number of estimated coefficients, for instance through optimization algorithms that reward the sparsest solution (i.e. the solution that reproduces the data with the least number of information-carrying frequency components). This way, the signal can be reconstructed even when it is undersampled. This solution to an underdetermined system can arguably be likened to constraining the parameter space in Bayesian models through priors, which can allow for local solutions to otherwise unsolvable problems. Thus, it is conceivable that one can take advantage of the fact that much natural temperature variation stems from daily and yearly cycles to build temperature interpolation algorithms that are more robust to unevenly sampled, or missing, temperature data. However, topics such as compressed sensing are beyond the scope of this work and remain exciting subjects for future ecology studies.

AUTH O R CO NTR I B UTI O N S
All work was distributed evenly, and randomly, across all authors.

CO N FLI C T O F I NTE R E S T S TATE M E NT
I declare no conflict of interest.

PE E R R E V I E W
The peer review history for this article is available at https://www. webof scien ce.com/api/gatew ay/wos/peer-revie w/10.1111/ 2041-210X.14092.

DATA AVA I L A B I L I T Y S TAT E M E N T
The R-code containing the functions used here and a tutorial has been archived at Zenodo with the identifier https://doi.org/10.5281/ zenodo.7687975 (von Schmalensee, 2023). The GitHub repository can be accessed at https://github.com/lokev s/sinc_inter polat ion/.

S U PP O RTI N G I N FO R M ATI O N
Additional supporting information can be found online in the Supporting Information section at the end of this article.
Appendix S1. Comparing sinc interpolation to linear and spline interpolation. The density distribution of the differences in R2 for all comparisons is represented on the right.