pgmuvi.lightcurve¶
- class pgmuvi.lightcurve.ACFResult(lag: Tensor, acf: Tensor, method: str, counts: Tensor | None = None, normalized: bool = True, band: str | float | None = None)¶
Bases:
objectResult container for
Lightcurve.acf().- lag¶
Lag values (same units as the time axis).
- Type:
torch.Tensor
- acf¶
Autocorrelation values at each lag.
- Type:
torch.Tensor
- method¶
The method used to compute the ACF (
"data"or"gp").- Type:
str
- counts¶
Number of data pairs contributing to each lag bin (data method only).
- Type:
torch.Tensor or None
- normalized¶
Whether the ACF has been normalised so that
acf(0) == 1.- Type:
bool
- band¶
Band label or wavelength used when computing the ACF, if applicable.
- Type:
str, float, or None
- acf: Tensor¶
- band: str | float | None = None¶
- counts: Tensor | None = None¶
- lag: Tensor¶
- method: str¶
- normalized: bool = True¶
- class pgmuvi.lightcurve.ComponentDiagnosticsResult(component_periods=None, component_frequencies=None, component_weights=None, component_period_scales=None, component_frequency_scales=None, n_components=0, kernel_family='', notes='', component_labels=None)¶
Bases:
objectKernel-component diagnostic information for a spectral-mixture GP.
These values are extracted directly from GP hyperparameters and are provided for diagnostic purposes only. They must not be interpreted as independent physical periods. The literature-comparable period estimates are the summed-PSD peaks stored in
PeriodSummaryResult.peaks.- component_periods¶
Centre period of each mixture component (1/frequency).
- Type:
numpy.ndarray
- component_frequencies¶
Centre frequency of each mixture component.
- Type:
numpy.ndarray
- component_weights¶
Relative amplitude weight of each mixture component.
- Type:
numpy.ndarray
- component_period_scales¶
Width (sigma) of each Gaussian component in period units.
- Type:
numpy.ndarray
- component_frequency_scales¶
Width (sigma) of each Gaussian component in frequency units.
- Type:
numpy.ndarray
- n_components¶
Number of mixture components.
- Type:
int
- kernel_family¶
Name of the spectral-mixture kernel family.
- Type:
str
- notes¶
Diagnostic notes for this component set.
- Type:
str
- component_labels¶
Human-readable label for each component, e.g.
["SM component 1", "SM component 2"].- Type:
list of str
- as_dict() dict¶
Return a plain-dict representation of this diagnostics object.
- class pgmuvi.lightcurve.InputHelpers¶
Bases:
objectMixin class providing helper methods for reading data from various input formats.
This class provides classmethods for instantiating a
Lightcurvefrom different input formats, with flexible column name detection.Lightcurveinherits from this class so all methods are available directly onLightcurve.- _X_COLUMN_NAMES¶
Candidate column names used for auto-detecting the time (independent variable) column, checked case-insensitively in order.
- Type:
list of str
- _Y_COLUMN_NAMES¶
Candidate column names used for auto-detecting the dependent variable (y) column, checked case-insensitively in order.
- Type:
list of str
- _YERR_COLUMN_NAMES¶
Candidate column names used for auto-detecting the uncertainty column, checked case-insensitively in order.
- Type:
list of str
- _WAVELENGTH_COLUMN_NAMES¶
Candidate column names used for auto-detecting a numeric wavelength column, checked case-insensitively in order. When such a column is found and contains more than one unique value, the data are loaded as a 2-D lightcurve whose
xdatahas shape(N, 2)with the time values in column 0 and the wavelength values in column 1.- Type:
list of str
- _WAVELENGTH_ID_COLUMN_NAMES¶
Candidate column names used for auto-detecting a string band identifier column (e.g.
"V","R","W1"), checked case-insensitively in order. When such a column is found it is ingested as thebandattribute of the resultingLightcurve.- Type:
list of str
- classmethod from_csv(filepath: str | Path, xcol: str | list[str] | None = None, ycol: str | None = None, yerrcol: str | None = None, wavelcol: str | None = None, **kwargs) Lightcurve¶
Instantiate a Lightcurve from a CSV file.
The file must have a header line whose entries are used to identify the relevant data columns. Column names are matched case-insensitively.
- 1-D lightcurves (single time series)
When only a time column and a flux/magnitude column are present, or when all observations share the same wavelength/band, the resulting
xdatais a 1-D tensor of shape(N,).- 2-D (multiband) lightcurves
When the CSV contains a numeric wavelength column with more than one unique value, the resulting
xdatahas shape(N, 2)where column 0 holds the time values and column 1 holds the numeric wavelength values. Theydata(and optionalyerr) remain 1-D tensors of shape(N,).The numeric wavelength column is selected in one of three ways:
Explicit ``xcol`` list: pass
xcolas a list of two column names, e.g.xcol=["time", "wavelength"]. The first element is the time column and the second is the wavelength column. All subsequent x-axis columns are stacked in the order given.Explicit ``wavelcol``: pass the column name as a separate
wavelcolkeyword argument.Auto-detection: if neither an iterable
xcolnor awavelcolis supplied, the method searches for a column whose name matches one of the entries in_WAVELENGTH_COLUMN_NAMES(e.g."wavelength","wl"). If such a column is found and contains more than one unique value, a 2-D lightcurve is returned automatically.
- Band labels
String band-identifier columns (e.g. one named
"band"or"filter"containing values like"V","R") are resolved independently of the numeric wavelength column. When the CSV contains a string-typed column whose name matches one of the entries in_WAVELENGTH_ID_COLUMN_NAMES, those labels are stored automatically inLightcurve.bandwhenbandis not supplied explicitly in**kwargs. For 1-D lightcurves, auto-population occurs only when the band-ID column contains exactly one distinct non-empty label (matching the 1-D constructor contract, which expects a single band label). If multiple distinct labels are present for 1-D input,bandis left unset and a warning is emitted. Numeric wavelength columns are used directly andLightcurve.bandis left asNoneunless the caller providesband=explicitly in**kwargs.
- Parameters:
filepath (str or pathlib.Path) – Path to the CSV file.
xcol (str or list of str or None, optional) – Name of the column containing the time (independent variable) data, or a list of column names to stack as the x-axis (first element is time, subsequent elements are additional dimensions such as wavelength). If not provided, auto-detection is attempted using
_X_COLUMN_NAMESfor the time column.ycol (str or None, optional) – Name of the column containing the dependent variable (y) data. If not provided, auto-detection is attempted using
_Y_COLUMN_NAMES.yerrcol (str or None, optional) – Name of the column containing the uncertainties on the dependent variable. If not provided, auto-detection is attempted using
_YERR_COLUMN_NAMES. If no matching column is found,yerris set toNone.wavelcol (str or None, optional) – Name of the column containing wavelength or band values. When provided, the time and wavelength columns are stacked to form a 2-D
xdata. Ignored whenxcolis a list.**kwargs – Additional keyword arguments passed to the Lightcurve constructor. If
bandis not provided and a string band-ID column exists, it is populated automatically.
- Returns:
A 1-D lightcurve when a single time column is used (or when the wavelength/band column has only one unique value), or a 2-D lightcurve when multiple wavelengths/bands are present.
- Return type:
- Raises:
ValueError – If a required column cannot be auto-detected and was not specified explicitly, or if an explicitly specified column name is not present in the file.
- class pgmuvi.lightcurve.Lightcurve(xdata, ydata, yerr=None, xtransform=None, ytransform=None, name=None, time_units=None, max_samples: int | None = 1000, max_samples_per_band: int | None = None, subsample_seed: int | None = None, check_sampling: bool = False, sampling_kwargs: dict | None = None, check_variability: bool = False, variability_kwargs: dict | None = None, band=None, **kwargs)¶
Bases:
InputHelpers,ModuleA class for storing, manipulating and fitting light curves
This class is designed to be a convenient way to store and manipulate light curve data, and to fit Gaussian Processes to that data. It is designed to be used with the GPyTorch library, and in future will be compatible with the Pyro library for MCMC fitting.
- Parameters:
xdata (Tensor of floats) – The independent variable data
ydata (Tensor of floats) – The dependent variable data
yerr (Tensor of floats, optional) – The uncertainties on the dependent variable data, by default None
xtransform (str, optional) – The transform to apply to the x data, by default None
ytransform (str, optional) – The transform to apply to the y data, by default None
time_units (str, astropy.units.UnitBase, or None, optional) – Units of the time axis. Time values are converted to days internally. If None (default) the data are assumed to already be in days.
band (array-like of str or None, optional) – Optional per-row band labels for a 2-D light curve. Each element must be a string identifier (e.g.
"V","R","W1"), and there must be exactly one label per observation row — i.e.len(band) == len(xdata)for 2-D data. For 1-D light curves a single-element array["V"]is accepted.None(default) means no band labels are stored.
- band¶
Per-row string labels aligned with
xdata, orNoneif no labels were provided.- Type:
numpy.ndarray of str or None
Examples
Notes
- acf(method='data', max_lag=None, n_lags=50, lag_edges=None, normalize=True, subtract_mean=True, band=None, reference_time=None)¶
Compute the autocorrelation function (ACF) of the light curve.
- Parameters:
method ({"data", "gp"}, optional) –
"data"estimates the ACF directly from the observations using a pairwise lag-binning estimator (handles uneven sampling)."gp"evaluates the ACF implied by the fitted GP covariance function. Default is"data".max_lag (float or None, optional) – Maximum lag to consider. If
None, defaults to half the total time baseline.n_lags (int, optional) – Number of lag bins (
method="data") or evaluation points (method="gp"). Default is 50. Must be a positive integer. Formethod="data"the returned arrays have lengthn_lags + 1because a zero-lag point is prepended.lag_edges (array-like or None, optional) – Explicit bin edges for the lag axis (
method="data"only). If provided, n_lags and max_lag are ignored.normalize (bool, optional) – If
True, normalise the ACF so thatacf(0) == 1. Default isTrue.subtract_mean (bool, optional) – If
True, subtract the sample mean before computing products (method="data"only). Default isTrue.band (str or None, optional) – Band label to use when the light curve is 2D (multiband). For
method="data"this argument is required when the light curve is 2D; aValueErroris raised if it isNone. Formethod="gp"with a 2D light curve the call always raisesNotImplementedErrorregardless of band, because GP-implied ACF for 2D kernels is not yet implemented.reference_time (float or None, optional) – Reference time used to anchor the GP covariance evaluation (
method="gp"only). IfNone, the mean of the time axis is used.
- Returns:
A
ACFResultinstance with attributeslag,acf,method,counts(data method only),normalized, andband.- Return type:
- Raises:
ValueError – If method is not
"data"or"gp".ValueError – If n_lags is not a positive integer.
ValueError – If the light curve is 2D and
method="data"and band isNone.ValueError – If lag_edges is invalid (not 1-D, fewer than two values, not strictly increasing, or contains non-finite values).
RuntimeError – If
method="gp"is requested butfit()has not been called yet.RuntimeError – If
method="gp"withnormalize=Trueand the zero-lag covariance is non-positive or non-finite.NotImplementedError – If
method="gp"is used with a 2D light curve.
Examples
>>> result = lc.acf(method="data") >>> result = lc.acf(method="gp", n_lags=500)
- append_data(new_values_x, new_values_y)¶
- assess_sampling_quality(verbose: bool = True, **kwargs) tuple¶
Assess whether lightcurve sampling is adequate for GP fitting.
- Parameters:
verbose (bool, default=True) – Print detailed assessment report
**kwargs (dict) –
Quality gate thresholds (see preprocess.quality.assess_sampling_quality):
min_points: int (default 15)
max_gap_fraction: float (default 0.3)
min_baseline_factor: float (default 3.0)
min_snr: float (default 3.0)
min_fraction_good_snr: float (default 0.5)
- Returns:
passes (bool) – True if all quality gates pass
diagnostics (dict) – Diagnostic information including gates, metrics, warnings, and recommendation
Examples
>>> lc = Lightcurve(t, y, yerr) >>> passes, diag = lc.assess_sampling_quality(verbose=True) >>> if diag['recommendation'] == 'PROCEED': ... lc.fit(...)
- assess_sampling_quality_per_band(verbose: bool = True, **kwargs) dict¶
Assess sampling quality independently for each wavelength band.
Only applicable for 2D (multiband) lightcurves.
- Parameters:
verbose (bool, default=True) – Print assessment for each band
**kwargs (dict) – Quality gate thresholds
- Returns:
- {
wavelength1: diagnostics_dict, wavelength2: diagnostics_dict, … ‘summary’: {
’n_bands’: int, ‘n_passing’: int, ‘passing_wavelengths’: list[float], ‘failing_wavelengths’: list[float] }
}
- Return type:
dict
- Raises:
ValueError – If lightcurve is not 2D (multiband).
- auto_select_model(verbose=True)¶
Automatically select the best model type based on data characteristics.
Analyses the data to recommend an appropriate GP model. For 1D data, the Lomb-Scargle periodogram is computed and the peak power used to decide between a quasi-periodic, periodic+stochastic, or Matérn model. For 2D multiwavelength data, per-band periodograms are compared to determine whether the variability is achromatic or wavelength-dependent.
- Parameters:
verbose (bool, optional) – If True, print a summary of the recommendation, by default True.
- Returns:
model_str (str) – Recommended model string suitable for passing directly to
fit()orset_model().diagnostics (dict) – Dictionary containing: -
'model'— same asmodel_str. -'reason'— human-readable explanation. - Additional data-dependent keys (e.g.'max_ls_power').
Examples
>>> from pgmuvi.lightcurve import Lightcurve >>> import torch >>> import numpy as np >>> t = torch.linspace(0, 20, 100) >>> y = torch.sin(2 * np.pi * t / 5) >>> lc = Lightcurve(t, y) >>> model_str, diag = lc.auto_select_model()
- check_variability(**kwargs) dict¶
Check if lightcurve shows significant variability.
Only applicable for 1-D lightcurves. For multiband data use
check_variability_per_band().- Parameters:
**kwargs (dict) – Arguments passed to is_variable(): - alpha: float (default 0.01) - fvar_min: float (default 0.05) - stetson_k_min: float diagnostic reference (default 0.95) - verbose: bool (default False)
- Returns:
Variability diagnostics from is_variable()
If the lightcurve is multiband (ndim > 1). Use
check_variability_per_band() instead.
Examples
>>> lc = Lightcurve(t, y, yerr) >>> diag = lc.check_variability(verbose=True) >>> print(f"Variable: {diag['decision']}")
- check_variability_per_band(**kwargs) dict¶
Check variability independently for each wavelength band.
Only applicable for multiband (2D) lightcurves where
xdata[:, 1]encodes the band/wavelength.- Parameters:
**kwargs (dict) –
- Arguments passed to is_variable()
’n_variable’: int, ‘variable_wavelengths’: list[float]
- Returns:
If the lightcurve is not 2-D multiband data (ndim != 2 columns
with time in column 0 and wavelength in column 1).
Examples
>>> lc2d = Lightcurve(xdata_2d, y, yerr) >>> results = lc2d.check_variability_per_band(verbose=True) >>> n_var = results['summary']['n_variable'] >>> n_bands = results['summary']['n_bands'] >>> print(f"{n_var}/{n_bands} bands variable")
- compute_psd(freq, means=None, scales=None, weights=None, raw=False, log=False, debug=False, **kwargs)¶
Compute the power spectral density for the model
- Parameters:
freq (array_like or tuple(array_likes)) – The Fourier duals at which to compute the PSD If array_like, assumes only one dual present. If tuple, duals are unpacked from it.
means (array_like, optional) – The means of the gaussians in the spectral mixture kernel, by default None. If None, the means from the model will be used.
scales (array_like, optional) – The scales of the gaussians in the spectral mixture kernel, by default None. If None, the scales from the model will be used.
weights (array_like, optional) – The weights of the gaussians in the spectral mixture kernel, by default None. If None, the weights from the model will be used.
raw (bool, optional) – If True, the PSD will be computed in the space that the model was trained in, by default False. If False, the PSD will be computed in the original space of the data.
**kwargs (dict, optional) – Any other keyword arguments to be passed.
- Returns:
psd – The power spectral density of the model at the frequencies given by freq.
- Return type:
array_like
- compute_sampling_metrics() dict¶
Compute temporal sampling quality metrics.
- Returns:
Comprehensive sampling metrics (see preprocess.quality.compute_sampling_metrics)
- Return type:
dict
Examples
>>> lc = Lightcurve(t, y, yerr) >>> metrics = lc.compute_sampling_metrics() >>> print(f"Nyquist period: {metrics['nyquist_period']:.2f}")
- compute_sampling_metrics_per_band() dict¶
Compute sampling metrics independently for each wavelength band.
Only applicable for 2D (multiband) lightcurves.
- Returns:
dict
- { – wavelength1: metrics_dict,
wavelength2: metrics_dict, … ‘summary’: {
’n_bands’: int, ‘min_points_across_bands’: int, ‘max_gap_fraction_worst_band’: float, ‘median_nyquist_period’: float
}
}
- Raises:
ValueError – If lightcurve is not 2D (multiband).
- classmethod concat(items, on_conflict='raise', **kwargs)¶
Concatenate multiple light curves into one 2-D
Lightcurve.- Parameters:
items (iterable of Lightcurve, str, or pathlib.Path) – Input light curves (or CSV paths) to concatenate. A bare
stris treated as a single item, not as an iterable of characters.on_conflict ({"raise", "skip"}, optional) – Action taken when a band label or wavelength appears in more than one input.
"raise"(default) raises aValueError;"skip"drops the offending constituent and emits aUserWarning.**kwargs – Additional keyword arguments forwarded to the
Lightcurveconstructor (e.g.xtransform,ytransform,name). They are not forwarded tofrom_csv().
- Returns:
A new 2-D
Lightcurvebuilt from all non-conflicting constituent bands across items, in input order. Always unfitted.- Return type:
- Raises:
TypeError – If any element of items is not a
Lightcurve,str, orpathlib.Path.ValueError – If items is empty.
ValueError – If some inputs have band information but others do not.
ValueError – If a 1-D input maps to more than one band or wavelength.
ValueError – If a conflict is detected and on_conflict is
"raise".
- cpu()¶
Move all model parameters and buffers to the CPU.
Note
This method modifies the module in-place.
- Returns:
self
- Return type:
Module
- cuda(device=0)¶
Move all model parameters and buffers to the GPU.
This also makes associated parameters and buffers different objects. So it should be called before constructing the optimizer if the module will live on GPU while being optimized.
Note
This method modifies the module in-place.
- Parameters:
device (int, optional) – if specified, all parameters will be copied to that device
- Returns:
self
- Return type:
Module
- drop_bands(bands: list | tuple | ndarray) Lightcurve¶
Return a new Lightcurve with the specified bands removed.
This complements the string band-label behavior of
select_bands(): every row whosebandlabel appears in bands is excluded from the returned object.- Parameters:
bands (list, tuple, or numpy.ndarray) – Band labels to remove. Each element must be a string (
strornumpy.str_). Numeric selectors,bytes,None, and nested containers are not accepted.- Returns:
A new
Lightcurvebuilt from the rows whosebandlabel is not in bands. Thename,xtransform, andytransformattributes are inherited from the original light curve. If none of the requested labels are present in the data the returned object is a copy of the original (no-op).- Return type:
- Raises:
TypeError – If bands is a bare string rather than a sequence.
TypeError – If any element of bands is not a string.
ValueError – If
bandisNone.ValueError – If all rows are removed (no data would remain).
- filter_variable_bands(**kwargs)¶
Create new Lightcurve with only variable bands retained.
Only applicable for multiband (2D) lightcurves where
xdata[:, 1]encodes the band/wavelength.Arguments passed to is_variable()
- Returns:
lightcurve (Lightcurve) – New instance containing only wavelengths that pass variability tests
None – If no bands pass variability tests
Examples
>>> lc2d = Lightcurve(xdata_2d, y, yerr) >>> lc_var = lc2d.filter_variable_bands() >>> # Check how many bands were retained via the per-band summary >>> results = lc2d.check_variability_per_band() >>> print(f"Retained {results['summary']['n_variable']} variable bands")
- filter_well_sampled_bands(**kwargs)¶
Create new Lightcurve with only well-sampled bands retained.
Only applicable for 2D (multiband) lightcurves.
- Parameters:
**kwargs (dict) – Quality gate thresholds
- Returns:
New instance containing only wavelengths that pass sampling checks
- Return type:
- Raises:
ValueError – If lightcurve is not 2D (multiband) or no bands pass sampling checks.
- fit(model=None, likelihood=None, num_mixtures=None, guess=None, periods=None, use_mls_init=True, use_best_band_init: bool = False, constraint_set=None, grid_size=2000, cuda=False, training_iter=300, max_cg_iterations=None, optim='AdamW', miniter=None, stop=1e-05, lr=0.1, stopavg=30, variance=False, **kwargs)¶
Fit the lightcurve
- Parameters:
model –
The model to use for the GP, by default None. If None, an error will be raised. If a string, it must be one of the following:
- Spectral mixture models:
’1D’: SpectralMixtureGPModel ‘2D’: TwoDSpectralMixtureGPModel ‘1DLinear’: SpectralMixtureLinearMeanGPModel ‘2DLinear’: TwoDSpectralMixtureLinearMeanGPModel ‘1DSKI’: SpectralMixtureKISSGPModel ‘2DSKI’: TwoDSpectralMixtureKISSGPModel ‘1DLinearSKI’: SpectralMixtureLinearMeanKISSGPModel ‘2DLinearSKI’: TwoDSpectralMixtureLinearMeanKISSGPModel ‘2DPowerLaw’: TwoDSpectralMixturePowerLawMeanGPModel ‘2DPowerLawSKI’: TwoDSpectralMixturePowerLawMeanKISSGPModel ‘2DDust’: TwoDSpectralMixtureDustMeanGPModel ‘2DDustSKI’: TwoDSpectralMixtureDustMeanKISSGPModel
- Alternative 1D models:
’1DQuasiPeriodic’: QuasiPeriodicGPModel ‘1DMatern’: MaternGPModel ‘1DPeriodicStochastic’: PeriodicPlusStochasticGPModel ‘1DLinearQuasiPeriodic’: LinearMeanQuasiPeriodicGPModel
- Separable 2D models:
’2DSeparable’: SeparableGPModel ‘2DAchromatic’: AchromaticGPModel ‘2DWavelengthDependent’: WavelengthDependentGPModel ‘2DDustMean’: DustMeanGPModel ‘2DPowerLawMean’: PowerLawMeanGPModel
- likelihoodstring, None or instance of
gpytorch.likelihoods.likelihood.Likelihood or Constraint, optional
If likelihood is passed, it will be passed along to set_likelihood() and used to set the likelihood function for the model. For details, see the documentation for set_likelihood().
- num_mixturesint or None, optional
The number of mixtures to use in the spectral mixture kernel. By default
None, which lets the MLS initialisation (seeuse_mls_init) choose the value automatically. Whenuse_mls_init=TrueandperiodsisNone, settingnum_mixturesto an integer N overrides the automatic count: the first N significant MLS periods are used; if N exceeds the number of significant periods, non-significant peaks are added to make up the difference. Whenuse_mls_init=Falseandnum_mixturesisNonea fallback of 4 is used.- guessdict, optional
A dictionary of the hyperparameters to use for the model and likelihood. The keys should be the names of the parameters, and the values should be Tensors containing the values of the parameters. If None, no hyperparameters will be set. If a hyperparameter is passed for a parameter that is not a model or likelihood parameter, it will be ignored.
- periodsarray-like or None, optional
Initial guesses for the periods (in the same units as the lightcurve time axis). When provided for 1D spectral-mixture kernels (i.e. when
ard_num_dims == 1), the MLS initialisation is skipped entirely:num_mixturesis set to the number of supplied periods and the spectral-mixture kernel frequencies are initialised from these values. If bothperiodsandguessare supplied, entries inguesstake priority over the period-derived frequencies. For multi- dimensional spectral-mixture models (e.g. 2D kernels), the current implementation does not useperiodsto seed mixture means; in those cases, only explicit initial values provided viaguess(or the model’s own defaults) will be used.- use_mls_initbool, optional
If
True(default) andperiodsisNoneand a 1D spectral-mixture model string is given (ard_num_dims == 1), the Multiband Lomb-Scargle (MLS) periodogram is run first to estimate the number of significant periods and their frequencies, which are used as initial guesses for the spectral-mixture kernel frequencies. Set toFalseto disable this behaviour and, for models that call it, fall back to GPyTorch’sinitialize_from_data. Note that several 2D spectral-mixture models do not currently callinitialize_from_dataat all, so for those models MLS-based or period-based frequency seeding is not applied and the underlying GPyTorch defaults are used instead.- use_best_band_initbool, optional
If
Trueand the lightcurve is multiband (ndim > 1) anduse_mls_init=TrueandperiodsisNone, a 1D Lomb-Scargle fit on the most-sampled band is used to seed the spectral-mixture frequency initialisation instead of the standard multiband LS. For 2D spectral-mixture models (ard_num_dims == 2, non-SKI), the fitted temporal frequencies are also used to initialise the temporal dimension of the kernel mixture means, with the minimum wavelength frequency (1/wavelength_span) as the default for the wavelength dimension, corresponding to approximately achromatic variability. This can improve convergence for sources with a large dynamic range in the number of observations across bands. Has no effect for 1D lightcurves or whenuse_mls_init=False.- constraint_setstr or None, optional
Name of a pre-defined source-type constraint set to apply via
set_default_constraints(). When provided, the period bounds defined in the constraint set are also used to filter MLS peaks before the model is constructed: peaks whose frequencies fall outside the constraint-set allowed range are excluded from the initialisation (with aRuntimeWarning). Currently supported values are"LPV"(Long-Period Variables, minimum period 100 in the native time units). PassNone(the default) to use only the data-driven bounds.- grid_sizeint, optional
The number of points to use in the grid for the KISS-GP models, by default 2000.
- cudabool, optional
Whether to use CUDA, by default False.
- training_iterint, optional
The number of iterations to use for training, by default 300.
- max_cg_iterationsint, optional
The maximum number of conjugate gradient iterations to use, by default None. If None, gpytorch.settings.max_cg_iterations will be used.
- optimstr or torch.optim.Optimizer, optional
The optimizer to use for training, by default “AdamW”. If a string, it must be one of the following:
‘AdamW’: torch.optim.AdamW ‘Adam’: torch.optim.Adam ‘SGD’: torch.optim.SGD
Otherwise, it must be an instance of torch.optim.Optimizer.
- miniterint, optional
The minimum number of iterations to use for training, by default None. If None, training_iter will be used.
- stopfloat, optional
The stopping criterion for the training, by default 1e-5.
- lrfloat, optional
The learning rate to use for the optimizer, by default 0.1.
- stopavgint, optional
The number of iterations to use for the stopping criterion, by default 30.
- variancebool, optional
If False (default), stored uncertainties are treated as errors (standard deviations) and are squared before being used as noise variances in the likelihood. Set to True if the stored uncertainties already represent variances.
- **kwargsdict, optional
Any other keyword arguments to be passed to the model constructor, likelihood constructor, or the optimizer.
- Returns:
_description_
- Return type:
_type_
- Raises:
ValueError – If no model is provided.
Notes
Data validation, quality checks, and subsampling are performed at object construction time (see
__init__()). Use thecheck_sampling,check_variability, andmax_samplesparameters of__init__()to control pre-processing.
- fit_LS(freq_only: bool = False, num_peaks: int = 1, single_threshold: float = 0.05, Nyquist_factor: int = 5, fap_method: str | None = None, use_best_band_init: bool = False, return_full: bool = False, **kwargs) tuple¶
Compute the (multiband) Lomb-Scargle periodogram. Periods returned for the num_peaks highest peaks in the periodogram. For a 1D lightcurve, the false-alarm probability is used
to estimate the significance of the periods, which are also returned. These can be used to filter out insignificant periods.
- For multi-band lightcurves (2D data), LombScargleMultiband is used
to compute periods across all bands simultaneously.
The method can also be used to return the entire grid of frequencies, which can be used by other methods such as compute_psd and plot_psd.
Parameters:¶
- freq_only: bool, optional, default=False
If True, only the frequency grid will be returned. This can be useful for methods such as compute_psd and plot_psd.
- num_peaks: int, optional, default=1
The number of peaks to extract from the Lomb-Scargle periodogram. If fewer peaks are found, only the available peaks will be returned.
- single_threshold: float, optional, default=0.05
The false alarm probability threshold for a single peak to be considered significant.
- Nyquist_factor: int, optional, default=5
The factor by which to multiply the Nyquist frequency to determine the maximum frequency to search for in the Lomb-Scargle periodogram. This will be approximately the number of points sampling the maximum in the resulting periodogram.
- fap_method: str or None, optional, default=None
Method used to compute the false-alarm probability (FAP) of the maximum periodogram peak (the global significance test). For 1D lightcurves the default is
'davies'(fast analytical upper bound; equivalent to'baluev'for practical purposes but significantly faster). Other valid astropy options are'baluev'and'bootstrap'. Note:'single'is a valid astropy option that computes the FAP for a single pre-specified frequency and is not appropriate forfap_max(a warning is issued and'baluev'is used instead); it is however used internally as the per-frequency p-value when applying the Benjamini-Hochberg correction. For multi-band lightcurves the default is'phase_scramble'. Slower but more accurate options are'bootstrap','calibrated', and'analytical'(fast Baluev-style approximation) (seeMultibandLSWithSignificance).
- use_best_band_init: bool, optional, default=False
If True and the lightcurve is multiband (ndim > 1), the Lomb-Scargle frequency grid is derived from the band with the most observations rather than from the full multiband dataset. This yields a finer frequency resolution focused on the most informative band, which can speed up and improve the periodogram search when sampling is highly heterogeneous across bands. Has no effect for 1D lightcurves.
- return_full: bool, optional, default=False
If True and
freq_only=False, also return the complete frequency grid and power spectrum alongside the peak frequencies and significance mask (see return values below). Ignored whenfreq_only=True. The periodogram itself is not recomputed, but returning the full grid may still allocate and/or copy the frequency and power tensors before returning them.
- kwargs: dict, optional
Additional keyword arguments to be passed to the LombScargle(Multiband) constructor.
Returns:¶
The return value depends on the combination of
freq_onlyandreturn_full:freq_only=True(return_fullis ignored):(freq_grid, power_grid)freq_grid: torch.Tensor of floats — the full frequency grid.
power_grid: torch.Tensor of floats — periodogram power at each frequency.
freq_only=False, return_full=False(default):(peak_freqs, significance_mask)peak_freqs: torch.Tensor of floats — frequencies of the
num_peakshighest periodogram peaks.significance_mask: torch.Tensor of bool — True for peaks that are statistically significant after Benjamini-Hochberg FDR correction.
freq_only=False, return_full=True:(peak_freqs, significance_mask, freq_grid, power_grid)peak_freqs: torch.Tensor of floats — as above.
significance_mask: torch.Tensor of bool — as above.
freq_grid: torch.Tensor of floats — the full frequency grid (already computed internally; returned at no extra cost).
power_grid: torch.Tensor of floats — periodogram power at each frequency (already computed internally).
- classmethod from_table(tab, file_format='votable', xcol='x', ycol='y', yerrcol='yerr', bandcol=None, **kwargs)¶
Instantiate a Lightcurve object with data read in from a VOTable.
- Parameters:
tab (astropy.table.Table object or str or pathlib.Path instance) – Table containing the input data. If str, name (with extension) of file containing the input data. In this case, the file_format keyword must be set accordingly.
file_format (str) – Format of file containing input data. Must be a format supported by Table.read. Only required if type(tab) is str.
xcol (str) – Name of column in table that contains the x data
ycol (str) – Name of column in table that contains the y data
yerrcol (str) – Name of column in table that contains the yerr data
bandcol (str or None, optional) – Name of the column containing string band labels (e.g.
"V","R","W1"). When provided, the per-row labels are read from this column and stored inLightcurve.band. IfNone(default), the method attempts to auto-detect a string-typed column whose name matches one of the entries in_WAVELENGTH_ID_COLUMN_NAMES(e.g."band","filter"); if found it is used as the band-label column. Thebandkwarg inkwargsalways takes precedence.kwargs – Arguments to be passed to the Lightcurve constructor, including
time_units(str orastropy.unitsunit, default None). Iftime_unitsis provided, the time axis read from xcol will be converted to days before being stored.
- Return type:
Lightcurve object
- get_constraints()¶
Return the constraints currently registered on the model.
Iterates over all constraints registered on the model (via GPyTorch’s
named_constraints) and returns a dictionary mapping each constraint name to the corresponding constraint object. A formatted summary is also printed to standard output.- Returns:
A dictionary mapping constraint names (str) to their
gpytorch.constraints.Constraintobjects. Returns an empty dict if no constraints have been registered.- Return type:
dict
- Raises:
RuntimeError – If the model has not been set yet (call
set_model()first).
See also
Examples
lc.set_model("1D", num_mixtures=4) lc.set_default_constraints() constraints = lc.get_constraints()
- get_parameters(raw=False, transform=True)¶
Returns a dictionary of the parameters of the model, with the keys being the names of the parameters and the values being the values of the parameters. This is useful for getting the values of the parameters after training, for example.
The routine is rather hacky, since there is no built-in way to get the unconstrained values of the parameters from the model without knowing exactly what they are ahead of time. This routine therefore gets the names of the raw parameters, and then uses those names with string manipulation and __getattr__ to get the values of the constrained parameters.
- Parameters:
raw (bool, default False) – If True, returns the raw values of the parameters, otherwise returns the constrained values of the parameters.
- Returns:
pars – A dictionary of the parameters of the model, with the keys being the names of the parameters and the values being the values of the parameters.
- Return type:
dict
- get_period_prior()¶
Return the period or frequency prior currently registered on the model.
Searches for a prior on the period or frequency parameter of the model (
mixture_means_priorfor spectral-mixture models,period_length_priorfor quasi-periodic models) and returns a dictionary of the priors found, keyed by the full parameter path. A formatted summary is also printed to standard output.- Returns:
A dictionary mapping prior names (str) to their prior objects. Returns an empty dict if no period/frequency prior has been registered or the model has no periodicity parameter.
- Return type:
dict
- Raises:
RuntimeError – If the model has not been set yet (call
set_model()first).
See also
Examples
lc.set_model("1D", num_mixtures=4) lc.set_period_prior(prior_set="LPV") prior_info = lc.get_period_prior()
- get_period_summary(n_grid=5000, min_freq=None, max_freq=None, peak_threshold_rel=0.2, uncertainty='peak_mass', n_peaks=None, mass_level=0.68, classify_lsp=False)¶
Return a literature-comparable period summary for the fitted model.
Unlike
get_periods(), which returns the raw kernel-basis parameters of each spectral-mixture component (component centres, scales, and weights), this method aims to produce a single dominant period that can be directly compared to published values.The method dispatches to the appropriate backend based on the type of kernel used by the model:
Spectral-mixture models (all
"1D","2D","SKI","PowerLaw","Dust"variants):Constructs the total positive-frequency PSD as a sum of weighted Gaussians, identifies the highest PSD peak, and returns its location as the dominant period. The half-maximum width of the peak provides a practical uncertainty interval.
Explicit-period models (
"1DQuasiPeriodic","1DLinearQuasiPeriodic"):Reads the fitted
period_lengthparameter directly from thePeriodicKernel. The RBF lengthscale is used as a coherence proxy to derive a period interval and Q-factor.- Periodic-plus-stochastic (
"1DPeriodicStochastic"): Extracts the period from the quasi-periodic sub-kernel. The summary notes flag the mixed periodic/stochastic nature of the model.
Separable 2D models (
"2DSeparable","2DAchromatic","2DWavelengthDependent","2DDustMean","2DPowerLawMean"):Identifies the time sub-kernel (
active_dims = [0]) and applies the appropriate backend to that sub-kernel only.- Non-periodic models (
"1DMatern"): Returns a consistent summary dictionary with
Nonevalues for all period-related fields rather than raising an exception, so that automated scripts can handle all model types gracefully.
Note
All uncertainty estimates are practical proxies, not posterior credible intervals. MCMC-based credible intervals are not yet implemented.
- Parameters:
n_grid (int, optional) – Number of points in the positive-frequency evaluation grid (spectral-mixture backend only). Default 5000.
min_freq (float or None, optional) – Minimum frequency for the evaluation grid (SM backend only). Defaults to
1 / time_span.max_freq (float or None, optional) – Maximum frequency for the evaluation grid (SM backend only). Defaults to the highest component centre plus five sigma.
peak_threshold_rel (float, optional) – Relative height threshold for significant peaks (SM backend). Default 0.2.
uncertainty (str, optional) – Uncertainty method. Only
"peak_mass"is supported for the spectral-mixture backend ("peak_width"raisesNotImplementedError). Non-SM backends always use their native interval method and ignore this parameter. Default"peak_mass".n_peaks (int or None, optional) – Number of peaks to analyze and return in
peaks. IfNone(default), defaults to_fit_num_mixtures_effectivewhen that attribute is available (i.e. after a call tofit()orset_model()), otherwise all detected peaks are returned. Pass an explicit integer to override.mass_level (float, optional) – Fraction of basin mass to enclose in the equal-tail interval (
"peak_mass"mode only). Default 0.68 (~1 sigma).classify_lsp (bool, optional) – If
True, flag peaks whose period ratio to the dominant peak falls within the Long Secondary Period range (5-15) and whose basin area fraction exceeds 0.05. DefaultFalse.
- Returns:
summary – Dictionary with keys:
component_periods- raw kernel component periodscomponent_weights- raw kernel component weightscomponent_period_scales- raw kernel period widthscomponent_frequencies- raw kernel component freqscomponent_frequency_scales- raw kernel frequency widthsfreq_grid- evaluation grid (Nonefor non-PSD backends)psd- PSD values (Nonefor non-PSD backends)dominant_frequency- frequency of the dominant peak (Nonefor non-periodic models)dominant_period-1 / dominant_frequency(Nonefor non-periodic models)period_interval_fwhm_like-(period_lo, period_hi)uncertainty interval (Nonefor non-periodic models; kept for backward compatibility)period_interval- same asperiod_interval_fwhm_like(generic key independent of uncertainty method)interval_definition- string describing the interval typeq_factor- coherence Q (Noneif not defined)peak_fraction- dominant peak height / total weightn_significant_peaks- peaks above thresholdsignificant_periods- periods of significant peaksmethod- string identifying the backend usednotes- additional diagnostic notes
- Return type:
dict
- Raises:
RuntimeError – If the model has not been initialised.
NotImplementedError – If an unsupported
uncertaintymethod is requested.
- Periodic-plus-stochastic (
- get_periods()¶
Returns a list of the periods, scales and weights of the model. This is useful for getting the periods after training, for example.
- get_priors()¶
Return the priors currently registered on the model.
Iterates over all priors registered on the model (via GPyTorch’s
named_priors) and returns a dictionary mapping each prior name to the corresponding prior object. A formatted summary is also printed to standard output.- Returns:
A dictionary mapping prior names (str) to their
gpytorch.priors.Priorobjects. Returns an empty dict if no priors have been registered.- Return type:
dict
- Raises:
RuntimeError – If the model has not been set yet (call
set_model()first).
See also
Examples
lc.set_model("1D", num_mixtures=4) lc.set_default_priors() priors = lc.get_priors()
- init_hypers_from_LombScargle(**kwargs)¶
- property magnitudes¶
- mcmc(sampler=None, num_samples=500, warmup_steps=100, num_chains=1, disable_progbar=False, max_cg_iterations=None, cuda=False, **kwargs)¶
Run an MCMC sampler on the model
This function runs an MCMC sampler on the model, using the sampler specified in the sampler attribute. The results are stored in the mcmc_results attribute.
- Parameters:
sampler (str or MCMC, optional) –
The name of the sampler to use. If None, pyro.infer.mcmc.NUTS will be used. If a string, it must be one of the following:
’NUTS’: pyro.infer.mcmc.NUTS ‘HMC’: pyro.infer.mcmc.HMC
Otherwise, it must be an instance of pyro.infer.mcmc.MCMC.
num_samples (int, optional) – The number of samples to draw from the posterior, by default 500.
warmup_steps (int, optional) – The number of warmup steps to use, by default 100.
disable_progbar (bool, optional) – Whether to disable the progress bar, by default False.
**kwargs (dict, optional)
- Returns:
mcmc_results – A dictionary containing the results of the MCMC sampling. The keys are the names of the parameters, and the values are the samples of the parameters.
- Return type:
dict
- merge(other, *, band=None, wavelength=None, on_conflict='raise')¶
Merge other into this light curve, appending new band(s).
- Parameters:
other (Lightcurve, str, or pathlib.Path) – The light curve (or CSV path) to merge. Must not be a list; for multiple inputs use
concat().band (str or array-like of str, optional) – Band label(s) to assign to other when other has no
bandattribute set. For a 1-D other this must be a scalar string; for a 2-D other this must have the same length as other.wavelength (float, optional) – Wavelength to assign when other is 1-D. Must not be provided for 2-D inputs.
on_conflict ({"raise", "skip"}, optional) – Action taken when a band label or wavelength in other already exists in
self."raise"(default) raises aValueError;"skip"silently drops that constituent band and emits aUserWarning.
- Returns:
A new 2-D
Lightcurvecontaining the rows ofselffollowed by the non-conflicting rows from other. The result is always unfitted (no model or posterior state).- Return type:
- Raises:
TypeError – If other is a list (use
concat()instead), or if other is not aLightcurve,str, orpathlib.Path.ValueError – If
selfis not 2-D.ValueError – If a conflict is detected and on_conflict is
"raise".ValueError – If wavelength is provided for a 2-D other.
ValueError – If other is 1-D and wavelength is not provided.
ValueError – If other is 1-D but band does not resolve to exactly one unique label.
- property ndim¶
- plot(ylim=None, yscale='auto', show=True, mcmc_samples=False, n_pred=1000, **kwargs)¶
Plot the model and data
- Parameters:
ylim (list, optional) – The y-limits of the plot, by default None. If None, the y-limits will be set automatically. For 2-D (multiwavelength) data the limits are determined independently for each wavelength.
yscale (str, optional) – The y-axis scale to use. Can be
'auto'(default),'linear'or'log'. When'auto', log scale is chosen for a given wavelength if all its flux values are positive and the ratio of maximum to minimum flux exceeds 100; otherwise linear scale is used. For 2-D data the scale is decided independently per wavelength. Note that whenmcmc_samplesisTrue, this parameter is currently ignored and the y-axis scale is set by the MCMC plotting routine.show (bool, optional) – Whether to show the plot, by default True.
mcmc_samples (bool, optional) – Whether to plot the samples from the MCMC run, by default False. This will only work if the MCMC sampler has been run.
n_pred (int, optional) – Number of prediction points used to construct the fine time grid for plotting. Lower values reduce memory usage and speed up plotting, especially for 2D light curves. Default is 1000.
**kwargs (dict, optional) – Any other keyword arguments to be passed to the plotting routine.
- Returns:
fig – The figure object of the plot. For 2-D (multiwavelength) data a list of figures is returned, one per wavelength.
- Return type:
matplotlib.pyplot.Figure or list of matplotlib.pyplot.Figure
- plot_acf(method='data', ax=None, **kwargs)¶
Plot the autocorrelation function of the light curve.
Calls
acf()and plots the result.- Parameters:
method ({"data", "gp"}, optional) – Which ACF to compute and plot. Default is
"data".ax (matplotlib.axes.Axes or None, optional) – Axes to draw on. If
None, a new figure and axes are created.**kwargs – Additional keyword arguments passed to
acf().
- Returns:
The axes with the ACF plotted.
- Return type:
matplotlib.axes.Axes
Examples
>>> ax = lc.plot_acf(method="data") >>> ax = lc.plot_acf(method="gp", n_lags=500)
- plot_corner(kind='scatter', var_names=None, filter_vars='like', marginals=True, point_estimate='median', **kwargs)¶
Plot a corner plot of the results of the MCMC sampling
- Parameters:
kind (str, optional) – The kind of plot to use, based on arviz.plot_pair. If None, the default behaviour of arviz.plot_pair will be used, by default ‘scatter’. Other options are ‘kde’ and ‘hexbin’.
var_names (list, optional) – A list of the names of the variables to include in the corner plot. If None, the variables for the mean function and the covariance function will be included, by default None.
filter_vars (str, optional) – A string specifying how to filter the variables, based on arviz.plot_pair. If None, the default behaviour of arviz.plot_pair will be used, by default ‘like’.
marginals (bool, optional) – Whether to include the marginal distributions, by default True.
point_estimate (str, optional) – The point estimate to plot, based on arviz.plot_pair. If None, no point estimate will be plotted, by default ‘median’.
- plot_period_summary(summary=None, show=True, log_freq=True, show_full_psd=None, max_peaks_to_mark=3, log_y=True, close=False, **kwargs)¶
Plot the period summary from
get_period_summary().Produces a matplotlib figure appropriate for the type of period summary:
Spectral-mixture PSD summary with a single analyzed peak (
PeriodSummaryResult,n_peaks_analyzed == 1): generates a single peak-centered panel zoomed in on the dominant peak. Passshow_full_psd=Trueto add a second full-range PSD panel.Spectral-mixture PSD summary with structured peaks (
PeriodSummaryResult,n_peaks_analyzed > 1): generates a multi-panel figure with the full PSD in the top panel and one zoomed panel per analyzed peak below. Each peak is labeled P1, P2, … with a distinct color.Spectral-mixture PSD summary (plain dict): plots the PSD curve with the dominant peak and dotted lines for other significant peaks.
Explicit-period summary (e.g. quasi-periodic): plots a single vertical line at the dominant frequency with an annotated period, interval, and Q-factor. No PSD curve is drawn because none is computed for this backend.
Non-periodic summary: produces a simple figure with explanatory text stating that no dominant period is defined for this kernel.
The figure type is determined by
summary["method"]and by whethersummary["freq_grid"]isNone.- Parameters:
summary (dict or None, optional) – Output of
get_period_summary(). IfNone, it is computed automatically. Extra keyword arguments (**kwargs) are forwarded toget_period_summary().show (bool, optional) – If
True(default), callplt.show(). IfFalse, return(fig, ax)for further customisation.log_freq (bool, optional) – If
True(default), plot the x-axis (frequency) on a log scale. Ignored for non-periodic summaries.log_y (bool, optional) – If
True(default), plot the y-axis (PSD) on a log scale. The lower y-axis limit is clamped automatically so that at most 10 decades below the maximum PSD value in each panel are shown, preventing near-zero noise from compressing the useful range. Set toFalseto use a linear y-axis. Ignored for non-periodic summaries and for panels where no PSD is drawn.show_full_psd (bool or None, optional) – Controls whether a full-range PSD panel is included in the single-peak case. When
None(default), a full-range panel is not added in single-peak mode (the main panel is already peak-centered) but is included in multi-peak mode. Set toTrueto force a full-range panel even in single-peak mode; set toFalseto suppress it even in multi-peak mode.max_peaks_to_mark (int, optional) – Maximum number of peaks to mark on the plot. In multi-peak mode this also limits the number of zoom panels created. Default is
3.close (bool, optional) – If True and show=True, close the figure immediately after displaying it. This is useful in notebooks or loops where many figures are generated. Ignored when show=False, because the figure is returned to the caller.
**kwargs – Additional keyword arguments forwarded to
get_period_summary()whensummaryisNone.
- Returns:
fig, ax – Returned when
show=False; otherwiseNone. For the multi-panel caseaxis the top axes.- Return type:
matplotlib.figure.Figure, matplotlib.axes.Axes
- plot_psd(freq=None, means=None, scales=None, weights=None, show=True, raw=False, log=(True, False), truncate_psd=True, logpsd=False, mcmc_samples=False, **kwargs)¶
Plot the power spectral density of the model
- Parameters:
freq (array_like, optional) – The frequencies at which to compute the PSD, by default None. If None, the frequencies will be computed automatically.
means (array_like, optional) – The means of the gaussians in the spectral mixture kernel, by default None. If None, the means from the model will be used.
scales (array_like, optional) – The scales of the gaussians in the spectral mixture kernel, by default None. If None, the scales from the model will be used.
weights (array_like, optional) – The weights of the gaussians in the spectral mixture kernel, by default None. If None, the weights from the model will be used.
show (bool, optional) – Whether to show the plot, by default True.
raw (bool, optional) – If True, the PSD will be computed in the space that the model was trained in, by default False. If False, the PSD will be computed in the original space of the data.
log (tuple, optional) – A tuple of two booleans, indicating whether to plot the x-axis and y-axis on a log scale, respectively, by default (True, False).
truncate_psd (float or bool, optional) – If not False, the PSD will be truncated at this value, by default True. This is useful for speeding up plotting when the frequency range is large. If logpsd is True, this value should be given in (natural) log space. If truncate_psd is True, the PSD will be truncated at 1e-6 times the maximum PSD for logpsd=False, and 1e-15 of the maximum PSD (i.e. max(ln(psd)) - 34.5388) for logpsd=True.
logpsd (bool, optional) – If True, the PSD will be plotted on a log scale, by default False. If True, truncate_psd must be given in (natural) log space.
mcmc_samples (bool, optional) – If True, many sample PSDs will be plotted using the MCMC samples, by default False. This will only work if the model has been fitted using MCMC.
**kwargs (dict, optional) – Any other keyword arguments to be passed to the plotting routine.
- Returns:
fig, ax – The figure and axes objects of the plot.
- Return type:
matplotlib.pyplot.Figure, matplotlib.pyplot.Axes
- plot_results()¶
- plot_trace(var_names=None, filter_vars='like', figsize=None, **kwargs)¶
Plot a trace plot of the results of the MCMC sampling
- Parameters:
var_names (list, optional) – A list of the names of the variables to include in the trace plot. If None, the variables for the mean function and the covariance function will be included, by default None.
- print_parameters(raw=False)¶
Prints the parameters of the model, with the keys being the names of the parameters and the values being the values of the parameters. This is useful for getting the values of the parameters after training, for example.
- Parameters:
raw (bool, default False) – If True, prints the raw values of the parameters, otherwise prints the constrained values of the parameters.
- print_periods()¶
- print_results()¶
- select_bands(bands: list | tuple | ndarray) Lightcurve¶
Return a new Lightcurve containing only the requested bands.
Bands are identified exclusively through the
bandattribute. Wavelength values play no role in selection.- Parameters:
bands (list, tuple, or numpy.ndarray) – A sequence of string band labels to select. Each element must be a
strornumpy.str_; the value is coerced tostrbefore comparison so numpy string scalars are handled naturally.bytes, numeric types, andNoneare rejected.- Returns:
A new
Lightcurveobject built from the subset of rows whosebandmatches at least one of the requested labels. Thename,xtransform, andytransformattributes are inherited from the original light curve, and the subsettedbandarray is preserved.- Return type:
- Raises:
TypeError – If bands is not a
list,tuple, ornumpy.ndarray.TypeError – If bands is a bare string (use
["label"]instead).TypeError – If any element of bands is not a
strornumpy.str_(e.g.bytes,int,float,None, or a nested list).ValueError – If
bandisNone.ValueError – If none of the requested labels are present in
band.
- set_constraint(constraint, debug=False, **kwargs)¶
Set the constraint for the model parameters
- Parameters:
constraint (dict, optional) – A dictionary of the constraints to use for the model parameters. The keys should be the names of the parameters, and the values should be instances of gpytorch.constraints.Constraint. If None, no constraints will be used. If a constraint is passed for a parameter that is not a model parameter, it will be ignored.
**kwargs (dict, optional) – Any other keyword arguments to be passed to the Constraint constructors.
- set_default_constraints(constraint_set=None, **kwargs)¶
Set the default constraints for the model and likelihood parameters
- The default constraints are as follows:
All parameters are constrained to be positive, except the mean of
the GP, which is constrained to be in the range of the y-data (a correction will be needed if the data are censored!) - The noise is constrained to be less than the standard deviation of the y-data, and greater than either 1e-4 or 1/10 of the smallest uncertainty on the y-data, if uncertainties are given, or 1e-4 times the standard deviation of the y data. - The mixture means greater than the frequency corresponding to the separation between the earliest and latest points in the data and less than the frequency corresponding to the separation between the two closest data points (should be updated to account for the window function and whatever we’re really sensitive to) - The mixture scales and weights are left with their default constraints as defined in GPyTorch.
- Parameters:
constraint_set (str or None, optional) –
Name of a pre-defined source-type constraint set to apply on top of the default constraints. When provided, the constraints defined for the named set (see
pgmuvi.constraints.CONSTRAINT_SETS) are merged into the default mixture-means constraint. Currently supported values:"LPV"Long-Period Variable stars. Enforces a lower period limit of 20 in the same time units as the input
xdata(typically interpreted as 20 days for LPV light curves) so that the fit is not pulled toward unphysically short periods. Ifxdatais provided in different time units, this numerical limit applies in those units.
Pass
None(the default) to use only the data-driven defaults.**kwargs (dict, optional) – Any keyword arguments to be passed to the Constraint constructors.
- set_default_priors(prior_set=None, **kwargs)¶
Set the default priors for the model and likelihood parameters
- The default priors are as follows:
Parameters that must be positive are given LogNormal, HalfNormal
or HalfCauchy priors, depending on the parameter. - The noise is given a HalfNormal prior with a scale of 1/10 of the smallest uncertainty on the y-data, if uncertainties are given, or 1/10 of the standard deviation of the y data. - The mean of the GP is given a Gaussian prior with a mean of the mean of the y-data and a standard deviation of 1/10 of the standard deviation of the y-data. - For spectral-mixture models the mixture means, scales and weights receive LogNormal(0, 1) priors. - If prior_set is provided,
set_period_prior()is called with that prior set to register a physically motivated prior on the period/frequency parameter of the model.
- Parameters:
prior_set (str or None, optional) – Name of a predefined prior set to apply to the period/frequency parameter (e.g.
"LPV"). IfNone(default), no period prior is added. Seeset_period_prior()andPRIOR_SETSfor available options.**kwargs (dict, optional) – Any keyword arguments to be passed to the Prior constructors.
- set_hypers(hypers=None, debug=False, **kwargs)¶
Set the hyperparameters for the model and likelihood. This is a convenience function that calls the model.initialize() to set the hyperparameters. However, first it applies any transforms to the hyperparameters, so that the user can pass the hyperparameters in the original data space if they wish.
- Parameters:
hypers (dict, optional) – A dictionary of the hyperparameters to use for the model and likelihood. The keys should be the names of the parameters, and the values should be Tensors containing the values of the parameters. If None, no hyperparameters will be set. If a hyperparameter is passed for a parameter that is not a model or likelihood parameter, it will be ignored.
**kwargs (dict, optional) – Any other keyword arguments to be passed to the initialize.
- set_likelihood(likelihood=None, variance=False, **kwargs)¶
Set the likelihood function for the model
- Parameters:
likelihood (string, None or instance of) –
- gpytorch.likelihoods.likelihood.Likelihood or Constraint,
optional
The likelihood function to use for the GP, by default None.
If
likelihoodisNoneand per-point uncertainties on the data are available (i.e.yerrhas been set), agpytorch.likelihoods.FixedNoiseGaussianLikelihoodis constructed and given a tensor of noise variances derived from those uncertainties. IflikelihoodisNoneand no uncertainties are available, a standardgpytorch.likelihoods.GaussianLikelihoodis used.If a string, it must be
'learn'. When'learn'is used and uncertainties are available, agpytorch.likelihoods.FixedNoiseGaussianLikelihoodis created with the same noise variance tensor and withlearn_additional_noise=True. If'learn'is used and no uncertainties are available, agpytorch.likelihoods.GaussianLikelihoodis created withlearn_additional_noise=True.If an instance of a
Likelihoodobject is passed, that object is used directly. If a Constraint object is passed, agpytorch.likelihoods.GaussianLikelihoodis constructed with the constraint passed as thenoise_constraintargument; this overrides any other keyword arguments to the likelihood.You can also provide a likelihood class (rather than an instance), in which case the class will be instantiated with the provided
kwargsunder the assumption that it is aLikelihoodsubclass. If per-point uncertainties are available, a first positional argument will also be passed containing the noise tensor. This tensor is in units of variance by default (see thevarianceparameter below).variance (bool, optional) –
Controls how stored per-point uncertainties are interpreted when constructing the noise tensor passed to likelihoods that require per-observation noise (e.g.
gpytorch.likelihoods. FixedNoiseGaussianLikelihoodor user-supplied likelihood classes that accept a noise argument).If
False(default), the uncertainties stored in the lightcurve are assumed to be errors (standard deviations). They are squared to produce noise variances before being passed to the likelihood.If
True, the stored uncertainties are assumed to already be variances and are passed through unchanged as the noise tensor.
- set_model(model=None, likelihood=None, num_mixtures=None, variance=False, **kwargs)¶
Set the model for the lightcurve
- Parameters:
model –
The model to use for the GP, by default None. If None, an error will be raised. If a string, it must be one of the following:
- Spectral mixture models (default):
’1D’: SpectralMixtureGPModel ‘2D’: TwoDSpectralMixtureGPModel ‘1DLinear’: SpectralMixtureLinearMeanGPModel ‘2DLinear’: TwoDSpectralMixtureLinearMeanGPModel ‘1DSKI’: SpectralMixtureKISSGPModel ‘2DSKI’: TwoDSpectralMixtureKISSGPModel ‘1DLinearSKI’: SpectralMixtureLinearMeanKISSGPModel ‘2DLinearSKI’: TwoDSpectralMixtureLinearMeanKISSGPModel ‘2DPowerLaw’: TwoDSpectralMixturePowerLawMeanGPModel ‘2DPowerLawSKI’: TwoDSpectralMixturePowerLawMeanKISSGPModel ‘2DDust’: TwoDSpectralMixtureDustMeanGPModel ‘2DDustSKI’: TwoDSpectralMixtureDustMeanKISSGPModel
- Alternative 1D models:
’1DQuasiPeriodic’: QuasiPeriodicGPModel ‘1DMatern’: MaternGPModel ‘1DPeriodicStochastic’: PeriodicPlusStochasticGPModel ‘1DLinearQuasiPeriodic’: LinearMeanQuasiPeriodicGPModel
- Separable 2D models:
’2DSeparable’: SeparableGPModel ‘2DAchromatic’: AchromaticGPModel ‘2DWavelengthDependent’: WavelengthDependentGPModel ‘2DDustMean’: DustMeanGPModel ‘2DPowerLawMean’: PowerLawMeanGPModel
- likelihoodstring, None or instance of
gpytorch.likelihoods.likelihood.Likelihood or Constraint, optional
If likelihood is passed, it will be passed along to set_likelihood() and used to set the likelihood function for the model. For details, see the documentation for set_likelihood().
- num_mixturesint, optional
The number of mixtures to use in the spectral mixture kernel, by default None. If None, a default value will be used. This value is passed to the constructor for the model if a string is passed as the model argument.
- variancebool, optional
Passed to set_likelihood(). If False (default), stored uncertainties are treated as errors and squared before being used as noise variances. Set to True if the stored uncertainties already represent variances.
- **kwargsdict, optional
Any other keyword arguments to be passed to the model constructor.
- set_period_prior(prior_set=None, prior_type='lognormal', mu=5.0, sigma=1.0, mean=300.0, std=75.0, lower_period=None, upper_period=None, period=True)¶
Set a prior on the period or frequency parameter of the model.
This method detects whether the model represents periodicity as a period (e.g.
period_lengthinQuasiPeriodicGPModel) or as a frequency (e.g.mixture_meansinSpectralMixtureGPModel) and registers an appropriate prior on the relevant parameter.For frequency-based models the period-space prior is transformed to frequency space with the correct change-of-variables Jacobian (see
LogNormalFrequencyPriorandNormalFrequencyPrior).Models with no periodicity parameter (e.g.
MaternGPModel) are silently skipped with a warning.- Parameters:
prior_set (str or None, optional) – Name of a predefined prior set (e.g.
"LPV"). When given, theprior_type,mu,sigma,mean,stdandlower_period/upper_perioddefaults are taken fromPRIOR_SETS. Any explicitly supplied keyword arguments override the prior-set values.prior_type (str, optional) – Which prior family to use. Either
"lognormal"(the default, LogNormal in period space withmuandsigma) or"normal"(Normal in period space withmeanandstd). Case-insensitive.mu (float, optional) – Mean of the underlying normal distribution for the Log-Normal period prior (i.e. the log-mean). Default
5.0(median period ≈ 148 days). Dimensionless (logarithmic units).sigma (float, optional) – Standard deviation of the underlying normal distribution for the Log-Normal period prior (i.e. the log-standard-deviation). Default
1.0. Dimensionless (logarithmic units).mean (float, optional) – Mean for the Normal period prior (days). Default
300.0.std (float, optional) – Standard deviation for the Normal period prior (days). Default
75.0.lower_period (float or None, optional) – Lower bound on period. When
period=True(default), this is in days (the assumed time unit of the data). Whenperiod=Falsethis is a lower bound in frequency units (1/days). Values outside this bound receive-inflog-prob. IfNoneand a prior_set is provided, the bound is taken from the prior set.upper_period (float or None, optional) – Upper bound on period (days when
period=True, 1/days whenperiod=False).period (bool, optional) – Controls the interpretation of
lower_periodandupper_periodfor frequency-parameterised models (i.e. spectral-mixture models whose periodicity is encoded asmixture_means). IfTrue(default), bounds are in period units (days). IfFalse, bounds are in frequency units (1/days). Has no effect for period-parameterised models (e.g.QuasiPeriodicGPModel), which always use period units.
- Raises:
ValueError – If prior_set is not a recognised name or if prior_type is not
"lognormal"or"normal".
Notes
The model must have been set (via
set_model()orfit()) before calling this method.For spectral-mixture models the prior is registered on
mixture_meansand applies element-wise to all mixture components.For quasi-periodic models the prior is registered on each
period_lengthparameter found in the model (there is typically only one).See also
pgmuvi.priors.LogNormalPeriodPrior,pgmuvi.priors.LogNormalFrequencyPrior,pgmuvi.priors.NormalPeriodPrior,pgmuvi.priors.NormalFrequencyPrior,pgmuvi.priors.PRIOR_SETSExamples
Set the LPV default prior on a spectral-mixture model:
lc.set_model("1D", num_mixtures=4) lc.set_period_prior(prior_set="LPV")
Set a Normal period prior explicitly:
lc.set_model("1DQuasiPeriodic") lc.set_period_prior(prior_type="normal", mean=300.0, std=75.0, lower_period=100.0)
- set_prior(prior=None, **kwargs)¶
Set the prior for the model parameters
- Parameters:
prior (dict, optional) – A dictionary of the priors to use for the model parameters. The keys should be the names of the parameters, and the values should be instances of gpytorch.priors.Prior. If None, no priors will be used. If a prior is passed for a parameter that is not a model parameter, it will be ignored.
**kwargs (dict, optional) – Any other keyword arguments to be passed to the Prior constructors.
- summary(prob=0.683, use_arviz=True, var_names=None, filter_vars='like', stat_focus='median', **kwargs)¶
Print a summary of the results of the MCMC sampling
- Parameters:
prob (float, optional) – The probability to use for the credible intervals, by default 0.683.
use_arviz (bool, optional) – Whether to use arviz to print the summary, by default True.
var_names (list, optional) – A list of the names of the variables to include in the summary. If None, the variables for the mean function and the covariance function will be included, by default None.
filter_vars (str, optional) – A string specifying how to filter the variables, based on arviz.summary. If None, the default behaviour of arviz.summary will be used, by default ‘like’.
stat_focus (str, optional) – A string specifying which statistic to focus on, based on arviz.summary. If None, the default behaviour of arviz.summary will be used (‘mean’), by default ‘median’.
- to_csv(filepath: str | Path = 'lightcurve.csv') None¶
Write lightcurve data to a CSV file.
The output always includes
time,wavelength, andfluxcolumns.flux_errorandbandare included when present on the instance. For 1-D lightcurves (time-onlyxdata),wavelengthis written as0.0for each row.- Parameters:
filepath (str or pathlib.Path, optional) – Destination CSV path. The file is created or overwritten. Default is
"lightcurve.csv".
- to_table()¶
Create an astropy table with the results.
- Parameters:
none
- Returns:
tab_results – Astropy table with the results.
- Return type:
astropy.table.Table
- transform_x(values)¶
- transform_y(values)¶
- write_period_summary_outputs(text_file=None, png_file=None, json_file=None, summary=None, show=False, close_figure=True, include_components=True, include_peaks=True, include_psd_info=False, include_psd_in_json=False, summary_kwargs=None, plot_kwargs=None)¶
Write period-summary outputs (text, PNG, JSON) to disk.
This is a high-level convenience wrapper around:
get_period_summary()— computes the summary if not suppliedPeriodSummaryResult.write_text()— human-readable text report_save_period_summary_figure()— period-summary figure (PNG)PeriodSummaryResult.write_json()— machine-readable JSON export
The method writes only the files whose paths are provided. Pass
text_file,png_file, and/orjson_filein any combination.- Parameters:
text_file (str, Path-like, or None, optional) – If given, the human-readable period-summary text is written here. The output is intended for direct reading by a researcher: it includes the dominant period, peak table, kernel-component diagnostics, and (optionally) PSD grid information.
png_file (str, Path-like, or None, optional) – If given, the period-summary figure is saved here. The PNG is a visualisation of the analyzed peak structure produced by
plot_period_summary().json_file (str, Path-like, or None, optional) – If given, a machine-readable JSON export is written here. The JSON contains the same information as the text report plus the raw array data (unless include_psd_in_json is
False).summary (dict or PeriodSummaryResult or None, optional) – A pre-computed period summary returned by
get_period_summary(). IfNone(default) the summary is computed by callingget_period_summary(**summary_kwargs). Supplying a pre-computed summary avoids redundant computation when multiple output files are requested.show (bool, optional) – Passed through to
plot_period_summary(). Ignored when png_file isNone. Default isFalse.close_figure (bool, optional) – If
True(default), close the matplotlib figure after saving. Set toFalseto keep the figure in memory for further inspection.include_components (bool, optional) – Forwarded to
PeriodSummaryResult.write_text(). Controls whether the kernel-component diagnostics block appears in the text output. Default isTrue.include_peaks (bool, optional) – Forwarded to
PeriodSummaryResult.write_text(). Controls whether the analyzed-peaks block appears in the text output. Default isTrue.include_psd_info (bool, optional) – Forwarded to
PeriodSummaryResult.write_text(). Controls whether PSD grid statistics appear in the text output. Default isFalse.include_psd_in_json (bool, optional) – Forwarded to
PeriodSummaryResult.write_json(). WhenTruethe full frequency grid and PSD arrays are embedded in the JSON file. Default isFalse(arrays are omitted to keep the file small).summary_kwargs (dict or None, optional) – Extra keyword arguments forwarded to
get_period_summary()when summary isNone. Ignored if summary is supplied.plot_kwargs (dict or None, optional) – Extra keyword arguments forwarded to
plot_period_summary()(and thus to_save_period_summary_figure()). Ignored when png_file isNone.
- Returns:
The period summary (computed or passed in).
- Return type:
PeriodSummaryResult or dict
Examples
Write all three output types in one call:
lc.write_period_summary_outputs( text_file="results/summary.txt", png_file="results/summary.png", json_file="results/summary.json", )
Reuse an existing summary to avoid recomputation:
s = lc.get_period_summary() lc.write_period_summary_outputs( summary=s, text_file="results/summary.txt", png_file="results/summary.png", )
- write_votable(filename)¶
Write the results to a votable file.
- Parameters:
filename (str) – The name of the file to write to.
- property xdata¶
The independent variable data
- Getter:
Returns the independent variable data in its raw
(untransformed) state :setter: Takes the input data and transforms it as requested by the user :type: torch.Tensor
- property ydata¶
The dependent variable data
- Getter:
Returns the dependent variable data in its raw
(untransformed) state :setter: Takes the input data and transforms it as requested by the user :type: torch.Tensor
- property yerr¶
The uncertainties on the dependent variable data
- Getter:
Returns the uncertainties on the dependent variable data in
its raw (untransformed) state :setter: Takes the input data and transforms it as requested by the user :type: torch.Tensor
- class pgmuvi.lightcurve.MinMax¶
Bases:
Transformer- inverse(data, shift=True, **kwargs)¶
Invert a MinMax transformation based on saved state
Invert the transformation of the data from the [0,1] interval. It used the stored min and range of the data for the inverse transformation.
- Parameters:
data (Tensor of floats) – The data to be reverse-transformed
- transform(data, dim=0, apply_to=None, recalc=False, shift=True, **kwargs)¶
Perform a MinMax transformation
Transform the data such that each dimension is rescaled to the [0,1] interval. It stores the min and range of the data for the inverse transformation.
- Parameters:
data (Tensor of floats) – The data to be transformed
apply_to (tensor of ints or slice objects, optional) – Which dimensions to apply the transform to. If None, apply to all
recalc (bool, default False) – Should the min and range of the transform be recalculated, or reused from previously?
shift (bool, default True) – Should the data be shifted such that the minimum value is 0? This is mainly included so that data or parameters can be transformed when they apply to a single period - in this case, only the range needs to be applied.
- class pgmuvi.lightcurve.PeriodPeakResult(rank: int = 1, frequency: float = nan, period: float = nan, height: float = nan, prominence: float = nan, area_fraction: float = nan, interval_frequency: tuple = (nan, nan), interval_period: tuple = (nan, nan), period_ratio_to_primary: float = 1.0, is_candidate_lsp: bool = False, notes: str = '', coherence_proxy: float = nan)¶
Bases:
objectA single PSD peak from
Lightcurve.get_period_summary().- area_fraction: float = nan¶
- as_dict() dict¶
- coherence_proxy: float = nan¶
- frequency: float = nan¶
- height: float = nan¶
- interval_frequency: tuple = (nan, nan)¶
- interval_period: tuple = (nan, nan)¶
- is_candidate_lsp: bool = False¶
- notes: str = ''¶
- period: float = nan¶
- period_ratio_to_primary: float = 1.0¶
- prominence: float = nan¶
- rank: int = 1¶
- class pgmuvi.lightcurve.PeriodSummaryResult(method='', model_name='', n_peaks_detected=0, n_peaks_analyzed=0, n_peaks_requested=None, dominant_period=None, dominant_frequency=None, peaks=None, freq_grid=None, psd=None, notes='', component_diagnostics=None, interval_definition='peak_centered_68pct_mass_interval', backend='', kernel_family='', time_kernel_family='', has_stochastic_background=False, q_factor=None)¶
Bases:
objectStructured result from
Lightcurve.get_period_summary().- as_dict() dict¶
- get(key, default=None)¶
- get_primary_peak()¶
Return the primary (rank-1) peak, or
Noneif none exist.- Returns:
The first entry in
peaks(sorted by ascending rank, so rank 1 is always first), orNonewhenpeaksis empty.- Return type:
PeriodPeakResult or None
- get_significant_peaks(threshold=0.68)¶
Return peaks whose area fraction meets or exceeds threshold.
- Parameters:
threshold (float, optional) – Minimum
area_fractionto qualify as significant. Default is0.68(~1 sigma).- Returns:
Peaks from
peaks(in rank order) for whichpeak.area_fraction >= threshold. Peaks with NaN area fraction are excluded.- Return type:
list of PeriodPeakResult
- get_top_n_peaks(n)¶
Return up to n peaks in ascending rank order.
- Parameters:
n (int) – Maximum number of peaks to return.
- Returns:
A slice of
peaksof lengthmin(n, len(peaks)).- Return type:
list of PeriodPeakResult
- items()¶
- keys()¶
- to_table() list¶
- to_text(include_components=True, include_peaks=True, include_psd_info=False, max_peaks_to_show=3) str¶
Return a human-readable text summary of this period result.
The text is plain UTF-8 text, suitable for writing to a
.txtfile, reading in a terminal, or storing alongside analysis outputs. It clearly separates analyzed peak results (the literature-comparable outputs) from kernel component diagnostics (internal quantities derived directly from GP hyperparameters).- Parameters:
include_components (bool, optional) – If
True(default), include a section listing the kernel component periods, frequencies, and weights. These are diagnostic quantities and should not be cited as final period determinations.include_peaks (bool, optional) – If
True(default), include one block per analyzed peak.include_psd_info (bool, optional) – If
True, include a short summary of the PSD grid (existence, length, frequency range, PSD range). The full arrays are never dumped. Default isFalse.max_peaks_to_show (int, optional) – Maximum number of peaks to show in detail. The primary peak is always shown first; up to
max_peaks_to_show - 1additional peaks follow. If more peaks exist, a count line is appended. Default is3.
- Returns:
Formatted text summary.
- Return type:
str
- values()¶
- write_json(filename, include_psd=False)¶
- write_text(filename, include_components=True, include_peaks=True, include_psd_info=False)¶
Write a human-readable text summary to filename.
Calls
to_text()and writes the result to disk.- Parameters:
filename (str or Path-like) – Destination file path. The file is created or overwritten.
include_components (bool, optional) – Forwarded to
to_text(). Default isTrue.include_peaks (bool, optional) – Forwarded to
to_text(). Default isTrue.include_psd_info (bool, optional) – Forwarded to
to_text(). Default isFalse.
- Returns:
The path to the file that was written, constructed from filename via
pathlib.Path. If filename is a relative path, the returned value is also relative.- Return type:
pathlib.Path
- class pgmuvi.lightcurve.RobustZScore¶
Bases:
Transformer- inverse(data, shift=True, **kwargs)¶
Invert a robust z-score transformation based on saved state
Invert the robust z-scoring of the data based on the saved median and median absolute deviation.
- Parameters:
data (Tensor of floats) – The data to be reverse-transformed
- transform(data, dim=0, apply_to=None, recalc=False, shift=True, **kwargs)¶
Perform a robust z-score transformation
Transform the data such that each dimension is rescaled such that its median is 0 and its median absolute deviation is 1.
- Parameters:
data (Tensor of floats) – The data to be transformed
apply_to (int or tensor of ints, optional) – Which dimensions to apply the transform to. If None, apply to all
recalc (bool, default False) – Should the parameters of the transform be recalculated, or reused from previously?
shift (bool, default True) – Should the data be shifted such that the median value is 0? This is mainly included so that data or parameters can be transformed when they apply to a single period - in this case, only the median absolute deviation needs to be applied.
- class pgmuvi.lightcurve.Transformer¶
Bases:
Module- inverse(data, shift=True, **kwargs)¶
Invert a transform based on saved parameters
This is a baseclass with no implementation, your subclass should implement the inverse transform itself
- transform(data, **kwargs)¶
Transform some data and return it, storing the parameters required to repeat or reverse the transform
This is a baseclass with no implementations, your subclass should implement the transform itself
- class pgmuvi.lightcurve.ZScore¶
Bases:
Transformer- inverse(data, shift=True, **kwargs)¶
Invert a z-score transformation based on saved state
Invert the z-scoring of the data based on the saved mean and standard deviation
- Parameters:
data (Tensor of floats) – The data to be reverse-transformed
- transform(data, dim=0, apply_to=None, recalc=False, shift=True, **kwargs)¶
Perform a z-score transformation
Transform the data such that each dimension is rescaled such that its mean is 0 and its standard deviation is 1.
- Parameters:
data (Tensor of floats) – The data to be transformed
apply_to (int or tensor of ints, optional) – Which dimensions to apply the transform to. If None, apply to all
recalc (bool, default False) – Should the parameters of the transform be recalculated, or reused from previously?
shift (bool, default True) – Should the data be shifted such that the mean value is 0? This is mainly included so that data or parameters can be transformed when they apply to a single period - in this case, only the standard deviation needs to be applied.
- pgmuvi.lightcurve.dict_walk_generator(indict, pre=None)¶
- pgmuvi.lightcurve.minmax(data, dim=0)¶