Skip to Content
SensorsSensors
  • Article
  • Open Access

13 August 2026

Bridging High-Resolution Environmental Sensor Observations and Process-State Prediction: A Distribution-Shift-Robust Time–Frequency Transformer (FT-Crossformer)

,
and
School of Information Engineering, Ningxia University, Yinchuan 750021, China
*
Author to whom correspondence should be addressed.
This article belongs to the Special Issue AI-Enhanced Sensor Data Integration and Processing

Abstract

High-resolution online sensors are now common in environmental process systems, yet turning their non-stationary, heterogeneous observation streams into reliable predictions of the underlying process state remains difficult. The statistical distribution of a sensor stream changes over time, the measured variables do not coincide with the state variables of interest, and repeatedly running a mechanistic process model for forward prediction is computationally costly. We present FT-Crossformer, a time–frequency Transformer that acts as a data-driven surrogate between multi-sensor observations and multivariate process-state prediction. To handle distribution shift in the sensor streams, a time-domain distribution-transformation module, together with an inverse-mapping module, performs an affine bias correction that removes per-window non-stationary statistics at the input and restores them at the output, so the gap between training and test distributions is reduced without discarding non-stationary information. We show that this affine correction, including its learnable per-variable scale and shift, acts in the frequency domain on every non-zero frequency component as one common scaling factor that does not depend on the frequency index, so it cannot change the relative magnitudes among the components. A frequency-stability measurement module and a frequency-weighting module therefore re-weight the spectral components of the observation signal so that the stable, task-relevant ones contribute more to the reconstructed signal. The cross-dimension attention of the Crossformer backbone serves as a multi-sensor fusion mechanism that models the dependencies among the measured variables. We validate the method on public benchmark datasets from different domains as a check of generality and, most relevantly, for environmental modeling on two real cases: a wastewater nitrogen-and-phosphorus-removal process and chlorophyll forecasting from an in situ estuary sensor mooring in San Francisco Bay. On the estuary chlorophyll data, which carries a strong train-to-test distribution shift, the full FT-Crossformer demonstrates superior accuracy among the evaluated models at the next-day nowcasting horizon, and an ablation shows that both the time-domain trans- formation and the frequency-domain weighting contribute to this accuracy. FT-Crossformer produces forward predictions from distribution-shifted sensor data with a single fixed-cost forward pass in place of a repeated mechanistic solve, which makes it a practical building block for sensor-data integration and assimilation in environmental process modeling.

1. Introduction

The spread of high-resolution online sensing in environmental engineering, such as dissolved-oxygen, ammonia, nitrate, phosphate and mixed-liquor-suspended-solids probes in wastewater treatment, as well as in aquatic ecological monitoring with in situ chlorophyll-a optical sensors, has produced a large stream of observational data, and at the same time it has exposed two well-known obstacles to turning that data into actionable predictions. Chlorophyll-a time series, a core biomarker for algal bloom and eutrophication warning, presents obvious multi-period oscillations driven by diurnal light cycles and seasonal hydrological variation, further complicating reliable forecasting. The first obstacle is computational. A mechanistic environmental process model, for example, an activated sludge model [1], is expensive to solve repeatedly for forward prediction, which motivates a fast data-driven surrogate that maps recent observations directly to future states. For aquatic ecology, complex biogeochemical mechanistic models similarly require heavy computation for high-frequency chlorophyll simulation. The second obstacle is that the raw sensor measurements are non-stationary and do not map directly onto the process state variables of interest: their statistical distribution changes over time as instruments age, zero points drift and the measurement environment varies, which degrades the accuracy and the generalization of a standard forecasting model. For chlorophyll monitoring, hydrodynamic shifts, seasonal temperature turnover and seasonal phytoplankton succession incur severe distribution shift between training sensor records and real prediction periods, causing prominent performance decay in conventional time-domain prediction models. Existing time–frequency chlorophyll prediction tools mostly focus on periodic decomposition rather than resisting distribution drift, lacking cross-scenario generalization capacity [2]. We address both obstacles with a single time–frequency Transformer that learns an operator from distribution-shifted multi-sensor observations to multivariate process-state predictions, specifically accommodating high-frequency chlorophyll and conventional water quality sensor signals.
We use a multivariate time series as the data structure for a sensor stream. A multivariate time series is a matrix X R T × D whose entry x t , d is the value of the d -th sensor at the t -th sampling instant, where T is the number of historical time steps and D is the number of sensors. The forecasting task is to predict the matrix Y R τ × D of the next τ steps. Such data carries a temporal pattern along the time axis and a nonlinear dependency among the variables along the sensor axis, and a forecasting model must capture both. Crossformer [3], a Transformer variant, models both dependencies through a dimension-segment embedding and a two-stage attention mechanism, and uses the information of correlated sensors to improve a prediction. Crossformer does not, however, account for a change in the underlying data-generating process, that is, for distribution shift. It assumes that the training data and the test data follow one distribution, whereas in an environmental process the two are split by time, so the distribution of the measured data changes and the predictive performance of Crossformer falls. Shao et al. [4] report the same effect: on a dataset whose distribution changes, a Transformer-based model tends to overfit and its performance drops markedly.
A second consideration concerns the domain of analysis. A multivariate time-series model usually extracts features and is built in the time domain, but the periodic, trend and fluctuation components of a series are often clearer in the frequency domain, because a series can be written as a superposition of frequency components [5,6]. Some periodic and trend structures of a series are represented more directly by a small number of frequency components than by the raw time-domain samples, so a model that operates in the time domain alone has no explicit access to that representation.
The contributions of this work are as follows. We propose FT-Crossformer, a time–frequency joint-modeling method built on the Crossformer backbone that addresses distribution shift in environmental sensor streams. We add a distribution-transformation module and an inverse-mapping module that form a symmetric affine pair, which removes the per-window non-stationary statistics of the input and restores them at the output, so the training–test distribution gap is reduced without losing non-stationary information. We show that this affine correction, with its learnable per-variable scale and shift, scales every non-zero frequency component by one factor that is the same for all frequency indices, leaving the relative magnitudes among the components unchanged, and we add a frequency-stability measurement module and a frequency-weighting module that re-weight the spectral components so that the stable, task-relevant ones contribute more to the reconstructed signal. We validate the method on public benchmarks and on two real environmental cases, a wastewater nitrogen-and-phosphorus-removal process and chlorophyll forecasting from an estuary sensor mooring, and we discuss the relation of the model to mechanistic models and to data assimilation. On the estuary chlorophyll data, the full model appears to be the most accurate at the next-day nowcasting horizon, and an ablation shows that both proposed components contribute to this accuracy.

