tick fix + check that all files exist before starting

This commit is contained in:
Mayeul Aubin 2025-05-21 10:41:28 +02:00
parent 56efcface5
commit dbc3c408a3

View file

@ -1,6 +1,7 @@
import numpy as np import numpy as np
import sys import sys
import os
sys.path.append('/home/aubin/Simbelmyne/sbmy_control/') sys.path.append('/home/aubin/Simbelmyne/sbmy_control/')
fs = 18 fs = 18
@ -10,11 +11,11 @@ def add_ax_ticks(ax, ticks, tick_labels):
from matplotlib import ticker from matplotlib import ticker
ax.set_xticks(ticks) ax.set_xticks(ticks)
ax.set_yticks(ticks) ax.set_yticks(ticks)
ax.set_xticklabels(tick_labels) ax.set_xticklabels([int(t) for t in tick_labels])
ax.set_yticklabels(tick_labels) ax.set_yticklabels([int(t) for t in tick_labels])
ax.set_xlabel('Mpc/h') ax.set_xlabel('Mpc/h')
ax.xaxis.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')) # ax.yaxis.set_major_formatter(ticker.FormatStrFormatter('%d'))
@ -177,6 +178,8 @@ if __name__ == "__main__":
ref_field = read_field(args.directory+args.reference) if args.reference is not None else None ref_field = read_field(args.directory+args.reference) if args.reference is not None else None
fields = [] fields = []
for k,f in enumerate(args.filenames): 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: if args.reference is not None and f == args.reference:
fields.append(ref_field) # Simply copy the reference field instead of reading it again fields.append(ref_field) # Simply copy the reference field instead of reading it again
if args.labels is not None: if args.labels is not None: