Python ApcorData Example

说明

python apcordata示例是从最受好评的开源项目中提取的实现代码,你可以参考下面示例的使用方式。

编程语言: Python

命名空间/包名称: ossosdownloadscore

示例#1
文件: test_models.py项目: OSSOS/MOP

 def create_real_first_image(self, path="data/testimg.fits"):
     # Put a real fits image on the first source, first observation
     apcor = ApcorData.from_string("4 15   0.19   0.01")
     hdulist = fits.open(self.get_abs_path(path))
     first_reading = self.model.get_current_workunit().get_sources()[0].get_readings()[0]
     self.first_snapshot = SourceCutout(first_reading, hdulist, apcor)
     self.image_manager.on_singlet_image_loaded(self.first_snapshot)

示例#2
文件: test_image.py项目: OSSOS/MOP

    def test_from_raw_string(self):
        rawstr = "4 15   0.19   0.01\n"

        # NOTE: not undertest
        self.parsed = ApcorData.from_string(rawstr)

        assert_that(self.parsed.ap_in, equal_to(self.ap_in))
        assert_that(self.parsed.ap_out, equal_to(self.ap_out))
        assert_that(self.parsed.apcor, equal_to(self.apcor))
        assert_that(self.parsed.apcor_err, equal_to(self.apcor_err))

示例#3
文件: test_snapshot.py项目: R136a1-/MOP

    def setUp(self):
        test_file = self.path("realstest2.measure3.reals.astrom")
        astrom_data = AstromParser().parse(test_file)

        self.reading = astrom_data.get_sources()[0].get_reading(0)

        # Load the real image
        hdulist = fits.open(self.path("cutout-1616687p.fits"))

        with open(self.path("1616687p10.apcor")) as fh:
            apcor = ApcorData.from_string(fh.read())

        # NOTE: the test image
        # vos://cadc.nrc.ca~vospace/OSSOS/dbimages/1616687/1616687p.fits
        # has cutout: [11][1449:1199,1429:1179] and is inverted.
        #
        # Therefore the first reading at (772.13, 3334.70) in observed
        # coordinates is at
        # (NAX1 - max cutout x, NAX2 - max cutout y)
        #  = (2112 - 1449, 4644 - 1429) = (663, 3215)
        self.original_pixel_x = 663
        self.original_pixel_y = 3215

        self.original_observed_x = 772.13
        self.original_observed_y = 3334.70

        x_offset = self.original_observed_x - self.original_pixel_x
        y_offset = self.original_observed_y - self.original_pixel_y

        self.undertest = SourceCutout(self.reading, hdulist,
                                      CoordinateConverter(x_offset, y_offset),
                                      apcor=apcor)

        assert_that(self.undertest.observed_x, equal_to(self.original_observed_x))
        assert_that(self.undertest.observed_y, equal_to(self.original_observed_y))

        assert_that(self.undertest.pixel_x, equal_to(self.original_pixel_x))
        assert_that(self.undertest.pixel_y, equal_to(self.original_pixel_y))

展开阅读全文