Skip to content

Commit

Permalink
Fix bug in overpass grouping
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiggi committed Jan 27, 2025
1 parent 95cfeda commit b01c590
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions gpm/bucket/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,28 @@ def get_list_overpass_time(timesteps, interval=None):
This function is typically called on a regional subset of a bucket archive.
"""
# Check interval
if interval is None:
interval = np.array(60, dtype="m8[m]")
timesteps = sorted(timesteps)


# Check timesteps
# - Ensure numpy.datetime64
timesteps = np.unique(timesteps)
timesteps = np.sort(timesteps)

# Deal with edge cases
if len(timesteps) == 0:
raise ValueError("No timesteps available.")

if len(timesteps) == 1:
return [(timesteps[0], timesteps[0])]

# Compute time difference
time_diff = np.diff(timesteps)

# Initialize
current_start_time = timesteps[0]
list_time_periods = []

current_start_time = timesteps[0]
for i, dt in enumerate(time_diff):
if i == 0:
continue
Expand All @@ -55,11 +66,10 @@ def get_list_overpass_time(timesteps, interval=None):
time_period = (current_start_time, end_time)
list_time_periods.append(time_period)
# Update
current_start_time = timesteps[i]
# Last point
end_time = timesteps[-1]
time_period = (current_start_time.astype(str), end_time.astype(str))
list_time_periods.append(time_period)
current_start_time = timesteps[i+1]

# Add the final group

Check notice on line 71 in gpm/bucket/analysis.py

View check run for this annotation

codefactor.io / CodeFactor

gpm/bucket/analysis.py#L71

Unresolved comment '# TODO: drop column with missing time'. (C100)
list_time_periods.append((current_start_time, timesteps[-1]))
return list_time_periods


Expand Down

0 comments on commit b01c590

Please sign in to comment.