Skip to content

Error on assign_coords #2

@rogerkuou

Description

@rogerkuou

In xarray_insar_example.ipynb, cell 10-13. If we simplify the script to the following:

ds_pointset = ds_pointset.reset_index("points")
ds_pointset = ds_pointset.assign_coords(points=range(ds_pointset.points.size))
ds_pointset = ds_pointset.reset_coords(("azimuth", "range")) # azimuth and range can be dealt as variables after `points` is defined as new coordinate.

an error occurs on assign_coords:

Output exceeds the [size limit](command:workbench.action.openSettings?[). Open the full output data [in a text editor](command:workbench.action.openLargeOutput?3dffe212-2a91-4ba8-aaed-47fcfd879433)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/mnt/c/Users/OuKu/Developments/MobyLe/JupyterNB_examples/xarray_insar_example.ipynb Cell 21 in <cell line: 2>()
      [1](vscode-notebook-cell://wsl%2Bubuntu-18.04/mnt/c/Users/OuKu/Developments/MobyLe/JupyterNB_examples/xarray_insar_example.ipynb#Y113sdnNjb2RlLXJlbW90ZQ%3D%3D?line=0) ds_pointset = ds_pointset.reset_index("points")
----> [2](vscode-notebook-cell://wsl%2Bubuntu-18.04/mnt/c/Users/OuKu/Developments/MobyLe/JupyterNB_examples/xarray_insar_example.ipynb#Y113sdnNjb2RlLXJlbW90ZQ%3D%3D?line=1) ds_pointset = ds_pointset.assign_coords(points=range(ds_pointset.points.size))
      [3](vscode-notebook-cell://wsl%2Bubuntu-18.04/mnt/c/Users/OuKu/Developments/MobyLe/JupyterNB_examples/xarray_insar_example.ipynb#Y113sdnNjb2RlLXJlbW90ZQ%3D%3D?line=2) ds_pointset = ds_pointset.reset_coords(("azimuth", "range"))

File ~/miniconda3/envs/mobyle/lib/python3.10/site-packages/xarray/core/common.py:592, in DataWithCoords.assign_coords(self, coords, **coords_kwargs)
    590 data = self.copy(deep=False)
    591 results: dict[Hashable, Any] = self._calc_assign_results(coords_combined)
--> 592 data.coords.update(results)
    593 return data

File ~/miniconda3/envs/mobyle/lib/python3.10/site-packages/xarray/core/coordinates.py:162, in Coordinates.update(self, other)
    160 other_vars = getattr(other, "variables", other)
    161 self._maybe_drop_multiindex_coords(set(other_vars))
--> 162 coords, indexes = merge_coords(
    163     [self.variables, other_vars], priority_arg=1, indexes=self.xindexes
    164 )
    165 self._update_coords(coords, indexes)

File ~/miniconda3/envs/mobyle/lib/python3.10/site-packages/xarray/core/merge.py:566, in merge_coords(objects, compat, join, priority_arg, indexes, fill_value)
    564 collected = collect_variables_and_indexes(aligned)
    565 prioritized = _get_priority_vars_and_indexes(aligned, priority_arg, compat=compat)
--> 566 variables, out_indexes = merge_collected(collected, prioritized, compat=compat)
...
    204     f"{indexes[index_id]!r}"
    205 )

ValueError: cannot set or update variable(s) 'points', which would corrupt the following index built from coordinates 'points', 'azimuth', 'range':
<xarray.core.indexes.PandasMultiIndex object at 0x7f5663d2c040>

According to PR #1 this is not an issue for Francesco. Need to investigate the cause.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions