Skip to content

Using_BHM_Visual_Inspection_VAC.ipynb. Enhancement #6

Description

@JosephKarpinski

https://github.com/sdss/dr20_tutorials/blob/main/vac_tutorials/Using_BHM_Visual_Inspection_VAC.ipynb

Enhancement

------------------------------------------------------------

NEW CELL: Small-multiples gallery of failure spectra

------------------------------------------------------------

'''
Replaces the single random spectrum in Cell 24-26 with a 3x3 grid so
recurring failure patterns (broad absorption, weak-line QSOs, sky
residuals) are visible at a glance instead of requiring many reruns.
Reuses xm from Cell 22.
'''

NB: xm from Cell 22 is the tuple returned by np.where(condition) -- xm[0] is the index array

n_panels = min(9, len(xm[0]))
idx = np.random.choice(xm[0], size=n_panels, replace=False)

fig, axes = plt.subplots(3, 3, figsize=(16, 9))
for ax, i in zip(axes.flat, idx):
s = j[i]
try:
specFile = access.full('specLite_coadd', run2d=run2d, obs=s['OBS'],
mjd=s['MJD'], catalogid=s['CATALOGID'], coadd=coadd)
if not access.exists('', full=specFile):
access.remote()
access.add('specLite_coadd', run2d=run2d, obs=s['OBS'],
mjd=s['MJD'], catalogid=s['CATALOGID'], coadd=coadd)
access.set_stream()
access.commit()
access.reset()
spectra = fits.getdata(specFile, 'COADD')
wave = np.power(10, spectra['LOGLAM'])
mask = (spectra['AND_MASK'] == 0)
ax.plot(wave[mask], spectra['FLUX'][mask], lw=0.7, label='Flux')
ax.plot(wave[mask], spectra['MODEL'][mask], lw=0.7, label='Model')
ax.set_title(f"z_pipe={s['Z']:.2f} z_vi={s['z_vi']:.2f}", fontsize=9)
except Exception as e:
ax.set_title(f"load failed: {e}", fontsize=8)
ax.set_xlabel('Wavelength (A)', fontsize=8)
axes.flat[0].legend(fontsize=8)
plt.tight_layout()
plt.show()

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions