libera_utils.scene_id.Scene#
- class libera_utils.scene_id.Scene(scene_id: int, variable_ranges: dict[str, tuple[float, float]])#
Bases:
objectRepresents a single scene with its variable bin definitions.
A scene defines a specific atmospheric state characterized by ranges of multiple variables (e.g., cloud fraction, optical depth, surface type). Data points are classified into scenes when all their variable values fall within the scene’s defined ranges.
- variable_ranges#
Dictionary mapping variable names to (min, max) tuples defining the acceptable range for each variable. None values indicate unbounded ranges (no min or no max constraint).
- matches(data_point)#
Check if a data point belongs to this scene
Examples
>>> scene = Scene( ... scene_id=1, ... variable_ranges={ ... "cloud_fraction": (0.0, 50.0), ... "optical_depth": (0.0, 10.0) ... } ... ) >>> scene.matches({"cloud_fraction": 30.0, "optical_depth": 5.0}) True >>> scene.matches({"cloud_fraction": 60.0, "optical_depth": 5.0}) False
Methods
matches(data_point)Check if a data point falls within all variable ranges for this scene.
Methods
matches(data_point)Check if a data point falls within all variable ranges for this scene.
Attributes
- matches(data_point: dict[str, float]) bool#
Check if a data point falls within all variable ranges for this scene.
- Parameters:
data_point (dict of str to float) – Dictionary of variable names to values
- Returns:
True if data point matches all variable ranges, False otherwise
- Return type:
Notes
A data point matches when: - All required variables are present in the data point - All variable values are within their specified ranges (inclusive) - No variable values are NaN
Range boundaries: - None for min_val means no lower bound - None for max_val means no upper bound - Both bounds are inclusive when specified
Examples
>>> scene = Scene( ... scene_id=1, ... variable_ranges={"temp": (0.0, 100.0), "pressure": (None, 1000.0)} ... ) >>> scene.matches({"temp": 50.0, "pressure": 900.0}) True >>> scene.matches({"temp": 150.0, "pressure": 900.0}) False >>> scene.matches({"temp": np.nan, "pressure": 900.0}) False