Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make wavelet_transform a writable attribute. #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

swillscsumb
Copy link

@swillscsumb swillscsumb commented Oct 11, 2017

That allows, for instance, reconstruction to be used with an altered wavelet_transform.

Example usage:

def get_wt_nmfd(wav_path, wav_prefix, plot_prefix):
    fs, x = wavfile.read(wav_path)
    dt = 1.0/fs
    dj = 1.0/16.0
    eps = np.spacing(1)
    do_nmfd = True
    wav_max = 2.0**15 - 1.0

    wa = WaveletAnalysis(x, wavelet=Morlet(), dt=dt, dj=dj, unbias=False)
    # wavelet power spectrum
    power = wa.wavelet_power
    wt = copy.deepcopy(wa.wavelet_transform)
    xi = wa.reconstruction()

    nmfd = None
    if do_nmfd:
        nmfd = nmfdkl.NMFDKL(power, 5, 2*power.shape[0]/3)
        new_v = nmfd.nmfdkl(20, 10)
        denom = 1.0 / (new_v[:, :, -1] + eps)
        for r in xrange(new_v.shape[2] - 1):
            wa.wavelet_transform = copy.deepcopy(wt)
            wa.wavelet_transform *= new_v[:, :, r]*denom
            xi = wa.reconstruction()

That allows, for instance, reconstruction to be used with an altered
wavelet_transform.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant