sage.data.psd.generate_psd

Filename : psds.py Description : Short description of the file

Created on 2025-12-16 18:08:32

__author__ = Narenraju Nagarajan __copyright__ = Copyright 2025, ProjectName __license__ = MIT Licence __version__ = 0.0.1 __maintainer__ = Narenraju Nagarajan __affiliation__ = N/A __email__ = N/A __status__ = [‘inProgress’, ‘Archived’, ‘inUsage’, ‘Debugging’]

GitHub Repository: NULL

Documentation: NULL

Attributes

logger

Classes

PSDGenerator

Normalising-flow-based PSD generative model trained in log-spline space.

Module Contents

logger[source]
class PSDGenerator(spline_coeffs, num_layers=5, hidden_features=64)[source]

Normalising-flow-based PSD generative model trained in log-spline space.

Fits a masked autoregressive flow (MAF, implemented via nflows) to the spline coefficients of real measured PSDs. Once trained, the flow can generate novel plausible PSD realisations by sampling from the latent Gaussian and inverting through the learned transform.

The overall pipeline is:

  1. Represent each real PSD as a set of log-spline coefficients (using LogSplineSmoothing).

  2. Fit the MAF on those coefficients (build_flow(), train_flow()).

  3. Sample new coefficient vectors from the flow and reconstruct PSDs via spline_to_psd().

Parameters:
  • spline_coeffs (numpy.ndarray, shape (N_psd, num_spline_coeffs)) – Matrix of spline coefficients from the training PSDs.

  • num_layers (int) – Number of autoregressive transform layers (default 5).

  • hidden_features (int) – Hidden-layer width in each MADE block (default 64).

spline_coeffs[source]
num_layers = 5[source]
hidden_features = 64[source]
flow = None[source]
learning_rate = 0.001[source]
batch_size = 128[source]
n_epochs = 50[source]
num_coeffs[source]
build_flow()[source]

Build normalising flow in spline coefficient space.

train_flow()[source]

Train the flow on spline coefficients.

spline_to_psd(coeffs, freqs, smoothing_spline=None)[source]

Convert spline coefficients to PSD values.

Parameters:
  • coeffs (numpy.ndarray) – (num_spline_coeffs,) or (N_samples, num_spline_coeffs)

  • freqs (numpy.ndarray) – frequency array corresponding to PSD

  • smoothing_spline – optional UnivariateSpline object to reconstruct PSD

Returns:

(len(freqs),) or (N_samples, len(freqs))

Return type:

psd

sample_psds(nsamples, freqs)[source]

Sample new PSDs from the trained flow.

Parameters:
Return type:

numpy.ndarray