supy.util.diagnose_q2

Contents

Tip

  1. Need help? Please let us know in the SUEWS Community.

  2. Please report issues with the manual on GitHub Issues (or use Report Issue for This Page for page-specific feedback).

  3. Please cite SUEWS with proper information from our Zenodo page.

6.3.7.7. supy.util.diagnose_q2#

supy.util.diagnose_q2(df_output: DataFrame, df_forcing: DataFrame, method: Literal['anomaly', 'extreme', 'diurnal'] = 'anomaly', threshold: float = 2.0, min_flux: float = 0.1) AttributionResult[source]#

Automatically identify anomalous q2 values and attribute the causes.

This convenience function identifies unusual q2 (2m specific humidity) 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 q2 vs. middle 50% - ‘diurnal’: Compare afternoon (12:00-15:00) vs. morning (06:00-10:00) Default ‘anomaly’.

  • threshold (float, optional) – Standard deviation threshold for anomaly detection. Default 2.0.

  • min_flux (float, optional) – Minimum flux threshold (W/m2) for resistance calculation. Timesteps with abs(Q_E) < min_flux are excluded. Default 0.1.

Returns:

Attribution decomposition with diagnostic interpretation.

Return type:

AttributionResult

Examples

Quick anomaly diagnosis:

>>> result = diagnose_q2(df_output, df_forcing, method="anomaly")
>>> print(result)
q2 Attribution Results
========================================
Mean delta_q2: +0.80 g/kg

6.3.7.7. Component Breakdown:#

q_ref : +0.55 g/kg (68.8%) flux_total : +0.18 g/kg (22.5%) resistance : +0.06 g/kg ( 7.5%) air_props : +0.01 g/kg ( 1.2%)

Closure residual: 1.23e-15 g/kg

>>> result.plot()  # Visualise decomposition