diff --git a/pipe/pipe.py b/pipe/pipe.py index 8ba723f..751babd 100644 --- a/pipe/pipe.py +++ b/pipe/pipe.py @@ -11,10 +11,29 @@ def image_pipe(imagepath: Path, namepattern: str, stacksize: int) -> np.ndarray: - images = np.zeros((stacksize, 800,800) + images = np.zeros((stacksize, 800,800)) for i in range(stacksize): images[i,:,:] = cv.imread(imagepath/namepattern.format(i), -1) return images +def spectrogram_pipe(specpath: Path, namepattern: str, freq_samples: int) + -> np.ndarray: + """ + Loads spectrograms for each stack iteration from an hdf5 data file. + Args: + specpath (Path): Path to the spectrogram files. + namepattern (str): Name pattern for the spectrogram files. + stacksize (int): Number of spectrograms in the stack. + freq_samples (int): Number of frequency samples in each spectrogram. + + Returns: + spectrograms (np.ndarray): Stack of spectrograms (2D array). + """ + + with h5py.File(specpath/namepattern.format(i), 'r') as f: + spectrograms = f['spectrogram'][:] + + return spectrograms + # EOF