tofu.data package

Provide data handling class and methods (storing, processing, plotting…)

Submodules

tofu.data._comp module

tofu.data._comp._filter_bandpass_rfft(data, t, dt, fs, nt, nch, df)[source]
tofu.data._comp._filter_bandpass_stft(data, t, dt, fs, nt, nch, df)[source]
tofu.data._comp._spectrogram_scipy_fourier(data, fs, nt, nch, fmin=None, window=('tukey', 0.25), deg=False, nperseg=None, noverlap=None, detrend='linear', stft=False, boundary='constant', padded=True, warn=True)[source]

Return a spectrogram for each channel, and a common frequency vector

The min frequency of interest fmin fixes the nb. of pt. per seg. (if None) The number of overlapping points is set to nperseg-1 if None The choice of the window type is a trade-off between:

Spectral resolution between similar frequencies/amplitudes:

=>

Dynamic range (lots of != frequencies of != amplitudes):

=>

Compromise:

=> ‘hann’

tofu.data._comp._spectrogram_scipy_wavelet(data, fs, nt, nch, fmin=None, wave='morlet', warn=True)[source]
tofu.data._comp.calc_svd(data, lapack_driver='gesdd')[source]
tofu.data._comp.filter_bandpass_fourier(t, data, method='stft', detrend='linear', df=None, harm=True, df_out=None, harm_out=True)[source]

Return bandpass FFT-filtered signal (and the rest)

Optionnally include all higher harmonics Can also exclude a frequency interval and its higher harmonics

Parameters
  • t (np.ndarray) – 1D array, monotonously increasing time vector with regular spacing

  • data (np.ndarray) – 1 or 2D array, with shape[0]=t.size, the data to be filtered

  • method (str) –

    Flag indicating which method to use:
    • ’rfft’: scipy.fftpack.rfft

    • ’stft’: scipy.signal.stft

  • df (None / list) – List or tuple of len()=2, containing the bandpass lower / upper bounds

  • harm (bool) – If True all the higher harmonics of df will also be included

  • df_out (None / list) – List or tuple of len()=2, containing the bandpass lower / upper bounds to be excluded from filtering (if it overlaps with high harmonics of df)

  • harm_out (bool) – If True, the higher harmonics of the interval df_out are also excluded

  • Test (bool) – If True tests all the input arguments for any mistake

Returns

  • In (np.ndarray) – Array with shape=data.shape, filtered signal retrieved from inverse FFT

  • Out (np.ndarray) – Array with shape=data.shape, excluded signal from filtering

tofu.data._comp.filter_svd(data, lapack_driver='gesdd', modes=[])[source]

Return the svd-filtered signal using only the selected mode

Provide the indices of the modes desired

tofu.data._comp.get_finterp_ani(idq2dR, idq2dPhi, idq2dZ, interp_t=None, interp_space=None, fill_value=None, mpltri=None, idmesh=None, vq2dR=None, vq2dPhi=None, vq2dZ=None, tall=None, tbinall=None, ntall=None, indtq=None, trifind=None, Type=None)[source]
tofu.data._comp.get_finterp_isotropic(idquant, idref1d, idref2d, vquant=None, vr1=None, vr2=None, interp_t=None, interp_space=None, idmesh=None, fill_value=None, tall=None, tbinall=None, ntall=None, indtq=None, indtr1=None, indtr2=None, mpltri=None, trifind=None)[source]
tofu.data._comp.spectrogram(data, t, fmin=None, method='scipy-fourier', deg=False, window='hann', detrend='linear', nperseg=None, noverlap=None, boundary='constant', padded=True, wave='morlet', warn=True)[source]

tofu.data._core module

class tofu.data._core.DataCam1D(data=None, t=None, X=None, lamb=None, dchans=None, dlabels=None, Id=None, Name=None, Exp=None, shot=None, Diag=None, dextra=None, lCam=None, config=None, fromdict=None, sep=None, SavePath='/home/lasofivec/tofu/doc/source', SavePath_Include=['Mod', 'Cls', 'Type', 'Exp', 'Deg', 'Diag', 'Name', 'shot'])[source]

Bases: tofu.data._core.DataAbstract

