From dbc3c408a3cd61cc6543dcd2487011888faf1eb2 Mon Sep 17 00:00:00 2001 From: Mayeul Aubin Date: Wed, 21 May 2025 10:41:28 +0200 Subject: [PATCH] tick fix + check that all files exist before starting --- analysis/slices.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/analysis/slices.py b/analysis/slices.py index 2febe16..e47eaff 100755 --- a/analysis/slices.py +++ b/analysis/slices.py @@ -1,6 +1,7 @@ import numpy as np import sys +import os sys.path.append('/home/aubin/Simbelmyne/sbmy_control/') fs = 18 @@ -10,11 +11,11 @@ def add_ax_ticks(ax, ticks, tick_labels): from matplotlib import ticker ax.set_xticks(ticks) ax.set_yticks(ticks) - ax.set_xticklabels(tick_labels) - ax.set_yticklabels(tick_labels) + ax.set_xticklabels([int(t) for t in tick_labels]) + ax.set_yticklabels([int(t) for t in tick_labels]) ax.set_xlabel('Mpc/h') - ax.xaxis.set_major_formatter(ticker.FormatStrFormatter('%d')) - ax.yaxis.set_major_formatter(ticker.FormatStrFormatter('%d')) + # ax.xaxis.set_major_formatter(ticker.FormatStrFormatter('%d')) # Does not work + # ax.yaxis.set_major_formatter(ticker.FormatStrFormatter('%d')) @@ -53,7 +54,7 @@ def plot_imshow_with_reference( data_list, sep = 10 if L[0] < 50 else 20 if L[0] < 100 else 50 if L[0]<250 else 100 if L[0] < 500 else 200 if L[0] < 1000 else 500 if L[0] < 2500 else 1000 ticks = [np.arange(0, l+1, sep)*len(dat)/l for l, dat in zip(L,data_list)] tick_labels = [np.arange(0, l+1, sep) for l in L] - + def score(data, reference): return np.linalg.norm(data-reference)/np.linalg.norm(reference) @@ -177,6 +178,8 @@ if __name__ == "__main__": ref_field = read_field(args.directory+args.reference) if args.reference is not None else None fields = [] for k,f in enumerate(args.filenames): + if not os.path.exists(args.directory+f): + raise FileNotFoundError(f"File {args.directory+f} does not exist.") if args.reference is not None and f == args.reference: fields.append(ref_field) # Simply copy the reference field instead of reading it again if args.labels is not None: