diff options
author | Volker Hoffmann <volker@cheleb.net> | 2013-03-22 10:45:27 +0100 |
---|---|---|
committer | Volker Hoffmann <volker@cheleb.net> | 2013-03-22 10:45:27 +0100 |
commit | 80046a10b7ed6aaae7036eca081bde988a6d48ef (patch) | |
tree | 46e6f37914b96659525c2e8aaf2564c6ad8105db | |
parent | 7b4c27aac091e42094c22f01fddb909e20f24759 (diff) |
plot mass flow profile
-rw-r--r-- | mkfig_MdotR.py | 48 | ||||
-rw-r--r-- | mkplot_MdotR.py | 15 | ||||
-rw-r--r-- | plots.py | 48 |
3 files changed, 111 insertions, 0 deletions
diff --git a/mkfig_MdotR.py b/mkfig_MdotR.py new file mode 100644 index 0000000..93da82b --- /dev/null +++ b/mkfig_MdotR.py @@ -0,0 +1,48 @@ +""" +Plot Mass Flow Profile -- Mdot(R). +""" + +import matplotlib as mpl +mpl.use('agg') + +import sys +from plots import plot_MdotR +from helpers import outputs +import numpy as np + + +# Parse Arguments +iout = 1 +if len(sys.argv) == 2: + iout = sys.argv[1] + +# Compute Requested Outputs +iouts = outputs(iout) + +# Loop over Requested Outputs, Determine MinMax +print "Determining MinMax." +first = True +for iiout in iouts[1:]: + + npz = np.load('MdotR_%05d.npz' % iiout) + + if first: + vmin = npz["MdotR"].min() + vmax = npz["MdotR"].max() + first = False + + else: + if npz["MdotR"].min() < vmin: + vmin = npz["MdotR"].min() + if npz["MdotR"].max() > vmax: + vmax = npz["MdotR"].max() + + npz.close() + +# Loop over Requested Outputs, Make Plots +for iiout in iouts[1:]: + + print "Saving Mass Flow Profile for Output %i." % iiout + plot_MdotR(iout=iiout, \ + show=False, save=True, ftype='png',\ + vmin=vmin, vmax=vmax) diff --git a/mkplot_MdotR.py b/mkplot_MdotR.py new file mode 100644 index 0000000..749bc97 --- /dev/null +++ b/mkplot_MdotR.py @@ -0,0 +1,15 @@ +""" +Plot Mass Flow Profile -- Mdot(R). +""" + +import sys +from plots import plot_MdotR + + +# Parse Arguments +iout = 1 +if len(sys.argv) == 2: + iout = int(sys.argv[1]) + +# Make Plot +plot_MdotR(iout=iout, show=True, save=False) @@ -357,3 +357,51 @@ def plot_MdotXY(iout, show=True, save=False, ftype='pdf',\ plt.show() npz.close() + + +""" +Plot/Save Mdot(R). +""" +def plot_MdotR(iout, \ + show=True, save=False, ftype='png',\ + vmin=float('nan'), vmax=float('nan'),\ + yscale='lin'): + + # Load File + npz = np.load('MdotR_%05d.npz' % iout) + + # Log? + if yscale == 'log': + MdotR = np.log10(npz["MdotR"]) + elif yscale == 'lin': + MdotR = npz["MdotR"] + + # Make Plot + plt.figure(1) + plt.plot(npz["rbins"], MdotR, 'b-') + plt.grid() + plt.xlim([0,4]) + # If Passed, Set Value Limits + if (not np.isnan(vmin)) or (not np.isnan(vmax)): + if yscale == 'log': + plt.ylim(np.log10(0.75 * vmin), np.log10(1.25 * vmax)) + elif yscale == 'lin': + if vmin < 0: + plt.ylim(1.25 * vmin, 1.25 * vmax) + else + plt.ylim(0.75 * vmin, 1.25 * vmax) + plt.xlabel('Radius (Arbitrary Units)') + plt.ylabel('Mass Flow (Arbitrary Units)') + if yscale == 'log': + plt.title('Log10 Mass Flow, t = (%.2f, %.2f)' % ( npz["tout1"], npz["tout2"] )) + elif yscale == 'lin': + plt.title('Mass Flow, t = (%.2f, %.2f)' % ( npz["tout1"], npz["tout2"] )) + + if save: + plt.savefig('MdotR_%05d.%s' % ( iout, ftype )) + plt.close() + + if show: + plt.show() + + npz.close() |