Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def main():
- import matplotlib
- matplotlib.use('Qt4Agg')
- import glob
- import numpy
- import h5py
- import pylab
- all_contour_files = glob.glob('contour_*.h5')
- max_time_index = numpy.max([int(fname.split('_')[1].replace('.h5','')) for fname in all_contour_files])
- for i in range(2,max_time_index+1,2):
- current_contour_files = glob.glob('contour_'+str(i)+'_*.h5')
- x_temp = []
- y_temp = []
- for fname in current_contour_files:
- with h5py.File(fname) as f:
- x_filtered = [x for x,y in zip(f['x'],f['y']) if x**2+y**2>0.02**2]
- y_filtered = [y for x,y in zip(f['x'],f['y']) if x**2+y**2>0.02**2]
- x_temp.extend(x_filtered)
- y_temp.extend(y_filtered)
- angles = numpy.arctan2(numpy.array(y_temp)+1, numpy.array(x_temp))
- x_sorted = numpy.array([x for a,x in sorted(zip(angles,x_temp))])
- y_sorted = numpy.array([y for a,y in sorted(zip(angles,y_temp))])
- pylab.plot(y_sorted, x_sorted)
- pylab.xlabel('x [parsec]')
- pylab.ylabel('y [parsec]')
- pylab.title('Shock fronts at 20 year intervals')
- pylab.axis('equal',adjustable='box')
- pylab.show()
- #pylab.savefig('shock_fronts.png')
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement