Plot output from OSG

In the demo to run python on the open science grid (OSG), we generated compressed numpy files that contain our results.

In this notebook, we extract these results and plot them on our data to confirm that our program ran correctly.

1. iterate through tar files and unzip them


In [3]:
import tarfile

fname_base = '/gh/data/example/lfp_set_PsTs/out.29419325.'
Nfiles = 10
for n in range(Nfiles):
    fname = fname_base + str(n) + '.tar.gz'
    tar = tarfile.open(fname, "r:gz")
    tar.extractall('/gh/data/example/lfp_set_PsTs/' + str(n) + '/')
    tar.close()

2. Load each array of Ps and Ts


In [4]:
import numpy as np

Ps = np.zeros(Nfiles, dtype=np.ndarray)
Ts = np.zeros(Nfiles, dtype=np.ndarray)
for n in range(Nfiles):
    Ps[n] = np.load('/gh/data/example/lfp_set_PsTs/' + str(n) + '/out/Ps_data.npy')
    Ts[n] = np.load('/gh/data/example/lfp_set_PsTs/' + str(n) + '/out/Ts_data.npy')

3. Load signals


In [5]:
lfps = np.zeros(Nfiles, dtype=np.ndarray)
for n in range(Nfiles):
    if n == 0:
        lfps[n] = np.load('/gh/data/example/lfp_set/' + str(10) + '.npy')
    else:
        lfps[n] = np.load('/gh/data/example/lfp_set/' + str(n) + '.npy')

4. Plot peaks and troughs on top of signals


In [7]:
import matplotlib.pyplot as plt
%matplotlib inline

plt.figure(figsize=(10,10))
for n in range(Nfiles):
    plt.subplot(Nfiles, 1, n+1)
    plt.plot(lfps[n], 'k')
#     plt.plot(Ps[n], lfps[n][Ps[n]], 'bo')
#     plt.plot(Ts[n], lfps[n][Ts[n]], 'ro')
    if n == Nfiles-1:
        plt.xlabel('Time (ms)')
    else:
        plt.xticks([])
    plt.ylim((-3000,3000))
    plt.yticks([-3000,0,3000])
    if n == 0:
        plt.ylabel('Voltage (uV)')



In [ ]: