plots.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 '''
4 Make some plots from simulation output
5 '''
6 
7 import numpy
8 import matplotlib.pyplot as plt
9 
10 def numpy_saver(filename, outfile):
11  '''
12  plot data from Numpy*Saver files
13  '''
14  tick1=0
15  tick2=500
16 
17  fp = numpy.load(filename)
18  frame = fp['frame__0'].T
19  channels = fp['channels__0']
20  chd = channels[1:] - channels[:-1]
21  chjumps = [0] + list(numpy.where(chd>1)[0]) + [channels.size-1]
22  indjumps = zip(chjumps[:-1], chjumps[1:])
23 
24  njumps = len(indjumps)
25  fig, axes = plt.subplots(nrows=njumps, ncols=1)
26  if njumps == 1:
27  axes = [axes]
28 
29  for ax, (ind1, ind2) in zip(axes, indjumps):
30  ch1 = channels[ind1+1]
31  ch2 = channels[ind2]
32 
33  extent = (tick1, tick2, ch2, ch1)
34 
35  print ( "array ind: [%4d,%4d] channels: [%4d,%4d] %d" % (ind1,ind2, ch1, ch2, ind2-ind1+1))
36  im = ax.imshow(frame[ind1+1:ind2,tick1:tick2],aspect='auto')#,extent=extent)
37  plt.colorbar(im, ax=ax)
38 
39  plt.savefig(outfile)
40  return fig,axes
41 
42 if '__main__' == __name__:
43  import sys
44  numpy_saver(sys.argv[1], sys.argv[2])
45 
auto zip(Iterables &&...iterables)
Range-for loop helper iterating across many collections at the same time.
Definition: zip.h:295
def numpy_saver(filename, outfile)
Definition: plots.py:10