3. Methodology

3.1. Crossformer Backbone

Crossformer captures the cross-time and cross-dimension dependencies of a multivariate time series through a dimension-segment embedding and a two-stage attention layer.

3.1.1. Dimension-Segment Embedding

Let the historical multivariate series be X 1 : T R T × D and let the target be the next τ steps X T + 1 : T + τ , where T is the number of historical steps and D is the number of variables. Rather than embedding the several variables at one timestamp, the dimension-segment embedding treats a run of consecutive values of a single variable as one embedding vector, so that the information of neighboring instants is preserved. Each variable is first cut into segments of length L s e g . We assume L s e g divides T and partition the time index { 1 , , T } into the consecutive blocks indexed by i with 1 i T / L s e g . The i -th segment of variable d , where 1 d D , is the ordered tuple of the values on the i -th block,
x i , d ( s ) = ( x t , d ) i 1 L s e g < t i L s e g R L s e g ,
where t is the time step, the entries of x i , d ( s ) are listed in increasing order of t , so x i , d ( s ) is a vector in R L s e g and not an unordered set, and the collection { x i , d ( s ) } i , d is a reindexing of the matrix X 1 : T . Each segment is embedded by a linear projection with a position embedding,
h i , d = E x i , d ( s ) + E i , d ( p o s ) ,
where E is a learnable projection matrix and E i , d ( p o s ) is the learnable position embedding of segment i in variable d . The result is a two-dimensional array H = { h i , d } whose two axes correspond to time and dimension, and which is the input of the two-stage attention layer.

3.1.2. Two-Stage Attention

The two-stage attention models the cross-time and the cross-dimension dependency in turn. Write the input array as Z ; let Z i , : be the vector of all dimensions at time step i and Z : , d the vector of all time steps in dimension d . The cross-time stage applies multi-head self-attention within each dimension,
Z ^ : , d = Z : , d + MSA Z : , d , Z : , d , Z : , d ,
Z : , d t i m e = Z ^ : , d + MLP L a y e r N o r m ( Z ^ : , d ) ,
where L a y e r N o r m is layer normalization, M S A is multi-head self-attention and M L P is a feed-forward network; the dependency among the segments of one dimension is captured in Z t i m e . To avoid the high cost of attention over the full array, the cross-dimension stage uses a small fixed number c of learnable router vectors at each time step i ,
B i , : = M S A R i , : , Z i , : t i m e , Z i , : t i m e ,
Z i , : = M S A Z i , : t i m e , B i , : , B i , : ,
Z ~ i , : = Z i , : t i m e + Z i , : ,
Z i , : d i m = Z ~ i , : + M L P L a y e r N o r m ( Z ~ i , : ) ,
where R i , : is the array of c router vectors at time step i , B i , : is the information the routers gather from all dimensions, Z i , : is the router output distributed back to the dimensions, Z ~ i , : is the residual output and Z i , : d i m is the output of the feed-forward network. The cross-time and the cross-dimension dependency are then both held in Z d i m .

3.2. Time-Domain Transformation

Distribution shift is a change in the underlying data-generating process, often caused by an observed or unobserved context [4]; the segment embedding of Crossformer preserves more of that local context than a per-timestamp embedding, which makes the backbone a suitable base. The cause of the shift is that the statistical properties of the data change over time. Removing the non-stationary information at the input reduces the gap, but the non-stationary information is needed for the prediction to keep its physical meaning, so it cannot simply be discarded.
To address this, we incorporate an affine transformation into the Crossformer model, comprising a transformation layer and its inverse, arranged symmetrically. The transformation layer acts on the input and re-centers the distribution at its mean, temporarily removing the non-stationary information. The inverse layer acts on the prediction and restores it to the original scale, so the gap between the training and the test distribution is reduced while the original distribution is preserved. For a batch of N multivariate input series X ( n ) , each with T historical steps and D variables and used to predict the next τ steps, the transformation module first computes, for each instance, the per-window mean and standard deviation,
μ d ( n ) = 1 T t = 1 T x t , d ( n ) ,
σ d ( n ) = 1 T t = 1 T x t , d ( n ) μ d ( n ) 2 ,
where x t , d ( n ) is the value of variable d at time step t in the n -th series, and where the training distribution P t r a i n ( X ) and the test distribution P t e s t ( X ) differ. The module then normalizes the input,
x ^ t , d ( n ) = γ d x t , d ( n ) μ d ( n ) σ d ( n ) 2 + ϵ + β d ,
where γ d and β d are learnable affine scale and shift parameters, is the Hadamard product and ϵ is a small constant for numerical stability. The scale γ d is initialized to 1 and the inverse layer below divides by this, so we keep γ d bounded away from zero through this initialization and through weight decay during training. The statistics μ d ( n ) , σ d ( n ) , γ d and β d are stored for the inverse layer.
The transformed series X ^ is the input of the encoder–decoder. In the encoder, every layer except the first merges two adjacent vectors in time to obtain a coarser representation and then applies the two-stage attention,
H ^ i , d l = W m e r g e H 2 i 1 , d l 1 H 2 i , d l 1 ,
H l = T S A H ^ l ,
where H is a two-dimensional array, W m e r g e is a learnable matrix, denotes concatenation, H ^ l is the merged array, T S A is the two-stage attention and H l is the output of encoder layer l . If the encoder has M layers, the decoder uses M + 1 layers,
H ~ l = T S A H l 1 ( d e c ) + E l ( d e c ) ,
H l ( d e c ) = H ~ l + c r o s s H ~ l , H l ,
Y l = H l ( d e c ) + M L P L a y e r N o r m ( H l ( d e c ) ) ,
where E l ( d e c ) is the learnable position embedding of the decoder, H ~ l is the two-stage attention output, H l ( d e c ) is the output after connecting the encoder and decoder, and Y l is the output after the residual connection and the feed-forward network. A linear projection of each layer produces that layer’s prediction, and the layer predictions are summed to give Y ^ .
To restore the physical meaning, the prediction Y ^ is passed to the inverse layer, which uses the stored statistics to invert the transformation,
X k ( n ) = t = 0 T 1 x t ( n ) e i 2 π k t / T ,   k = 0 , 1 , , K 1 ,
which yields the output Y on the original scale. Figure 1 shows the two layers together with the per-window distribution at each stage of the pipeline.
Figure 1. Time-domain transformation. The distribution-transformation module removes the per-window non-stationary statistics (mean and standard deviation) at the input, and the inverse-mapping module restores them at the output. The insets (ad) show the per-window distribution of the original input, of the transformed input, of the prediction in the transformed space, and of the output after inverse mapping.

3.3. Frequency-Domain Weighting

The time-domain transformation reduces the distribution shift in the time domain, but it creates a new problem in the frequency domain. As shown below, the transformation maps the original data to a more compact, mean-centered distribution in the time domain, yet in the frequency domain it multiplies every non-zero frequency component by one factor that is the same for all frequency indices, so the relative magnitudes among the components do not change. The transformation thus gives no extra weight to the components that carry the task-relevant features, and the result remains sensitive to noise in the other components. To tackle this challenge, we propose a novel frequency-domain weighting mechanism, which integrates a frequency-stability measurement module for quantifying component stability and an adaptive frequency-weighting module for dynamic component re-weighting. Figure 2 contrasts the effect of the transformation in the two domains and makes this point precise.
Figure 2. Effect of the time-domain transformation in the two domains. (a) In the time domain, it maps the original signal distribution to a zero-centered distribution. (b) In the frequency domain, it scales every non-zero component by a single common factor, so the relative magnitudes of the components are unchanged; this is the blurring of the task-relevant frequency components that the frequency-domain weighting is designed to undo.
Given a dataset of N series, consider one scalar channel of the n -th sample over the window of length T . Its discrete Fourier transform is
X k ( n ) = t = 0 T 1 x t ( n ) e i 2 π k t / T ,   k = 0 , 1 , , K 1 ,
where each X k ( n ) is a complex scalar. A length- T DFT of a real signal is conjugate-symmetric, so the non-negative frequencies determine the spectrum; we keep these and set K = T / 2 + 1 , so the frequency index runs k = 0 , 1 , , K 1 . The quantity | X k ( n ) | is the modulus of the complex coefficient X k ( n ) , that is, the magnitude of frequency component k . To quantify stability we use a measure based on the coefficient of variation [31], the ratio of the standard deviation to the mean of a component’s magnitude taken over the N training samples,
C V k = σ | X k | μ | X k | ,   μ | X k | = 1 N n = 1 N | X k ( n ) | ,
where μ | X k | and σ | X k | are the mean and the standard deviation of the magnitude of component k across the N samples. A component with a smaller coefficient of variation has a magnitude that is more nearly constant across samples, and we call it more stable. Fixing a threshold c 0 , the stable set is
S = { k : C V k c 0 } ,
the set of frequency indices whose magnitude varies little across the training samples. The measure C V k and the set S enter the weighting module below through the initialization of its weights.
We now show that the full affine transformation of Equation (11), including its learnable scale and shift, acts on each non-zero frequency as a single scaling factor that does not depend on the frequency index. Fix one variable d and one window, and abbreviate μ = μ d , σ = σ d , γ = γ d , β = β d . The transformed series is
x ^ t = γ x t μ σ 2 + ϵ + β .
Take the DFT and use its linearity,
X ^ k = γ σ 2 + ϵ t = 0 T 1 x t e i 2 π k t / T + β γ μ σ 2 + ϵ t = 0 T 1 e i 2 π k t / T .
The first sum is X k by definition. The second sum is a geometric series in e i 2 π k / T , which equals T at k = 0 and 0 for every other k in 0 , , T 1 ; write this as T δ k , where δ k is 1 at k = 0 and 0 otherwise. Hence,
X ^ k = γ σ 2 + ϵ X k + β γ μ σ 2 + ϵ T δ k .
For a non-zero frequency k 0 the constant term drops, so
X ^ k = γ σ 2 + ϵ X k ,     | X ^ k | = γ σ 2 + ϵ | X k | ,
where | X ^ k | is the magnitude of component k after the transformation. The learnable shift β and the mean μ contribute only at k = 0 , that is, only to the DC bin. For every k 0 , the affine transformation multiplies the coefficient by the single factor γ / σ 2 + ϵ , which is the same for all non-zero frequency indices and depends only on the variable d through γ d and σ d . The transformation therefore leaves the ratios | X ^ k | / | X ^ k | among non-zero frequencies unchanged, so it cannot by itself separate the task-relevant components, which motivates the weighting below.
In the frequency-weighting module, the series is first smoothed by a first-order difference and then transformed; the spectrum is split into its real and imaginary parts.
Δ x t = x t x t 1 ,
F ( Δ x ) k = R k + i I k ,
( R , I ) = R F ( Δ x ) , I F ( Δ x ) ,
where Δ is the difference operator, F ( Δ x ) is the DFT of the differenced series on the same K = T / 2 + 1 non-negative frequencies, and R and I are the real-part and imaginary-part vectors indexed by k = 0 , , K 1 . A learnable linear projection is applied to each part and combined with the original part by a Hadamard product, which re-weights the components,
R ~ = R W R R + b R ,
I ~ = I W I I + b I ,
where W R and W I are the weight matrices of the real and the imaginary part and b R and b I are bias vectors. We separately project the real and imaginary parts—corresponding to the cosine and sine components—at a merely linear computational cost, thereby enabling their independent re-weighting. The stability measure couples to this re-weighting through the initialization: we set the bias so that the initial per-index gain W R R + b R (and likewise for I ) starts near 1 on the stable set S and near 0 off it, that is, the initialization passes the components in S and damps the rest:
( b R ) k = ( b I ) k = 1 , k S , 0 , k S ,     W R , W I   initialized   to   0 .
With the aforementioned initialization, while stable components are held constant initially, the sequential adaptive iteration of parameters W R , W I , b R , b I and S during training enables the weighted reinforcement of the stable or task-relevant components and the concomitant attenuation of non-stable ones, through which the final weights are learned. The re-weighted parts are returned to the time domain by the inverse transform that matches the one-sided spectrum above,
x ~ t = 1 T k = 0 T 1 R ~ k + i I ~ k e i 2 π k t / T ,
where for k > T / 2 the coefficients R ~ k + i I ~ k are filled in by conjugate symmetry from the non-negative frequencies, so the sum runs over all T bins and x ~ is real and has the same length as x .

3.4. Full Model

Figure 3 shows how these modules are assembled. FT-Crossformer combines the dimension-segment embedding, the two-stage attention, the distribution-transformation module, the inverse-mapping module, the frequency-stability measurement module, the frequency-weighting module and the encoder–decoder. The historical data first enters the distribution-transformation module, which re-centers the input distribution at its mean and temporarily removes the non-stationary statistics. The frequency-stability measurement module then transforms the data to the frequency domain by the DFT, measures the coefficient of variation in each component across the training samples and forms the stable set S ; this set initializes the weights of the frequency-weighting module, which re-weights the spectral representation by the learnable linear projection of Equations (28)–(30) and returns to the time domain by the inverse DFT. The dimension-segment embedding splits the series into segments, and the embedded output enters the multilayer encoder–decoder, where each encoder layer applies the two-stage attention to capture the cross-time and the cross-dimension dependency and the decoder forms a prediction layer by layer. The inverse-mapping module then restores the distribution and produces the final prediction. The distribution shift is corrected in the time domain, and in the frequency domain the re-weighting starts from the stable components and is then learned, which together improve the accuracy and the generalization of the model.
Figure 3. FT-Crossformer architecture. A time-domain distribution-transformation and inverse-mapping pair wraps the Crossformer backbone; between them, a frequency-stability measurement module and a frequency-weighting module re-weight the stable spectral components, after which dimension-segment embedding and two-stage attention produce the prediction.

4. Experiments

We first test the method on public benchmarks from different domains to establish that it forecasts under distribution shift beyond a single application. We then run an ablation, and we report two real environmental cases: chlorophyll forecasting from an estuary sensor mooring and a wastewater nitrogen-and-phosphorus-removal process. A final subsection relates the model to mechanistic models and to data assimilation, and discusses inference cost.

4.1. Public Benchmarks: A Check of Generality

We use five widely used public datasets that span energy, traffic, weather, public health and economics. The Electricity Transformer Temperature (ETT) dataset [12] contains seven factors of an electricity transformer, including load features and oil temperature, recorded hourly (ETTh1, ETTh2) and every fifteen minutes (ETTm1, ETTm2). The Influenza Like Illness (ILI) dataset [13] is the weekly ratio of influenza patients to all patients from the US Centers for Disease Control and Prevention between 2002 and 2021. Traffic [13] is the hourly road-occupancy rate from 862 sensors on San Francisco Bay Area freeways between January 2015 and December 2016. Weather [13] is 21 meteorological factors recorded every ten minutes in 2020 at the Max Planck Institute for Biogeochemistry, Bremen, Germany. Exchange Rate [13] is the daily exchange-rate panel of eight countries between 1990 and 2016, which carries a long-term trend and a random walk.
We compare FT-Crossformer with six typical models: iTransformer [15], DLinear [32], Crossformer [3], FEDformer [14], Autoformer [13] and Informer [12]. Each split is normalized with the mean and the standard deviation of the training set. All experiments were performed on a workstation running Ubuntu 20.04.1 LTS, equipped with an NVIDIA RTX A6000 96GB GPU and an Intel Xeon Gold 6326 @ 2.90GHz CPU. The implementation was built upon PyTorch 1.13.1 with CUDA 11.7 support. The proposed model adopts an enhanced Crossformer architecture consisting of three encoder layers and four decoder layers; the number of routers in the two-stage attention is ten; the hidden state has dimension 256; multi-head attention uses four heads; the historical window is 96. The segment length is six when the prediction length is below 168 and 24 otherwise; the batch size is 32, reduced to 8 on Traffic to fit memory. Training uses Adam, with the initial learning rate chosen from { 5 × 10 3 , 10 3 , 5 × 10 4 , 10 4 , 5 × 10 5 , 10 5 } by grid search and halved each epoch; the loss is the mean-squared error, dropout is 0.2, normalization is layer normalization, the activation is GELU and the attention weights use a softmax. Training runs for 20 epochs with early stopping after three epochs without an improvement in the validation loss. The implementation uses PyTorch and each result is the mean of three runs.
We report the mean absolute error (MAE) and the mean-squared error (MSE),
M A E = 1 n i = 1 n y i y ^ i ,
M S E = 1 n i = 1 n y i y ^ i 2 ,
where n is the length of the test set, y i is the true value and y ^ i is the prediction; both are in [ 0 , + ) , both equal zero at a perfect prediction, and a lower value is better.
Table 1 reports the comparison over the datasets and the prediction lengths. FT-Crossformer obtains the best result on every prediction length of every dataset except two long-horizon cases on Traffic. At τ = 168 and τ = 336 on Traffic, iTransformer attains a lower MSE while FT-Crossformer still attains the lower MAE; at the other prediction lengths FT-Crossformer demonstrates superior accuracy on both metrics. Relative to the original Crossformer, the average MSE drops by about 26.0% on ETTh2 and by about 20.7% on Traffic, so the method improves over the backbone on both datasets. The gain on ETTh2 is consistent with the train/test distribution shift that the chronological split induces: Figure 4 embeds the ETTh2 sensor channels with t-SNE, and under a random split (panel a) the training and test points overlap, whereas under the chronological split used for forecasting (panel b) the test points occupy a region of the embedding distinct from the training points.
Table 1. Public-benchmark comparison across prediction lengths. The best results are shown in bold. Each entry is the mean of three runs.
Figure 4. Distribution shift under a chronological split, illustrated on the ETTh2 benchmark by a t-SNE embedding of the sensor channels. (a) Under a random split, the training and test points overlap. (b) Under the chronological split used for forecasting, the test points occupy a distinct region of the embedding, i.e., the training and test distributions differ.

