Seasonally variable relationships between surface water temperature and inflow in the upper San Francisco Estuary

Water temperature and inflow are key environmental drivers in aquatic systems that are linked through a causal web of factors including climate, weather, water management, and their downstream linkages. However, we do not yet fully understand the relationship between inflow and water temperature, especially in complex managed systems such as estuaries. The San Francisco Estuary is the center of a critical water supply infrastructure and home to a deteriorating ecosystem with several declining fish species at the warm edge of their thermal range. We used generalized additive modeling of long‐term monitoring data to evaluate the relationship between inflow and water temperature along with its spatio‐seasonal variability. Most commonly, we found a negative temperature‐inflow relationship in which water temperatures increased as inflow decreased, up to 2°C from high‐ to low‐inflow years. However, the opposite (positive) relationship was observed in the winter months, and in the western (downstream) regions from July–September, up to − 1.2°C from high‐ to low‐inflow years. These results were upheld by models that included the long‐term temperature trend or used salinity as a proxy for location. Upstream factors likely played the biggest role in the summer when local precipitation is negligible, whereas local precipitation and the related weather conditions may drive much of the winter pattern. Although further mechanistic studies are needed to infer the direct effect of dam releases on water temperatures, these results provide a broader understanding of the impacts of flood and drought dynamics for those tasked with managing estuarine ecosystems.

Water temperature and freshwater flow are two key environmental drivers in estuarine ecosystems that define seasonal and interannual variability. Changes in temperature determine the timing and duration of phytoplankton and zooplankton blooms and the survival, spawning, and migration of key fish species (Winder and Schindler 2004;Munsch et al. 2019;Goertler et al. 2021). As the climate continues to warm, temperature will likely play an increasingly important role as metabolic demands increase and high temperature extremes reach lethal levels for cold-water species (Jager et al. 1999;Brown et al. 2016b;Del Rio et al. 2019). Variability in freshwater flow affects the physical, chemical, and biological processes of estuarine systems through various pathways (Kimmerer 2002a, b) and can drive species adaptation at an evolutionary scale through the fluctuations of floods and droughts (Lytle and Poff 2004). However, in many systems, freshwater flow has been altered and diverted for human use, often to the detriment of native biota (Postel 2000;Marchetti and Moyle 2001). The subject of freshwater flow has often been a source of controversy as it is a limited resource with ever-growing competing demands (Poff et al. 2003;Kimmerer 2004;Moyle et al. 2018). Given the sizable role of temperature and freshwater flow in determining the trajectory of aquatic ecosystems, a better understanding of the dynamics between these two fundamental variables can help the management of water resources for threatened and endangered species.
The thermal regime of freshwater ecosystems is determined primarily by the relationship between atmospheric influences (such as air temperature, humidity, and solar radiation) and water temperatures more so than freshwater input (van Vliet et al. 2011;Wagner et al. 2011;Vroom et al. 2017). Nonetheless, the correlation between atmospheric influences and water temperature can be altered through a variety of external flowrelated factors such as dam releases, cloud coverage, groundwater inflows, river flows, wastewater inputs, riparian shading, and wind shelters (Webb et al. 2003;van Vliet et al. 2011). For streams and rivers at high altitudes, the interaction between water temperature and flow is more apparent, as snowmelt runoff can slow the rate of water temperature increase from rising air temperatures in springtime (Webb and Nobilis 1997;Yarnell et al. 2010). Furthermore, air temperature itself can be indirectly linked to changes in flow. Storms that bring rainfall and thus increased inflow also influence air temperatures   (Fig. 1). However, it is less clear how water temperatures change with freshwater flow in large estuarine ecosystems with vast networks of tributaries, reservoirs, water diversion facilities, and a mosaic of habitats. It is also unclear how much these temperature-inflow relationships may vary over space and time.
Estuaries are some of the most heavily impacted ecosystems on the planet. Many human activities and settlements have centered on estuaries due to their wide array of resources and ecosystem services, which has led to extensive changes associated with the decline of key species (Costanza et al. 1997;Edgar et al. 2000). The list of environmental and socioeconomic issues commonly found in estuaries is exemplified by the San Francisco Estuary (hereafter referred to as "estuary") in central California, USA. Freshwater that flows into the estuary serves as drinking water for over 25 million people, irrigation water for a $36 billion/year agricultural industry, wintering habitat for millions of birds on the Pacific Flyway, and home to several endangered fish species (Service 2007;Cloern et al. 2011). There is high variability in precipitation from year to year in California, leading to wild swings between dry and wet years (Dettinger et al. 2016) that are projected to strengthen due to climate change (Swain et al. 2018). Combined with rising temperatures, this precipitation variability poses a complex challenge for water management (Persad et al. 2020). California represents the southernmost (i.e., warmest) range for a number of anadromous fish species such as Chinook Salmon (Oncorhynchus tshawytscha) and White Sturgeon (Acipenser transmontanus) (Schreier et al. 2013;Hecht et al. 2015). The unpredictable and complex nature of the system has made freshwater flow management a difficult balancing act.
It is no coincidence that this estuary is one of the best studied and well monitored in the world, with a considerable amount of research focusing on the effects of freshwater flow and water temperature (e.g., Kimmerer 2004;Wagner et al. 2011;Vroom et al. 2017). Yet for many studies on the estuary, these two variables have been treated as separate, independent physical properties. The reasoning is that cold water from snowmelt runoff or reservoir releases can be hundreds of kilometers upstream from the estuary, and river temperatures close to the estuary are primarily driven by local conditions (Daniels and Danner 2020). Consequently, there is a general expectation that the amount of precipitation and/or river discharge should have little effect on water temperature in this downstream portion of the watershed (Sommer 2020). Nevertheless, the policy and biological implications of water temperature and inflow are inextricably linked (Yarnell et al. 2010;Munsch et al. 2019;Daniels and Danner 2020), so an understanding of the relationship between these two variables is critical for effective management.
The purpose of our study is to evaluate the relationship (if any) between total inflow, local precipitation, and water temperature in this complex estuarine ecosystem. We used monitoring data that have been collected over the span of five decades and a model framework that allows for concurrent testing of climate change patterns. Causal mechanisms are not explored in our study because freshwater flow is linked to multiple variables, which may themselves be drivers of water temperature patterns (e.g., snowmelt, warm winter storms; Fig. 1). We did not assess air temperature effects in these initial analyses because air temperature data of the same spatio-temporal scope as our water temperature data were not available. However, we did assess the spatial and seasonal variability in the correlation between flow and water temperature. Understanding the spatio-seasonal variation in flow and water temperature relationship should help illustrate the contrasting ecosystem conditions between wet and dry years, and its implications for the species that reside in the estuary.

