1. Sam Skillman
  2. multiplot_tools

Commits

Sam Skillman  committed 8e8ff9f

Adding a test example, as well as modifying it so that it prints the x and y axis names, just to be clear for the user.

  • Participants
  • Parent commits 22b3096
  • Branches default

Comments (0)

Files changed (3)

File .hgignore

View file
 syntax: glob
 *.pyc
 
+tests/profiles.h5
+tests/4panel_test.png
+
 syntax: regexp
 .*\#.*\#$

File multiplot_tools/phase_plots.py

View file
     return '%0.1f'%(10.**x)
 
 def getkey(d,k):
-    return d[[key for key in d.keys() if k in key][0]]
+    keyname = [key for key in d.keys() if k in key][0]
+    return d[keyname], keyname
 
 def phase_plot(phase, field,
         xlabel='', ylabel='', zlabel='',
         xlog=True, ylog=True, zlog=True,
         cmap='spectral', zdex=None, zmax=None):
 
-    xvals = getkey(phase.attrs, 'x-axis')
-    yvals = getkey(phase.attrs, 'y-axis')
+    xvals, xkeyname = getkey(phase.attrs, 'x-axis')
+    yvals, ykeyname = getkey(phase.attrs, 'y-axis')
+
+    print 'Using %s as the x-axis' % xkeyname
+    print 'Using %s as the y-axis' % ykeyname
 
     xmin,xmax,ymin,ymax = xvals.min(), xvals.max(), yvals.min(), yvals.max()
     lxmin,lxmax,lymin,lymax = na.log10(xmin), na.log10(xmax), na.log10(ymin), na.log10(ymax)

File tests/test_multi_phase.py

View file
+from multiplot_tools import new_figure, phase_plot 
+import h5py as h5
+import matplotlib.pylab as pl
+
+f = h5.File('profiles.h5','r')
+
+tphase = f['Temperature-Density-2d']
+
+layout = [2,2]
+fig = new_figure(0, layout)
+
+pl.subplot(layout[0],layout[1], 1)
+phase_plot(tphase, 'x-velocity', xlabel='Density', ylabel='Temperature',
+        zlabel='x velocity', 
+        cmap='spectral')
+
+pl.subplot(layout[0],layout[1], 2)
+phase_plot(tphase, 'y-velocity', xlabel='Density', ylabel='Temperature',
+        zlabel='y velocity', 
+        cmap='spectral')
+
+pl.subplot(layout[0],layout[1], 3)
+phase_plot(tphase, 'z-velocity', xlabel='Density', ylabel='Temperature',
+        zlabel='z velocity', 
+        cmap='spectral')
+
+pl.subplot(layout[0],layout[1], 4)
+phase_plot(tphase, 'DivV', xlabel='Density', ylabel='Temperature',
+        zlabel='Divergence', zlog=False, 
+        cmap='spectral')
+
+
+
+
+# if layout == (2,3):
+#     pl.subplot(layout[0],layout[1], 5)
+#     phase_plot(tphase, 'ShockKE', xlabel='Density ($g/cm^3$)', ylabel='Temperature (K)', 
+#             zlabel='Kinetic Energy',zdex=4.)
+#     pl.subplot(layout[0],layout[1], 6)
+#     phase_plot(tphase, 'TotHoeftRadio', xlabel='Density ($g/cm^3$)',
+#             ylabel='Temperature (K)', zlabel='Radio Emission', zdex=8.)
+
+pl.savefig('4panel_test.png',bbox_inches='tight',dpi=200)
+
+
+
+