SpectrogramDict๏ƒ

Stability: Stable

What it is๏ƒ

Use SpectrogramDict to keep multiple Spectrogram objects together while preserving channel labels and metadata.

Representative Signatures๏ƒ

SpectrogramDict(data: dict[str, Spectrogram])
SpectrogramDict.to_matrix()

Minimal Example๏ƒ

from gwexpy.spectrogram import Spectrogram, SpectrogramDict
import numpy as np

dct = SpectrogramDict({"A": Spectrogram(np.ones((8, 16)), dt=1.0, df=1.0)})
mat = dct.to_matrix()

API Reference๏ƒ

The detailed generated API continues below on this page.

Inherits from: PhaseMethodsMixin, UserDict

Dictionary of Spectrogram objects.

Note

Spectrogram objects can be very large in memory. Use inplace=True where possible to update container in-place.

Physical Context๏ƒ

Use SpectrogramDict when the identity of each time-frequency map matters: station name, channel, detector state, or preprocessing branch.

  • keys are often part of the scientific interpretation

  • this container is useful when you need batch operations but still want explicit provenance

Common Misreadings๏ƒ

  1. assuming a shared key pattern means shared normalization or transform settings

  2. comparing per-key outputs without checking whether all maps were generated by the same transform family

  3. reading output-file dataset names as the original physical labels after sanitization

Where to go next๏ƒ

Methods๏ƒ

__init__๏ƒ

__init__(self, dict=None, **kwargs)

Initialize self. See help(type(self)) for accurate signature.

(Inherited from PhaseMethodsMixin)

angle๏ƒ

angle(self, unwrap: bool = False, deg: bool = False, **kwargs: Any) -> Any

Alias for phase(unwrap=unwrap, deg=deg).

bootstrap_asd๏ƒ

bootstrap_asd(self, *args, **kwargs)

Estimate robust ASD from each spectrogram in the dict (returns FrequencySeriesDict).

crop๏ƒ

crop(self, t0, t1, inplace=False)

Crop each spectrogram in time.

Parameters๏ƒ

t0, t1 : float Start and end times. inplace : bool, optional If True, modify in place.

Returns๏ƒ

SpectrogramDict

crop_frequencies๏ƒ

crop_frequencies(self, f0, f1, inplace=False)

Crop each spectrogram in frequency.

Parameters๏ƒ

f0, f1 : float or Quantity Start and end frequencies. inplace : bool, optional If True, modify in place.

Returns๏ƒ

SpectrogramDict

degree๏ƒ

degree(self, unwrap: 'bool' = False) -> "'SpectrogramDict'"

Compute phase (in degrees) of each spectrogram.

interpolate๏ƒ

interpolate(self, dt, df, inplace=False)

Interpolate each spectrogram to new resolution.

Parameters๏ƒ

dt : float New time resolution. df : float New frequency resolution. inplace : bool, optional If True, modify in place.

Returns๏ƒ

SpectrogramDict

phase๏ƒ

phase(self, unwrap: bool = False, deg: bool = False, **kwargs: Any) -> Any

Calculate the phase of the data.

Parameters๏ƒ

unwrap : bool, optional If True, unwrap the phase to remove discontinuities. Default is False. deg : bool, optional If True, return the phase in degrees. Default is False (radians). **kwargs Additional arguments passed to the underlying calculation.

Returns๏ƒ

Series or Matrix or Collection The phase of the data.

plot๏ƒ

plot(self, **kwargs)

Plot all spectrograms stacked vertically.

plot_summary๏ƒ

plot_summary(self, **kwargs)

Plot Dictionary as side-by-side Spectrograms and percentile summaries.

radian๏ƒ

radian(self, unwrap: 'bool' = False) -> "'SpectrogramDict'"

Compute phase (in radians) of each spectrogram.

read๏ƒ

read(self, source, *args, **kwargs)

Read dictionary from HDF5 file keys -> dict keys.

rebin๏ƒ

rebin(self, dt, df, inplace=False)

Rebin each spectrogram to new time/frequency resolution.

Parameters๏ƒ

dt : float New time bin size. df : float New frequency bin size. inplace : bool, optional If True, modify in place.

Returns๏ƒ

SpectrogramDict

to_cupy๏ƒ

to_cupy(self, *args, **kwargs) -> 'dict'

Convert each item to cupy.ndarray. Returns a dict.

to_dask๏ƒ

to_dask(self, *args, **kwargs) -> 'dict'

Convert each item to dask.array. Returns a dict.

to_jax๏ƒ

to_jax(self, *args, **kwargs) -> 'dict'

Convert each item to jax.Array. Returns a dict.

to_matrix๏ƒ

to_matrix(self)

Convert to SpectrogramMatrix.

Returns๏ƒ

SpectrogramMatrix 3D array of (N, Time, Freq).

to_tensorflow๏ƒ

to_tensorflow(self, *args, **kwargs) -> 'dict'

Convert each item to tensorflow.Tensor. Returns a dict.

to_torch๏ƒ

to_torch(self, *args, **kwargs) -> 'dict'

Convert each item to torch.Tensor. Returns a dict.

update๏ƒ

update(self, other=None, **kwargs)

D.update([E, ]**F) -> None. Update D from mapping/iterable E and F. If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

(Inherited from UserDict)

write๏ƒ

write(self, target, *args, **kwargs)

Write dictionary to file.

For HDF5 output you can choose a layout (default is GWpy-compatible dataset-per-entry).

sgd.write("out.h5", format="hdf5")               # GWpy-compatible (default)
sgd.write("out.h5", format="hdf5", layout="group")  # legacy group-per-entry

HDF5 dataset names (for GWpy path=):

  • Keys are sanitized to be HDF5-friendly (e.g. H1:SPEC -> H1_SPEC).

  • If multiple keys sanitize to the same name, a suffix like __1 is added.

  • The original keys are stored in file attributes, and gwexpy restores them on read.

Warning

Never unpickle data from untrusted sources. pickle/shelve can execute arbitrary code on load.

Pickle portability note: pickled gwexpy SpectrogramDict unpickles as a built-in dict of GWpy Spectrogram (gwexpy not required on the loading side).