Study region
The San Francisco Estuary is the largest estuary on the west coast of United States, ranging from the marine-influenced San Francisco Bay to the tidal freshwater Sacramento-San Joaquin Delta (Delta; Fig. 2). Freshwater inflow largely comes from the Sacramento River to the north (85%) and San Joaquin River to the south (11%) (Kimmerer 2002b), with lesser inputs from the Cosumnes and Mokelumne Rivers to the east. All four rivers meet at the Delta, a network of leveed channels and tidal lakes. In the winter and spring of wetter years, the Yolo Bypass floodplain reroutes a considerable portion of the Sacramento River water (Sommer et al. 2001;Kimmerer 2004). The Yolo Bypass is contained within the larger Cache Slough complex, an area with remnant and restored wetlands that supplies important fish habitat (Sommer and Mejia 2013). Downstream of the Delta is Suisun Bay, which leads into another series of bays (San Francisco Bay) that eventually flow into the Pacific Ocean. North of Suisun Bay is the Suisun Marsh, a brackish marsh complex composed of tidal and backwater sloughs, ponds, and diked wetlands managed primarily for overwintering water fowls (Meng and Matern 2001). To minimize the influence of ocean dynamics on water temperature and focus on our study objective, we limited our study area to the upper estuary (the area in Fig. 2), where ocean temperatures have a greatly reduced impact (Vroom et al. 2017).
The estuary has a Mediterranean climate with wet winters and warm, dry summers. Precipitation is highly variable interannually and can occur over relatively few days in a given year (Dettinger and Cayan 2014;Dettinger et al. 2016). Because of this, inflow varies tenfold over both seasonal and annual time scales (Kimmerer 2002b). The upper estuary is the center of a complex water conveyance system linking the high supply in northern California during the winter to the high demand in central and southern California in the summer and fall. There are few undammed tributaries left in the estuary watershed so most inflow comes from reservoir releases (Kimmerer 2004;Brown and Bauer 2010). Water is stored in these upstream reservoirs during the wet season and then released during the summer and fall to flow through the Delta toward two large export pumps in the south Delta, which deliver water into large canals to central and southern California. Reservoir releases are also used to push out encroaching saltwater and keep the Delta fresh. Higher inflow in winter and spring months is often a result of increased releases due to high amounts of precipitation and snowmelt, but moderate amounts of precipitation can also lead to increased releases if there is a relatively high carryover storage from the previous water year. Meanwhile, inflow in the summer and fall is more strictly tied to the conditions in the preceding winter and spring months (higher precipitation in winter-spring leads to higher inflow in the summer-fall). The export rates from the export pumps often exceed flow rates from the nearby San Joaquin River, thus pulling water from the Sacramento River southward through the interconnected Delta channels. There have been no long-term trends in annual total inflow or outflow rates since the 1950s, but water operations have shifted the seasonal pattern of inflow such that reservoir storage has increased in the spring and releases have increased in the summer (Kimmerer 2002b;Hutton et al. 2017).
In the upper estuary, water temperatures are primarily driven by atmospheric influences such as air temperature, solar radiation, and cloud cover, although inflowing river temperatures have increasing influence closer to the river inputs (Wagner et al. 2011;Vroom et al. 2017). Over longer time periods (a year or more), atmospheric influences overpower river input effects on water temperatures (Wagner et al. 2011). Ocean temperatures have a negligible influence on water temperatures east (upstream) of the confluence of the Sacramento and San Joaquin Rivers (Confluence) (Vroom et al. 2017). The upper estuary is generally well-mixed. Salinity stratification is uncommon in this region especially upstream of the Confluence and temperature stratification is rare, limited to a few deep locations (e.g., Rough and Ready Island in the San Joaquin River near Stockton, the Sacramento River near Rio Vista, and the Sacramento Deepwater Ship Channel; Fig. 2), and temporary (Kimmerer 2004;Vroom et al. 2017;Bashevkin 2022).

