|
49 | 49 | ConvertDetectorAngleToPositionAngle, |
50 | 50 | HtmIndex20, Ebv, MomentsIuuSky, MomentsIvvSky, MomentsIuvSky, |
51 | 51 | SemimajorAxisFromMoments, SemiminorAxisFromMoments, |
52 | | - PositionAngleFromMoments, |
53 | 52 | CorrelationIuuSky, CorrelationIvvSky, CorrelationIuvSky, |
54 | 53 | SemimajorAxisFromCorrelation, SemiminorAxisFromCorrelation, |
55 | 54 | PositionAngleFromCorrelation |
56 | | - ) |
| 55 | + PositionAngleFromMoments, ConvertDetectorAngleErrToPositionAngleErr) |
57 | 56 |
|
58 | 57 | ROOT = os.path.abspath(os.path.dirname(__file__)) |
59 | 58 |
|
@@ -762,6 +761,70 @@ def testConvertDetectorAngleToPositionAngle(self): |
762 | 761 |
|
763 | 762 | np.testing.assert_allclose(coord_diff, 0, rtol=0, atol=5e-6) |
764 | 763 |
|
| 764 | + # Test position angle error propogation |
| 765 | + def testConvertDetectorAngleErrToPositionAngleErr(self): |
| 766 | + """Test conversion of position angle err in detector degrees to |
| 767 | + position angle erron sky |
| 768 | + """ |
| 769 | + dipoleSep = 10 |
| 770 | + ixx = 10 |
| 771 | + testPixelDeltas = np.random.uniform(-100, 100, size=(self.nRecords, 2)) |
| 772 | + # testConvertPixelToArcSecond uses a meas_base LocalWcsPlugin |
| 773 | + # but we're using a simple WCS as our example, so this doesn't really matter |
| 774 | + # and we'll just use the WCS directly |
| 775 | + for dec in np.linspace(-90, 90, 10): |
| 776 | + for theta in (-45, 0, 90): |
| 777 | + for x, y in zip(np.random.uniform(2 * 1109.99981456774, size=10), |
| 778 | + np.random.uniform(2 * 560.018167811613, size=10)): |
| 779 | + wcs = self._makeWcs(dec=dec, theta=theta) |
| 780 | + cd_matrix = wcs.getCdMatrix() |
| 781 | + |
| 782 | + self.dataDict["dipoleSep"] = np.full(self.nRecords, dipoleSep) |
| 783 | + self.dataDict["ixx"] = np.full(self.nRecords, ixx) |
| 784 | + self.dataDict["slot_Centroid_x"] = np.full(self.nRecords, x) |
| 785 | + self.dataDict["slot_Centroid_y"] = np.full(self.nRecords, y) |
| 786 | + self.dataDict["someCentroid_x"] = x + testPixelDeltas[:, 0] |
| 787 | + self.dataDict["someCentroid_y"] = y + testPixelDeltas[:, 1] |
| 788 | + self.dataDict["orientation"] = np.arctan2( |
| 789 | + self.dataDict["someCentroid_y"] - self.dataDict["slot_Centroid_y"], |
| 790 | + self.dataDict["someCentroid_x"] - self.dataDict["slot_Centroid_x"], |
| 791 | + ) |
| 792 | + self.dataDict["orientation_err"] = np.arctan2( |
| 793 | + self.dataDict["someCentroid_y"] - self.dataDict[ "slot_Centroid_y"], |
| 794 | + self.dataDict["someCentroid_x"] - self.dataDict["slot_Centroid_x"], |
| 795 | + )*.001 |
| 796 | + |
| 797 | + self.dataDict["base_LocalWcs_CDMatrix_1_1"] = np.full(self.nRecords, |
| 798 | + cd_matrix[0, 0]) |
| 799 | + self.dataDict["base_LocalWcs_CDMatrix_1_2"] = np.full(self.nRecords, |
| 800 | + cd_matrix[0, 1]) |
| 801 | + self.dataDict["base_LocalWcs_CDMatrix_2_1"] = np.full(self.nRecords, |
| 802 | + cd_matrix[1, 0]) |
| 803 | + self.dataDict["base_LocalWcs_CDMatrix_2_2"] = np.full(self.nRecords, |
| 804 | + cd_matrix[1, 1]) |
| 805 | + df = self.getMultiIndexDataFrame(self.dataDict) |
| 806 | + |
| 807 | + # Test detector angle to position angle conversion |
| 808 | + func = ConvertDetectorAngleErrToPositionAngleErr( |
| 809 | + "orientation", |
| 810 | + "orientation_err", |
| 811 | + "base_LocalWcs_CDMatrix_1_1", |
| 812 | + "base_LocalWcs_CDMatrix_1_2", |
| 813 | + "base_LocalWcs_CDMatrix_2_1", |
| 814 | + "base_LocalWcs_CDMatrix_2_2" |
| 815 | + ) |
| 816 | + |
| 817 | + func_pa = ConvertDetectorAngleToPositionAngle( |
| 818 | + "orientation", |
| 819 | + "base_LocalWcs_CDMatrix_1_1", |
| 820 | + "base_LocalWcs_CDMatrix_1_2", |
| 821 | + "base_LocalWcs_CDMatrix_2_1", |
| 822 | + "base_LocalWcs_CDMatrix_2_2" |
| 823 | + ) |
| 824 | + val = self._funcVal(func, df) |
| 825 | + val_pa = self._funcVal(func_pa, df) |
| 826 | + |
| 827 | + |
765 | 828 | def testConvertPixelToArcseconds(self): |
766 | 829 | """Test calculations of the pixel scale, conversions of pixel to |
767 | 830 | arcseconds. |
|
0 commit comments