@classmethod
def from_hdf(cls, fp, template_hash, root=None, load_to_memory=True,
    load_now=False):
    """Load a compressed waveform from the given hdf file handler.

        The waveform is retrieved from:
        `fp['[{root}/]compressed_waveforms/{template_hash}/{param}']`,
        where `param` is the `sample_points`, `amplitude`, and `phase`.

        Parameters
        ----------
        fp : h5py.File
            An open hdf file to write the compressed waveform to.
        template_hash : {hash, int, str}
            The id of the waveform.
        root : {None, str}
            Retrieve the `compressed_waveforms` group from the given string.
            If `None`, `compressed_waveforms` will be assumed to be in the
            top level.
        load_to_memory : {True, bool}
            Set the `load_to_memory` attribute to the given value in the
            returned instance.
        load_now : {False, bool}
            Immediately load the `sample_points`/`amplitude`/`phase` to memory.


        Returns
        -------
        CompressedWaveform
            An instance of this class with parameters loaded from the hdf file.
        """
    if root is None:
        root = ''
    else:
        root = '%s/' % root
    group = '%scompressed_waveforms/%s' % (root, str(template_hash))
    fp_group = fp[group]
    sample_points = fp_group['sample_points']
    amp = fp_group['amplitude']
    phase = fp_group['phase']
    if load_now:
        sample_points = sample_points[:]
        amp = amp[:]
        phase = phase[:]
    return cls(sample_points, amp, phase, interpolation=fp_group.attrs[
        'interpolation'], tolerance=fp_group.attrs['tolerance'], mismatch=
        fp_group.attrs['mismatch'], precision=fp_group.attrs['precision'],
        load_to_memory=load_to_memory)
