libera_utils.scene_id.calculate_cloud_phase#
- libera_utils.scene_id.calculate_cloud_phase(cloud_phase_lower: float | ndarray[Any, dtype[floating]], cloud_phase_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 weighted cloud phase from upper and lower cloud layers.
Computes the dominant cloud phase by weighting each layer’s phase by its cloud fraction contribution and rounding to the nearest integer phase classification (1=liquid, 2=ice).
- Parameters:
cloud_phase_lower (float or ndarray) – Cloud phase for lower layer (1=liquid, 2=ice)
cloud_phase_upper (float or ndarray) – Cloud phase for upper layer (1=liquid, 2=ice)
cloud_fraction_lower (float or ndarray) – Cloud fraction for lower layer (0-100)
cloud_fraction_upper (float or ndarray) – Cloud fraction for upper layer (0-100)
cloud_fraction (float or ndarray) – Total cloud fraction (0-100)
- Returns:
Cloud phase weighted by cloud fraction and rounded to nearest integer (1=liquid, 2=ice), or np.nan if no valid data
- Return type:
float or ndarray
Notes
The weighted average is rounded to the nearest integer to provide a discrete phase classification. Values between 1 and 2 are rounded to either 1 or 2, with 1.5 rounding to 2.
Examples
>>> cloud_phase(1.0, 2.0, 30.0, 70.0, 100.0) 2.0 # (1*30 + 2*70)/100 = 1.7, rounds to 2 >>> cloud_phase(1.0, 1.0, 50.0, 50.0, 100.0) 1.0 # All liquid