def show_the_data(paths, t=None, x=None, y=None, z=None, **kwargs):
    """Function which plots the data.

    Parameters
    ----------
    paths : tuple
        The paths of the runs
    t : slice
        The desired t slice of showdata
    x : slice
        The desired x slice of showdata
    y : slice
        The desired y slice of showdata
    z : slice
        The desired z slice of showdata
    **kwargs : key word arguments
        Not used here, but acts like a "dumpster" for additional keyword
        arguments
    """

    for path in paths:
        print("Showing data from {}".format(path))
        n = collect('n', xguards=False, yguards=False, path=path, info=False)

        # Show the data
        showdata(n[t, x, y, z])
def show_the_data(paths, t=None, x=None, y=None, z=None, **kwargs):
    """Function which plots the data.

    Parameters
    ----------
    paths : tuple
        The paths of the runs
    t : slice
        The desired t slice of showdata
    x : slice
        The desired x slice of showdata
    y : slice
        The desired y slice of showdata
    z : slice
        The desired z slice of showdata
    **kwargs : key word arguments
        Not used here, but acts like a "dumpster" for additional keyword
        arguments
    """

    for path in paths:
        print("Showing data from {}".format(path))
        n = collect('n', xguards=False, yguards=False, path=path, info=False)

        # Show the data
        showdata(n[t,x,y,z])
Beispiel #3
0
    def showScanData(self, quant, simType, interval=5, filename='blah',
                     movie=0, fps=5, dpi=300):
        '''
        can only be used on ypi laptop with ffmpeg installed
        gotta make sure path to dataDir is the laptop one
        '''
        if filename == 'blah':
            filename = '{}-{}.mp4'.format(quant, simType)
        else:
            filename = filename
        dataDir = self.dataDir.split('/')[1:-1]  # [4:]
        newDir = ''
        for i in dataDir:
            newDir += '/' + i

        quant = self.scanCollect(quant, simType)
        interval = slice(0, -1, interval)
        titles = self.scanParams

        tme = self.scanCollect('t_array', simType)
        times = []
        for i in tme:
            times.append(i.shape[0])
        uniqTimes = list(set(times))
        uniqTimesIdx = []
        for i in uniqTimes:
            uniqTimesIdx.append(listDuplicates(times, i))
        quantIdx = max(uniqTimesIdx, key=len)

        newQuant = []
        newTitles = []
        for i in quantIdx:
            newQuant.append(quant[i][interval])
            newTitles.append(titles[i])
        newTme = tme[quantIdx[0]][interval]

        # print(newQuant[0].shape)
        # print(newTme.shape)
        # print(newTitles)

        if movie == 1:
            vidDir = newDir + '/analysis/vid'
            if os.path.isdir(vidDir) is not True:
                os.mkdir(vidDir)
            os.chdir(vidDir)

        # return newQuant, newTitles, newTme

        showdata(newQuant, titles=newTitles, t_array=newTme,
                 movie=movie, fps=fps, dpi=dpi, cmap='plasma')

        if movie == 1:
            os.system('mv animation.mp4 {}'.format(filename))
def show_the_data(path, t=None, x=None, y=None, z=None):
    """Function which plots the data.

    Input
    path     -   the path of a run
    t        -   the desired t slice of showdata
    x        -   the desired x slice of showdata
    y        -   the desired y slice of showdata
    z        -   the desired z slice of showdata
    """

    print("Showing data from " + path)
    n = collect('n', xguards=False, yguards=False, path=path, info=False)

    # Show the data
    showdata(n[t, x, y, z])
def show_the_data(path, t=None, x=None, y=None, z=None):
    """Function which plots the data.

    Input
    path     -   the path of a run
    t        -   the desired t slice of showdata
    x        -   the desired x slice of showdata
    y        -   the desired y slice of showdata
    z        -   the desired z slice of showdata
    """

    print("Showing data from " + path)
    n = collect('n', xguards=False, yguards=False, path=path, info=False)

    # Show the data
    showdata(n[t,x,y,z])
# get some parameters
A = max(options['blob']['A'],
        options['blob2']['A'])  # amplitude of the largest filament
Lx = options['mesh']['Lx']  # radial width of domain, in units of rho_s
Lz = options['mesh']['Lz']  # binormal width of domain, in units of rho_s

# x-coordinate in units of rho_s
# make coordinates 2d arrays so that they broadcast correctly with data arrays
x = numpy.linspace(0.5 / nx * Lx, Lx * (1. - 0.5 / nx), nx)[:, numpy.newaxis]