Data processing
We used two datasets in this study. The first was an integrated dataset of discrete water quality data from the upper San Francisco Estuary (Bashevkin 2022). This dataset includes surface water temperature measurements (upper 1 m) from 11 long-term boat-based monitoring surveys that sampled at least monthly at several locations throughout the estuary (Fig. 2). We used this discrete dataset because of the long temporal range of its broad geographical scope, which enabled us to link the interannual variability in inflow and water temperatures and investigate the spatial and seasonal differences in this relationship with sufficient power. The second dataset was the Dayflow model of Delta hydrology produced by the California Department of Water Resources (https:// data.cnra.ca.gov/dataset/dayflow). This model calculates daily inflow and in-Delta precipitation (among other quantities) and is used extensively in research and management of the estuary. The methods used by the California Department of Water Resources to calculate the quantities we used in this analysis are briefly described below. Inflow is calculated as the sum of the principal surface water flows into the Delta. Precipitation values are based on measurements at the Stockton Fire Sta. 4 (37.9997 , À121.3174 , Fig. 2), which are then converted to a volumetric flow rate assuming the entire Delta experiences the same precipitation and that storm drainage is evenly distributed over 5 d. The Delta area used for this calculation was changed in 1980 so we corrected all pre-1980 precipitation values to conform to the more recent calculation method.
The integrated water quality dataset was processed as in Bashevkin et al. (2021) for the development of five statistical models (Table 1). Briefly, the integrated dataset contains surface water measurements (upper 1 m) from 11 long-term boatbased monitoring surveys. We selected the nine surveys from this set that were over 10 years old for this analysis as in Bashevkin et al. (2021). Data records with missing values in any of the key variables (water temperature, date, time, latitude, and longitude, plus salinity for model 4 [see below and Tables 1, 2]) or collected outside the standard time window of data collection (05:00-20:00) were excluded. Next, we converted all times to Pacific Daylight Time to remove the influence of Daylight Savings Time, removed data from nonfixed sampling stations, and selected one data record per month per station. The latter two steps helped account for and reduce the temporal autocorrelation. Then we filtered the dataset to the spatial region of interest (Fig. 2). For the salinity model (model 4), we also removed any observations with extreme salinity values (defined as a deviation from the regional mean over 10 times the regional standard deviation). Lastly, we added back-looking 30-day running mean (mean over the past 30 days) inflow and precipitation from the Dayflow dataset to each data record in the water temperature dataset and removed water temperature data records with no corresponding Dayflow data (October 2019 and later). All data processing was conducted with R 4.0.3 (R Core Team 2020). The final datasets spanned April 1969 to September 2019 and contained 58,900 water temperature observations for all models except for the salinity model (model 4), which used a dataset with 55,941 observations due to the removal of observations with missing or anomalous salinity values.

Model structure
To evaluate the relationships between hydrologic inputs (total inflow or in-Delta precipitation) and surface water temperature, and how those relationships vary seasonally, spatially, and along the salinity continuum, we used generalized additive models fit with the R package mgcv (Wood 2011;Wood et al. 2016). Models were constructed similarly to Bashevkin et al. (2021) and further details on model construction can be found there. The response variable was surface water temperature ( C), and predictor variables included latitude, longitude, salinity (for model 4), ordinal date (day of year), 30-day mean inflow (for models 1-4), 30-day mean precipitation (for model 5), year (for model 3), and time-of-day expressed as time since midnight. All predictor variables were centered by their mean and scaled by their standard deviation prior to model fitting (i.e., standard score). The models each contained at least four of five major components (outlined in Table 2 Model fitting was performed with the mgcv function bam, which is built for large datasets, and with the "discrete" option enabled to speed up computation. The scaled-t model family (function scat) was used to account for outliers in the dataset. Basis dimensions of smooth terms were assessed first with the gam.check function. If any smooths looked potentially problematic from this assessment, models were refit with a higher basis dimension and compared to the original with regards to Akaike Information Criterion (AIC) values and model predictions. To assess the degree of residual spatiotemporal autocorrelation, we calculated the spatiotemporal variogram on the model residuals using the R package gstat (Pebesma 2004;Gräler et al. 2016).

Models 1 and 2: Spatio-seasonal trends in the temperaturetotal inflow relationship
To determine the spatial and seasonal patterns in the relationship between water temperature and total inflow (temperature-inflow relationship), we fit model 1 with all model components except for the long-term temperature trend Evaluate the temperature-inflow relationship along the salinity continuum in place of spatial coordinates to reflect what estuarine biota will experience 5 Evaluate the temperature-precipitation (instead of temperature-inflow) relationship spatially and seasonally (C3) ( Table 2), and with the inflow variable centered and scaled by the monthly means and standard deviations (Table 3). We used this monthly scaling to produce interpretable results despite the wide seasonal variability in inflow and ensure temperature-inflow relationships were based on among rather than within-year inflow differences. However, to ensure that this monthly standardization did not overly influence the results, we fit another model (model 2) exactly the same as model 1 but with the inflow variable centered and standardized by the global (instead of monthly) mean and standard deviation from the Dayflow dataset (Table 2).
Model 3: Incorporating long-term temperature change Water temperature in the upper San Francisco Estuary has risen over the past five decades (Bashevkin et al. 2021), which may confound our results because dry years were more frequent in the latter half of our time series . To assess whether long-term underlying temperature changes could affect our results, we fit model 3, which was identical to model 1 but with an additional component to estimate the long-term water temperature trend (i.e., climate change). This component (C3) was identical to the temperature-inflow relationship component (C2) but instead Table 2. Model descriptions and components. C1, C2, etc. represent numbered model components. For each component, the specific variables used are described. If there is no specific variable at that component level, "NM" indicates the component was not modified among models. "DOY" represents day-of-year, "precip" represents precipitation; and "absent" indicates the model component was not included.  Table 3. Mean and standard deviation of 30-day mean inflow and precipitation from Dayflow, for each month of the year. For each day of the month, the inflow and precipitation over the prior 30 days was averaged into the 30-day mean. Then, these 30-day mean values for each day of the month were aggregated into the mean and standard deviations (SD) shown in this table, which were used to center and scale, respectively, the variables prior to fitting models 1 and 3-5. All values are in cubic feet per second (cfs; 1 cubic foot = 0.028 m 3 ). of multiplying the smooth by inflow, it was multiplied by the water year (centered and scaled; Table 2). Water years begin in October and end in the following September. This component was identical to that used in Bashevkin et al. (2021) except in this case, we used water years instead of calendar years to better match the structure of the dataset.

Month
Model 4: Salinity-seasonal trends in the temperature-total inflow relationship Salinity is often used as a proxy for estuarine position and is an important indicator for species occupancy (Sommer et al. 2011;Feyrer et al. 2015). Evaluating water temperature changes at a particular salinity zone thus can be insightful, as estuarine biota often distribute themselves along a salinity gradient rather than a particular geographical position in an estuary. For this reason, we fit model 4 with a thin plate smooth of salinity (centered and scaled) substituted for the spatial element of model component C2. The spatial element of component C1 was retained to continue correcting for spatial autocorrelation (Table 2).

Model 5: Spatio-seasonal trends in the temperatureprecipitation relationship
To determine the influence of in-Delta precipitation on water temperatures, we fit model 5 with the in-Delta precipitation values from Dayflow. This model was identical to model 1 but with the inflow variable replaced with an analogous 30-day mean precipitation variable (Table 2).

Model predictions
Model predictions were used to assess the interdependent impacts of our covariates on water temperature. For the spatially explicit models (models 1-3, 5), we generated these predictions on an evenly spaced grid of 100 Â 100 cells over the spatial domain of our dataset, which was then filtered to just those cells that contained water, resulting in 1698 cells. We chose the midpoint of each cell as a point location for model predictions. For model 4, in which salinity was used as a proxy for estuarine position, we used an evenly spaced sequence of 100 salinity values from the 5th to the 95th percentile salinity value in the base dataset.
We then created a dataset with all combinations of the evenly spaced point locations (or salinity values for model 4) and the ordinal dates corresponding to the 15th of each month. The time of day was set to noon. To avoid extrapolation, we removed any covariate combinations that were not present in the underlying dataset, for example, by removing point locations outside the geographical sampling footprint for each month. For model 4, we avoided extrapolation by removing salinity values outside the 5th to 95th percentile values for each month. To assess the relationship between inflow and water temperature, we extracted the predicted value of model component C2 (effect of inflow [or precipitation] on water temperature represented as a smooth of spatial position [or salinity] and ordinal date) and its standard error. The standard errors were converted to 99.9% confidence intervals, representing a p-value of 0.001 as our cutoff for statistical significance. This conservative cutoff was used to account for any residual autocorrelation unaccounted for by the AR(1) structure.

Model validation
All models conformed to linear model assumptions (Fig. 3). The adjusted R 2 values for models 1-5 were 0.9225, 0.9226, 0.9245, 0.9232, and 0.9186, respectively. The spatiotemporal variograms revealed some temporal autocorrelation at a lag of 1 month but none at later months or along the spatial dimension ( Supplementary Figs. S5-S9).
Spatio-seasonal trends in the total inflow temperature relationship The relationship between water temperature and total inflow (temperature-inflow relationship) had considerable geographic and seasonal variability (Fig. 4). General patterns were similar for model 1 (inflow scaled by monthly mean and standard deviation) and model 2 (inflow scaled by global mean Fig. 4. Relationship between monthly standardized Delta inflow and surface water temperature (temperature-inflow relationship) from model 1. Inflow was represented as the 30-day mean inflow for each temperature observation, which was then centered and standardized by the monthly mean and standard deviation, respectively. Thus, the numbers represent the water temperature change ( C) for each one standard deviation ("SD") change in inflow (cubic feet per second: "cfs"). The inflow standard deviation magnitude varies monthly (Table 3, Supplementary Fig. S12). Red areas represent a positive correlation and blue a negative correlation. Only areas with significant (p < 0.001) temperature-inflow relationships are plotted, with gray areas representing no significant temperature-inflow relationship. and standard deviation) (Supplementary Figs. S10, S11), so further results are presented from model 1 to aid interpretability.
The majority of significant temperature-inflow relationships (p < 0.001; blue or red areas in Fig. 4) were negative, wherein increased inflow was associated with reduced water temperatures. These negative temperature-inflow relationships were strongest (highest magnitude) in the East, particularly in the months of March-June and October-November. However, we also detected significant positive temperature-inflow relationships, wherein increased inflow was associated with increased water temperatures. These positive temperatureinflow relationships were strongest and most widespread in January in the central-eastern regions, and they were also apparent in western regions in February, July, August, and September, and in the East in December. The summer months (July-September) were characterized by an east-west divide in the direction of the temperature-inflow relationship, with a negative temperature-inflow relationship in the west, and positive in the east, while December had the reverse pattern (Fig. 4, Supplementary Fig. S13).
Negative temperature-inflow relationships reached higher magnitudes than the positive temperature-inflow relationships on the monthly standardized scale (Fig. 4). For example, temperature-inflow relationships reached slightly more than À1 C/SD inflow in May, which corresponded to a 1 C drop in water temperature for each 31,207 cubic foot per second (cfs) of increased 30-day mean inflow, and a difference of 2 C between generally dry (À1 SD) and wet (1 SD) conditions (Table 3, Fig. 4). In January, the temperature-inflow relationship reached +0.6 C/SD inflow, which corresponded to a 0.6 C increase in water temperature for each 46,404 cfs of increased 30-day mean inflow, and a difference of 1.2 C Fig. 5. Relationship between monthly standardized Delta inflow and surface water temperature (temperature-inflow relationship) along the salinity axis from model 4. The smooth line represents the mean temperature-inflow relationship, while shaded regions represent the 95%, 99%, and 99.9% confidence intervals. Salinities are truncated to values within the 5th and 95th percentiles of observed values for each month. The horizontal line represents no relationship between inflow and surface water temperature while the vertical red line indicates the monthly average salinity of the Confluence region (Fig. 6, Supplementary Fig. S15). The geographical and seasonal distribution of the salinity field can be seen in Fig. 6 and Supplementary Fig. S15. Salinities are given in parts per thousand (PPT). The y-axis represents the water temperature change ( C) for each one standard deviation ("SD") change in inflow (cubic feet per second: "cfs"), where this standard deviation magnitude is defined monthly (Table 3, Supplementary Fig. S12).
between dry and wet conditions (Table 3, Fig. 4). Furthermore, inflow values reached greater high than low extremes in most months such that ranges of two or more standard deviations above the mean were common for most months, while the lows only reached one standard deviation below the mean in most months (Supplementary Fig. S12).
Model 3, in which the long-term water temperature trend was added to the model, produced almost identical results to model 1 (Fig. 4, Supplementary Figs. S11, S14). The only discernable difference was a larger region with a positive temperature-inflow relationship in December ( Supplementary Fig. S14).

Salinity-seasonal trends in the temperature total inflow relationship
Results from model 4, in which salinity was included as a proxy for location, generally conformed to those from model 1 although there were key differences (Fig. 5). The Delta is maintained to be freshwater year-round through water operations, so areas with salinity <1.5 PPT in the wetter months and <3 PPT in the drier months generally correspond to the Delta (upstream of the Confluence). Areas downstream of the Delta tend to be much more dynamic in salinity (Fig. 6, Supplementary Fig. S15). As in model 1, negative temperatureinflow relationships were observed in March (salinity <1.5 or >3 PPT), April-May (all salinities), June (salinity < 1.5), and October-November (all salinities). In May, June, and to some extent in October, the same gradient of an increasingly positive temperature-inflow relationship from low to high salinity (east to west) was observed, but this gradient was not as apparent in the other months. At the lower end of the salinity range, the April temperature-inflow relationship also became increasingly positive with increasing salinity, but at salinities >3 the pattern shifted and temperature-inflow relationships became increasingly negative with increasing salinity. This shift at a salinity of 3 was also apparent in February, March, and to a lesser extent in June and July. Positive temperatureinflow relationships similar to model 1 were found in January (salinity <9), February (salinity <3), and July-September (salinity <6) (Fig. 5).
The biggest differences between models 2 and 4 were detected in March, August, and December. In March, model 4 detected a positive temperature-inflow relationship in salinities from 1.5-3, while in model 1 all detected temperatureinflow relationships were negative for this month. However, salinities from 1.5-3 would include Suisun Marsh (Figs. 2, 6), where temperature-inflow relationships from model 1 were weak in March and the confidence intervals spanned positive values ( Supplementary Fig. S13). In August, model 4 detected positive temperature-inflow relationships at the lowest salinities, while model 1 detected negative temperature-inflow relationships in the east where salinities are lowest. However, model 1 did detect positive temperature-inflow relationships in some low-salinity areas east of the confluence and both models detected negative temperature-inflow relationships at the highest salinities (westernmost areas), although those temperature-inflow relationships were not significant in model 4. In December, model 4 detected negative temperature-inflow relationships at low salinities (east) and positive temperatureinflow relationships at high salinities (west), while in model 1 the reverse trend was observed. However, in the very lowest salinities corresponding to the regions in which positive temperature-inflow relationships were detected in model 1, the temperature-inflow relationship was very close to 0 in model 4.

Spatio-seasonal trends in the temperature precipitation relationship
The temperature-precipitation relationship was generally similar to the temperature-inflow relationship, with the same seasonal pattern in the direction of the relationship (Figs. 4,7,  Supplementary Fig. S11). However, the temperatureprecipitation relationship was greatly weakened in the summer months when precipitation is very low (Table 3), revealing the impact of inflow from out of the system driving the observed summer temperature-inflow relationship. Furthermore, the temperature-precipitation relationship was stronger and more widespread in December and January when strong winter storms can change air temperature regimes as well as releasing copious rainfall (Fig. 7).

Discussion
Ecological demand for cold freshwater is likely to grow as global air and water temperatures increase. Coldwater habitat requirements for endangered fishes have led to adjustments in the timing and volume of reservoir releases in the upper extent of California's Sacramento River (Brown and Bauer 2010). Water releases are expected to have less of an effect on water temperature in the upper estuary, hundreds of river kilometers downstream of reservoirs, so no active temperature management currently exists (though note that some smaller watersheds are close to the upper estuary). But despite this general assumption, there is some uncertainty in the extent and magnitude of the correlation between inflow and water temperature in the upper estuary given the various drivers of inflow that can indirectly affect water temperature ( Fig. 1) (Kimmerer 2004;Jeffries et al. 2016;Sommer 2020). The goal of this study is not to recommend the use of freshwater flow to manage water temperature, but rather to better understand the temperature changes we would expect based Fig. 7. Relationship between monthly standardized in-Delta precipitation and surface water temperature (temperature-precipitation relationship) from model 5. Only areas with significant (p < 0.001) temperature-precipitation relationships are plotted, with gray areas representing no significant trend. Note that precipitation is largely absent during the dry summers (Table 3) and precipitation values are calculated based on one station near Stockton (Fig. 2). The color scale represents the water temperature change ( C) for each one standard deviation ("SD") change in precipitation (cubic feet per second: "cfs"), where this standard deviation magnitude is defined monthly (Table 3).
on the amount of freshwater flow that enters the system, and in effect how we can expect water temperatures to change across dry vs. wet years.
We found persistent correlations between inflow and water temperature, but the strength and direction of these correlations exhibited considerable seasonal and spatial variability. Negative temperature-inflow relationships in which higher inflow was associated with lower water temperatures were most commonly observed, but positive relationships were also observed in the winter months and in the western regions during the mid-late summer (July-September). The temperature-inflow relationship was likely driven by upstream factors (e.g., snowmelt, dam releases, or inflowing river temperature) during the summer months when in-Delta precipitation had a negligible relationship with water temperature (temperature-precipitation relationship). In contrast, in-Delta precipitation and the related weather conditions may drive much of the pattern in the winter months when the temperature-precipitation relationship was stronger.
We found similar results from a range of model structures, providing evidence for the robustness of our approach (Supplementary Fig. S11). With model 2, we validated that our method of standardizing inflow for each month did not influence the broad patterns in temperature-inflow relationships by comparing the results with our main model (model 1, Fig. 4, Supplementary Figs. S10, S11). In model 3, we estimated the long-term water temperature trend on top of the temperature-inflow relationship to confirm that the temperature-inflow relationship was not confounded by cooccurring long-term trends in water temperature and inflow (Fig. 4, Supplementary Figs. S11, S14). In addition, the longterm water temperature trend estimated in model 3 (Supplementary Fig. S16) was almost identical to that estimated in a prior study using a similar model structure (without the inflow component) and the same dataset (Bashevkin et al. 2021). In model 4, we assessed the temperature-inflow relationship along the salinity continuum instead of over space. Model 4 generally produced similar results as model 1, although there were some differences (Figs. 4, 5). Many of the areas of contrast between models 2 and 4 corresponded to a significant effect from one model and no significant effect of the other model, rather than conflicting directions of effects. This is likely because model 4 could transcend geographic bounds to infer patterns for select positions on the salinity continuum while model 1 was firmly rooted in geography.

Comparison to prior studies
In the upper estuary, inflowing river temperature can play a role in dictating water temperatures near the points of river input (Vroom et al. 2017). The magnitude of inflow would thus be expected to have an influence as well by controlling how far the river temperature effect penetrates the estuary. Yet few studies have looked at temperature-inflow or temperatureprecipitation relationships in the upper estuary, particularly at the level of spatio-seasonal resolution we include in our analysis. Some of these studies have suggested that reservoirreleased inflow (an effect that we were unable to isolate in this study) has little influence on water temperatures (Cloern et al. 2011;Sommer 2020). Similarly, Daniels and Danner (2020) found that the influence of dam discharges and discharge temperatures are greatly reduced (but not eliminated) toward the lower reaches of the Sacramento River, such that air temperature is the primary correlate of Sacramento River temperatures at the most downstream region in their study (a location over 50 km upstream of our study region). However, several other studies found a general pattern of negative temperature-inflow relationships that corresponds to our findings. For example, Kimmerer (2004) compared air to water temperature correlations for low and high flow events and found negative temperatureinflow relationships at two sites along the Sacramento River and near the Confluence. Jeffries et al. (2016) compared water temperatures from the 2012-2015 extreme drought to the prior 17 years and found significantly warmer temperatures during the drought period for April-July. Munsch et al. (2019) found nonsignificant negative correlations between winter precipitation and April water temperatures. Lastly, Nobriga et al. (2021) found negative relationships between flow and water temperature on the Sacramento and San Joaquin Rivers within the Delta in April, May, and June.
Temperature-inflow relationships have been investigated before in estuaries and streams at more coarse resolutions. A study of the Mississippi River Estuary found that large discharges of cooler freshwater could have a cooling effect on the whole estuary (Lane et al. 2007). Similarly, in the Yaquina Estuary (Oregon, USA) a 20% reduction in river discharge during the dry season was projected to result in water temperature increases up to 1.4 C. The impact was highest upstream and became negligible farther downstream (Brown et al. 2016a). Many studies on streams and rivers also found negative temperature-inflow relationships, likely due to the greater water mass at higher flows increasing the thermal inertia and thus dampening the impact of local air temperatures while increasing the impact of upstream water temperatures (Gu et al. 1998;Chang and Lawler 2011;van Vliet et al. 2011). In contrast, a study of a cool river in Japan found that water temperatures initially increased during high discharges from rainstorms (positive temperature-inflow relationship), but as the peak flows receded the stream temperatures decreased to values even lower than they were initially. The authors concluded that the initial increase was due to the warmer temperature of the rainfall than the stream, while the later reduction in temperature was due to the influx of cooler subsurface water (Kobayashi et al. 1999). Together, these studies suggest that the temperature-inflow relationship can modify the relative contributions of local and upstream conditions on water temperatures and that the temperature-inflow relationship is dependent on the relative temperatures of the water body of interest, rainfall, and inflowing waters (whether from upstream or groundwater).

Geographical divides in the temperature-inflow relationship
Our results show upstream-downstream gradients in the size and direction of the temperature-inflow relationship corresponding to increasingly negative relationships near the river inputs in the east and increasingly positive relationships near the connection to San Francisco Bay in the west. These gradients are especially apparent from April through October (Fig. 4), corresponding to most of the "dry season" when inflow would be driven mostly by reservoir releases with some contribution of snowmelt early in the season. April is on the boundary of the wet and dry season (Table 3) and the gradient is least discernable for that month. In July-September and December, these gradients were strong enough to produce divergences in the direction of the temperature-inflow relationship (Fig. 4). During the summer (July-September) when temperatures and their spatial variability are highest (Fig. 8), we found a positive temperature-inflow relationship in the west and a negative relationship in the east, while the pattern was reversed in December. This may reflect the conflicting influences of the more seasonally stable (western) San Francisco Bay water temperatures and the seasonally variable (eastern) Delta water temperatures. In the summer, Suisun Bay waters are often cooler than the Delta, while in December that balance is reversed. Thus, inflowing waters of an intermediate temperature between these two water bodies may be able to simultaneously cool the Delta and warm Suisun Bay in the summer, with the reverse pattern in the winter, resulting in the observed pattern. It is worth noting that stratification is more common downstream (west) of the Confluence where the water becomes more saline (Fig. 6). Upstream (eastern) freshwater forms the surface layer of the water column and more saline downstream (western) water pushed upstream by the tides forms the bottom layer. Because our analysis was focused on surface water temperatures, results downstream of the confluence may not be reflective of temperature throughout the water column under stratified conditions.

Temperature-inflow relationships in the dry season
For most of the dry season (April-November), the temperature-precipitation relationship is reduced or nonexistent relative to the wet-season months, although a major exception is the boundary month April in which the temperature-precipitation relationship is most strongly negative (Fig. 7). The greater magnitude of the temperature-inflow relationship than the temperature-precipitation relationship implies a greater importance of external influences like river temperature or flow (Figs. 1, 4, 7). This is bolstered by the stronger magnitude of the temperature-inflow relationship near the river inputs to the north, south, and east (Fig. 4). Interestingly, in most of these months, the strong temperature-inflow relationship persists farther into the Delta along the Sacramento corridor (from the North) than along the San Joaquin River corridor (from the South). This would further suggest a link to river inflow since the Sacramento River inputs 85% of all inflow into the Delta, while the San Joaquin River contributes just 11% on average (Kimmerer 2002b). Riverine input would be expected to show this pattern of reduced water temperatures correlated with higher flows when river temperatures are cooler than the ambient water in the upper estuary. This is generally the case for the Sacramento River for all months except December and January in most years (Bashevkin, unpublished data). Sacramento river temperatures at a site over 50 km upstream of our study region are primarily controlled by atmospheric influences, although dam discharge volume can play a role in the spring (Daniels and Danner 2020). Releases of cold water used to keep rivers cool for Salmon from closer reservoirs such as Folsom and New Melones may play a role in the negative temperature-inflow relationship we observed in the summer and fall. However, we do not yet know the extent to which these cold-water releases impact Delta water temperatures.
Higher flows could reduce residence time and increase overall water volume in the upper estuary, thereby decreasing the influence of local air temperatures and reducing water temperatures as was seen in prior studies (Gu et al. 1998;Webb et al. 2003;Chang and Lawler 2011). In the upper estuary, air temperatures often exceed 30 C in the summer and adjacent months during the daytime. But on most nights, marine air intrusions drop the temperature an extra 6 C cooler than it would be under other wind conditions (Zaremba and Carroll 1999). Increased thermal inertia from higher flow volumes could help dampen the impact of the daytime temperature spikes and keep water temperatures lower than they would be under lower flows. Water volume and thermal inertia would be expected to have the greatest impact on water temperatures near the river inputs, where we did detect some of the highest magnitude temperature-inflow relationships (Fig. 4). These are also the regions where river inflows have the largest impact on water volume (Maendly and Copeland 2021).

Temperature-inflow relationships in the wet season
In the wet season (December-March), we found consistent temperature-inflow and temperature-precipitation relationships, implying a potential role of local precipitation or its correlates in driving the temperature-inflow relationship in this season. In the winter months (December-February), we found strongly positive temperature-inflow and especially temperature-precipitation relationships (Figs. 4, 7). High flows during these months are often associated with atmospheric river events, which are accompanied by warmer air temperatures . The strongly positive temperature-precipitation relationships particularly point toward these storms and their associated weather conditions (e.g., air temperature, relative humidity) as drivers of the winter temperature-inflow pattern we observed (Vroom et al. 2017, Fig. 1). However, it is interesting that the positive temperature-inflow relationship did not persist throughout the full wet season, which extends into March (Table 3).
The temperature-inflow and temperature-precipitation relationships are both negative in March (a pattern that continues into April), which may suggest that the influence of March storms may be different from that of December-February storms. One explanation for this directional switch in March could be an increased influence of cloud cover in March compared to the deeper winter due to the increased solar radiation from longer daytimes. Cloud cover reduces water temperatures (Vroom et al. 2017) so cloudiness from storms could have a strong cooling effect in March and other sunnier months, while its influence could be superseded by air temperature and humidity in the winter when daytime is shorter. Another potential explanation could be the influence of cool snowmelt starting in March. Earlier in the wet season, much of the precipitation is stored as snow in higher elevations which typically begins to melt between March and April. Cool snowmelt runoff may explain some of the negative temperature-inflow relationships we observed starting in March. While mainstem Sacramento River temperatures may be unlikely to influence local water temperatures in the upper estuary due to the long distance from the upper reservoirs (Daniels and Danner 2020), several other rivers have a much shorter journey from the mountains to the upper estuary (e.g., the American and Feather Rivers to the North, and the San Joaquin River to the South). The San Joaquin River may have a particularly strong influence in the southern portion of the Delta since it is primarily snowmelt-driven, but it only contributes about 11% of annual total inflow (Kimmerer 2002b). However, except for the Cosumnes River, all river inputs to the upper estuary are controlled by reservoir releases, so snowmelt would only have an influence if directly released from reservoirs, which can occur frequently in wet years for flood control purposes.
It is worth noting that the Yolo Bypass floodplain may also play a role in the temperature-inflow relationship during wet seasons (Fig. 2). The Yolo Bypass only floods during the winter and spring of wet years between October and June, with inundation peaking from January-March (Sommer et al. 2001). During very wet years, it can divert a large proportion of the Sacramento River water, accounting for roughly a third of the total inflow (Kimmerer 2004). The flooding of Yolo Bypass considerably increases the amount of shallow water area, potentially allowing water temperature to equilibrate more quickly with air temperature while increasing water residence time.

Implications
Both water temperature and freshwater flow are expected to change due to climate warming, adding further pressure to species of concern and negatively impacting important ecosystem services such as water supply (Knowles et al. 2018). While the exact drivers of the temperature-inflow relationships we observed are not identified in this study, all are linked in some way to precipitation (Fig. 1). Precipitation in California is extremely variable year-to-year, more so than any other region of the United States (Dettinger et al. 2016). The temperatureinflow relationships detected in this study persisted despite increasing water temperatures (Bashevkin et al. 2021), changing precipitation regimes (Swain et al. 2018), and adjustments to water operations due to environmental regulations. Under climate change, precipitation variability is expected to increase, resulting in both increasingly intense droughts and wet periods, as well as increasingly strong swings between the two extremes (Swain et al. 2018). Our results suggest that water temperatures may be impacted along with the expected effects on Delta inflow. In the winter months (December-February), increasingly extreme wet years with high inflow may result in warmer water temperatures during these years (Figs. 4,  7). In the rest of the year, higher inflow during these extreme wet years may result in cooler water temperatures, especially in the eastern portion of the upper estuary and areas closer to river inputs (Figs. 4, 7). Meanwhile, increasingly strong droughts may result in cooler water temperatures in the winter and warmer water temperatures in other months. Furthermore, these patterns may interact with water supply management which can strongly influence inflow especially during the spring, summer, and fall months (Kimmerer 2002b). While annual average inflow does not have a detectible trend over the historical record , monthly average inflow has decreased in the months of June through October and decreased in April and May (Hutton et al. 2017).
The upper estuary serves as key habitat for a variety of aquatic species of concern. Multiple flow-abundance relationships for some of these species have been well documented and studied, though some remain contentious due to either weak correlation or a lack of mechanistic understanding (Kimmerer et al. 2009(Kimmerer et al. , 2013Tamburello et al. 2019). Our results indicate that flow-related changes in water temperature may be a contributing mechanism that underlies a number of these flow-abundance relationships. For example, Longfin Smelt (Spirinchus thaleichthys), a fish species listed under the California Endangered Species Act, exhibit a strong positive relationship with flow (Nobriga and Rosenfield 2016; Mahardja et al. 2021), but the mechanism behind this relationship is not entirely clear (but see Grimaldo et al. 2020). Larval and juvenile Longfin Smelt demonstrate sensitivity to high temperatures; thus warmer springtime water temperatures may partially explain their decline during droughts (Jeffries et al. 2016;Mahardja et al. 2017;Peterson and Barajas 2018).
While a number of fish species are close to their thermal limits where temperature can directly influence survival, nonlethal temperature changes can also significantly alter key life history processes (Jeffries et al. 2016;Brown et al. 2016b;Zillig et al. 2021). Some life history processes are dependent on absolute temperatures, but we do not make absolute temperature predictions in this paper. However, the direction and magnitude of temperature changes can also be informative for understanding impacts on fishes. The United States Endangered Species Act-listed Delta Smelt (Hypomesus transpacificus), along with other native species, spawn in the spring during specific temperature regimes that are cooler than those required by nonnative fishes (Meng and Matern 2001;Bennett 2005). Elevated water temperatures of the magnitude we related to inflow changes can reduce Delta Smelt reproductive success by shortening the duration of their spawning window (Brown et al. 2016b). For Chinook Salmon (Oncorhynchus tshawytscha), a species of high cultural and economic importance, the upper estuary habitat serves as rearing grounds during the wintertime. California is the warmest extent of the Chinook Salmon natural range (Hecht et al. 2015), placing them close to the maximum temperatures the species can tolerate. Cooler winter temperatures enable juvenile salmon to spend more time feeding and growing in the estuarine habitat, which increases their survival in the next oceanic stage of their life (Munsch et al. 2019). Temperature increases of as little as 1 C in winter could reduce the juvenile salmon rearing time by several days, decrease their maximum sizes by a few millimeters, and reduce their survival.

Next steps
Given the uncertainty of the mechanisms underlying the patterns we found in this study, further studies are needed to delineate the specific drivers of water temperature and inflow dynamics prior to implementing any flow-related temperature management actions in the upper estuary. In this first-pass high-level analysis of temperature-inflow relationships in the upper estuary, we did not directly assess causal relationships. We did not evaluate the influence of atmospheric influences such as air temperatures due to the lack of data with the same spatiotemporal scope as our water temperature dataset. Nonetheless, as shown in our conceptual model (Fig. 1) air temperature is directly linked to water temperatures. Various processes that determine atmospheric influences but are indirectly linked to inflow patterns could be driving the observed water temperature trends. For example, if dry years are hotter on average than wet years (Diffenbaugh et al. 2015), due to the same underlying climate patterns driving inflow variability, this could partially explain our observed negative temperature-inflow relationships in some months. If our observed temperature-inflow relationships are indeed driven by atmospheric influences, then flow management would not be able to affect water temperatures in the upper estuary. Future targeted studies on the relationship between atmospheric influences and flow are needed to disentangle these causal links.
Another key unknown is the potential influence of coldwater releases from upstream dams on the estuary water temperatures. Some studies (e.g., Cloern et al. 2011) have suggested that upstream cold-water releases do not have much of an effect on Delta water temperatures, but we are not aware of a conclusive test of this hypothesis for all of the important upstream dams (e.g., reservoirs that are relatively close in distance to the Delta). This could be investigated in conjunction with an analysis of the relative temperature difference between inflowing waters at the sites of river inputs verses the waters within the estuary. These questions could best be answered with continuous air temperature, water temperature, and flow sensor data in a future analysis.
We did not account for tides in this analysis due to the lack of historical tidal stage data for the locations in our study and due to the monthly timescale of our data and analysis. Tides have been shown to influence water temperatures in Suisun Marsh where spring tides in the summer coincide with the late evening and early morning. This results in shallow flooded marsh plains during the coolest parts of the day, enabling rapid cooling of those waters which then drain into and cool the larger sloughs when the tide recedes (Enright et al. 2013). This process results from the confluence in timing of the solar, lunar, and diel cycles and will be reversed in 167 years. While much of our data was collected in much larger and deeper channels than those studied by Enright et al. (2013), it is likely, especially in areas adjacent to tidal marsh, that tides could influence temperature dynamics. In main channels far from tidal marshes, tidal mixing could equilibrate temperatures between adjacent regions. Further study on the influence of tidal dynamics on water temperatures both near marshes and in open channels would help elucidate their large-scale impacts.
While many uncertainties remain, it is unlikely that just one factor is driving our observed temperature-inflow relationships (Fig. 1). Multi-variable investigations such as mechanistic, physics-based modeling could be used to disentangle the numerous interacting drivers.

Conclusion
Here we illustrate seasonal variation in the relationships between water temperature, precipitation, and total inflow in the largest estuary on the west coast of the United States, which plays a central role in statewide water supply and fisheries. Temperature and inflow are key variables in estuarine management and are both expected to be strongly impacted by climate change. Our results demonstrate that flow-related water temperature changes up 2 C can occur depending on inflow conditions, and that the magnitude and direction of this flow-temperature relationship changes spatially and seasonally. Water management in the southwestern United States is a difficult balancing act between species persistence, ecosystem health and services, and water supply. To make well-informed decisions, it is crucial to understand the multifaceted impacts of floods and droughts, and the potential temperature shifts associated with them. Our modeling framework can be leveraged on other systems with sufficient monitoring data to quantify similar relationships between crucial variables like inflow and water temperature.