Data object used for 1D cameras or list of 1D cameras

_ddef = {'Id': {'include': ['Mod', 'Cls', 'Exp', 'Diag', 'Name', 'shot', 'version']}, 'dtreat': {'order': ['mask', 'interp-indt', 'interp-indch', 'data0', 'dfit', 'indt', 'indch', 'indlamb', 'interp-t']}}
_dstrip = {'allowed': [0, 1, 2, 3], 'strip': None}
classmethod _is2D()[source]
classmethod _isSpectral()[source]
class tofu.data._core.DataCam1DSpectral(data=None, t=None, X=None, lamb=None, dchans=None, dlabels=None, Id=None, Name=None, Exp=None, shot=None, Diag=None, dextra=None, lCam=None, config=None, fromdict=None, sep=None, SavePath='/home/lasofivec/tofu/doc/source', SavePath_Include=['Mod', 'Cls', 'Type', 'Exp', 'Deg', 'Diag', 'Name', 'shot'])[source]

Bases: tofu.data._core.DataCam1D

Data object used for 1D cameras or list of 1D cameras

_ddef = {'Id': {'include': ['Mod', 'Cls', 'Exp', 'Diag', 'Name', 'shot', 'version']}, 'dtreat': {'order': ['mask', 'interp-indt', 'interp-indch', 'data0', 'dfit', 'indt', 'indch', 'indlamb', 'interp-t']}}
_dstrip = {'allowed': [0, 1, 2, 3], 'strip': None}
classmethod _isSpectral()[source]
property lamb
property nlamb
class tofu.data._core.DataCam2D(data=None, t=None, X=None, lamb=None, dchans=None, dlabels=None, dX12='geom', Id=None, Name=None, Exp=None, shot=None, Diag=None, dextra=None, lCam=None, config=None, fromdict=None, sep=None, SavePath='/home/lasofivec/tofu/doc/source', SavePath_Include=['Mod', 'Cls', 'Type', 'Exp', 'Deg', 'Diag', 'Name', 'shot'])[source]

Bases: tofu.data._core.DataAbstract

Data object used for 2D cameras or list of 2D cameras

_checkformat_dX12(dX12=None)[source]
_ddef = {'Id': {'include': ['Mod', 'Cls', 'Exp', 'Diag', 'Name', 'version']}, 'dtreat': {'order': ['mask', 'interp-indt', 'interp-indch', 'data0', 'dfit', 'indt', 'indch', 'indlamb', 'interp-t']}}
_dstrip = {'allowed': [0, 1, 2, 3], 'strip': None}
classmethod _is2D()[source]
classmethod _isSpectral()[source]
property dX12
get_X12plot(plot='imshow')[source]
set_dX12(dX12=None)[source]
class tofu.data._core.DataCam2DSpectral(data=None, t=None, X=None, lamb=None, dchans=None, dlabels=None, dX12='geom', Id=None, Name=None, Exp=None, shot=None, Diag=None, dextra=None, lCam=None, config=None, fromdict=None, sep=None, SavePath='/home/lasofivec/tofu/doc/source', SavePath_Include=['Mod', 'Cls', 'Type', 'Exp', 'Deg', 'Diag', 'Name', 'shot'])[source]

Bases: tofu.data._core.DataCam2D

Data object used for 1D cameras or list of 1D cameras

_ddef = {'Id': {'include': ['Mod', 'Cls', 'Exp', 'Diag', 'Name', 'shot', 'version']}, 'dtreat': {'order': ['mask', 'interp-indt', 'interp-indch', 'data0', 'dfit', 'indt', 'indch', 'indlamb', 'interp-t']}}
_dstrip = {'allowed': [0, 1, 2, 3], 'strip': None}
classmethod _isSpectral()[source]
property lamb
property nlamb
class tofu.data._core.Plasma2D(dtime=None, dradius=None, d0d=None, d1d=None, d2d=None, dmesh=None, config=None, Id=None, Name=None, Exp=None, shot=None, fromdict=None, sep=None, SavePath='/home/lasofivec/tofu/doc/source', SavePath_Include=['Mod', 'Cls', 'Type', 'Exp', 'Deg', 'Diag', 'Name', 'shot'])[source]

Bases: tofu.utils.ToFuObject

A generic class for handling 2D (and 1D) plasma profiles

Provides:
  • equilibrium-related quantities

  • any 1d profile (can be remapped on 2D equilibrium)

  • spatial interpolation methods

static _add_ref_from_file(pfe=None, key=None, group=None, dim=None, quant=None, units=None, origin=None, name=None, comments=None, delimiter=None)[source]
_checkformat_addref(key=None, data=None, group=None, dim=None, quant=None, units=None, origin=None, name=None, comments=None, delimiter=None)[source]
static _checkformat_dtrm(dtime=None, dradius=None, dmesh=None, d0d=None, d1d=None, d2d=None)[source]
classmethod _checkformat_inputs_Id(Id=None, Name=None, Exp=None, shot=None, include=None, **kwdargs)[source]
_checkformat_inputs_dgeom(config=None)[source]
_checkformat_qr12RPZ(quant=None, ref1d=None, ref2d=None, q2dR=None, q2dPhi=None, q2dZ=None)[source]
static _checkformat_shapes(dins)[source]
_complement()[source]
_ddef = {'Id': {'include': ['Mod', 'Cls', 'Exp', 'Diag', 'Name', 'shot', 'version']}, 'dtreat': {'order': ['mask', 'interp-indt', 'interp-indch', 'data0', 'dfit', 'indt', 'indch', 'indlamb', 'interp-t']}}
_dstrip = {'allowed': [0, 1], 'strip': None}
static _extract_dnd(dnd, k0, dim_=None, quant_=None, name_=None, origin_=None, units_=None)[source]
_fill_dins(dins)[source]
static _find_lref(shape=None, k0=None, dd=None, ddstr=None, dindref=None, lrefname=['t', 'radius'])[source]
_from_dict(fd)[source]
_get_finterp(idquant=None, idref1d=None, idref2d=None, idq2dR=None, idq2dPhi=None, idq2dZ=None, interp_t=None, interp_space=None, fill_value=None, ani=False, Type=None)[source]
_get_indtmult(idquant=None, idref1d=None, idref2d=None)[source]
static _get_indtu(t=None, tall=None, tbinall=None, idref1d=None, idref2d=None, indtr1=None, indtr2=None)[source]
_get_keyingroup(key, group=None, msgstr=None, raise_=False)[source]
static _get_keys_ddata()[source]
static _get_keys_dgeom()[source]
static _get_keys_dgroup()[source]
static _get_keys_dindref()[source]
static _get_largs_dgeom()[source]
static _get_largs_dindrefdatagroup()[source]
_get_ldata(dim=None, quant=None, name=None, units=None, origin=None, indref=None, group=None, log='all', return_key=True)[source]
_get_quantrefkeys(qq, ref1d=None, ref2d=None)[source]
_get_tcom(idquant=None, idref1d=None, idref2d=None, idq2dR=None)[source]
static _get_time_common_arrays(dins, choose=None)[source]
_init(dtime=None, dradius=None, dmesh=None, d0d=None, d1d=None, d2d=None, config=None, **kwargs)[source]

To be overloaded

_interp_on_common_time(lkeys, choose='min', interp_t=None, t=None, fill_value=nan)[source]

Return a dict of time-interpolated data

_interp_on_common_time_arrays(dins, choose='min', interp_t=None, t=None, fill_value=nan)[source]

Return a dict of time-interpolated data

property _lquantboth

Return list of quantities available both in 1d and 2d

_reset()[source]

To be overloaded

_set_dindrefdatagroup(dtime=None, dradius=None, dmesh=None, d0d=None, d1d=None, d2d=None)[source]
_strip(strip=0, verb=True)[source]
_strip_ddata(strip=0)[source]
_strip_dgeom(strip=0, force=False, verb=True)[source]
classmethod _strip_init()[source]

To be overloaded

_to_dict()[source]
add_quantity(key=None, data=None, depend=None, dim=None, quant=None, units=None, origin=None, name=None)[source]

Add a quantity

add_ref(key=None, data=None, group=None, dim=None, quant=None, units=None, origin=None, name=None, comments=None, delimiter=None)[source]

