Skip to content

Commit

Permalink
Improved docstrings for many functions in post-processing
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaunFell committed Sep 4, 2024
1 parent ffd8b41 commit edcbb92
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 20 deletions.
10 changes: 4 additions & 6 deletions PostProcessing/IntegralsPlot.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ def main():
IOError: Data path not found
IOError: Data file not found
RuntimeError: No plot variables specified
SystemError: No plot variables specified
SystemError: Number of x limits does not match number of plot variables
SystemError: Number of linestyles does not match number of plot variables
RuntimeError: Number of linestyles does not match number of plot variables.
RuntimeError: Number of xlims does not match number of plot variables.
"""

#Extract basic file information
Expand All @@ -55,7 +54,7 @@ def main():

#get the plot variables
plot_variables = config["VariableData"].get("plot_variables", "").split()
if len(plot_variables) == 0:
if not plot_variables:
raise RuntimeError("No plot variables specified.")


Expand All @@ -66,7 +65,7 @@ def main():
if linestyles == "":
linestyles = None

if not len(linestyles) == len(plot_variables) and linestyles != None:
if len(linestyles) != len(plot_variables) and linestyles is not None:
raise RuntimeError("Number of linestyles does not match number of plot variables.")

# get the x limits
Expand All @@ -88,4 +87,3 @@ def main():
main()
elif __visit_script_file__ == __visit_source_file__:
raise RuntimeError("This file should not be run with VisIt, only Python!")

1 change: 0 additions & 1 deletion PostProcessing/Source/Common/Engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,3 @@ def setup_engine(config):
if not openengine_status:
print("Job submission failed. Exiting...")
sys.exit(1)

26 changes: 23 additions & 3 deletions PostProcessing/Source/Common/PlotSetup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ def Annotation_Setup(config):
Args:
config (configparser.ConfigParser): instance of a ConfigParser class that holds the users parameters
Raises:
RuntimeError: Could not set Annotation attributes. Aborting.
"""

#initialize verbosity printing
Expand Down Expand Up @@ -73,6 +76,9 @@ def Pseudocolor_Setup(config, variableToPlot, setplotbounds, plotbounds):
variableToPlot (str): name of the variable to be plotted
setplotbounds (bool): flag to specify whether bounds for the plotting variable should be specified
plotbounds (list): list of two values that specify the minimum and maximum value of the plot variable
Raises:
RuntimeError: Could not set Pseudocolor attributes. Aborting.
"""

#initialize verbosity printing
Expand Down Expand Up @@ -130,6 +136,9 @@ def Volume_Setup(config, variableToPlot):
Args:
config (configparser.ConfigParser): instance of a ConfigParser class that holds the users parameters
variableToPlot (str): name of the variable to be plotted
Raises:
RuntimeError: Could not set Volume attributes. Aborting.
"""

#initialize verbosity printing
Expand Down Expand Up @@ -205,6 +214,9 @@ def SliceAttribute_Setup(config):
Args:
config (configparser.ConfigParser): instance of a ConfigParser class that holds the users parameters
Raises:
RuntimeError: Could not set slice attributes. Aborting.
"""

#initialize verbosity printing
Expand Down Expand Up @@ -264,6 +276,9 @@ def Mesh_Setup(config):
Args:
config (configparser.ConfigParser): instance of a ConfigParser class that holds the users parameters
Raises:
RuntimeError: Could not set mesh attributes. Aborting.
"""

#initialize verbosity printing
Expand Down Expand Up @@ -292,6 +307,9 @@ def View_2D_Setup(config):
Args:
config (configparser.ConfigParser): instance of a ConfigParser class that holds the users parameters
Raises:
RuntimeError: Failed to set 2D view.
"""

#initialize verbosity printing
Expand Down Expand Up @@ -338,7 +356,7 @@ def View_2D_Setup(config):
#set the above view attributes
status = visit.SetView2D(View2DAtts)

if not status:
if not status:
raise RuntimeError("Failed to set 2D view")

return status
Expand All @@ -349,6 +367,9 @@ def View_3D_Setup(config):
Args:
config (configparser.ConfigParser): instance of a ConfigParser class that holds the users parameters
Raises:
RuntimeError: Failed to set 3D view.
"""

#initialize verbosity printing
Expand Down Expand Up @@ -382,7 +403,7 @@ def View_3D_Setup(config):
#set the above view attributes
status = visit.SetView3D(View3DAtts)

if not status:
if not status:
raise RuntimeError("Failed to set 3D view")

return status
Expand Down Expand Up @@ -451,4 +472,3 @@ def Save_Current_Window(config, variableToPlot):
status = visit.SaveWindow()

return status

6 changes: 0 additions & 6 deletions PostProcessing/Source/Common/Plotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ def make_visit_plot(config, variableToPlot, hdf5files, plot_type = '2d', setplot
plotbounds (list, optional): list of two values that specify the minimum and maximum value of the plot variable. Defaults to [0,1].
Raises:
IOError: Database could not be opened
RuntimeError: TimeSlider could not advance
RuntimeError: Window could not be saved
SystemError: Plot could not be cleared from memory
Expand Down Expand Up @@ -83,8 +82,3 @@ def make_visit_plot(config, variableToPlot, hdf5files, plot_type = '2d', setplot
plotdelete_status = visit.DeleteAllPlots()
if not plotdelete_status:
raise SystemError("Plot could not be deleted!")





20 changes: 20 additions & 0 deletions PostProcessing/Source/Common/Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,17 @@ def Open_Database(config):

@require_visit
def Close_Database(config):
"""Close a VisIt database object
Args:
config (configparser.ConfigParser): instance of a ConfigParser class that holds the users parameters
Raises:
IOError: Could not close database!
Returns:
int: status code of closing database
"""

if MultipleDatabase(config):
filename_prefix = os.path.join(config["Header"]["hdf5_path"], config["Header"]["plot_header"])
Expand Down Expand Up @@ -311,6 +322,15 @@ def save_pyplot_fig(config, varname):


def make_movie(config, plotvariable):
"""Generates movie using ffmpeg from a series of images
Args:
config (configparser.ConfigParser): instance of a ConfigParser class that holds the users parameters
plotvariable (str): name of the variable to be plotted
Raises:
OSError: ffmpeg failed. Could not make the movie.
"""

make_movie = config["Output"].getint("make_movie", fallback = 0)

Expand Down
1 change: 0 additions & 1 deletion PostProcessing/Source/OneD/LinePlot.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,3 @@ def make_plots(config, data_obj, plot_variables, plotbounds = None, linestyles
plt.legend()
plt.ylabel("") #remove ylabel for combined plot
save_pyplot_fig(config, "combined")

6 changes: 3 additions & 3 deletions PostProcessing/VisitPlot.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def main():
"""main function to run VisIt plot routines
Raises:
OSError: ffmpeg failed. Could not make the movie.
RuntimeError: No plot variables specified!
"""

# get list of all hdf5 plot files
Expand All @@ -40,8 +40,8 @@ def main():

# get list of plot variables
plot_variables = config["VariableData"].get("plot_variables", "").split()
if len(plot_variables) == 0:
raise SystemError("No plot variables specified!")
if not plot_variables:
raise RuntimeError("No plot variables specified!")

verbPrint("Number of plot variables: ", len(plot_variables))
verbPrint("Variables to be plotted: ", config["VariableData"].get("plot_variables", ""))
Expand Down

0 comments on commit edcbb92

Please sign in to comment.