4.2. Ablation Study

We remove one component at a time to measure its contribution. “w/o FDW” removes the frequency-stability measurement module and the frequency-weighting module; “w/o DTIM” removes the distribution-transformation module and the inverse-mapping module; “w/o DSETA” removes the dimension-segment embedding and the two-stage attention, so the model embeds the several variables at a single time point and captures only the temporal dependency. Table 2 reports the result on ETTh2 and ILI. Removing FDW raises both MSE and MAE on every prediction length, more so at the long horizons, which shows that the frequency-weighting module contributes to the accuracy; the mechanism we attribute to it is the re-weighting of the spectral components from the stable set (Equations (28)–(30)), which is the design intent rather than a quantity the ablation isolates on its own. Removing DTIM or DSETA raises every metric markedly, which shows that both the dimension-segment embedding and the distribution transformation contribute; we read this as the segment embedding retaining the local context and the distribution transformation reducing the shift before prediction.
Table 2. Ablation on ETTh2 and ILI. Best results are shown in bold.

4.3. Chlorophyll Forecasting from Estuarine Sensor Moorings

The environmental and oceanic case is the forecasting of chlorophyll concentration at a fixed estuarine sensor mooring. The mooring sits in Carquinez Strait, in the northern reach of the San Francisco Bay estuary, at 38.067° N, 122.23° W, where the strait joins San Pablo Bay to Suisun Bay and the Sacramento–San Joaquin Delta (Figure 5). Chlorophyll at this location is set by several coupled, time-varying drivers. Freshwater inflow from the Delta, which differs strongly between the dry and the wet years of the California hydrological cycle, controls the salinity, the residence time and the nutrient supply of the water passing the strait; tides and wind resuspend sediment, so the suspended-particle load, and the light it leaves for phytoplankton, change from sub-daily to seasonal scales; and nutrient form and grazing further constrain the phytoplankton biomass that the chlorophyll signal measures [33,34,35]. Because these drivers act together and change between years, the chlorophyll series is non-stationary and its marginal distribution is not the same in different parts of the record.
Figure 5. Study area. The Carquinez YSI mooring (star) at 38.067° N, 122.23° W, in Carquinez Strait between San Pablo Bay and Suisun Bay in the northern San Francisco Bay estuary. (a) Satellite imagery, with the main sub-embayments labeled and a California-context inset; (b) topographic basemap. Basemaps: Esri, Maxar, Earthstar Geographics.
The hourly record we use runs from September 2016 to August 2019, which spans the end of the 2012–2016 California drought and the wetter years that followed, so the freshwater forcing, and with it the chlorophyll regime, differs between the training and the test segments. The co-measured temperature, salinity, turbidity, dissolved oxygen and pH are observable proxies for these drivers, and the model forecasts chlorophyll from them while their joint distribution shifts; this is the setting the present method is built for. The record is served by NOAA CoastWatch ERDDAP (dataset rtcctdCMAysi from the San Francisco State University Estuary and Ocean Science Center) and contains 25,560 samples. The target variable is chlorophyll (chl, in μg/L), and the model also receives temperature, salinity, turbidity, dissolved oxygen and pH from the same mooring. We split the record chronologically, so the training and the test segment are disjointed in time. The chlorophyll mean rises from 1.99 to 2.58 μg/L across this split, and a two-sample Kolmogorov–Smirnov test on the marginal chlorophyll distribution gives a statistic of 0.287. The sensor stream therefore carries a clear distribution shift, which Figure 6 shows together with the prediction of the model against the observed chlorophyll.
Figure 6. Real estuary chlorophyll from the Carquinez YSI mooring (ERDDAP rtcctdCMAysi). (Left): the train and test marginal distributions of chlorophyll, which differ (mean 1.99 against 2.58 μg/L, KS statistic 0.287). (Right): the FT-Crossformer prediction against the observed chlorophyll on the test segment at horizon τ = 24 .
Overall, the FT-Crossformer model can effectively simulate the changes in chlorophyll concentration as shown in the upper panel of Figure 6. Especially in the prediction of chlorophyll concentration of the nearly one-month period, the model can reflect the fluctuations in chlorophyll concentration with the spring and neap tide. Furthermore, the predicted series can also track the observed value closely, reproducing the rising and falling trend within 24 h, which is caused by tidal oscillation [36,37]. However, as shown in the lower panel of Figure 6, some short-term peak values may be smoothed out, which should be related to the abrupt hydrodynamic disturbances, or calm winds with high air temperature [38].
At the short, operationally relevant horizon τ = 24 , that is, next-day nowcasting from the hourly sensors, the full FT-Crossformer is the best of the four models we compare. Table 3 reports the mean-squared error and the mean absolute error on the real data, averaged over two seeds. The full model attains an MSE of 0.1848, below the 0.1873 of the variant without the frequency-domain weighting, the 0.1925 of the variant without the time-domain transformation and the 0.1912 of the Crossformer backbone. Removing the frequency-domain weighting raises the error, so this component contributes at the short horizon.
Table 3. Real estuary chlorophyll (Carquinez YSI mooring, ERDDAP rtcctdCMAysi) at horizon τ = 24, mean over two seeds. Best results are shown in bold.
At this horizon, the ablation in Table 3 confirms that both proposed components contribute. Removing the frequency-domain weighting raises the MSE from 0.1848 to 0.1873, and removing the time-domain transformation raises it to 0.1925; the full model is below both, and it also improves on the Crossformer backbone, which attains 0.1912.
In the aforementioned time-series forecasting experiment, preprocessed multivariate environmental data are fed into the distribution transformation module of the FT-Crossformer, which temporarily detaches non-stationary statistical information from the data. Following transformation to the frequency domain via the Discrete Fourier Transform (DFT), the frequency-stability measurement module identifies task-relevant stable frequency components that are subsequently enhanced through adaptive weighting while unstable ones are suppressed. Upon restoration to the time domain via inverse DFT, the dimension-segmented embedding module preserves data contextualization and feeds into a multi-layer encoder–decoder architecture wherein the encoder, leveraging a two-stage attention mechanism, concurrently captures temporal dependencies encompassing seasonal, periodic, and short-term patterns alongside inter-variable correlations across the feature dimension, while the decoder generates layer-wise predictions that are subsequently recovered through the inverse transformation module to yield the final environmental variable forecasts. Thus, through the synergistic interplay of its constituent modules, FT-Crossformer enables accurate chlorophyll forecasting from authentic, distribution-shifted estuarine sensor streams, thereby furnishing an efficacious technical paradigm for intricate environmental surveillance.

