window_correction seems sensitive to formatting of `dim`
See original GitHub issueI haven’t been able to reproduce this with synthetic data (sorry!)
But for my real data, xrft.power_spectrum(u_unfiltered.isel(x0=1000,y0=1000).load(),dim='time', window='hann',window_correction=True)
gives the error:
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
~/.conda/envs/pangeo2/lib/python3.7/site-packages/xarray/core/dataarray.py in _getitem_coord(self, key)
692 try:
--> 693 var = self._coords[key]
694 except KeyError:
KeyError: 't'
During handling of the above exception, another exception occurred:
KeyError Traceback (most recent call last)
<ipython-input-40-09826e26c18a> in <module>
----> 1 xrft.power_spectrum(u_unfiltered.isel(x0=1000,y0=1000).load(),dim='time', window='hann',window_correction=True)
~/.conda/envs/pangeo2/lib/python3.7/site-packages/xrft/xrft.py in power_spectrum(da, dim, real_dim, scaling, window_correction, **kwargs)
712 )
713 else:
--> 714 windows, _ = _apply_window(da, dim, window_type=kwargs.get("window"))
715 ps = ps / (windows ** 2).mean()
716 fs = np.prod([float(ps[d].spacing) for d in updated_dims])
~/.conda/envs/pangeo2/lib/python3.7/site-packages/xrft/xrft.py in _apply_window(da, dims, window_type)
97 win_func(len(da[d]), sym=False), dims=da[d].dims, coords=da[d].coords
98 )
---> 99 for d in dims
100 ]
101
~/.conda/envs/pangeo2/lib/python3.7/site-packages/xrft/xrft.py in <listcomp>(.0)
97 win_func(len(da[d]), sym=False), dims=da[d].dims, coords=da[d].coords
98 )
---> 99 for d in dims
100 ]
101
~/.conda/envs/pangeo2/lib/python3.7/site-packages/xarray/core/dataarray.py in __getitem__(self, key)
702 def __getitem__(self, key: Any) -> "DataArray":
703 if isinstance(key, str):
--> 704 return self._getitem_coord(key)
705 else:
706 # xarray-style array indexing
~/.conda/envs/pangeo2/lib/python3.7/site-packages/xarray/core/dataarray.py in _getitem_coord(self, key)
695 dim_sizes = dict(zip(self.dims, self.shape))
696 _, key, var = _get_virtual_variable(
--> 697 self._coords, key, self._level_coords, dim_sizes
698 )
699
~/.conda/envs/pangeo2/lib/python3.7/site-packages/xarray/core/dataset.py in _get_virtual_variable(variables, key, level_vars, dim_sizes)
169 ref_var = dim_var.to_index_variable().get_level_variable(ref_name)
170 else:
--> 171 ref_var = variables[ref_name]
172
173 if var_name is None:
KeyError: 't'
Whereas xrft.power_spectrum(u_unfiltered.isel(x0=1000,y0=1000).load(),dim=['time'], window='hann',window_correction=True)
is totally fine.
Any idea what is causing this? Is all testing performed on data with single character dimension names? Perhaps that is the problem?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:12 (9 by maintainers)
Top Results From Across the Web
The LMS Test.Lab Modal Analysis manual
EXPONENTIAL WINDOW CORRECTION IN MODAL ANALYSIS . ... A Universal File is a physical file in ASCII format, containing symbolic data in.
Read more >High Performance Listview for React Native and Web - Morioh
This is a high performance listview for React Native and Web with support for complex layouts. JS only with no native dependencies, inspired...
Read more >Dear Referee #1
Referee's comment: One of the main problems of the manuscript is that the shown data is not well ... In addition, there are...
Read more >Model SR785 Dynamic Signal Analyzer
you don't mind formatting will do. Make sure the write protect tab is off. Press [Disk]. Select the Disk menu. Press <Disk Upkeep>....
Read more >Model SR780 Network Signal Analyzer - thinkSRS.com
3.5 inch DOS compatible format, 1.44 Mbytes capacity. ... Dimensions. 17"W x 8"H x 22"D ... A window correction factor is also included...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It looks like
_apply_window
does not supportdim
being a string (only a list of string). We must’ve missed this, but it should be an easy fix.That would be great, thanks @dougiesquire!