Skip to content
Snippets Groups Projects

Improve readability of lockloss page

Merged Yannick Lecoeuche requested to merge yannick.lecoeuche/locklost:readability into master
Compare and
5 files
+ 145
92
Compare changes
  • Side-by-side
  • Inline
Files
5
+ 25
32
@@ -27,6 +27,7 @@ def find_lpy(event):
infile_csv = 'saturations.csv'
inpath_csv = event.gen_path(infile_csv)
sat_channel = ''
lpy_lim = 4*config.SATURATION_THRESHOLD
if os.path.exists(inpath_csv):
with open(inpath_csv, 'r') as f:
first_sat = f.readline()
@@ -53,22 +54,38 @@ def find_lpy(event):
for title in titles:
for corner, coeff in lpy_map[title].items():
idx = channels.index(get_sus_channel(base_channel, corner))
lpy[title] += bufs[idx].data * coeff
lpy[title] += (bufs[idx].data * coeff)/lpy_lim
colors = ['#2c7fb8', '#e66101', '#5e3c99']
offset = -0.5
fig, axs = plt.subplots(3, sharex=True, figsize=(27,16))
for ax, dof, color, title in zip(axs, lpy.values(), colors, titles):
ax.plot(t, dof, color = color, label = title, alpha = 0.8, lw = 2)
ax.plot(
t,
dof,
color = color,
label = title,
alpha = 0.8,
lw = 2
)
ax.axhline(
1,
color='red',
linestyle='--',
lw=3,
label = 'saturation threshold'
)
ax.axhline(
-1,
color='red',
linestyle='--',
lw=3
)
# offset = window[0] / 6 # window dependent offset from lock loss
offset = -0.5
y_max, y_min = gen_ylim(dof, t, offset=offset)
# set y-limits manually if channel is flat during this period
if y_min == y_max:
ax.set_ylim(-1, 1)
else:
ax.set_ylim(y_min, y_max)
ax.set_ylim(-1.2, 1.2)
ax.set_xlim(window[0], window[1])
ax.set_xlabel(
'Time [s] since lock loss at {}'.format(gps),
@@ -77,12 +94,6 @@ def find_lpy(event):
ax.grid()
ax.legend()
# change y-ticks so that ticks don't overlap
for ax in axs:
nbins = len(ax.get_xticklabels())
locator = MaxNLocator(nbins=nbins, prune='both', min_n_ticks=5)
ax.yaxis.set_major_locator(locator)
fig.text(0.04, 0.5, r"Counts", ha='center', va='center', rotation='vertical')
fig.subplots_adjust(hspace=0)
plt.setp([ax.get_xticklabels() for ax in fig.axes[:-1]], visible=False)
@@ -99,24 +110,6 @@ def find_lpy(event):
logging.info("LPY plot bypassed (no saturating suspensions).")
def gen_ylim(y, t, offset = 0):
t_before = np.where(t < offset)[0]
y_before = y[t_before]
### set range depending on sign
y_min, y_max = min(y_before), max(y_before)
if y_min < 0:
y_min = y_min * 1.2
else:
y_min = y_min * 0.8
if y_max < 0:
y_max = y_max * 0.8
else:
y_max = y_max * 1.2
return y_max, y_min
def get_sus_channel(base_channel, corner):
return '{}_{}_DQ'.format(base_channel, corner)
Loading