<s> """<STR_LIT>""" <EOL> from brian2 import * <EOL> import numpy as np <EOL> import mpl_toolkits . mplot3d . axes3d as p3 <EOL> from matplotlib import pyplot as plt <EOL> from matplotlib import animation <EOL> import h5py <EOL> class Anim3dScatterPlot : <EOL> plottingTimeRange = <NUM_LIT> <EOL> def openHdf5 ( self , hdf5name , permision = "<STR_LIT:w>" ) : <EOL> self . hdf = h5py . File ( hdf5name , permision ) <EOL> def closeHdf5 ( self ) : <EOL> self . hdf . close ( ) <EOL> def getData ( self , group , level ) : <EOL> return self . hdf [ '<STR_LIT:/>' + group + '<STR_LIT:/>' + str ( level ) ] <EOL> def getDownsampleData ( self , group , start , end , screenSize = <NUM_LIT> ) : <EOL> bestLevel = <NUM_LIT:1> <EOL> data = self . getData ( group , bestLevel ) <EOL> print group + "<STR_LIT>" + str ( bestLevel ) + "<STR_LIT>" <EOL> start = int ( start / bestLevel ) <EOL> end = int ( end / bestLevel ) <EOL> if ( end > data . shape [ <NUM_LIT:0> ] ) : <EOL> print data . shape <EOL> print "<STR_LIT>" + str ( float ( end ) ) + "<STR_LIT>" + str ( float ( data . shape [ <NUM_LIT:0> ] * bestLevel / <NUM_LIT> ) ) + "<STR_LIT>" <EOL> end = data . shape [ <NUM_LIT:0> ] - <NUM_LIT:1> <EOL> return data [ start : end ] <EOL> def incorperateData ( self , group , start , end ) : <EOL> start = int ( start * <NUM_LIT> ) <EOL> end = int ( end * <NUM_LIT> ) <EOL> voltage = self . getDownsampleData ( '<STR_LIT>' , start , end ) <EOL> spikes = self . getDownsampleData ( '<STR_LIT>' , start , end ) <EOL> return voltage , spikes <EOL> def create3dAnim ( self ) : <EOL> plottingTimeRange = self . plottingTimeRange <EOL> self . openHdf5 ( '<STR_LIT>' , permision = "<STR_LIT:r>" ) <EOL> start = <NUM_LIT> <EOL> end = <NUM_LIT> <EOL> voltage , spikes = self . incorperateData ( '<STR_LIT>' , start , end ) <EOL> times = np . array ( range ( <NUM_LIT:0> , len ( voltage ) ) ) * <NUM_LIT> <EOL> fig = plt . figure ( ) <EOL> ax = p3 . Axes3D ( fig ) <EOL> ax . set_xlim3d ( [ <NUM_LIT:0.0> , <NUM_LIT> ] ) <EOL> ax . set_xlabel ( '<STR_LIT>' ) <EOL> ax . set_ylim3d ( [ - <NUM_LIT> , <NUM_LIT> ] ) <EOL> ax . set_ylabel ( '<STR_LIT>' ) <EOL> ax . set_zlim3d ( [ - <NUM_LIT> , <NUM_LIT> ] ) <EOL> ax . set_zlabel ( '<STR_LIT>' ) <EOL> ax . set_title ( '<STR_LIT>' ) <EOL> ax . view_init ( elev = <NUM_LIT> , azim = - <NUM_LIT:10> ) <EOL> c = np . array ( [ [ <NUM_LIT:0> ] , [ <NUM_LIT:0> ] , [ <NUM_LIT:0> ] , [ <NUM_LIT:0> ] ] ) <EOL> line = ax . plot ( c [ <NUM_LIT:0> , <NUM_LIT:0> : <NUM_LIT:1> ] , c [ <NUM_LIT:1> , <NUM_LIT:0> : <NUM_LIT:1> ] , c [ <NUM_LIT:2> , <NUM_LIT:0> : <NUM_LIT:1> ] , lw = <NUM_LIT:4> ) [ <NUM_LIT:0> ] <EOL> line2 = ax . plot ( c [ <NUM_LIT:0> , <NUM_LIT:0> : <NUM_LIT:1> ] , c [ <NUM_LIT:1> , <NUM_LIT:0> : <NUM_LIT:1> ] , c [ <NUM_LIT:2> , <NUM_LIT:0> : <NUM_LIT:1> ] , lw = <NUM_LIT:4> ) [ <NUM_LIT:0> ] <EOL> line3 = ax . plot ( c [ <NUM_LIT:0> , <NUM_LIT:0> : <NUM_LIT:1> ] , c [ <NUM_LIT:1> , <NUM_LIT:0> : <NUM_LIT:1> ] , c [ <NUM_LIT:2> , <NUM_LIT:0> : <NUM_LIT:1> ] , lw = <NUM_LIT:4> ) [ <NUM_LIT:0> ] <EOL> line4 = ax . plot ( c [ <NUM_LIT:0> , <NUM_LIT:0> : <NUM_LIT:1> ] , c [ <NUM_LIT:1> , <NUM_LIT:0> : <NUM_LIT:1> ] , c [ <NUM_LIT:2> , <NUM_LIT:0> : <NUM_LIT:1> ] , lw = <NUM_LIT:4> ) [ <NUM_LIT:0> ] <EOL> xVals = np . array ( [ [ <NUM_LIT:0.0> ] * plottingTimeRange , [ <NUM_LIT:1> ] * plottingTimeRange , [ <NUM_LIT:2> ] * plottingTimeRange , [ <NUM_LIT:3> ] * plottingTimeRange ] ) <EOL> def generateLine ( timePoint ) : <EOL> timePointEnd = timePoint + plottingTimeRange <EOL> line . set_data ( xVals [ <NUM_LIT:0> ] , times [ <NUM_LIT:0> : plottingTimeRange ] ) <EOL> line . set_3d_properties ( transpose ( voltage ) [ <NUM_LIT:0> ] [ timePoint : timePointEnd ] ) <EOL> line2 . set_data ( xVals [ <NUM_LIT:1> ] , times [ <NUM_LIT:0> : plottingTimeRange ] ) <EOL> line2 . set_3d_properties ( transpose ( voltage ) [ <NUM_LIT:1> ] [ timePoint : timePointEnd ] ) <EOL> line3 . set_data ( xVals [ <NUM_LIT:2> ] , times [ <NUM_LIT:0> : plottingTimeRange ] ) <EOL> line3 . set_3d_properties ( transpose ( voltage ) [ <NUM_LIT:2> ] [ timePoint : timePointEnd ] ) <EOL> line4 . set_data ( xVals [ <NUM_LIT:3> ] , times [ <NUM_LIT:0> : plottingTimeRange ] ) <EOL> line4 . set_3d_properties ( transpose ( voltage ) [ <NUM_LIT:3> ] [ timePoint : timePointEnd ] ) <EOL> if timePoint == <NUM_LIT:100> or timePoint == <NUM_LIT:200> or timePoint == <NUM_LIT> or timePoint == <NUM_LIT> or timePoint == <NUM_LIT> : <EOL> print '<STR_LIT>' , timePoint <EOL> line_ani = animation . FuncAnimation ( fig , generateLine , frames = <NUM_LIT:1000> , interval = <NUM_LIT> , blit = False ) <EOL> ext = '<STR_LIT>' <EOL> fps = <NUM_LIT:30> <EOL> codec = { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : '<STR_LIT>' } . get ( ext , '<STR_LIT>' ) <EOL> line_ani . save ( '<STR_LIT>' , fps = <NUM_LIT:30> , extra_args = [ '<STR_LIT>' , '<STR_LIT>' ] ) <EOL> plt . show ( ) <EOL> def __init__ ( self ) : <EOL> self . create3dAnim ( ) <EOL> self . closeHdf5 <EOL> def main ( ) : <EOL> run3dAnim = Anim3dScatterPlot ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : main ( ) <EOL> print '<STR_LIT>' </s>
