mirror of
https://gitlab.science.ru.nl/mthesis-edeboone/m-thesis-introduction.git
synced 2024-11-14 02:23:32 +01:00
ZH: indicate when k-finding find the same ks
This commit is contained in:
parent
0447df4f43
commit
d5d1686a6b
1 changed files with 19 additions and 2 deletions
|
@ -11,6 +11,7 @@ from itertools import combinations, zip_longest, product
|
|||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
from os import path
|
||||
import os
|
||||
from scipy.interpolate import interp1d
|
||||
|
||||
from earsim import REvent
|
||||
|
@ -165,6 +166,11 @@ if __name__ == "__main__":
|
|||
antennas_fname = path.join(fname_dir, beacon.antennas_fname)
|
||||
time_diffs_fname = 'time_diffs.hdf5' if not True else antennas_fname
|
||||
|
||||
## This is a file indicating whether the k-finding algorithm was
|
||||
## stopped early. This happens when the ks do not change between
|
||||
## two consecutive iterations.
|
||||
run_break_fname = path.join(fname_dir, 'ca_breaked_run')
|
||||
|
||||
# create fig_dir
|
||||
if fig_dir:
|
||||
os.makedirs(fig_dir, exist_ok=True)
|
||||
|
@ -267,6 +273,11 @@ if __name__ == "__main__":
|
|||
x_fine = np.linspace(-scale2d, scale2d, 40)
|
||||
y_fine = np.linspace(-scale2d, scale2d, 40)
|
||||
|
||||
## Remove run_break_fname if it exists
|
||||
try:
|
||||
os.remove(run_break_fname)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
##
|
||||
## Do calculations on the grid
|
||||
|
@ -377,8 +388,14 @@ if __name__ == "__main__":
|
|||
|
||||
# Abort if no improvement
|
||||
if ( r!= 0 and (old_ks_per_loc == ks_per_loc[best_idx]).all() ):
|
||||
print("No changes from previous grid, breaking")
|
||||
# TODO: notate this case somewhere
|
||||
print("No changes from previous grid, breaking at iteration {r} out of {N_runs}")
|
||||
|
||||
try:
|
||||
with open(run_break_fname, 'wt', encoding='utf-8') as fp:
|
||||
fp.write(f"Breaked at grid iteration {r} out of {N_runs}")
|
||||
except:
|
||||
pass
|
||||
|
||||
break
|
||||
|
||||
old_ks_per_loc = ks_per_loc[best_idx]
|
||||
|
|
Loading…
Reference in a new issue