libera_utils.scene_id.calculate_cloud_fraction_weighted_property_for_layer#
- libera_utils.scene_id.calculate_cloud_fraction_weighted_property_for_layer(property_lower: float | ndarray[Any, dtype[floating]], property_upper: float | ndarray[Any, dtype[floating]], cloud_fraction_lower: float | ndarray[Any, dtype[floating]], cloud_fraction_upper: float | ndarray[Any, dtype[floating]], cloud_fraction: float | ndarray[Any, dtype[floating]]) float | ndarray[Any, dtype[floating]]#
Calculate cloud fraction weighted property from upper and lower layers.
Computes a weighted average of a cloud property across two atmospheric layers, where the weights are determined by each layer’s contribution to total cloud fraction.
- Parameters:
property_lower (float or ndarray) – Property values for the lower cloud layer
property_upper (float or ndarray) – Property values for the upper cloud layer
cloud_fraction_lower (float or ndarray) – Cloud fraction for the lower cloud layer (0-100)
cloud_fraction_upper (float or ndarray) – Cloud fraction for the upper cloud layer (0-100)
cloud_fraction (float or ndarray) – Total cloud fraction (0-100)
- Returns:
Property weighted by cloud fraction and summed across layers, or np.nan if no valid data or zero total cloud fraction
- Return type:
float or ndarray
Notes
- The weighting formula is:
- result = (property_lower * cloud_fraction_lower / cloud_fraction) +
(property_upper * cloud_fraction_upper / cloud_fraction)
Returns NaN when: - Total cloud fraction is zero or NaN - Both layers have invalid (NaN) property values - All cloud fractions are NaN
Examples
>>> calculate_cloud_fraction_weighted_property_for_layer( ... property_lower=10.0, property_upper=20.0, ... cloud_fraction_lower=30.0, cloud_fraction_upper=70.0, ... cloud_fraction=100.0 ... ) 17.0 # (10*30 + 20*70)/100