Figure 1

Start by loading some boiler plate: matplotlib, numpy, scipy, json, functools, and a convenience class.


In [1]:
%matplotlib inline
import matplotlib
matplotlib.rcParams['figure.figsize'] = (10.0, 16.0)
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import interp1d, InterpolatedUnivariateSpline
from scipy.optimize import bisect
import json
from functools import partial
class Foo: pass

And some more specialized dependencies:

  1. Slict provides a convenient slice-able dictionary interface
  2. Chest is an out-of-core dictionary that we'll hook directly to a globus remote using...
  3. glopen is an open-like context manager for remote globus files

In [2]:
from chest import Chest
from slict import CachedSlict
from glopen import glopen, glopen_many

Configuration for this figure.


In [3]:
config = Foo()
config.name     = "HighAspect/HA_conductivity_1.0E-5/HA_conductivity_1.0E-5"
config.arch_end = "alcf#dtn_mira/projects/alpha-nek/experiments/"
config.frame = 100
config.lower = .1
config.upper = .9

Open a chest located on a remote globus endpoint and load a remote json configuration file.


In [4]:
c = Chest(path      = "{:s}-results".format(config.name),
          open      = partial(glopen,      endpoint=config.arch_end),
          open_many = partial(glopen_many, endpoint=config.arch_end))
sc = CachedSlict(c)
with glopen(
            "{:s}.json".format(config.name), mode='r',
            endpoint = config.arch_end,
            ) as f:
    params = json.load(f)

We want to grab all the data for the selected frame.


In [5]:
T = sc[:,'H'].keys()[config.frame]
frame = sc[T,:]
c.prefetch(frame.full_keys())

In [6]:
fig = plt.figure()

nx = frame['t_yz'].shape[0]
ny = frame['t_yz'].shape[1]

full = np.concatenate((frame['t_yz'], np.flipud(frame['t_yz'])), axis=0)

plt.imshow(full[:,int(ny*config.lower):int(ny*config.upper)].transpose(),
           origin='lower')
plt.colorbar();


Plot the bubble height, the 'H' keys, vs. time. Use a spline to compute the derivative.


In [7]:
fig = plt.figure()

nx = frame['t_yz'].shape[0]
ny = frame['t_yz'].shape[1]

plt.imshow(frame['fz_yz'][:,int(ny*config.lower):int(ny*config.upper)].transpose(),
           vmin = -params['atwood']*params['g']*2,
           vmax =  params['atwood']*params['g']*2,
           origin='lower')
plt.colorbar();
plt.contour(frame['fz_yz'][:,int(ny*config.lower):int(ny*config.upper)].transpose(), 
            colors='k', 
            levels=[-params['atwood']*params['g'], params['atwood']*params['g']])
#axs[1].imshow(frame['fz_yz'].transpose(), origin='lower')


Out[7]:
<matplotlib.contour.QuadContourSet at 0x2b5aa8003da0>

In [8]:
def laplace(grid):
    from numpy.fft import fftn, ifftn, fftfreq
    kx = fftfreq(grid.shape[0])
    ky = fftfreq(grid.shape[1])
    kgrid = fftn(grid)
    for i in range(kgrid.shape[0]):
        for j in range(kgrid.shape[1]):
            if kx[i] != 0 or ky[j] != 0:
                kgrid[i,j] = kgrid[i,j] / (kx[i]**2 + ky[j]**2)
    kgrid[0,0] = 0.
    rgrid = np.array(ifftn(kgrid), dtype=float)
    return rgrid

In [9]:
fig = plt.figure()

nx = frame['t_yz'].shape[0]
ny = frame['t_yz'].shape[1]
full = np.concatenate((frame['vorticity_yz'], -np.flipud(frame['vorticity_yz'])), axis=0)
plt.imshow(full[:,int(ny*config.lower):int(ny*config.upper)].transpose(),
           origin='lower')
#axs[1].imshow(frame['fz_yz'].transpose(), origin='lower')
plt.colorbar();



In [10]:
full = np.concatenate((frame['vorticity_yz'], -np.flipud(frame['vorticity_yz'])), axis=0)
streamfunction = laplace(full[:,:]);


/home/maxhutch/anaconda3/lib/python3.4/site-packages/IPython/kernel/__main__.py:11: ComplexWarning: Casting complex values to real discards the imaginary part

In [11]:
fig = plt.figure()

nx = frame['t_yz'].shape[0]
ny = frame['t_yz'].shape[1]
print(np.max(streamfunction), np.min(streamfunction))
full = np.concatenate((frame['t_yz'], np.flipud(frame['t_yz'])), axis=0)

#background = np.tile(frame['t_yz'][:,int(ny*config.lower):int(ny*config.upper)].transpose(), (1,4))
background = np.tile(streamfunction[:,int(ny*config.lower):int(ny*config.upper)].transpose(), (1,4))
foreground = np.tile(streamfunction[:,int(ny*config.lower):int(ny*config.upper)].transpose(), (1,4))

plt.imshow(background,
           origin='lower', alpha=0.1)
plt.colorbar();
plt.contour(foreground,
           origin='lower', colors='k',
           #levels=[-100,0,100]
           )
#axs[1].imshow(frame['fz_yz'].transpose(), origin='lower')


220582.473942 -220582.473942
Out[11]:
<matplotlib.contour.QuadContourSet at 0x2b5a9c117390>

In [12]:
fig = plt.figure()

nx = frame['t_yz'].shape[0]
ny = frame['t_yz'].shape[1]
full = np.concatenate((frame['total_pressure_yz'], np.flipud(frame['total_pressure_yz'])), axis=0)
plt.imshow(full[:,int(ny*config.lower):int(ny*config.upper)].transpose(),
           origin='lower')
#axs[1].imshow(frame['fz_yz'].transpose(), origin='lower')
plt.colorbar();



In [13]:
%install_ext http://raw.github.com/jrjohansson/version_information/master/version_information.py 
%load_ext version_information 
%version_information numpy, matplotlib, slict, chest, glopen, globussh


Installed version_information.py. To use it, type:
  %load_ext version_information
Out[13]:
SoftwareVersion
Python3.4.3 64bit [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]
IPython3.0.0
OSLinux 3.2.0 4 amd64 x86_64 with debian 7.8
numpy1.9.2
matplotlib1.4.3
slict0.2.5
chest0.2.1
glopen0.0.11
globussh0.1.0
Thu Jul 02 10:14:07 2015 CDT