mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 13:45:36 -04:00
only add png or h5 extension if not present in plots.py (#3036)
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
This commit is contained in:
parent
dcb80338c5
commit
3e16c038fe
1 changed files with 16 additions and 5 deletions
|
|
@ -171,8 +171,14 @@ def _get_plot_image(plot, cwd):
|
|||
from IPython.display import Image
|
||||
|
||||
# Make sure .png file was created
|
||||
stem = plot.filename if plot.filename is not None else f'plot_{plot.id}'
|
||||
png_file = Path(cwd) / f'{stem}.png'
|
||||
png_filename = plot.filename if plot.filename is not None else f'plot_{plot.id}'
|
||||
|
||||
# Add file extension if not already present. The C++ code added it
|
||||
# automatically if it wasn't present.
|
||||
if Path(png_filename).suffix != ".png":
|
||||
png_filename += ".png"
|
||||
|
||||
png_file = Path(cwd) / png_filename
|
||||
if not png_file.exists():
|
||||
raise FileNotFoundError(
|
||||
f"Could not find .png image for plot {plot.id}. Your version of "
|
||||
|
|
@ -630,7 +636,7 @@ class Plot(PlotBase):
|
|||
cv.check_type('plot meshlines', meshlines, dict)
|
||||
if 'type' not in meshlines:
|
||||
msg = f'Unable to set the meshlines to "{meshlines}" which ' \
|
||||
'does not have a "type" key'
|
||||
'does not have a "type" key'
|
||||
raise ValueError(msg)
|
||||
|
||||
elif meshlines['type'] not in ['tally', 'entropy', 'ufs', 'cmfd']:
|
||||
|
|
@ -968,8 +974,13 @@ class Plot(PlotBase):
|
|||
# Run OpenMC in geometry plotting mode and produces a h5 file
|
||||
openmc.plot_geometry(False, openmc_exec, cwd)
|
||||
|
||||
stem = self.filename if self.filename is not None else f'plot_{self.id}'
|
||||
h5_voxel_file = Path(cwd) / f'{stem}.h5'
|
||||
h5_voxel_filename = self.filename if self.filename is not None else f'plot_{self.id}'
|
||||
|
||||
# Add file extension if not already present
|
||||
if Path(h5_voxel_filename).suffix != ".h5":
|
||||
h5_voxel_filename += ".h5"
|
||||
|
||||
h5_voxel_file = Path(cwd) / h5_voxel_filename
|
||||
if output is None:
|
||||
output = h5_voxel_file.with_suffix('.vti')
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue