ModelOutput¶
Container returned by ParcelModel.run(mode="full"). Holds the full state trajectory
and post-solve diagnostics, with format-conversion methods for pandas, polars, xarray,
NetCDF, CSV, and Parquet.
ModelOutput
dataclass
¶
ModelOutput(
time: ndarray,
state: ndarray,
aerosols: list,
summary: dict,
V: float | AbstractUpdraft,
T0: float,
S0: float,
P0: float,
accom: float,
)
Output from a single ParcelModel run.
Attributes:
| Name | Type | Description |
|---|---|---|
time |
np.ndarray, shape ``(n_time,)``
|
Simulation time (s). |
state |
np.ndarray, shape ``(n_time, 7 + nr)``
|
Full state trajectory. The first seven columns are the bulk parcel
variables (see |
aerosols |
list[AerosolSpecies]
|
Aerosol modes, in the same order as the radius columns in |
summary |
dict
|
Post-solve diagnostics: |
V |
float | AbstractUpdraft
|
Updraft used for the run (stored for dataset metadata). |
T0, S0, P0, accom |
float
|
Initial conditions (stored for dataset metadata). |
Nd
property
¶
Total activated droplet number concentration (m⁻³) at the last trajectory step.
Evaluated by comparing wet radii against per-bin critical radii at
summary["nd_t_eval"] (the final output time, which is
terminate_depth m above S_max when terminate=True).
This is a hard-threshold diagnostic; for the differentiable analog see issue #67.
to_pandas ¶
Return (parcel_df, {species: aerosol_df}) as pandas DataFrames.
parcel_df has columns ["z", "P", "T", "wv", "wc", "wi", "S"]
indexed by simulation time. Each aerosol_df has columns
["r000", "r001", …] (wet radii in metres) with the same time index.
Source code in pyrcel/model_output.py
to_polars ¶
Return (parcel_df, {species: aerosol_df}) as polars DataFrames.
Columns and layout mirror to_pandas; the time
index becomes an
explicit "time" column (polars does not have a named index).
Source code in pyrcel/model_output.py
to_xarray ¶
Return a CF-flavoured xarray.Dataset.
Mirrors the variable layout of the legacy NetCDF writer: a time
coordinate, per-species <species>_bins coordinates with dry radii /
kappa / number concentration, wet-radius histories <species>_size,
parcel thermodynamic profiles, and the post-solve summary as scalar
variables / global attributes.
Source code in pyrcel/model_output.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | |
to_netcdf ¶
to_csv ¶
Write the flat parcel trajectory (all state columns + radius bins) to CSV.
Columns: time, then all state variables, then per-bin wet radii
prefixed by species (e.g. sulfate_r000).
Source code in pyrcel/model_output.py
to_parquet ¶
Write the flat parcel trajectory (all state columns + radius bins) to Parquet.