I noticed when testing out an aggregation of raster data to US counties, that the aggregation works great even with coordinate names of x and y, but the weightmap diagnostic function throws an error unless the coordinates are renamed to lon and lat.
venv/lib/python3.12/site-packages/xagg/classes.py in ?(self, poly_id, ds, fig, ax)
53
54 # Adjust grids between the input ds and the weightmap grid (in case subset to
55 # bbox was used)
56 with set_options(silent=True):
---> 57 ds = subset_find(ds,self.source_grid)
58
59 # Plot diagnostic figure
60 fig,ax=diag_fig(self,poly_id,ds,fig=fig,ax=ax)
venv/lib/python3.12/site-packages/xagg/auxfuncs.py in ?(ds0, ds1, silent)
409 if silent is None:
410 silent = get_options()['silent']
411
412 if 'loc' not in ds0.sizes:
--> 413 ds0 = ds0.stack(loc = ('lat','lon'))
414 was_stacked = True
415 else:
416 was_stacked = False
venv/lib/python3.12/site-packages/xarray/util/deprecation_helpers.py in ?(*args, *kwargs)
139 # Upgrade to DeprecationWarning in the future, when the renaming is complete.
140 PendingDeprecationWarning,
141 )
142 kwargs["dim"] = kwargs.pop(old_name)
--> 143 return func(args, **kwargs)
venv/lib/python3.12/site-packages/xarray/core/dataarray.py in ?(self, dim, create_index, index_cls, **dim_kwargs)
2903 See Also
2904 --------
2905 DataArray.unstack
2906 """
-> 2907 ds = self._to_temp_dataset().stack(
2908 dim,
2909 create_index=create_index,
2910 index_cls=index_cls,
venv/lib/python3.12/site-packages/xarray/util/deprecation_helpers.py in ?(*args, *kwargs)
139 # Upgrade to DeprecationWarning in the future, when the renaming is complete.
140 PendingDeprecationWarning,
141 )
142 kwargs["dim"] = kwargs.pop(old_name)
--> 143 return func(args, **kwargs)
venv/lib/python3.12/site-packages/xarray/core/dataset.py in ?(self, dim, create_index, index_cls, **dim_kwargs)
5413 """
5414 dim = either_dict_or_kwargs(dim, dim_kwargs, "stack")
5415 result = self
5416 for new_dim, dims in dim.items():
-> 5417 result = result._stack_once(dims, new_dim, index_cls, create_index)
5418 return result
venv/lib/python3.12/site-packages/xarray/core/dataset.py in ?(self, dims, new_dim, index_cls, create_index)
5343 new_coord_names = set(self._coord_names)
5344 if create_index or create_index is None:
5345 product_vars: dict[Any, Variable] = {}
5346 for dim in dims:
-> 5347 idx, idx_vars = self._get_stack_index(dim, create_index=create_index)
5348 if idx is not None:
5349 product_vars.update(idx_vars)
5350
venv/lib/python3.12/site-packages/xarray/core/dataset.py in ?(self, dim, multi, create_index)
5299 if create_index and stack_index is None:
5300 if dim in self._variables:
5301 var = self.variables[dim]
5302 else:
-> 5303 , _, var = _get_virtual_variable(self._variables, dim, self.sizes)
5304 # dummy index (only stack_coords will be used to construct the multi-index)
5305 stack_index = PandasIndex([0], dim)
5306 stack_coords = {dim: var}
I noticed when testing out an aggregation of raster data to US counties, that the aggregation works great even with coordinate names of
x
andy
, but the weightmap diagnostic function throws an error unless the coordinates are renamed tolon
andlat
.Traceback:
Virtual environment:
This is related to JOSS review: https://github.com/openjournals/joss-reviews/issues/7239