4.4. Wastewater Nitrogen-And-Phosphorus Removal

This case uses real data from a wastewater-treatment plant that runs the common anaerobic–anoxic–oxic (AAO) process for nitrogen and phosphorus removal, a biological process for nitrogen removal, phosphorus removal and the degradation of organic matter. The influent and the phosphorus-rich sludge that are returned from the secondary clarifier enter the anaerobic tank, where phosphorus-accumulating organisms release phosphorus and the absorption of organic matter lowers the biochemical oxygen demand and the ammonia concentration. In the anoxic tank the internal recycling yields nitrate and nitrite, and denitrifying bacteria reduce the organic matter to nitrogen gas. In the oxic tank, labeled the aerobic tank in Figure 7, nitrification continues, the ammonia concentration falls and the nitrate concentration rises while the phosphorus-accumulating organisms take up phosphorus in excess, and the secondary clarifier discharges the surplus sludge. Figure 7 shows the process, together with the online sensors that supply the forecasting inputs.
Figure 7. The anaerobic–anoxic–oxic (AAO) nitrogen-and-phosphorus-removal process. Online sensors on the influent and effluent streams provide the multivariate observations used for forecasting.
The data records 12 process variables from this plant between 25 September 2024 and 21 February 2025: influent chemical oxygen demand, influent ammonia, influent total phosphorus, influent total nitrogen, influent pH, influent flow, influent water temperature, nitrate concentration, effluent chemical oxygen demand, effluent ammonia, effluent total phosphorus and effluent total nitrogen. The sampling interval is ten minutes, which yields 18,986 samples. The training set and the test set are split by time, and their per-variable means and variances differ, so the operating data exhibits distribution shift over the recording period. These 12 variables are exactly the high-resolution sensor observations that this Special Issue is concerned with, and the prediction of the effluent nitrogen and phosphorus from the influent and operating sensors is an instance of an observation-to-state mapping.
We use the same setting as before. Table 4 reports the comparison over the prediction lengths. FT-Crossformer obtains the best result on every prediction length: relative to the original Crossformer, the average MSE drops by 63.9%, and relative to the second-best iTransformer it drops by 10.1%, which provides evidence for the accurate performance and the generalization capability of the method on real environmental sensor data.
Table 4. Wastewater AAO nitrogen-and-phosphorus-removal prediction across prediction lengths. Best in bold.

4.5. Relation to Mechanistic Models and Data Assimilation

The two environmental cases support the reading of FT-Crossformer as a data-driven surrogate and a learned observation operator rather than as a generic forecaster. A mechanistic model of the AAO process, such as an activated sludge model [1], requires the repeated numerical solution of a stiff system of ordinary differential equations for each forward prediction, and its rate parameters must be calibrated to the plant. FT-Crossformer replaces that iterative stiff-ODE solve with a single forward pass of a trained network, paid once per window at deployment, while the training cost is paid once, offline. The model therefore addresses the first obstacle stated in the introduction, the computational cost of repeated forward prediction, by replacing the repeated numerical solution with a fixed-cost forward pass. We do not report a measured latency or FLOP comparison here, so this is a structural statement about the form of the computation rather than a measured speedup.
The model also addresses the second obstacle, the mapping from observations to states. Its input is the set of measured sensor variables and its output is the predicted process state, including effluent nitrogen and phosphorus, which are not measured at the same resolution; and the distribution-transformation and inverse-mapping pair is a learned quality-control and bias-correction step in the non-stationary sensor stream. In the language of data assimilation, FT-Crossformer can serve either as a fast surrogate for the forward model or as a learned observation operator inside an assimilation loop [27,39]. The model is a prediction model and not a variational or ensemble assimilation scheme; coupling it with a variational or ensemble method, so that the network supplies the forward operator or the observation operator and the assimilation supplies the uncertainty quantification, is a direction for future work.

5. Conclusions

We presented FT-Crossformer, a time–frequency joint-modeling method built on the Crossformer backbone that addresses the distribution shift and the variable coupling of non-stationary environmental sensor streams. The time-domain transformation, introduced via an affine transformation, mitigates distribution shift while preserving non-stationary information; concurrently, the frequency-domain weighting, implemented through stability quantification and adaptive weighting, amplifies the task-relevant frequency components that the transformation would otherwise leave unseparated. The public benchmarks and the ablation provide evidence supporting the generality and the contribution of each component, and the wastewater nitrogen-and-phosphorus-removal case shows accurate and robust prediction on real environmental sensor data. On real estuary chlorophyll data, the full model demonstrates superior accuracy at the next-day nowcasting horizon, and both proposed components contribute to this accuracy. The remaining limitations are the size and the computational cost of the model under resource-constrained deployment, which calls for a lighter model that meets low-latency requirements, and the coupling of the surrogate with a variational or ensemble assimilation scheme.

