Commit 67dbf35b authored by Salko Jr, Robert's avatar Salko Jr, Robert
Browse files

Expand plot tools

Adds three new scripts for plotting liquid, vapor, and droplet axial velocity plus entry points. Expands on the surface plotter tool so it can accept a maximum value for data to show in contour plot. Adds tests for these scripts as well.
parent b0e6903a
Loading
Loading
Loading
Loading
+41 −7
Original line number Diff line number Diff line
@@ -332,6 +332,36 @@ class PlotTools(object):
       """
       me._chanPlotMaxWrapper('chan_void_vap', "Void [-]", state, ch, figname)

   def plotChAxialVliq(me, state=None, ch=None, figname=None):
       """ Makes an axial plot of liquid velocity for a channel

       Args:
          state (int): State number to plot (1-based).  If not present, selects state with maximum.
          ch (int): Chan number to plot (1-based). If not present, selects chan with maximum.
          figname (str): Name of the figure.
       """
       me._chanPlotMaxWrapper('chan_velocity_liq', "Velocity [m/s]", state, ch, figname)

   def plotChAxialVvap(me, state=None, ch=None, figname=None):
       """ Makes an axial plot of vapor velocity for a channel

       Args:
          state (int): State number to plot (1-based).  If not present, selects state with maximum.
          ch (int): Chan number to plot (1-based). If not present, selects chan with maximum.
          figname (str): Name of the figure.
       """
       me._chanPlotMaxWrapper('chan_velocity_vap', "Velocity [m/s]", state, ch, figname)

   def plotChAxialVdrp(me, state=None, ch=None, figname=None):
       """ Makes an axial plot of droplet velocity for a channel

       Args:
          state (int): State number to plot (1-based).  If not present, selects state with maximum.
          ch (int): Chan number to plot (1-based). If not present, selects chan with maximum.
          figname (str): Name of the figure.
       """
       me._chanPlotMaxWrapper('chan_velocity_drp', "Velocity [m/s]", state, ch, figname)

   def plotChAxialQuality(me, state=None, ch=None, figname=None):
       """ Makes an axial plot of equilibrium quality for a channel

@@ -363,7 +393,7 @@ class PlotTools(object):
       me._chanPlotMaxWrapper('massflux_tot', "Mass flux [kg/m**2/s]", state, ch, figname)


   def plotPinCoupling(me, pin, dataset, state=None, figname=None, axialBounds=None, maxTemp=None):
   def plotPinCoupling(me, pin, dataset, state=None, figname=None, axialBounds=None, minData=None, maxData=None):
      """ Makes a contour plot of rod surface data

      Passed dataset must be a coupling dataset (has prefix of "coupling")
@@ -376,7 +406,8 @@ class PlotTools(object):
         axialBounds (float) : List of 2 values.  Specify min and max axial locations to include
            in plot.  Specify "None" to use the dataset min or max.  First value is the min and
            second is the max.
         maxTemp (float) : Maximum temp to show in contour plot [C]
         minData (float) : Minimum value to show in contour plot
         maxData (float) : Maximum value to show in contour plot

      """
      if state is None:
@@ -405,11 +436,14 @@ class PlotTools(object):
      if axialBounds_[1] is None:
         axialBounds_[1] = max(axial)

      if maxTemp is None:
         maxTemp_ = np.max(data)
      if maxData is None:
         maxData_ = np.max(data)
      else:
         maxData_ = maxData
      if minData is None:
         minData_ = np.min(data)
      else:
         maxTemp_ = maxTemp
      minTemp_ = np.min(data)
         minData_ = minData

      fig, ax = plt.subplots()
      plt.title(location)
@@ -419,7 +453,7 @@ class PlotTools(object):
      #v = np.linspace(minTemp_, maxTemp_, 7, endpoint=True)
      #c1 = ax.contourf(azimuthal, axial, data, v)
      #cbar = plt.colorbar(c1)
      im = ax.pcolor(azimuthal, axial, data, vmin=minTemp_, vmax=maxTemp_)
      im = ax.pcolor(azimuthal, axial, data, vmin=minData_, vmax=maxData_)
      ax.grid()
      cbar = fig.colorbar(im)
      dataset = dataset.replace('_',' ')
+18 −0
Original line number Diff line number Diff line
import argparse
from PlotTools import PlotTools

def main():
   parser = argparse.ArgumentParser(description="Plot the axial droplet velocity distribution in a channel.  All indices are 1-based.")
   parser.add_argument('h5name', type=str, help="HDF5 file")
   parser.add_argument('--state', type=int, nargs="?", help="State to plot.  Defaults to state with max droplet velocity.")
   parser.add_argument('--ch', type=int, action='append', help="""Channel to plot.  Defaults to channel with max droplet velocity.
         Can plot multiple channels (e.g. --ch 1 --ch 2 --ch 3 ...)""")
   parser.add_argument('--figname', type=str, nargs="?", help="Name of figure.  Defaults to name based on location and dataset type.")
   args = parser.parse_args()

   plotter = PlotTools(args.h5name)

   plotter.plotChAxialVdrp(args.state, args.ch, args.figname)

if __name__=='__main__':
   main()
+18 −0
Original line number Diff line number Diff line
import argparse
from PlotTools import PlotTools

def main():
   parser = argparse.ArgumentParser(description="Plot the axial liquid velocity distribution in a channel.  All indices are 1-based.")
   parser.add_argument('h5name', type=str, help="HDF5 file")
   parser.add_argument('--state', type=int, nargs="?", help="State to plot.  Defaults to state with max liquid velocity.")
   parser.add_argument('--ch', type=int, action='append', help="""Channel to plot.  Defaults to channel with max liquid velocity.
         Can plot multiple channels (e.g. --ch 1 --ch 2 --ch 3 ...)""")
   parser.add_argument('--figname', type=str, nargs="?", help="Name of figure.  Defaults to name based on location and dataset type.")
   args = parser.parse_args()

   plotter = PlotTools(args.h5name)

   plotter.plotChAxialVliq(args.state, args.ch, args.figname)

if __name__=='__main__':
   main()
+18 −0
Original line number Diff line number Diff line
import argparse
from PlotTools import PlotTools

def main():
   parser = argparse.ArgumentParser(description="Plot the axial vapor velocity distribution in a channel.  All indices are 1-based.")
   parser.add_argument('h5name', type=str, help="HDF5 file")
   parser.add_argument('--state', type=int, nargs="?", help="State to plot.  Defaults to state with max vapor velocity.")
   parser.add_argument('--ch', type=int, action='append', help="""Channel to plot.  Defaults to channel with max vapor velocity.
         Can plot multiple channels (e.g. --ch 1 --ch 2 --ch 3 ...)""")
   parser.add_argument('--figname', type=str, nargs="?", help="Name of figure.  Defaults to name based on location and dataset type.")
   args = parser.parse_args()

   plotter = PlotTools(args.h5name)

   plotter.plotChAxialVvap(args.state, args.ch, args.figname)

if __name__=='__main__':
   main()
+2 −1
Original line number Diff line number Diff line
@@ -9,12 +9,13 @@ def main():
   parser.add_argument('--figname', type=str, nargs="?", help="Name of figure.  Defaults to name based on location.")
   parser.add_argument('--min_axial', type=float, help="Lower axial bound of plot (defaults to minimum axial location).")
   parser.add_argument('--max_axial', type=float, help="Upper axial bound of plot (defaults to maximum axial location).")
   parser.add_argument('--min', type=float, help="Lower bound for data")
   parser.add_argument('--max', type=float, help="Upper bound for data")
   args = parser.parse_args()

   plotter = PlotTools(args.h5name)

   plotter.plotPinCoupling(args.pin, 'coupling_surface_tke', args.state, args.figname, [args.min_axial, args.max_axial], args.max)
   plotter.plotPinCoupling(args.pin, 'coupling_surface_tke', args.state, args.figname, [args.min_axial, args.max_axial], args.min, args.max)

if __name__=='__main__':
   main()
Loading