Support for the spectra files (kin|mag|u2)_spec_#.TAG

class magic.MagicSpectrum(datadir='.', field='e_kin', iplot=True, ispec=None, ave=False, normalize=False, tag=None, tags=None, quiet=False)[source]

This class can be used to read and display the spectra:

>>> # display the content of kin_spec_1.tag
>>> # where tag is the most recent file in the current directory
>>> sp = MagicSpectrum(field='e_kin', ispec=1)
>>> # display the content of mag_spec_ave.test on one single figure
>>> sp = MagicSpectrum(field='e_mag', tag='test', ave=True)
>>> # display both kinetic and magnetic energy spectra on same graph
>>> sp = MagicSpectrum(field='combined', ave=True)
__init__(datadir='.', field='e_kin', iplot=True, ispec=None, ave=False, normalize=False, tag=None, tags=None, quiet=False)[source]
Parameters:
  • field (str) – the spectrum you want to plot, ‘e_kin’ for kinetic energy, ‘e_mag’ for magnetic

  • iplot (bool) – display the output plot when set to True (default is True)

  • ispec (int) – the number of the spectrum you want to plot

  • tag (str) – file suffix (tag), if not specified the most recent one in the current directory is chosen

  • tags (list) – a list of tags to be considered

  • ave (bool) – plot a time-averaged spectrum when set to True

  • datadir (str) – current working directory

  • quiet (bool) – when set to True, makes the output silent (default False)

get_file(ispec, datadir, tag, tags, quiet)[source]

This routine is used to determine which files need do be read or stacked. The outputs are stored in a look-up table.

Parameters:
  • ispec (int) – the number of the spectrum you want to plot

  • datadir (str) – current working directory

  • tag (str) – file suffix (tag), if not specified the most recent one in the current directory is chosen

  • tags (list) – a list of tags to be considered

  • quiet (bool) – when set to True, makes the output silent (default False)

Returns speclut:

a look-up table which contains the different fields

Rtype speclut:

dict

plot()[source]

Plotting function

Support for the 2-D spectra files

class magic.MagicSpectrum2D(datadir='.', field='e_mag', iplot=False, ispec=None, tag=None, cm='magma', levels=33, precision=<class 'numpy.float64'>, ave=False)[source]

This class can be used to read and display 2-D spectra in the \((r,\ell)\) and in the \((r,m)\) planes

>>> # display the content of 2D_kin_spec_1.tag
>>> # where tag is the most recent file in the current directory
>>> sp = MagicSpectrum2D(field='e_kin', ispec=1, levels=17, cm='seismic')
>>> # display the content of 2D_mag_spec_3.test
>>> sp = MagicSpectrum2D(field='e_mag', tag='test', ispec=3)
__init__(datadir='.', field='e_mag', iplot=False, ispec=None, tag=None, cm='magma', levels=33, precision=<class 'numpy.float64'>, ave=False)[source]
Parameters:
  • field (str) – the spectrum you want to plot, ‘e_kin’ for kinetic energy, ‘e_mag’ for magnetic

  • iplot (bool) – display the output when set to True (default is True)

  • ispec (int) – the number of the spectrum you want to plot

  • tag (str) – file suffix (tag=, if not specified the most recent one in the current directory is chosen

  • cm (str) – name of the colormap (default=’jet’)

  • levels (int) – number of contour levels (default 33)

  • precision (str) – single or double precision

  • datadir (str) – current working directory

  • ave (bool) – plot a time-averaged spectrum when set to True

plot(levels, cm, cut=1.0)[source]

Plotting function

Parameters:
  • levels (int) – number of contour levels

  • cm – name of the colormap

  • cut (float) – adjust the contour maximum to max(abs(data))*cut