Author Contributions

Conceptualization, Z.Y. and H.G.; methodology, validation, investigation, resources, Y.G. and Z.Y.; data curation, Y.G.; writing—original draft preparation, Y.G.; writing—review and editing, Z.Y. and H.G.; visualization, Z.Y.; supervision, funding acquisition, H.G. All authors have read and agreed to the published version of the manuscript.

Funding

This research was funded by Ningxia Natural Science Foundation (Grant No. 2026AAC030163).

Institutional Review Board Statement

Not applicable.

Data Availability Statement

The estuary chlorophyll data from the Carquinez YSI mooring (ERDDAP rtcctdCMAysi) used in this study are openly available in the San Francisco State University Estuary and Ocean Science Center (https://www.diver.orr.noaa.gov/ accessed on 3 February 2026), meanwhile the wastewater data comes from the private factory and cannot be made public.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Henze, M.; Gujer, W.; Mino, T.; van Loosdrecht, M.C.M. Activated sludge models ASM1, ASM2, ASM2d and ASM3. IWA Sci. Tech. Rep. 2000, 9, 118–121. [Google Scholar]
  2. Sun, X.; Yan, D.; Wu, S.; Chen, Y.; Qi, J.; Du, Z. Enhanced forecasting of chlorophyll-a concentration in coastal waters through integration of Fourier analysis and Transformer networks. Water Res. 2024, 263, 156–168. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  3. Zhang, Y.; Yan, J. Crossformer: Transformer utilizing cross-dimension dependency for multivariate time series forecasting. In Proceedings of the Eleventh International Conference on Learning Representations (ICLR), Kigali, Rwanda, 1–5 May 2023. [Google Scholar]
  4. Shao, Z.; Wang, F.; Xu, Y.; Wei, W.; Yu, C.; Zhang, Z.; Yao, D.; Sun, T.; Jin, G.; Cao, X.; et al. Exploring progress in multivariate time series forecasting: Comprehensive benchmarking and heterogeneity analysis. IEEE Trans. Knowl. Data Eng. 2024, 37, 291–305. [Google Scholar]
  5. Zhang, X.; Feng, S.; Ma, J.; Lin, H.; Li, X.; Ye, Y.; Li, F.; Ong, Y.S. FRNet: Frequency-based rotation network for long-term time series forecasting. In Proceedings of the 30th ACM SIGKDD Conference on Knowledge Discovery and Data Mining, Barcelona, Spain, 25–29 August 2024. [Google Scholar]
  6. Piao, X.; Chen, Z.; Murayama, T.; Matsubara, Y.; Sakurai, Y. Fredformer: Frequency debiased transformer for time series forecasting. In Proceedings of the 30th ACM SIGKDD Conference on Knowledge Discovery and Data Mining, Barcelona, Spain, 25–29 August 2024. [Google Scholar]
  7. Kaur, J.; Parmar, K.S.; Singh, S. Autoregressive models in environmental forecasting time series: A theoretical and application review. Environ. Sci. Pollut. Res. 2023, 30, 19617–19641. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  8. Yamak, P.T.; Yujian, L.; Gadosey, P.K. A comparison between ARIMA, LSTM, and GRU for time series forecasting. In Proceedings of the 2019 2nd International Conference on Algorithms, Computing and Artificial Intelligence, Sanya, China, 20–22 December 2019. [Google Scholar]
  9. Wan, R.; Mei, S.; Wang, J.; Liu, M.; Yang, F. Multivariate temporal convolutional network: A deep neural networks approach for multivariate time series forecasting. Electronics 2019, 8, 876. [Google Scholar] [CrossRef] [Scilit]
  10. Hochreiter, S.; Schmidhuber, J. Long short-term memory. Neural Comput. 1997, 9, 1735–1780. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  11. Vaswani, A.; Shazeer, N.; Parmar, N.; Uszkoreit, J.; Jones, L.; Gomez, A.N.; Kaiser, Ł.; Polosukhin, I. Attention is all you need: Advances in neural information processing systems. In Proceedings of the 31st Annual Conference on Neural Information Processing Systems (NIPS 2017), Long Beach, CA, USA, 4–9 December 2017. [Google Scholar]
  12. Zhou, H.; Zhang, S.; Peng, J.; Zhang, S.; Li, J.; Xiong, H.; Zhang, W. Informer: Beyond efficient transformer for long sequence time-series forecasting. In Proceedings of the 35th AAAI Conference on Artificial Intelligence, Virtual, 2–9 February 2021. [Google Scholar]
  13. Wu, H.; Xu, J.; Wang, J.; Long, M. Autoformer: Decomposition transformers with auto-correlation for long-term series forecasting. Adv. Neural Inf. Process. Syst. 2021, 34, 22419–22430. [Google Scholar]
  14. Zhou, T.; Ma, Z.; Wen, Q.; Wang, X.; Sun, L.; Jin, R. FEDformer: Frequency enhanced decomposed transformer for long-term series forecasting. In Proceedings of the 39th International Conference on Machine Learning, Baltimore, MD, USA, 17–23 July 2022. [Google Scholar]
  15. Liu, Y.; Hu, T.; Zhang, H.; Wu, H.; Wang, S.; Ma, L.; Long, M. iTransformer: Inverted transformers are effective for time series forecasting. arXiv 2023, arXiv:2310.06625. [Google Scholar]
  16. Rabanser, S.; Günnemann, S.; Lipton, Z. Failing loudly: An empirical study of methods for detecting dataset shift. In Proceedings of the 33rd Conference on Neural Information Processing Systems (NeurIPS 2019), Vancouver, Canada, 8–14 December 2019. [Google Scholar]
  17. Lipton, Z.; Wang, Y.; Smola, A. Detecting and correcting for label shift with black box predictors. In Proceedings of the 35th International Conference on Machine Learning, Stockholm, Sweden, 10–15 July 2018. [Google Scholar]
  18. Kulinski, S.; Bagchi, S.; Inouye, D.I. Feature shift detection: Localizing which features have shifted via conditional distribution tests. Adv. Neural Inf. Process. Syst. 2020, 33, 19523–19533. [Google Scholar]
  19. Farahani, A.; Voghoei, S.; Rasheed, K.; Arabnia, H.R. A brief review of domain adaptation. In Advances in Data Science and Information Engineering; Springer: Cham, Switzerland, 2021; pp. 877–894. [Google Scholar]
  20. Na, J.; Jung, H.; Chang, H.J.; Hwang, W. Fixbi: Bridging domain spaces for unsupervised domain adaptation. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, Virtual, 19–25 June 2021. [Google Scholar]
  21. Ge, C.; Huang, R.; Xie, M.; Lai, Z.; Song, S.; Li, S.; Huang, G. Domain adaptation via prompt learning. IEEE Trans. Neural Netw. Learn. Syst. 2023, 36, 1160–1170. [Google Scholar]
  22. Wang, J.; Lan, C.; Liu, C.; Ouyang, Y.; Qin, T.; Lu, W. Generalizing to unseen domains: A survey on domain generalization. IEEE Trans. Knowl. Data Eng. 2022, 35, 8052–8072. [Google Scholar]
  23. Robey, A.; Pappas, G.J.; Hassani, H. Model-based domain generalization. Adv. Neural Inf. Process. Syst. 2021, 34, 20210–20229. [Google Scholar]
  24. Ding, Y.; Wang, L.; Liang, B.; Liang, S.; Wang, Y.; Chen, F. Domain generalization by learning and removing domain-specific features. Adv. Neural Inf. Process. Syst. 2022, 35, 24226–24239. [Google Scholar] [CrossRef] [Scilit]
  25. Reichstein, M.; Camps-Valls, G.; Stevens, B.; Jung, M.; Denzler, J.; Carvalhais, N.; Prabhat. Deep learning and process understanding for data-driven earth system science. Nature 2019, 566, 195–204. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  26. Boukabara, S.-A.; Krasnopolsky, V.; Penny, S.G.; Stewart, J.Q.; McGovern, A.; Hall, D.; Hoeve, J.E.T.; Hickey, J.; Huang, H.-L.A.; Williams, J.K.; et al. Outlook for exploiting artificial intelligence in the earth and environmental sciences. Bull. Am. Meteorol. Soc. 2021, 102, E1016–E1032. [Google Scholar] [CrossRef] [Scilit]
  27. Geer, A.J. Learning earth system models from observations: Machine learning or data assimilation? Philos. Trans. R. Soc. A 2021, 379, 20200089. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  28. Newhart, K.B.; Holloway, R.W.; Hering, A.S.; Cath, T.Y. Data-driven performance analyses of wastewater treatment plants: A review. Water Res. 2019, 157, 498–513. [Google Scholar] [CrossRef] [Scilit] [PubMed]
  29. Blix, K.; Eltoft, T. Machine learning automatic model selection algorithm for oceanic chlorophyll-a content retrieval. Remote Sens. 2018, 10, 775. [Google Scholar] [CrossRef] [Scilit]
  30. Cael, B.B.; Bisson, K.; Boss, E.; Erickson, Z.K. Information content of ocean-color time series. Geophys. Res. Lett. 2023, 50, 37. [Google Scholar]
  31. Jalilibal, Z.; Amiri, A.; Castagliola, P.; Khoo, M.B. Monitoring the coefficient of variation: A literature review. Comput. Ind. Eng. 2021, 161, 107600. [Google Scholar] [CrossRef] [Scilit]
  32. Zeng, A.; Chen, M.; Zhang, L.; Xu, Q. Are transformers effective for time series forecasting? In Proceedings of the 37th AAAI Conference on Artificial Intelligence, Washington, DC, USA, 7–14 February 2023. [Google Scholar]
  33. Cloern, J.E.; Jassby, A.D. Drivers of change in estuarine-coastal ecosystems: Discoveries from four decades of study in san francisco bay. Rev. Geophys. 2012, 50, RG4001. [Google Scholar] [CrossRef] [Scilit]
  34. Wang, Z.; Chai, F.; Dugdale, R.; Liu, Q.; Xue, H.; Wilkerson, F.; Chao, Y.; Zhang, Y.; Zhang, H. The interannual variabilities of chlorophyll and nutrients in San Francisco Bay: A modeling study. Ocean Dyn. 2020, 70, 1169–1186. [Google Scholar] [CrossRef] [Scilit]
  35. Wang, Z.; Chai, F.; Xue, H.; Wang, X.H.; Zhang, Y.J.; Dugdale, R.; Wilkerson, F. Light regulation of phytoplankton growth in San Francisco Bay studied using a 3D sediment transport model. Front. Mar. Sci. 2021, 8, 633707. [Google Scholar] [CrossRef] [Scilit]
  36. Martin, M.A.; Fram, J.P.; Stacey, M.T. Seasonal chlorophyll a fluxes between the coastal Pacific Ocean and San Francisco Bay. Mar. Ecol. Prog. Ser. 2007, 337, 51–61. [Google Scholar] [CrossRef] [Scilit]
  37. Cloern, J.E. Tidal stirring and phytoplankton bloom dynamics in an estuary. J. Mar. Res. 1991, 49, 203–221. [Google Scholar] [CrossRef] [Scilit]
  38. Cloern, J.E.; Schraga, T.S.; Lopez, C.B.; Knowles, N.; Labiosa, R.G.; Dugdale, R. Climate anomalies generate an exceptional dinoflagellate bloom in San Francisco Bay. Geophys. Res. Lett. 2005, 32, L14608. [Google Scholar] [CrossRef] [Scilit]
  39. Edwards, C.A.; Moore, A.M.; Hoteit, I.; Cornuelle, B.D. Regional Ocean Data Assimilation. Annu. Rev. Mar. Sci. 2015, 7, 21–42. [Google Scholar] [CrossRef] [Scilit] [PubMed]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Article Metrics

Citations

Article Access Statistics

Multiple requests from the same IP address are counted as one view.