Skip to content

Commit

Permalink
Edit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dryczanowski committed Jul 25, 2024
1 parent ed52540 commit 628e082
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 26 deletions.
2 changes: 1 addition & 1 deletion tests/models/test_image_querying.py
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ def test_image_query(ptf_ref, decam_reference, decam_datastore, decam_default_ca
# assert results4[1].type == 'Sci' # the second one is the regular image
assert results4[0].type == 'Sci' # the first one out is the regular image
assert results4[1].type == 'ComSci' # the second one is the high quality coadd
# import pdb; pdb.set_trace()
import pdb; pdb.set_trace()
# check that the DECam difference and new image it is based on have the same limiting magnitude and quality
stmt = Image.query_images(instrument='DECam', type=3)
diff = session.scalars(stmt).first()
Expand Down
53 changes: 28 additions & 25 deletions tests/models/test_measurements.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,33 +119,36 @@ def test_measurements_attributes(measurer, ptf_datastore, test_config):
assert limMagEst == pytest.approx(20.00, abs=0.5)

from pipeline.data_store import DataStore
ds = DataStore(image_id=1126)
im = ds.get_image()
sl = ds.get_sources()
# import pdb; pdb.set_trace()
limMagResults = sl.estimate_lim_mag(aperture=1, givePlotParams=True)
limMagEst = limMagResults[0]
snrs = limMagResults[1]
mags = limMagResults[2]
grad = limMagResults[3]
intercept = limMagResults[4]

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()
# import pdb; pdb.set_trace()
from models.source_list import SourceList
from models.base import SmartSession

with SmartSession() as session:
ds = DataStore(image_id=1126)
im = ds.get_image()
# sl = ds.get_sources()
sl = (session.query( SourceList ).filter( SourceList.image_id==1126 ).all())[0]
import pdb; pdb.set_trace()
limMagResults = sl.estimate_lim_mag(aperture=1, givePlotParams=True)
limMagEst = limMagResults[0]
snrs = limMagResults[1]
mags = limMagResults[2]
grad = limMagResults[3]
intercept = limMagResults[4]

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_db.png')
plt.show()
# import pdb; pdb.set_trace()



Expand Down

0 comments on commit 628e082

Please sign in to comment.