Skip to content

Commit 6feaef6

Browse files
committed
PressureDependenceJob.draw(output_directory) now takes optional filename_stem argument.
Instead of it always being called network.pdf you can now change what it's called. Default is still network.pdf, and argument order is preserved if you call as ordered arguments, for backwards compatibility. This new feature is used when saving the diagram in the case of an InvalidMicrocanonicalRateError
1 parent 09ec287 commit 6feaef6

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

arkane/pdep.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -618,14 +618,18 @@ def plot(self, output_directory):
618618
plt.savefig(os.path.join(output_directory, 'plots', 'kinetics_{0:d}.pdf'.format(count)))
619619
plt.close()
620620

621-
def draw(self, output_directory, file_format='pdf'):
621+
def draw(self, output_directory, file_format='pdf', filename_stem='network'):
622622
"""
623623
Generate a PDF drawing of the pressure-dependent reaction network.
624624
This requires that Cairo and its Python wrapper be available; if not,
625625
the drawing is not generated.
626626
627627
You may also generate different formats of drawings, by changing format to
628628
one of the following: `pdf`, `svg`, `png`.
629+
630+
The default filename stem is 'network', which will result in a file
631+
named 'network.pdf' in the specified output directory. You can change
632+
this by passing a different `filename_stem` argument.
629633
"""
630634

631635
# Skip this step if cairo is not installed
@@ -639,7 +643,7 @@ def draw(self, output_directory, file_format='pdf'):
639643

640644
from rmgpy.pdep.draw import NetworkDrawer
641645

642-
path = os.path.join(output_directory, 'network.' + file_format)
646+
path = os.path.join(output_directory, f'{filename_stem}.{file_format}')
643647

644648
NetworkDrawer().draw(self.network, file_format=file_format, path=path)
645649

rmgpy/rmg/pdep.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ def update(self, reaction_model, pdep_settings, requires_rms=False):
880880
K = self.calculate_rate_coefficients(Tlist, Plist, method)
881881
except InvalidMicrocanonicalRateError:
882882
if output_directory:
883-
job.draw(output_directory, file_format='pdf')
883+
job.draw(output_directory, filename_stem=f'network{self.index:d}_{len(self.isomers)}', file_format='pdf')
884884
logging.info(f"Network {self.index} has been drawn and saved as a pdf in {output_directory}.")
885885
raise
886886

0 commit comments

Comments
 (0)