Skip to main content

Module expression

Module expression 

Source
Expand description

Arithmetic band-math expression: parse (b5-b4)/(b5+b4) → RPN, eval per-pixel. Grammar is arithmetic-only: + - * /, unary minus, parens, float literals, b<N>. Numbers are plain decimals (2.5, 0.5); scientific notation (1e3) is not supported.

Enums§

Token
RPN token. Band(i) is 0-indexed (source b1 → Band(0)).

Functions§

eval_rpn
Evaluate RPN given per-pixel band values (bands[i] = value of source band i+1). Caller must validate max_band_ref < bands.len() once before the pixel loop; an out-of-range band defensively yields NaN (never panics).
max_band_ref
Highest 0-indexed band referenced, or None if no band refs.
parse_expression
Parse arithmetic and one-based band references (b1, b2, …) into RPN.