Conversion of G_#.TAG files to vts/vti files

class magic.graph2vtk.Graph2Vtk(gr, filename='out', scals=['vr', 'emag', 'tfluct'], vecs=['u', 'B'], potExtra=False, ratio_out=2, nrout=32, deminc=True, outType='vts', nFiles=1, nx=96, ny=96, nz=96, labFrame=False)[source]

This class allows to transform an input graphic file to a file format readable by paraview/visit or mayavi. It also allows to compute a possible potential extrapolation of the field lines in an arbitrary outer spherical shell domain

>>> # Load a graphic file
>>> gr = MagicGraph(ivar=1)
>>> # store myOut.vts
>>> Graph2Vtk(gr, 'myOut', outType='vts')
>>> # store u' and B for the vector fields and vortz and T for the scalars
>>> Graph2Vtk(gr, scals=['temp', 'vortz'], vecs=['ufluct', 'B'])
>>> # store only T'
>>> Graph2Vtk(gr, scals=['tempfluct'], vecs=[])
>>> # store only B with its potential extrapolation up to 3*r_cmb
>>> Graph2Vtk(gr, scals=[], vecs=['B'], potExtra=True, ratio_out=3)
>>> # Extrapolate on a cartesian grid of size 128^3
>>> Graph2Vtk(gr, outType='vti', nx=128, ny=128, nz=128)
__init__(gr, filename='out', scals=['vr', 'emag', 'tfluct'], vecs=['u', 'B'], potExtra=False, ratio_out=2, nrout=32, deminc=True, outType='vts', nFiles=1, nx=96, ny=96, nz=96, labFrame=False)[source]
Parameters:
  • filename (str) – the file name of the output (without extension)

  • gr (magic.MagicGraph) – the input graphic file one wants to transform to vts/vti

  • scals (list(str)) – a list that contains the possible input scalars: ‘entropy’, ‘vr’, ‘vp’, ‘tfluct’, ‘vortz’, ‘vortzfluct’, ‘ekin’, ‘emag’, ‘vortr’, ‘colat’

  • vecs (list(str)) – a list that contains the possible input vectors: ‘u’, ‘b’, ‘ufluct’, ‘bfluct’

  • potExtra (bool) – when set to True, calculates the potential extrapolation of the magnetic field up to ratio_out*r_cmb

  • ratio_out (float) – in case of potential extrapolation, this is the ratio of the external outer radius to r_cmb (rout/rcmb)

  • nrout (integer) – in case of potential extrapolation, this input allows to specify thenumber of radial grid points in the outer spherical envelope

  • deminc (bool) – a logical to indicate if one wants do get rid of the possible azimuthal symmetry

  • outType (str) – nature of the VTK file produced. This can be either ‘vts’ for the spherical grid or ‘vti’ for an extrapolation on a cartesian grid

  • nFiles (int) – number of output chunks in case of parallel vts file format (pvts)

  • nx (int) – number of grid points in the x direction

  • ny (int) – number of grid points in the x direction

  • nz (int) – number of grid points in the x direction

  • labFrame (bool) – when set to True, transform the velocity to the lab frame

__weakref__

list of weak references to the object (if defined)

writeVTI(filename, nx=96, ny=96, nz=96)[source]

In this case, the output is extrapolated on a cartesian grid and then written in a vti file.

Parameters:
  • filename (str) – the file name of the output (without extension)

  • nx (int) – number of grid points in the x direction

  • ny (int) – number of grid points in the x direction

  • nz (int) – number of grid points in the x direction

writeVTS(filename, nFiles)[source]

This function stores the output on a structured-grid vts file.

Parameters:
  • filename (str) – the file name of the output (without extension)

  • nFiles (int) – number of outpute files (in case of pvts)

magic.graph2vtk.sph2cart_scal(scals, radius, nx=96, ny=96, nz=96, minc=1)[source]

This function interpolates a series of scalar fields from the spherical coordinates to the cartesian coordinates.

Parameters:
  • scals (numpy.ndarray[nscals,nphi,ntheta,nr]) – an array that contains the different scalar quantities

  • radius (numpy.ndarray) – the input radius

  • nx (int) – number of grid points in the x direction

  • ny (int) – number of grid points in the x direction

  • nz (int) – number of grid points in the x direction

  • minc (int) – azimuthal symmetry

Returns:

a tuple that contains the scalars, the max of the grid and the grid spacing

Return type:

(numpy.ndarray[nscals,nz,ny,nx],float,float)

magic.graph2vtk.sph2cart_vec(vecr, vect, vecp, radius, nx=96, ny=96, nz=96, minc=1)[source]

This function interpolates a series of vector fields from the spherical coordinates to the cartesian coordinates.

Parameters:
  • vecr (numpy.ndarray[nvecs,nphi,ntheta,nr]) – the radial components of the different vector fields

  • vect (numpy.ndarray[nvecs,nphi,ntheta,nr]) – the latitudinal components of the different vector fields

  • vecp (numpy.ndarray[nvecs,nphi,ntheta,nr]) – the azimuthal components of the different vector fields

  • radius (numpy.ndarray) – the input radius

  • nx (int) – number of grid points in the x direction

  • ny (int) – number of grid points in the x direction

  • nz (int) – number of grid points in the x direction

  • minc (int) – azimuthal symmetry

Returns:

a tuple that contains the three vectors components

Return type:

(numpy.ndarray[nvecs,nz,ny,nx],…)

Potential extrapolation

class magic.potExtra.ExtraPot(rcmb, brcmb, minc, ratio_out=2.0, nrout=32, cutCMB=False, deminc=True)[source]

This class is used to compute the potential field extrapolation of the magnetic field in an arbitrary outer spherical shell domain. It takes as an input the magnetic field at the CMB.

__init__(rcmb, brcmb, minc, ratio_out=2.0, nrout=32, cutCMB=False, deminc=True)[source]
Parameters:
  • bcmb (numpy.ndarary) – the surface radial field, array of dimension [np, nt]

  • rcmb (float) – the value of the radius at the surface

  • minc (int) – azimuthal symmetry

  • ratio_out (float) – the ratio of the outer sphere radius to the surface radius

  • nrout (int) – the number of radial point (linearly spaced) of the extrapolated field in the outer spherical domain

  • cutCMB (bool) – a logical if one wants to remove the first grid point (useful if one then wants to merge the graphic file with the extrapolation)

  • deminc (bool) – a logical to indicate if one wants do get rid of the possible azimuthal symmetry

__weakref__

list of weak references to the object (if defined)

avg(field='br', levels=12, cm='RdYlBu_r', normed=True, vmax=None, vmin=None)[source]

A small routine to plot the azimuthal averages of the extrapolated fields.

Parameters:
  • field (str) – the quantity you want to plot: ‘br’ or ‘bp’

  • levels (int) – the number of contour levels

  • cm (str) – the name of the colormap

  • vmax (float) – maximum value of the contour levels

  • vmin (float) – minimum value of the contour levels

  • normed (bool) – when set to True, the colormap is centered around zero. Default is True, except for entropy/temperature plots.