xbudget.nodesΒΆ
Typed expression tree for xbudget recipes.
An xbudget recipe (the nested recipe dict loaded from YAML) describes
how to build each budget term from raw model diagnostics. These dataclasses give
the recipe an explicit, immutable shape so the parser, evaluator, and query
helpers can dispatch on node type instead of probing dict keys.
The grammar (mirrors the YAML, see recipes/*.yaml):
Budget := name, metadata, {side: Term} # side in {lhs, rhs}
Term := name, path, explicit_var?, [Operation]
Operation := Sum | Product | Difference
Sum/Product := [(operand_name, Operand)]
Difference := source variable name (differenced across a grid axis)
Operand := Constant | VarRef | Term
A Term may carry more than one Operation (e.g. a bulk Product and an
equivalent finer Sum decomposition of the same quantity); each operation
yields its own output variable when evaluated.
Classes
|
A named budget (e.g. |
|
A scalar factor/addend in a sum or product (e.g. a density, a sign). |
|
Finite-difference a staggered quantity across its grid axis. |
|
Horizontal flux divergence |
|
Multiply named operands together. |
|
Safe reciprocal (1/x with zeros mapped to infinity) of a variable. |
|
Add named operands together. |
|
A node in a budget tree: a named quantity defined by its operations. |
|
A reference to a raw diagnostic variable expected in the dataset. |