MCPcopy Create free account
hub / github.com/PyWavelets/pywt / idwtn

Function idwtn

pywt/_multidim.py:219–311  ·  view source on GitHub ↗

Single-level n-dimensional Inverse Discrete Wavelet Transform. Parameters ---------- coeffs: dict Dictionary as in output of ``dwtn``. Missing or ``None`` items will be treated as zeros. wavelet : Wavelet object or name string, or tuple of wavelets Wavel

(coeffs, wavelet, mode='symmetric', axes=None)

Source from the content-addressed store, hash-verified

217
218
219def idwtn(coeffs, wavelet, mode='symmetric', axes=None):
220 """
221 Single-level n-dimensional Inverse Discrete Wavelet Transform.
222
223 Parameters
224 ----------
225 coeffs: dict
226 Dictionary as in output of ``dwtn``. Missing or ``None`` items
227 will be treated as zeros.
228 wavelet : Wavelet object or name string, or tuple of wavelets
229 Wavelet to use. This can also be a tuple containing a wavelet to
230 apply along each axis in ``axes``.
231 mode : str or list of string, optional
232 Signal extension mode used in the decomposition,
233 see :ref:`Modes <ref-modes>`. This can also be a tuple of modes
234 specifying the mode to use on each axis in ``axes``.
235 axes : sequence of ints, optional
236 Axes over which to compute the IDWT. Repeated elements mean the IDWT
237 will be performed multiple times along these axes. A value of ``None``
238 (the default) selects all axes.
239
240 For the most accurate reconstruction, the axes should be provided in
241 the same order as they were provided to ``dwtn``.
242
243 Returns
244 -------
245 data: ndarray
246 Original signal reconstructed from input data.
247
248 """
249
250 # drop the keys corresponding to value = None
251 coeffs = {k: v for k, v in coeffs.items() if v is not None}
252
253 # drop the keys corresponding to value = None
254 coeffs = {k: v for k, v in coeffs.items() if v is not None}
255
256 # Raise error for invalid key combinations
257 coeffs = _fix_coeffs(coeffs)
258
259 if (not _have_c99_complex and
260 any(np.iscomplexobj(v) for v in coeffs.values())):
261 real_coeffs = {k: v.real for k, v in coeffs.items()}
262 imag_coeffs = {k: v.imag for k, v in coeffs.items()}
263 return (idwtn(real_coeffs, wavelet, mode, axes) +
264 1j * idwtn(imag_coeffs, wavelet, mode, axes))
265
266 # key length matches the number of axes transformed
267 ndim_transform = max(len(key) for key in coeffs)
268
269 try:
270 coeff_shapes = (v.shape for k, v in coeffs.items()
271 if v is not None and len(k) == ndim_transform)
272 coeff_shape = next(coeff_shapes)
273 except StopIteration:
274 raise ValueError("`coeffs` must contain at least one non-null wavelet "
275 "band")
276 if any(s != coeff_shape for s in coeff_shapes):

Callers 4

idwt2Function · 0.85
iswtnFunction · 0.85
_reconstructMethod · 0.85
waverecnFunction · 0.85

Calls 4

_fix_coeffsFunction · 0.85
_modes_per_axisFunction · 0.85
_wavelets_per_axisFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected