def test_decompose_recompose():
    """Tests cascade decomposition."""

    pytest.importorskip("netCDF4")

    root_path = pysteps.rcparams.data_sources["bom"]["root_path"]
    rel_path = os.path.join("prcp-cscn", "2", "2018", "06", "16")
    filename = os.path.join(root_path, rel_path, "2_20180616_120000.prcp-cscn.nc")
    precip, _, metadata = pysteps.io.import_bom_rf3(filename)

    # Convert to rain rate from mm
    precip, metadata = pysteps.utils.to_rainrate(precip, metadata)

    # Log-transform the data
    precip, metadata = pysteps.utils.dB_transform(
        precip, metadata, threshold=0.1, zerovalue=-15.0
    )

    # Set Nans as the fill value
    precip[~np.isfinite(precip)] = metadata["zerovalue"]

    # Set number of cascade levels
    num_cascade_levels = 9

    # Construct the Gaussian bandpass filters
    _filter = filter_gaussian(precip.shape, num_cascade_levels)

    # Decompose precip
    decomp = decomposition_fft(precip, _filter)

    # Recomposed precip from decomp
    recomposed = recompose_fft(decomp)
    # Assert
    assert_array_almost_equal(recomposed.squeeze(), precip)
Tests cascade decomposition.
pysteps/tests/test_cascade.py