Skip to content

Commit fe97342

Browse files
committed
Added 'runid' argument to plot_residuals function, to be displayed in the title.
1 parent 58ef31e commit fe97342

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

sourcespec/source_residuals.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,8 @@ def compute_mean_residuals(residual_dict, min_spectra=20):
288288
return residual_mean
289289

290290

291-
def plot_residuals(residual_dict, residual_mean, outdir, ymin=None, ymax=None):
291+
def plot_residuals(residual_dict, residual_mean, outdir,
292+
ymin=None, ymax=None, runid=None):
292293
"""
293294
Plot residuals.
294295
@@ -306,6 +307,9 @@ def plot_residuals(residual_dict, residual_mean, outdir, ymin=None, ymax=None):
306307
ymax : float
307308
Upper limit of Y axis
308309
(default: None)
310+
runid : str
311+
Run ID, to be shown in title
312+
(default: None)
309313
"""
310314
for spec_mean in residual_mean:
311315
stat_id = spec_mean.id
@@ -320,7 +324,11 @@ def plot_residuals(residual_dict, residual_mean, outdir, ymin=None, ymax=None):
320324
True, which='both', linestyle='solid', color='#DDDDDD', zorder=0)
321325
ax.set_xlabel('frequency (Hz)')
322326
ax.set_ylabel('residual amplitude (obs - synth) in magnitude units')
323-
ax.set_title(f'residuals: {stat_id}{len(res)} records')
327+
if runid:
328+
title = f'{stat_id} – run_id: {runid} - {len(res)} records'
329+
else:
330+
title = f'{stat_id}{len(res)} records'
331+
ax.set_title(title)
324332
fig.savefig(figurefile, bbox_inches='tight')
325333
plt.close(fig)
326334
print(f'Residual plot saved to: {figurefile}')
@@ -356,7 +364,7 @@ def main():
356364
ymin, ymax = args.yrange
357365
plot_residuals(
358366
residual_dict, residual_mean, outdir,
359-
ymin=ymin, ymax=ymax
367+
ymin=ymin, ymax=ymax, runid=runid
360368
)
361369

362370
# write the mean residuals (the stations corrections)

0 commit comments

Comments
 (0)