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
Classes
Normalising-flow-based PSD generative model trained in log-spline space. |
Module Contents
- 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:
Represent each real PSD as a set of log-spline coefficients (using
LogSplineSmoothing).Fit the MAF on those coefficients (
build_flow(),train_flow()).Sample new coefficient vectors from the flow and reconstruct PSDs via
spline_to_psd().
- Parameters:
- 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:
nsamples (int)
freqs (numpy.ndarray)
- Return type: