From 416355e0cedfe902026190cf1b3b13d90de52955 Mon Sep 17 00:00:00 2001 From: Ben Smith Date: Mon, 28 Sep 2026 09:32:07 -0700 Subject: [PATCH] mosaic: don't share the default spacing list between mosaics mosaic.__init__ used a mutable default (spacing=[None,None]), and update_spacing() modified that list in place through the spacing property. The first mosaic built in a process therefore set the spacing for every later mosaic created without an explicit spacing, so a coarse-resolution mosaic built after a fine one was gridded at the fine spacing (mostly empty/NaN). Default to None and copy the spacing argument into a new list. Also fix update_spacing() computing dy from x instead of y. Co-Authored-By: Claude Opus 5.5 --- pointCollection/grid/mosaic.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pointCollection/grid/mosaic.py b/pointCollection/grid/mosaic.py index ee43807..f77c1ba 100644 --- a/pointCollection/grid/mosaic.py +++ b/pointCollection/grid/mosaic.py @@ -16,7 +16,7 @@ import pointCollection as pc class mosaic(data): - def __init__(self, spacing=[None,None], **kwargs): + def __init__(self, spacing=None, **kwargs): #self.x=None #self.y=None #self.t=None @@ -27,7 +27,8 @@ def __init__(self, spacing=[None,None], **kwargs): self.extent=[np.inf,-np.inf,np.inf,-np.inf] self.dimensions=[None,None,None] self.field_dims={} - self.spacing=spacing + # copy spacing so that mosaics never share a spacing list + self.spacing=[None, None] if spacing is None else list(spacing) self.tile_weight=None self.fill_value=np.nan self.normalized=True @@ -58,7 +59,7 @@ def update_spacing(self, temp): dx = temp.x[1] - temp.x[0] if not dx == 0: self.spacing[0] = dx - dy = temp.x[1] - temp.x[0] + dy = temp.y[1] - temp.y[0] if not dy == 0: self.spacing[1] = dy except: