-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updates to use visitInfo Tickets/dm 6625 #17
Merged
Merged
Changes from 3 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
0bfe809
Add support for decam to ccdimage.cc
parejkoj 4be903a
Add initial attempt at decam test
parejkoj ba2fc7a
Initial work on non-interactive plotting for new HSC data
parejkoj 137b4cc
Rename to use test_ prefix.
parejkoj 6c097ae
Update to use obs_base
parejkoj 6fd68ee
Remove unnecessary files.
parejkoj f8935ae
autoformat to cleanup indentation.
parejkoj 597fd63
Take metadata from visitInfo, cleanup mjd, remove camera
parejkoj 06c8809
pex.logging cleanups
parejkoj e0e7b01
cleanup every const double & -> double for great SWIGing
parejkoj d6b6792
Cleanup tests to use lsstSim data with bigger dataId
parejkoj bb1c4cb
Cleanup naming conventions, formatting, and expTime cruft.
parejkoj cc9f823
Loosen tolerances post-ERA fix
parejkoj 2d8945e
Clean up no longer needed code
parejkoj File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -171,22 +171,23 @@ def _do_plots(self, dataRefs, visitCatalogs, | |
astropy.visualization.quantity_support() | ||
plt.ion() | ||
|
||
plot_all_wcs_deltas(plt, dataRefs, visitCatalogs, self.oldWcsList) | ||
|
||
name = self.id().strip('__main__.') | ||
old_rms_relative = rms_per_star(old_relative) | ||
old_rms_absolute = rms_per_star(old_absolute) | ||
new_rms_relative = rms_per_star(new_relative) | ||
new_rms_absolute = rms_per_star(new_absolute) | ||
print(len(dataRefs)) | ||
print("N dataRefs:", len(dataRefs)) | ||
print("relative RMS (old, new):", old_rel_total, new_rel_total) | ||
print("absolute RMS (old, new):", old_abs_total, new_abs_total) | ||
plot_rms_histogram(plt, old_rms_relative, old_rms_absolute, new_rms_relative, new_rms_absolute, | ||
old_rel_total, old_abs_total, new_rel_total, new_abs_total) | ||
old_rel_total, old_abs_total, new_rel_total, new_abs_total, name) | ||
|
||
plot_all_wcs_deltas(plt, dataRefs, visitCatalogs, self.oldWcsList, name) | ||
|
||
# So one can muck-about with things after plotting... | ||
plt.show() | ||
import pdb | ||
pdb.set_trace() | ||
# plt.show() | ||
# import pdb | ||
# pdb.set_trace() | ||
|
||
|
||
def rms_per_star(data): | ||
|
@@ -213,11 +214,14 @@ def rms_total(data): | |
return (np.sqrt(total/n) * u.radian).to(u.arcsecond) | ||
|
||
|
||
def plot_all_wcs_deltas(plt, dataRefs, visitCatalogs, oldWcsList, perCcdPlots=False): | ||
def plot_all_wcs_deltas(plt, dataRefs, visitCatalogs, oldWcsList, name, | ||
perCcdPlots=False): | ||
"""Various plots of the difference between old and new Wcs.""" | ||
|
||
plot_all_wcs_quivers(plt, dataRefs, visitCatalogs, oldWcsList) | ||
plot_wcs_magnitude(plt, dataRefs, visitCatalogs, oldWcsList) | ||
print('plotting heat maps') | ||
plot_wcs_magnitude(plt, dataRefs, visitCatalogs, oldWcsList, name) | ||
print('plotting quivers') | ||
plot_all_wcs_quivers(plt, dataRefs, visitCatalogs, oldWcsList, name) | ||
|
||
if perCcdPlots: | ||
for i, ref in enumerate(dataRefs): | ||
|
@@ -248,12 +252,12 @@ def wcs_convert(xv, yv, wcs): | |
return xout, yout | ||
|
||
|
||
def plot_all_wcs_quivers(plt, dataRefs, visitCatalogs, oldWcsList): | ||
def plot_all_wcs_quivers(plt, dataRefs, visitCatalogs, oldWcsList, name): | ||
"""Make quiver plots of the WCS deltas for each CCD in each visit.""" | ||
|
||
for cat in visitCatalogs: | ||
fig = plt.figure() | ||
fig.set_tight_layout(True) | ||
# fig.set_tight_layout(True) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove commented-out code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
ax = fig.add_subplot(111) | ||
for old_wcs, ref in zip(oldWcsList, dataRefs): | ||
if ref.dataId['visit'] != cat: | ||
|
@@ -268,6 +272,7 @@ def plot_all_wcs_quivers(plt, dataRefs, visitCatalogs, oldWcsList): | |
plt.xlabel('RA') | ||
plt.ylabel('Dec') | ||
plt.title('visit: {}'.format(cat)) | ||
plt.savefig('.plots/{}-{}-quivers.pdf'.format(name, cat)) | ||
|
||
|
||
def plot_wcs_quivers(ax, wcs1, wcs2, dim): | ||
|
@@ -279,7 +284,7 @@ def plot_wcs_quivers(ax, wcs1, wcs2, dim): | |
return ax.quiver(x1, y1, uu, vv, units='x', pivot='tail', scale=1e-3, width=1e-5) | ||
|
||
|
||
def plot_wcs_magnitude(plt, dataRefs, visitCatalogs, oldWcsList): | ||
def plot_wcs_magnitude(plt, dataRefs, visitCatalogs, oldWcsList, name): | ||
for cat in visitCatalogs: | ||
fig = plt.figure() | ||
fig.set_tight_layout(True) | ||
|
@@ -302,8 +307,8 @@ def plot_wcs_magnitude(plt, dataRefs, visitCatalogs, oldWcsList): | |
xmax = x1.max() if x1.max() > xmax else xmax | ||
ymax = y1.max() if y1.max() > ymax else ymax | ||
magnitude = (np.linalg.norm((uu, vv), axis=0)*u.radian).to(u.arcsecond).value | ||
img = ax.imshow(magnitude, vmin=0, vmax=0.2, | ||
aspect='auto', extent=extent, cmap=plt.get_cmap('viridis')) | ||
img = ax.imshow(magnitude, vmin=0, vmax=0.3, | ||
aspect='auto', extent=extent, cmap=plt.get_cmap('magma')) | ||
# TODO: add CCD bounding boxes to the plot once DM-5503 is finished. | ||
# TODO: add a circle for the full focal plane. | ||
|
||
|
@@ -316,6 +321,7 @@ def plot_wcs_magnitude(plt, dataRefs, visitCatalogs, oldWcsList): | |
plt.xlabel('RA') | ||
plt.ylabel('Dec') | ||
plt.title('visit: {}'.format(cat)) | ||
plt.savefig('.plots/{}-{}-heatmap.pdf'.format(name, cat)) | ||
|
||
|
||
def plot_wcs(plt, wcs1, wcs2, dim, center=(0, 0), name=""): | ||
|
@@ -332,13 +338,14 @@ def plot_wcs(plt, wcs1, wcs2, dim, center=(0, 0), name=""): | |
|
||
def plot_rms_histogram(plt, old_rms_relative, old_rms_absolute, | ||
new_rms_relative, new_rms_absolute, | ||
old_rel_total, old_abs_total, new_rel_total, new_abs_total): | ||
old_rel_total, old_abs_total, new_rel_total, new_abs_total, | ||
name): | ||
"""Plot histograms of the star separations and their RMS values.""" | ||
plt.figure() | ||
|
||
color_rel = 'black' | ||
ls_old = 'dotted' | ||
color_abs = 'blue' | ||
color_abs = 'green' | ||
ls_new = 'dashed' | ||
plotOptions = {'lw': 2, 'range': (0, 0.1)*u.arcsecond, 'normed': True, | ||
'bins': 30, 'histtype': 'step'} | ||
|
@@ -359,3 +366,4 @@ def plot_rms_histogram(plt, old_rms_relative, old_rms_absolute, | |
plt.xlim(plotOptions['range']) | ||
plt.xlabel('arcseconds') | ||
plt.legend(loc='best') | ||
plt.savefig('.plots/%s-histogram.pdf'%name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# See COPYRIGHT file at the top of the source tree. | ||
|
||
from __future__ import division, absolute_import, print_function | ||
|
||
import unittest | ||
import os | ||
|
||
from astropy import units as u | ||
|
||
import lsst.afw.geom | ||
import lsst.afw.coord as afwCoord | ||
import lsst.utils | ||
import lsst.pex.exceptions | ||
|
||
import jointcalTestBase | ||
|
||
try: | ||
data_dir = lsst.utils.getPackageDir('validation_data_decam') | ||
os.environ['ASTROMETRY_NET_DATA_DIR'] = os.path.join(data_dir, 'astrometry_net_data') | ||
except lsst.pex.exceptions.NotFoundError: | ||
data_dir = None | ||
|
||
# We don't want the absolute astrometry to become significantly worse | ||
# than the single-epoch astrometry (about 0.040"). | ||
# This value was empirically determined from the first run of jointcal on | ||
# this data, and will likely vary from survey to survey. | ||
absolute_error = 48e-3*u.arcsecond | ||
# Set to True for a comparison plot and some diagnostic numbers. | ||
do_plot = False | ||
|
||
|
||
# for MemoryTestCase | ||
def setup_module(module): | ||
lsst.utils.tests.init() | ||
|
||
|
||
class JointcalTestDECAM(jointcalTestBase.JointcalTestBase, lsst.utils.tests.TestCase): | ||
def setUp(self): | ||
jointcalTestBase.JointcalTestBase.setUp(self) | ||
self.do_plot = do_plot | ||
self.match_radius = 0.1*lsst.afw.geom.arcseconds | ||
|
||
# position of the validation_data_decam catalog | ||
center = afwCoord.IcrsCoord(150.1191666*lsst.afw.geom.degrees, 2.20583333*lsst.afw.geom.degrees) | ||
radius = 3*lsst.afw.geom.degrees | ||
self._prep_reference_loader(center, radius) | ||
|
||
self.input_dir = os.path.join(data_dir, 'data') | ||
self.all_visits = [176837, 176846] | ||
|
||
@unittest.skipIf(data_dir is None, "validation_data_decam not setup") | ||
def test_jointcalTask_2_visits(self): | ||
# NOTE: The relative RMS limit was empirically determined from the | ||
# first run of jointcal on this data. We should always do better than | ||
# this in the future! | ||
relative_error = 25e-3*u.arcsecond | ||
self._testJointCalTask(2, relative_error, absolute_error) | ||
|
||
|
||
# TODO: the memory test cases currently fail in jointcal. Filed as DM-6626. | ||
# class MyMemoryTestCase(lsst.utils.tests.MemoryTestCase): | ||
# pass | ||
|
||
if __name__ == "__main__": | ||
lsst.utils.tests.init() | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the commented-out debugging code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. All the plotting code is going to be pulled into another place soon.