Skip to content

Commit

Permalink
bugfix addresses #101 allow RecSec 'save' to be None
Browse files Browse the repository at this point in the history
  • Loading branch information
bch0w committed Mar 8, 2023
1 parent 2487f8e commit 4a7b0d7
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions pysep/recsec.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def __init__(self, pysep_path=None, syn_path=None, stations=None,
:param show: show the figure as a graphical output
:type save: str
:param save: path to save output figure, will create the parent
directory if it doesn't exist. If None, will not save.
directory if it doesn't exist. If None, will not save (default).
.. note::
Internal RecSec parameters
Expand Down Expand Up @@ -696,15 +696,16 @@ def check_parameters(self):
if len(self.figsize) != 2:
err.figsize = "must be tuple defining (horizontal, vertical) extent"

if os.path.exists(self.save) and not self.overwrite:
err.save = (f"path {self.save} already exists. Use '--overwrite' "
f"flag to save over existing figures.")

if self.save:
_dirname = os.path.abspath(os.path.dirname(self.save))
if not os.path.exists(_dirname):
logger.info(f"creating output directory {_dirname}")
os.makedirs(_dirname)
if os.path.exists(self.save) and not self.overwrite:
err.save = (f"path {self.save} already exists. Use "
f"'--overwrite' flag to save over existing figures"
)
else:
_dirname = os.path.abspath(os.path.dirname(self.save))
if not os.path.exists(_dirname):
logger.info(f"creating output directory {_dirname}")
os.makedirs(_dirname)

if err:
out = "ERROR - Parameter errors, please make following changes:\n"
Expand Down

0 comments on commit 4a7b0d7

Please sign in to comment.