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
DM-12473: Add getParallacticAngle() to visitInfo #297
Conversation
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.
Please add a unit test and more documentation as to what the returned angle measures. I had a few other small suggestions as well.
include/lsst/afw/image/VisitInfo.h
Outdated
@@ -174,6 +174,9 @@ class VisitInfo : public table::io::PersistableFacade<VisitInfo>, public table:: | |||
// get hour angle at the boresight | |||
geom::Angle getBoresightHourAngle() const; | |||
|
|||
// get parallactic angle at the boresight |
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.
Please expand this comment so define the returned angle -- it is the angle from what to what?
src/image/VisitInfo.cc
Outdated
@@ -414,6 +414,15 @@ geom::Angle VisitInfo::getLocalEra() const { return getEra() + getObservatory(). | |||
|
|||
geom::Angle VisitInfo::getBoresightHourAngle() const { return getLocalEra() - getBoresightRaDec()[0]; } | |||
|
|||
geom::Angle VisitInfo::getBoresightParAngle() const { | |||
double _parallactic_y, _parallactic_x, result; | |||
_parallactic_y = sin(getBoresightHourAngle()); |
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.
Please make the conversion to radians explicit, e.g. getBoresightHourAngle.asRadians()
src/image/VisitInfo.cc
Outdated
@@ -425,6 +434,7 @@ std::ostream& operator<<(std::ostream& os, VisitInfo const& visitInfo) { | |||
os << "boresightRaDec=" << visitInfo.getBoresightRaDec() << ", "; | |||
os << "boresightAzAlt=" << visitInfo.getBoresightAzAlt() << ", "; | |||
os << "boresightAirmass=" << visitInfo.getBoresightAirmass() << ", "; | |||
os << "boresightParAngle=" << visitInfo.getBoresightParAngle() << ", "; |
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.
I suggest omitting this because it is not a constructor argument and the representation is intended to be an executable representation in Python
I have added three new unit tests and edited the comments to define parallactic angle more precisely. |
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.
Thanks for the unit test and improved docs. I'm afraid I still want more of each -- more doc information so the sign is clear, and a non-trivial test (with corrected doc string) so the math is thoroughly tested.
include/lsst/afw/image/VisitInfo.h
Outdated
@@ -174,6 +174,10 @@ class VisitInfo : public table::io::PersistableFacade<VisitInfo>, public table:: | |||
// get hour angle at the boresight | |||
geom::Angle getBoresightHourAngle() const; | |||
|
|||
// get parallactic angle at the boresight | |||
// Equal to the angle measured at zenith between the North celestial pole and the boresight. |
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.
This still does not specify the sign of the angle. Please add more words or reword. Here is one long, if clumsy, possibility: "This is the angular separation between two great circle arcs that meet at the zenith: the meridian and the arc from the zenith to the target. The angle is 0 if the target is on the meridian north of the zenith, positive if the object is east of the meridian, and pi if the object is on the meridian south of the zenith."
Also, use a /** style comment block when the doc is more than one line (as it now is, and justifiably so).
tests/test_visitInfo.py
Outdated
self.assertAnglesAlmostEqual(visitInfo.getBoresightParAngle(), parAngle) | ||
|
||
def test_parallacticAngleNorthMeridian(self): | ||
"""An observation on the Meridian in the Northern hemisphere has a parallactic angle of pi radians.""" |
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.
In the office you said it will be pi if the target is south of the telescope, 0 if north of the telescope on the meridian. I think that is clearer than "in the Norther hemisphere", especially since the hemisphere should not matter.
Also please add a test for positive or negative not on the meridian. The two tests you have now will pass regardless of the sign of the parallactic angle! I realize it may be a bit trickier to predict the correct angle, but I think it is well worth testing at least one non-trivial case, since trivial cases can all too easily hide math errors.
Also I suggest you simplify this test by only setting the VisitInfo fields that matter. VisitInfo can be constructed using keyword arguments and any of them can be omitted.
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.
Good points, you are correct. I will update the two meridian tests to be north and south of zenith, not in the northern or southern hemisphere.
For the test of the sign of the parallactic angle, doesn't the first test test_parallacticAngle
catch that? There it checks the results for the coordinates of data1 and data2 against precomputed values.
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.
Yes, test_parallacticAngle is exactly what I was asking for. My apologies for missing that.
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.
Shouldn't have underscores in Science Pipelines 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.
Okay. I was copying the style of the test immediately before the ones I added, but I suppose that one was an exception.
Please take another look. I have revised the documentation and the tests, and fixed a discrepancy in the definition while working it over. Please also check if the test |
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.
This looks great. Thanks for the improvements.
tests/test_visitInfo.py
Outdated
self.assertAnglesAlmostEqual(visitInfo.getBoresightParAngle(), parAngle) | ||
|
||
def test_parallacticAngleNorthMeridian(self): | ||
"""An observation on the Meridian in the Northern hemisphere has a parallactic angle of pi radians.""" |
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.
Yes, test_parallacticAngle is exactly what I was asking for. My apologies for missing that.
@@ -48,7 +50,7 @@ def propertySetFromDict(keyValDict): | |||
return metadata | |||
|
|||
|
|||
class VisitInfoTestCase(unittest.TestCase): | |||
class VisitInfoTestCase(lsst.utils.tests.TestCase): |
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.
Thank you for this change
20da5e9
to
2c2024f
Compare
Regarding @PaulPrice's comment about the test case names: I think we usually prefer to keep things consistent within a file. You could update all the names, I suppose. |
Adds a simple function to VisitInfo, that calculates the parallactic angle at the boresight of the exposure.