pyLOM.SPOD#

Module contents#

pyLOM.SPOD.run(X: ndarray, t: ndarray, nDFT: int = 0, nolap: int = 0, remove_mean: bool = True)[source]#

Run SPOD analysis of a matrix X.

Parameters:
  • X (np.ndarray) – data matrix.

  • t (np.ndarray) – times at which the snapshots of X were collected

  • nDFT (int, optional) – number of points in each window (0 will set default value: ~10% nt)

  • nolap (int, optional) – number of overlap points between windows (0 will set default value: 50% nwin)

  • remove_mean (bool, optional) – whether or not to remove the mean flow (default, True)

Returns:

where the first array is L, the modal energy spectra, the second array is P, SPOD modes, whose spatial dimensions are identical to those of X and finally f is the frequency vectors

Return type:

[(np.ndarray), (np.ndarray), (np.ndarray)]

pyLOM.SPOD.extract_modes(L: ndarray, P: ndarray, ivar: int, npoints: int, iblock: int = 1, modes: list = [], reshape: bool = True)[source]#

When performing POD of several variables simultaneously, this function separates the spatial modes from each of the variables.

Parameters:
  • L (np.ndarray) – modal energy spectra

  • P (np.ndarray) – SPOD spatial modes

  • ivar (int) – ID of the variable (i. e.) position in which it was concatenated to the rest of data (min=1, max=number of concatenated variables)

  • npoints (int) – number of points in the domain per variable

  • modes (list, optional) – list containing the id of the modes to separate (default []).

  • iblock (int, optional) – block ID which we want to extract the modes from.

  • reshape (bool, optional) – if true the output will be given as (len(modes)*npoints,) if not it the result will be (npoints, len(modes)) (default `` True ``)

Returns:

modes of the variable ivar

Return type:

np.ndarray

pyLOM.SPOD.save(fname: str, L: ndarray, P: ndarray, f: ndarray, ptable: PartitionTable, nvars: int = 1, pointData: bool = True, mode: str = 'w')[source]#

Store SPOD results in serial or parallel according to the partition used to compute the SPOD. It will be saved on a h5 file.

Parameters:
  • fname (str) – path to the .h5 file in which the SPOD will be saved

  • L (np.ndarray) – modal energy

  • P (np.ndarray) – SPOD spatial modes

  • f (np.ndarray) – modes frequencies

  • ptable (PartitionTable) – partition table used to compute the SPOD

  • nvars (int, optional) – number of concatenated variables when computing the SPOD (default 1)

  • pointData (bool, optional) – bool to specify if the SPOD was performed either on point data or cell data (default True)

  • mode (str, optional) – mode in which the HDF5 file is opened, ‘w’ stands for write mode and ‘a’ stands for append mode. Write mode will overwrite the file and append mode will add the informaiton at the end of the current file, choose with great care what to do in your case (default w).

pyLOM.SPOD.load(fname: str, vars: list = ['L', 'P', 'f'], nmod: int = -1, ptable: PartitionTable = None)[source]#

Load SPOD results from a .h5 file in serial or parallel according to the partition used to compute the SPOD.

Parameters:
  • fname (str) – path to the .h5 file in which the SPOD was saved

  • vars (list) – list of variables to load. The following notation, consistent with the save function, is used, ‘L’: modes energy ‘P’: spatial modes ‘f’: modes frequency

  • all (the default option is to load them)

  • script. (but it is not recommended to load the spatial modes if they are not going to be used during the rest of the)

  • nmod (int, optional) – number of modes to load. By default it will load all the saved modes (default, -1)

  • ptable (PartitionTable, optional) – partition table to use when loading the data (default None).

pyLOM.SPOD.plotMode(L: ndarray, P: ndarray, freqs: ndarray, mesh: Mesh, dset: Dataset, ivar: int, pointData: bool = True, modes: ndarray = np.array([1], np.int32), **kwargs)[source]#

Plot a SPOD mode, including both the real and imaginary parts

Parameters:
  • L (np.ndarray) – modal energy spectra

  • P (np.ndarray) – spatial SPOD modes

  • freqs (np.ndarray) – frequencies at which the modes are computed

  • mesh (Mesh) – mesh at which the data is represented

  • dset (Dataset) – pyLOM Dataset containing the case information

  • ivar (int) – index of the variable inside the dataset

  • pointData (bool, optional) – whether the data is represented on points or cell (default, True)

  • modes (np.ndarray, optinal) – IDs of the modes to plot

pyLOM.SPOD.plotSpectra(f: ndarray, L: ndarray, fig: figure = None, ax: axes = None)[source]#

Plot the frequency-enegy spectrum

Parameters:
  • f (np.ndarray) – frequencies at which the modes are computed

  • L (np.ndarray) – energy of each frequency

  • fig (plt.figure, optional) – figure object in which the plot will be done (default: [])

  • axs (plt.axes, optional) – axes object in which the plot will be done (default: [])

Returns:

figure and axes objects of the plot

Return type:

[plt.figure, plt.axes]