From 2683f97d5d04ae0e445d570ee7d98c58c0be3709 Mon Sep 17 00:00:00 2001 From: Abhishek Yenpure Date: Tue, 1 Jul 2025 17:31:59 -0700 Subject: [PATCH] fix(global average): Analytics explorer global average fix --- src/pan3d/ui/analytics.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/pan3d/ui/analytics.py b/src/pan3d/ui/analytics.py index bc61800..da6f0cc 100644 --- a/src/pan3d/ui/analytics.py +++ b/src/pan3d/ui/analytics.py @@ -223,22 +223,20 @@ def apply_spatial_average_full_temporal(self, axis=None): """ Calculate spatial average for data for full temporal resoulution """ - if axis is None: - axis = ["X"] - ds = self.source.input active_var = self.state.color_by - select = self.get_selection_criteria(full_temporal=True) - average = ( - ds.isel(select).spatial.average(active_var, axis) - if axis is not None - else ds.isel(select).spatial.average(active_var) - ) - + # Apply spatial average + if axis is not None: + average = ds.isel(select).spatial.average(active_var, axis) + else: + average = ds.isel(select).spatial.average(active_var) + # Optionally apply temporal grouping group_by = self.state.group_by + if group_by == group_options.get(GroupBy.NONE): return average + return average.temporal.group_average( active_var, freq=group_by.lower(), weighted=True )