specparam.data.data.Data

class specparam.data.data.Data(check_freqs=True, check_data=True, format='power', model=None)[source]

Object for managing data for spectral parameterization - for 1D data.

Parameters:
check_freqsbool

Whether to check the frequency values. If so, raises an error for uneven spacing.

check_databool

Whether to check the spectral data. If so, raises an error for any NaN / Inf values.

format{‘power’}

The representation format of the data.

modelSpectralModel, optional

The model object this object is linked to, to provide access to other attributes.

Attributes:
checksdict

Specifiers for which aspects of the data to run checks on.

freqs1d array

Frequency values for the spectral data.

freq_rangelist of [float, float]

Frequency range of the spectral data, as [lowest_freq, highest_freq].

freq_resfloat

Frequency resolution of the spectral data.

power_spectrum1d array

Power values.

Notes

All power values are stored internally in log10 scale.

__init__(check_freqs=True, check_data=True, format='power', model=None)[source]

Initialize Data object.

Methods

__init__([check_freqs, check_data, format, ...])

Initialize Data object.

add_data(freqs, power_spectrum[, freq_range])

Add data (frequencies, and power spectrum values) to the current object.

add_meta_data(meta_data)

Add data information into object from a SpectrumMetaData object.

get_checks()

Return check statuses of the current object.

get_data([component, space])

Get a data component.

get_meta_data()

Return data information from the current object.

plot([plt_log])

Plot the power spectrum.

print([concise])

Print out a data summary.

set_checks([check_freqs, check_data])

Set check statuses, which control if an error is raised based on check on the inputs.

Attributes

has_data

Indicator for if the object contains data.

n_freqs

Indicator for the number of frequency values.

add_data(freqs, power_spectrum, freq_range=None)[source]

Add data (frequencies, and power spectrum values) to the current object.

Parameters:
freqs1d array

Frequency values for the power spectrum, in linear space.

power_spectrum1d array

Power spectrum values, which must be input in linear space.

freq_rangelist of [float, float], optional

Frequency range to restrict power spectrum to. If not provided, keeps the entire range.

Notes

If called on an object with existing data it will be cleared by this method call.

add_meta_data(meta_data)[source]

Add data information into object from a SpectrumMetaData object.

Parameters:
meta_dataSpectrumMetaData

A meta data object containing meta data information.

get_checks()[source]

Return check statuses of the current object.

Returns:
ModelChecks

Object containing the check statuses from the current object.

get_data(component='full', space='log')[source]

Get a data component.

Parameters:
component{‘full’, ‘aperiodic’, ‘peak’}
Which data component to return.

‘full’ - full power spectrum ‘aperiodic’ - isolated aperiodic data component ‘peak’ - isolated peak data component

space{‘log’, ‘linear’}
Which space to return the data component in.

‘log’ - returns in log10 space. ‘linear’ - returns in linear space.

Returns:
output1d array

Specified data component, in specified spacing.

Notes

The ‘space’ parameter doesn’t just define the spacing of the data component values, but rather defines the space of the additive data definition such that power_spectrum = aperiodic_component + peak_component. With space set as ‘log’, this combination holds in log space. With space set as ‘linear’, this combination holds in linear space.

get_meta_data()[source]

Return data information from the current object.

Returns:
SpectrumMetaData

Object containing meta data from the current object.

property has_data

Indicator for if the object contains data.

property n_freqs

Indicator for the number of frequency values.

plot(plt_log=False, **plt_kwargs)[source]

Plot the power spectrum.

print(concise=False)[source]

Print out a data summary.

Parameters:
concisebool, optional, default: False

Whether to print a concise version of the report.

set_checks(check_freqs=None, check_data=None)[source]

Set check statuses, which control if an error is raised based on check on the inputs.

Parameters:
check_freqsbool, optional

Whether to check the frequency data.

check_databool, optional

Whether to check the power spectrum data.

Examples using specparam.data.data.Data

Model Sub-Objects

Model Sub-Objects