Skip to content

ValueError: IndexVariable objects must be 1-dimensional #27

@guin0x

Description

@guin0x

Hi, I'm trying to use this library to plot a 2d spectra of some buoy data.
Following this I face the following error on ow_spc.plot(col='location):

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/home/guin0x/Harmony_GITHUB/scripts/main_script_gui_with_buoypy.ipynb Cell 15' in <cell line: 6>()
      [3](vscode-notebook-cell:/home/guin0x/Harmony_GITHUB/scripts/main_script_gui_with_buoypy.ipynb#ch0000016?line=2) print('freqs = ',freqs)
      [4](vscode-notebook-cell:/home/guin0x/Harmony_GITHUB/scripts/main_script_gui_with_buoypy.ipynb#ch0000016?line=3) print(list(freqs))
----> [6](vscode-notebook-cell:/home/guin0x/Harmony_GITHUB/scripts/main_script_gui_with_buoypy.ipynb#ch0000016?line=5) ow_spc.plot(col='location')
      [8](vscode-notebook-cell:/home/guin0x/Harmony_GITHUB/scripts/main_script_gui_with_buoypy.ipynb#ch0000016?line=7) theta = np.arange(0., 360., 5.)
      [9](vscode-notebook-cell:/home/guin0x/Harmony_GITHUB/scripts/main_script_gui_with_buoypy.ipynb#ch0000016?line=8) ow_dir = ow_spc.as_directional(theta,s=5)

File ~/env/Harmony/lib/python3.10/site-packages/oceanwaves/plot.py:189, in OceanWavesPlotMethods.__call__(self, **kwargs)
    184         if not 'subplot_kws' in kwargs.keys():
    185             kwargs.update(dict(subplot_kws = dict(projection = 'polar'),
    186                                sharex = False,
    187                                sharey = False))
--> 189 r = super(OceanWavesPlotMethods, self).__call__(**kwargs)
    191 self.find_axes(r)
    192 self.rotate_axes()

File ~/env/Harmony/lib/python3.10/site-packages/xarray/plot/plot.py:866, in _PlotMethods.__call__(self, **kwargs)
    865 def __call__(self, **kwargs):
--> 866     return plot(self._da, **kwargs)

File ~/env/Harmony/lib/python3.10/site-packages/xarray/plot/plot.py:332, in plot(darray, row, col, col_wrap, ax, hue, rtol, subplot_kws, **kwargs)
    328     plotfunc = hist
    330 kwargs["ax"] = ax
...
-> 2668     raise ValueError(f"{type(self).__name__} objects must be 1-dimensional")
   2670 # Unlike in Variable, always eagerly load values into memory
   2671 if not isinstance(self._data, PandasIndexingAdapter):

ValueError: IndexVariable objects must be 1-dimensional

Any idea what I'm doing wronge? Should I post this somewhere else?
Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions