idwt(cA, cD, wavelet, mode='symmetric', axis=-1) Single level Inverse Discrete Wavelet Transform. Parameters ---------- cA : array_like or None Approximation coefficients. If None, will be set to array of zeros with same shape as ``cD``. cD : array_like or
(cA, cD, wavelet, mode='symmetric', axis=-1)
| 189 | |
| 190 | |
| 191 | def idwt(cA, cD, wavelet, mode='symmetric', axis=-1): |
| 192 | """ |
| 193 | idwt(cA, cD, wavelet, mode='symmetric', axis=-1) |
| 194 | |
| 195 | Single level Inverse Discrete Wavelet Transform. |
| 196 | |
| 197 | Parameters |
| 198 | ---------- |
| 199 | cA : array_like or None |
| 200 | Approximation coefficients. If None, will be set to array of zeros |
| 201 | with same shape as ``cD``. |
| 202 | cD : array_like or None |
| 203 | Detail coefficients. If None, will be set to array of zeros |
| 204 | with same shape as ``cA``. |
| 205 | wavelet : Wavelet object or name |
| 206 | Wavelet to use |
| 207 | mode : str, optional (default: 'symmetric') |
| 208 | Signal extension mode, see :ref:`Modes <ref-modes>`. |
| 209 | axis: int, optional |
| 210 | Axis over which to compute the inverse DWT. If not given, the |
| 211 | last axis is used. |
| 212 | |
| 213 | Returns |
| 214 | ------- |
| 215 | rec: array_like |
| 216 | Single level reconstruction of signal from given coefficients. |
| 217 | |
| 218 | Examples |
| 219 | -------- |
| 220 | >>> import pywt |
| 221 | >>> (cA, cD) = pywt.dwt([1,2,3,4,5,6], 'db2', 'smooth') |
| 222 | >>> pywt.idwt(cA, cD, 'db2', 'smooth') |
| 223 | array([ 1., 2., 3., 4., 5., 6.]) |
| 224 | |
| 225 | One of the neat features of ``idwt`` is that one of the ``cA`` and ``cD`` |
| 226 | arguments can be set to None. In that situation the reconstruction will be |
| 227 | performed using only the other one. Mathematically speaking, this is |
| 228 | equivalent to passing a zero-filled array as one of the arguments. |
| 229 | |
| 230 | >>> (cA, cD) = pywt.dwt([1,2,3,4,5,6], 'db2', 'smooth') |
| 231 | >>> A = pywt.idwt(cA, None, 'db2', 'smooth') |
| 232 | >>> D = pywt.idwt(None, cD, 'db2', 'smooth') |
| 233 | >>> A + D |
| 234 | array([ 1., 2., 3., 4., 5., 6.]) |
| 235 | |
| 236 | """ |
| 237 | # TODO: Lots of possible allocations to eliminate (zeros_like, asarray(rec)) |
| 238 | # accept array_like input; make a copy to ensure a contiguous array |
| 239 | |
| 240 | if cA is None and cD is None: |
| 241 | raise ValueError("At least one coefficient parameter must be " |
| 242 | "specified.") |
| 243 | |
| 244 | # for complex inputs: compute real and imaginary separately then combine |
| 245 | if not _have_c99_complex and (np.iscomplexobj(cA) or np.iscomplexobj(cD)): |
| 246 | if cA is None: |
| 247 | cD = np.asarray(cD) |
| 248 | cA = np.zeros_like(cD) |
no test coverage detected