Add a reference

The reference data is contained in data, which can be:
  • np.array: a 1d profile

  • dict: for mesh

  • str: absolute path to a file, holding a 1d profile

Please also provide (if not included in file if data is a str):
  • key: unique str identifying the data

  • group: str identifying the reference group (self.dgroup.keys())

If data is a str to a file, key and group (and others) can be included in the file

Parameters dim, quant, units, origin and name are optional Parameters comments and delimiter and only used if data is the path to a .txt file (fed to np.loadtxt)

calc_signal_from_Cam(cam, t=None, quant=None, ref1d=None, ref2d=None, q2dR=None, q2dPhi=None, q2dZ=None, Brightness=True, interp_t=None, interp_space=None, fill_value=None, res=0.005, DL=None, resMode='abs', method='sum', ind=None, out=<class 'object'>, plot=True, dataname=None, fs=None, dmargin=None, wintit=None, invert=True, units=None, draw=True, connect=True)[source]
compute_bremzeff(Te=None, ne=None, zeff=None, lamb=None, tTe=None, tne=None, tzeff=None, t=None, interp_t=None)[source]

Return the bremsstrahlung spectral radiance at lamb

The plasma conditions are set by:
  • Te (eV)

  • ne (/m3)

  • zeff (adim.)

The wavelength is set by the diagnostics
  • lamb (m)

The vol. spectral emis. is returned in ph / (s.m3.sr.m)

The computation requires an intermediate : gff(Te, zeff)

compute_fanglev(BR=None, BPhi=None, BZ=None, ne=None, lamb=None, t=None, interp_t=None, tBR=None, tBPhi=None, tBZ=None, tne=None)[source]

Return the vector faraday angle at lamb

The plasma conditions are set by:
  • BR (T) , array of R component of B

  • BRPhi (T) , array of phi component of B

  • BZ (T) , array of Z component of B

  • ne (/m3)

The wavelength is set by the diagnostics
  • lamb (m)

The vector faraday angle is returned in T / m

property config
property ddata
property dgroup
property dindref
property dmesh
property dradius
property dtime
get_Data(lquant, X=None, ref1d=None, ref2d=None, remap=False, res=0.01, interp_space=None, dextra=None)[source]
get_dextra(dextra=None)[source]
get_finterp2d(quant=None, ref1d=None, ref2d=None, q2dR=None, q2dPhi=None, q2dZ=None, interp_t=None, interp_space=None, fill_value=None, Type=None)[source]

Return the function interpolating (X,Y,Z) pts on a 1d/2d profile

Can be used as input for tf.geom.CamLOS1D/2D.calc_signal()

get_summary(sep='  ', line='-', just='l', table_sep=None, verb=True, return_=False)[source]

Summary description of the object content

get_tcommon(lq, prefer='finer')[source]

Check if common t, else choose according to prefer

By default, prefer the finer time resolution

get_time(key)[source]

Return the time vector associated to a chosen quantity (identified by its key)

get_time_common(lkeys, choose=None)[source]

Return the common time vector to several quantities

If they do not have a common time vector, a reference one is choosen according to criterion choose

interp_pts2profile(pts=None, vect=None, t=None, quant=None, ref1d=None, ref2d=None, q2dR=None, q2dPhi=None, q2dZ=None, interp_t=None, interp_space=None, fill_value=None, Type=None)[source]

Return the value of the desired profiles_1d quantity

For the desired inputs points (pts):
  • pts are in (X,Y,Z) coordinates

  • space interpolation is linear on the 1d profiles

At the desired input times (t):
  • using a nearest-neighbourg approach for time

interp_t(dkeys, choose='min', interp_t=None, t=None, fill_value=nan)[source]
plot(lquant, X=None, ref1d=None, ref2d=None, remap=False, res=0.01, interp_space=None, sharex=False, bck=True)[source]
plot_combine(lquant, lData=None, X=None, ref1d=None, ref2d=None, remap=False, res=0.01, interp_space=None, sharex=False, bck=True)[source]

plot combining several quantities from the Plasma2D itself and optional extra list of Data instances

set_dgeom(config=None)[source]
strip(strip=0, verb=True)[source]

