Tip
Need help? Please let us know in the SUEWS Community.
Please report issues with the manual on GitHub Issues (or use Report Issue for This Page for page-specific feedback).
Please cite SUEWS with proper information from our Zenodo page.
6.3.7.6. supy.util.diagnose_t2#
- supy.util.diagnose_t2(df_output: DataFrame, df_forcing: DataFrame, method: Literal['anomaly', 'extreme', 'diurnal'] = 'anomaly', threshold: float = 2.0, hierarchical: bool = True, min_flux: float = 0.1) AttributionResult[source]#
Automatically identify anomalous T2 values and attribute the causes.
This convenience function identifies unusual T2 behaviour within a single simulation run and diagnoses the driving factors by comparing aggregate statistics between reference (normal) and target (anomaly) periods.
- Parameters:
df_output (pd.DataFrame) – SUEWS output DataFrame
df_forcing (pd.DataFrame) – Forcing DataFrame. Must contain ‘Tair’, ‘RH’, ‘pres’ columns.
method (str, optional) – Detection method: - ‘anomaly’: Compare timesteps > threshold sigma from daily mean - ‘extreme’: Compare top/bottom 5% of T2 vs. middle 50% - ‘diurnal’: Compare afternoon peak (12:00-15:00) vs. morning (06:00-10:00) Default ‘anomaly’.
threshold (float, optional) – Standard deviation threshold for anomaly detection. Default 2.0.
hierarchical (bool, optional) – Include flux budget breakdown. Default True.
min_flux (float, optional) – Minimum flux threshold (W/m2) for resistance calculation. Timesteps with abs(Q_H) < min_flux are excluded. Default 0.1.
- Returns:
Attribution decomposition with diagnostic interpretation.
- Return type:
Examples
Quick anomaly diagnosis:
>>> result = diagnose_t2(df_output, df_forcing, method="anomaly") >>> print(result) T2 Attribution Results ======================================== Mean delta_T2: +2.80 degC
6.3.7.6. Component Breakdown:#
T_ref : +2.10 degC (75.0%) flux_total : +0.50 degC (17.9%) resistance : +0.18 degC ( 6.4%) air_props : +0.02 degC ( 0.7%)
Closure residual: 1.23e-15 degC
>>> result.plot() # Visualise decomposition