Skip to content

Commit

Permalink
feat : Handles case where xarray data is empty for flash_age composites.
Browse files Browse the repository at this point in the history
  • Loading branch information
ClementLaplace committed Sep 20, 2024
1 parent 6b59245 commit 0ebb1fe
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions satpy/composites/lightning.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"""Composite classes for the LI instrument."""

import logging
import sys

import numpy as np
import xarray as xr
Expand Down Expand Up @@ -65,6 +66,10 @@ def _normalize_time(self,data:xr.DataArray,attrs:dict)->xr.DataArray:
begin_time = end_time - np.timedelta64(self.time_range, "m")
# Drop values that are bellow begin_time
data = data.where(data >= begin_time, drop=True)
# exit if data is empty afer filtering
if data.size == 0 :
LOG.error(f"All the flash_age events happened before {begin_time}")
sys.exit(1)
# Normalize the time values
normalized_data = (data - begin_time) / (end_time - begin_time)
# Ensure the result is still an xarray.DataArray
Expand Down

0 comments on commit 0ebb1fe

Please sign in to comment.