Remove non-essential attributes to save memory / disk usage

Useful to save a very compressed version of the object The higher strip => the more stripped the object Use strip=0 to recover all atributes

See the difference by doing:

> self.get_nbytes() > self.strip(-1) > self.get_nbytes()

Parameters

strip (int) –

Flag indicating how much to strip from the object

0: Make complete (retrieve all attributes) 1: dgeom pathfiles

-1: Equivalent to strip=1

tofu.data._core_new module

class tofu.data._core_new.DataCollection(dgroup=None, dref=None, dref_static=None, ddata=None, dobj=None, Id=None, Name=None, fromdict=None, SavePath=None, include=None, sep=None)[source]

Bases: tofu.utils.ToFuObject

A generic class for handling data

Provides methods for:
  • introspection

  • plateaux finding

  • visualization

__check_which(which=None, return_dict=None)

Check which in [‘data’] + list(self._dobj.keys()

_allowed_groups = None
_check_qr12RPZ(quant=None, ref1d=None, ref2d=None, q2dR=None, q2dPhi=None, q2dZ=None, group1d=None, group2d=None)[source]
classmethod _checkformat_inputs_Id(Id=None, Name=None, include=None, **kwdargs)[source]
_data_none = None
_ddata = {}
_ddef = {'Id': {'include': ['Mod', 'Cls', 'Name', 'version']}, 'params': {'ddata': {'dim': (<class 'str'>, 'unknown'), 'name': (<class 'str'>, 'unknown'), 'quant': (<class 'str'>, 'unknown'), 'source': (<class 'str'>, 'unknown'), 'units': (<class 'str'>, 'a.u.')}, 'dobj': {}}}
_dgroup = {}
_dobj = {}
_dref = {}
_dref_static = {}
_dstrip = {'allowed': [0, 1], 'strip': None}
_fit_one_dim(key=None, group=None, Type=None, func=None, **kwdargs)[source]

Return the parameters of a fitted function

The interpolated data is chosen method select() with args:
  • key, ind

dout: dict

dict of interpolated data

dfail: dict of failed interpolations, with error messages

_forced_group = None
_from_dict(fd)[source]
_get_common_ref_data_nearest(group=None, lkey=None, return_all=None)[source]

Typically used to get a common (intersection) time vector

Returns a time vector that contains all time points from all data Also return a dict of indices to easily remap each time vector to tall

such that t[ind] = tall (with nearest approximation)

_get_finterp(idquant=None, idref1d=None, idref2d=None, idmesh=None, idq2dR=None, idq2dPhi=None, idq2dZ=None, interp_t=None, interp_space=None, fill_value=None, ani=None, Type=None, group0d=None, group2d=None)[source]
property _get_lquant_both

Return list of quantities available both in 1d and 2d

_get_pts_from_mesh(key=None)[source]

Get default pts from a mesh

_get_ref_from_key(key=None, group=None)[source]

Get the key of the ref in chosen group

_get_sort_index(which=None, param=None)[source]

Return sorting index ofself.ddata dict

_group0d = 'time'
_group1d = 'radius'
_group2d = 'mesh2d'
_ind_tofrom_key(ind=None, key=None, group=None, returnas=<class 'int'>, which=None)[source]

Return ind from key or key from ind for all data

_init(dgroup=None, dref=None, dref_static=None, ddata=None, dobj=None, **kwargs)[source]

To be overloaded

_interp_one_dim(ind=None, key=None, group=None, kind=None, bounds_error=None, fill_value=None)[source]

Return a dict of interpolated data

Uses scipy.inpterp1d with args:
  • kind, bounds_error, fill_value

The interpolated data is chosen method select() with args:
  • key, ind

The interpolation is done against a reference vector x
  • x can be a key to an existing ref

  • x can be user-provided array

    in thay case the group should be specified (to properly identify the interpolation dimension)

dout: dict

dict of interpolated data

dfail: dict of failed interpolations, with error messages

_interp_pts2d_to_quant1d(pts=None, vect=None, t=None, quant=None, ref1d=None, ref2d=None, q2dR=None, q2dPhi=None, q2dZ=None, interp_t=None, interp_space=None, fill_value=None, Type=None, group0d=None, group1d=None, group2d=None, return_all=None)[source]

Return the value of the desired 1d quantity at 2d points

For the desired inputs points (pts):
  • pts are in (X, Y, Z) coordinates

  • space interpolation is linear on the 1d profiles

At the desired input times (t):
  • using a nearest-neighbourg approach for time

_max_ndim = None
_plot_axvlines(which=None, key=None, ind=None, param_x=None, param_txt=None, sortby=None, sortby_def=None, sortby_lok=None, ax=None, ymin=None, ymax=None, ls=None, lw=None, fontsize=None, side=None, dcolor=None, dsize=None, fraction=None, figsize=None, dmargin=None, wintit=None, tit=None)[source]

plot rest wavelengths as vertical lines

_plot_timetraces(ntmax=1, group='time', key=None, ind=None, Name=None, color=None, ls=None, marker=None, ax=None, axgrid=None, fs=None, dmargin=None, legend=None, draw=None, connect=None, lib=None)[source]
_reserved_keys = None
_reset()[source]

To be overloaded

_show_in_summary = 'all'
_show_in_summary_core = ['shape', 'ref', 'group']
_strip(strip=0, verb=True)[source]
_strip_ddata(strip=0, verb=0)[source]
classmethod _strip_init()[source]

To be overloaded

_to_dict()[source]
add_data(key=None, data=None, ref=None, **kwdargs)[source]
add_group(group=None)[source]
add_obj(which=None, key=None, **kwdargs)[source]
add_param(param, value=None, which=None)[source]

Add a parameter, optionnally also set its value

add_ref(key=None, group=None, data=None, **kwdargs)[source]
add_ref_static(key=None, which=None, **kwdargs)[source]
static convert_spectral(data=None, units_in=None, units_out=None, returnas=None)[source]

convert wavelength / energy/ frequency

Available units:

wavelength: m, mm, um, nm, A energy: J, eV, keV frequency: Hz, kHz, MHz, GHz

Can also just return the conversion coef if returnas=’coef’

property ddata

the dict of data

property dgroup

The dict of groups

property dobj

the dict of obj

property dref

the dict of references

property dref_static

the dict of references

get_drefddata_as_input(key=None, ind=None, group=None)[source]
get_lparam(which=None)[source]

Return the list of params for the chosen dict (‘data’ or dobj[<>])

get_param(param=None, key=None, ind=None, returnas=None, which=None)[source]

Return the array of the chosen parameter (or list of parameters)

Can be returned as:
  • dict: {param0: {key0: values0, key1: value1…}, …}

  • np[.ndarray: {param0: np.r_[values0, value1…], …}

get_subset(key=None, ind=None, group=None, Name=None)[source]
get_summary(show=None, show_core=None, sep='  ', line='-', just='l', table_sep=None, verb=True, return_=False)[source]

Summary description of the object content

remove_data(key=None, propagate=True)[source]

Remove a data (or list of data)

remove_group(group=None)[source]

Remove a group (or list of groups) and all associated ref, data

remove_obj(key=None, which=None, propagate=True)[source]

Remove a data (or list of data)

remove_param(param=None, which=None)[source]

Remove a parameter, none by default, all if param = ‘all’

remove_ref(key=None, propagate=None)[source]

Remove a ref (or list of refs) and all associated data

remove_ref_static(key=None, which=None, propagate=None)[source]

Remove a static ref (or list) or a whole category

key os provided:
=> remove only the desired key(s)

works only if key is not used in ddata and dobj

which is provided:
=> treated as param, the whole category of ref_static is removed

if propagate, the parameter is removed from ddata and dobj

save(path=None, name=None, strip=None, sep=None, deep=True, mode='npz', compressed=False, verb=True, return_pfe=False)[source]

Save the ToFu object

ToFu provides built-in saving and loading functions for ToFu objects. Specifying saving path ad name is optional (defaults recommended) The mode refers to the file format

Good practices are:
  • save all struct objects

Parameters
  • obj (ToFuObject subclass instance) – The object to be saved

  • path (None / str) – The folder where to save, if None (recommended), uses obj.Id.SavePath

  • name (None / str) – The file name, if None (recommended), uses obj.Id.SaveName

  • mode (str) –

    Flag specifying the saving mode
    • ’npz’: numpy file

    • ’mat’: matlab file

  • strip (int) – Flag indicating how stripped the saved object should be See docstring of self.strip()

  • deep (bool) –

    Flag, used when the object has other tofu objects as attributes Indicated whether these attribute object should be:

    • True: converted to dict themselves in order to be saved inside

      the same file as attributes (-> uses self.to_dict(deep=’dict’))

    • False: not converted, in that the strategy would be to save them

      separately and store only the reference to the saved files instead of the objects themselves. To do this, you must:

      1/ Save all object attributes independently 2/ Store only the reference by doing self.strip(-1)

      The strip() method will check they have been saved before removing them, and throw an Exception otherwise

      3/ self.save(deep=False)

  • compressed (bool) – Flag indicating whether to compress the file (slower, not recommended)

  • verb (bool) – Flag indicating whether to print a summary (recommended)

select(which=None, log=None, returnas=None, **kwdargs)[source]

Return the indices / keys of data matching criteria

The selection is done comparing the value of all provided parameters The result is a boolean indices array, optionally with the keys list It can include:

  • log = ‘all’: only the data matching all criteria

  • log = ‘any’: the data matching any criterion

If log = ‘raw’, a dict of indices arrays is returned, showing the details for each criterion

set_param(param=None, value=None, ind=None, key=None, which=None)[source]

Set the value of a parameter

value can be:
  • None

  • a unique value (int, float, bool, str, tuple) common to all keys

  • an iterable of vlues (array, list) => one for each key

A subset of keys can be chosen (ind, key, fed to self.select()) to set only the value of some key

sortby(param=None, order=None, which=None)[source]

sort the self.ddata dict by desired parameter

strip(strip=0, verb=True)[source]

Remove non-essential attributes to save memory / disk usage

Useful to save a very compressed version of the object The higher strip => the more stripped the object Use strip=0 to recover all atributes

See the difference by doing:

> self.get_nbytes() > self.strip(-1) > self.get_nbytes()

Parameters

strip (int) –

Flag indicating how much to strip from the object

0: Make complete (retrieve all attributes) 1: None

-1: Equivalent to strip=1

switch_ref(new_ref=None)[source]

Use the provided key as ref (if valid)

to_DataFrame(which=None)[source]
to_PlotCollection(key=None, ind=None, group=None, Name=None, dnmax=None, lib='mpl')[source]
update(dobj=None, ddata=None, dref=None, dref_static=None, dgroup=None)[source]

Can be used to set/add data/ref/group

Will update existing attribute with new dict

tofu.data._def module

tofu.data._plot module

tofu.data._plot.Data_plot(lData, key=None, bck=True, indref=0, cmap=None, ms=4, vmin=None, vmax=None, vmin_map=None, vmax_map=None, cmap_map=None, normt_map=False, ntMax=None, nchMax=None, nlbdMax=None, inct=[1, 10], incX=[1, 5], inclbd=[1, 10], lls=None, lct=None, lcch=None, lclbd=None, cbck=None, fmt_t='06.3f', fmt_X='01.0f', fmt_l='07.3f', invert=True, Lplot='In', dmarker=None, sharey=True, sharelamb=True, fs=None, dmargin=None, wintit=None, tit=None, fontsize=None, labelpad=None, draw=True, connect=True)[source]
tofu.data._plot.Data_plot_combine(lData, key=None, bck=True, indref=0, cmap=None, ms=4, vmin=None, vmax=None, vmin_map=None, vmax_map=None, cmap_map=None, normt_map=False, ntMax=None, nchMax=None, nlbdMax=3, inct=[1, 10], incX=[1, 5], inclbd=[1, 10], lls=None, lct=None, lcch=None, lclbd=None, cbck=None, fmt_t='06.3f', fmt_X='01.0f', sharex=False, invert=True, Lplot='In', dmarker=None, fs=None, dmargin=None, wintit=None, tit=None, fontsize=None, labelpad=None, draw=True, connect=True)[source]
tofu.data._plot.Data_plot_spectrogram(Data, tf, f, lpsd, lang, fmax=None, key=None, bck=True, indref=0, cmap_f=None, cmap_img=None, ms=4, vmin=None, vmax=None, normt=False, ntMax=None, nfMax=3, lls=['-', '--', '-.', ':'], lct=[(0.12156862745098039, 0.4666666666666667, 0.7058823529411765), (1.0, 0.4980392156862745, 0.054901960784313725), (0.17254901960784313, 0.6274509803921569, 0.17254901960784313), (0.6823529411764706, 0.7803921568627451, 0.9098039215686274), (1.0, 0.7333333333333333, 0.47058823529411764), (0.596078431372549, 0.8745098039215686, 0.5411764705882353)], lcch=[(0.8392156862745098, 0.15294117647058825, 0.1568627450980392), (0.5803921568627451, 0.403921568627451, 0.7411764705882353), (0.5490196078431373, 0.33725490196078434, 0.29411764705882354), (1.0, 0.596078431372549, 0.5882352941176471), (0.7725490196078432, 0.6901960784313725, 0.8352941176470589), (0.7686274509803922, 0.611764705882353, 0.5803921568627451)], plotmethod='imshow', invert=False, fs=None, dmargin=None, wintit='tofu-1.4.10-alpha9-349-gd9149398        report issues / requests at https://github.com/ToFuProject/tofu/issues', tit=None, fontsize=None, draw=True, connect=True)[source]

tofu.data._spectrafit2d module

tofu.data._spectrafit2d.fit_spectra2d_x0_per_row()[source]
tofu.data._spectrafit2d.fit_spectra_2d(data2d, indt=None, nbin_init=None, nmax=None, bck=None, nbsplines=None)[source]

Return fitted spectra

Can handle unique or multiple time Takes already formatted 2d data:

  • (nx, ny)

  • (nt, nx, ny)

x being the horizontal / spectral direction (lambda)

tofu.data._spectrafit2d.get_2dspectralfit_func(lamb0, forcelamb=False, deg=None, knots=None)[source]
tofu.data._spectrafit2d.get_dindx(bckdeg=None, dlines=None, nbs=None)[source]
tofu.data._spectrafit2d.get_func1d_all(n=5, lamb0=None)[source]
tofu.data._spectrafit2d.get_func1d_lamb0fix(n=5, lamb0=None)[source]
tofu.data._spectrafit2d.get_func2d(y0, y1, x0_y, bspl_n, bspl_deg)[source]
tofu.data._spectrafit2d.get_funccostjac()[source]
tofu.data._spectrafit2d.get_knots_nbs_for_bsplines(knots_unique, deg)[source]
tofu.data._spectrafit2d.get_lamb0_from_dlines(dlines)[source]
tofu.data._spectrafit2d.get_multigaussianfit2d_costfunc(lamb=None, phi=None, data=None, std=None, lamb0=None, forcelamb=None, deg=None, knots=None, nlamb0=None, nkperbs=None, nbs=None, nc=None, debug=None)[source]
tofu.data._spectrafit2d.get_p0bounds_all(x, y, nmax=None, lamb0=None)[source]
tofu.data._spectrafit2d.get_p0bounds_lambfix(x, y, nmax=None, lamb0=None)[source]
tofu.data._spectrafit2d.get_peaks(x, y, nmax=None)[source]
tofu.data._spectrafit2d.get_x0_bounds(x01d=None, dlines=None, dindx=None, lamb=None, data=None)[source]
tofu.data._spectrafit2d.multigaussianfit2d(lamb, phi, data, std=None, lamb0=None, forcelamb=None, knots=None, deg=None, nbsplines=None, x0=None, bounds=None, method=None, max_nfev=None, xtol=None, ftol=None, gtol=None, loss=None, verbose=0, debug=None)[source]
tofu.data._spectrafit2d.multiplegaussianfit1d(x, spectra, nmax=None, lamb0=None, forcelamb=None, p0=None, bounds=None, max_nfev=None, xtol=None, verbose=0, percent=None, plot_debug=False)[source]
tofu.data._spectrafit2d.remove_bck(x, y)[source]