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 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', '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]
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_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

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.5.0-3-g96c1c10c        report issues / requests at https://github.com/ToFuProject/tofu/issues', tit=None, fontsize=None, draw=True, connect=True)[source]

tofu.data._spectrafit2d module