Skip to content

Commit

Permalink
Add test for limiting magnitude estimate
Browse files Browse the repository at this point in the history
  • Loading branch information
dryczanowski committed Jul 10, 2024
1 parent 626c819 commit 948c898
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion tests/models/test_measurements.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,31 @@ def test_measurements_attributes(measurer, ptf_datastore, test_config):
m.flux_apertures[m.best_aperture] = original_flux
new_im.zp.dzp = original_zp_err

# TODO: add test for limiting magnitude (issue #143)
#test for limiting magnitude
srcList = ptf_datastore.sources
limMagEst, snrs, mags, grad, intercept = srcList.estimate_lim_mag(aperture=1)

#Skip the lim mag test if using PSF photometry (i.e. if limMagEst==None)
if limMagEst != None:
#if interactive testing enabled, make and save a Magnitude vs SNR plot
if os.getenv('INTERACTIVE') is not None:
xdata = np.linspace(np.log(3),np.log(20),1000)
plt.plot(snrs,mags,linewidth=0,marker='o',c='midnightblue')
plt.plot(xdata, grad * xdata + intercept, c='firebrick')
plt.xlabel('log SNR')
plt.ylabel('magnitude')
plt.title('Limiting magntiude = {:.2f} mag'.format(limMagEst))
ymin,ymax = plt.gca().get_ylim()
plt.vlines(x=np.log(5),ymin=ymin,ymax=ymax)
plt.hlines(y=limMagEst,xmin=np.log(3),xmax=np.log(20))
plt.xlim(np.log(3),np.log(20))
plt.ylim(ymin,ymax)
plt.savefig('plots/snr_mag_plot.png')
plt.show()

#check the limiting magnitude is consistent with previous runs
assert limMagEst == pytest.approx(20.668, abs=0.05)



def test_filtering_measurements(ptf_datastore):
Expand Down

0 comments on commit 948c898

Please sign in to comment.