From 2e4461769d5d4871ea5b36308f9649ffd154fd90 Mon Sep 17 00:00:00 2001 From: Massimiliano Lincetto Date: Tue, 17 Oct 2023 11:09:51 +0200 Subject: [PATCH] set plotting dir --- skyreader/result.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/skyreader/result.py b/skyreader/result.py index d8b3584a..834bce17 100644 --- a/skyreader/result.py +++ b/skyreader/result.py @@ -594,6 +594,9 @@ def check_result(self): for k in self.result: if "nside-" not in k: raise RuntimeError("\"nside\" not in result file..") + + PLOT_DIR = Path("./output/plots") + PLOT_DIR.mkdir(exist_ok=True) @staticmethod # Calculates are using Gauss-Green theorem / shoelace formula @@ -821,7 +824,7 @@ def create_plot(self, dozoom = False): print(f"saving: {plot_filename}...") - fig.savefig(plot_filename, dpi=dpi, transparent=True) + fig.savefig(self.PLOT_DIR / plot_filename, dpi=dpi, transparent=True) print("done.") @@ -1150,7 +1153,7 @@ def bounding_box(ra, dec, theta, phi): savename = unique_id + ".contour_" + val + ".txt" try: print("Dumping to", savename) - ascii.write(tab, savename, overwrite=True) + ascii.write(tab, self.PLOT_DIR / savename, overwrite=True) except OSError as err: print("OS Error prevented contours from being written, maybe a memory issue.") print(err) @@ -1215,7 +1218,7 @@ def bounding_box(ra, dec, theta, phi): # Save the figure print("saving: {0}...".format(plot_filename)) #ax.invert_xaxis() - fig.savefig(plot_filename, dpi=dpi, transparent=True) + fig.savefig(self.PLOT_DIR / plot_filename, dpi=dpi, transparent=True) print("done.")