# z-coordinate in units of rho_s
z = numpy.linspace(0., Lz, nz, endpoint=False)[numpy.newaxis, :]

# make a movie of the density
showdata(data['n'][inds], t_array=data['t_array'], x=x[:, 0], y=z[0, :])

# find the centre-of-mass position of the filaments

# take 'filament' to be the density above this level
nmin = 1. + threshold * A

nFilament = data['n'][inds] - nmin
# zero all negative entries, which represent density below the threshold
nFilament[nFilament < 0.] = 0.

# calculate centre-of-mass
# sum over x- and z-dimensions
# don't need area element dx*dz because we only want ratios of integrals
nTotal = numpy.sum(nFilament, axis=(1, 2))
xCoM = numpy.sum(x * nFilament, axis=(1, 2)) / nTotal
Beispiel #7
0
plt.colorbar()
plt.subplot(133)
plt.title('neutral gas density')
plt.contourf(xx, t, ng[:, :, 0, 0], 100)
plt.xlabel('position')
plt.ylabel(r'time [$\mu$s]')
plt.colorbar()
plt.tight_layout()
plt.show()

# plot energy density
plt.figure(figsize=(5, 5))
plt.subplot(111)
plt.title('electron energy density')
plt.contourf(xx, t, NeE[:, :, 0, 0], 100)
plt.xlabel('position')
plt.ylabel(r'time [$\mu$s]')
plt.colorbar()
plt.tight_layout()
plt.show()

showdata(ne[::2, :, ny // 2, :])
showdata(ni[::2, :, ny // 2, :])
showdata(ng[::2, :, ny // 2, :])

showdata(phi[:, :, 0, :])

plt.plot(phiext[:, -1, ny // 2, 0])
plt.grid()
plt.show()
Beispiel #8
0
#!/usr/bin/env python3

from boututils.showdata import showdata
from boutdata import collect
from numpy import *
from matplotlib import pyplot as plt
import sys
import os

# T = collect('T', tind = [5500,6000], yguards = False)
phi = collect('phi', yguards=False)
n = collect('n', yguards=False)
vort = collect('vort', yguards=False)

x = slice(2, -2)
y = 0
z = slice(None)
t = slice(None)

n = n[t, x, y, z]
phi = phi[t, x, y, z]
# T =       T[t,x,y,z]
vort = vort[t, x, y, z]

showdata([[n], [phi], [vort]], titles=['n', 'phi', 'vort'])
Beispiel #9
0
# along with STORM.  If not, see <https://www.gnu.org/licenses/>.

from boutdata.data import BoutOutputs
from boututils.showdata import showdata
import numpy
from sys import exit, argv

# get object that provides access to output from BOUT++
outputs = BoutOutputs(path='.', xguards=False, yguards=False)

# choose variables to plot
varlist = ['n', 'T', 'vort', 'phi', 'U', 'V']

# get y-index (giving position in direction parallel to B)
if len(argv) > 1:
    # get from command line argument
    yindex = int(argv[1])
else:
    # choose midpoint of grid as default
    yindex = outputs['n'].shape[2] // 2

# make a numpy index slice
# indices are {t,x,y,z} so we will make an animation of values on the x-z plane
# at y=yindex
plot_indices = numpy.index_exp[:, :, yindex, :]

# show animation
showdata([outputs[var][plot_indices] for var in varlist], titles=varlist)

exit(0)
Beispiel #10
0
plt.subplot(131)
plt.title('electron density')
plt.contourf(xx, t, ne[:, :, 0], 100)
plt.xlabel('position')
plt.ylabel(r'time [$\mu$s]')
plt.colorbar()
plt.subplot(132)
plt.title('ion density')
plt.contourf(xx, t, ni[:, :, 0], 100)
plt.xlabel('position')
plt.ylabel(r'time [$\mu$s]')
plt.colorbar()
plt.subplot(133)
plt.title('electron energy density')
plt.contourf(xx, t, np.log(E[:, :, 0]), 100)
plt.xlabel('position')
plt.ylabel(r'time [$\mu$s]')
plt.colorbar()
plt.tight_layout()
plt.show()

showdata(ne[::2, :, 0])
showdata(ni[::2, :, 0])
# showdata(ng[::2,:,0])
showdata(E[:, :, 0])
showdata(phi[:, :, 0])

plt.plot(phiext[:, -1, 0])
plt.grid()
plt.show()