• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python accessors.sourcefinder_image_from_accessor函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tkp.accessors.sourcefinder_image_from_accessor函数的典型用法代码示例。如果您正苦于以下问题:Python sourcefinder_image_from_accessor函数的具体用法?Python sourcefinder_image_from_accessor怎么用?Python sourcefinder_image_from_accessor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了sourcefinder_image_from_accessor函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: testWcsConversionConsistency

    def testWcsConversionConsistency(self):
        """
        Check that extracting a source from FITS and CASA versions of the
        same dataset gives the same results (especially, RA and Dec).
        """

        fits_image = accessors.sourcefinder_image_from_accessor(
                       accessors.FitsImage(os.path.join(DATAPATH,
                         'sourcefinder/GRB130828A/SWIFT_554620-130504.fits')))
        # Abuse the KAT7 CasaImage class here, since we just want to access
        # the pixel data and the WCS:
        casa_image = accessors.sourcefinder_image_from_accessor(
               accessors.kat7casaimage.Kat7CasaImage(
                     os.path.join(DATAPATH,
                         'sourcefinder/GRB130828A/SWIFT_554620-130504.image')))

        ew_sys_err, ns_sys_err = 0.0, 0.0
        fits_results = fits_image.extract(det=5, anl=3)
        fits_results = [result.serialize(ew_sys_err, ns_sys_err) for result in fits_results]
        casa_results = casa_image.extract(det=5, anl=3)
        casa_results = [result.serialize(ew_sys_err, ns_sys_err) for result in casa_results]
        self.assertEqual(len(fits_results), 1)
        self.assertEqual(len(casa_results), 1)
        fits_src = fits_results[0]
        casa_src = casa_results[0]

        self.assertEqual(len(fits_src),len(casa_src))
        for idx, _ in enumerate(fits_src):
            self.assertAlmostEqual(fits_src[idx], casa_src[idx], places=5)
开发者ID:ajstewart,项目名称:tkp,代码行数:29,代码来源:test_image.py


示例2: testFlatImage

 def testFlatImage(self):
     sfimage = accessors.sourcefinder_image_from_accessor(
         SyntheticImage(data=np.zeros((512,512))))
     self.assertTrue(np.ma.max(sfimage.data) == np.ma.min(sfimage.data),
                     msg = "Data should be flat")
     with self.assertRaises(RuntimeError):
         sfimage.extract(det=5,anl=3)
开发者ID:ajstewart,项目名称:tkp,代码行数:7,代码来源:test_image.py


示例3: forced_fits

def forced_fits(image_path, positions, parset):
    """
    Perform forced source measurements on an image based on a list of
    positions.

    :param image_path: path to image for measurements.
    :param positions: list of (ra, dec) pairs for measurement.
    :param parset: configuration parameterset as a dictionary.
    """
    logger.info("Forced fitting in image: %s" % (image_path))
    fitsimage = tkp.accessors.open(image_path)

    data_image = sourcefinder_image_from_accessor(fitsimage,
                            margin=parset['margin'], radius=parset['radius'],
                            detection_threshold=parset['detection_threshold'],
                            analysis_threshold=parset['analysis_threshold'],
                            ra_sys_err=parset['ra_sys_err'],
                            dec_sys_err=parset['dec_sys_err'])

    if len(positions):
        boxsize = parset['box_in_beampix'] * max(data_image.beam[0],
                                                 data_image.beam[1])
        forced_fits = data_image.fit_fixed_positions(positions, boxsize)
        return [forced_fit.serialize() for forced_fit in forced_fits]
    else:
        return []
开发者ID:jdswinbank,项目名称:tkp,代码行数:26,代码来源:source_extraction.py


示例4: get_detection_labels

def get_detection_labels(filename, det, anl, beam, configuration, plane=0):
    print "Detecting islands in %s" % (filename,)
    print "Thresholding with det = %f sigma, analysis = %f sigma" % (det, anl)
    ff = open_accessor(filename, beam=beam, plane=plane)
    imagedata = sourcefinder_image_from_accessor(ff, **configuration)
    labels, labelled_data = imagedata.label_islands(det * imagedata.rmsmap, anl * imagedata.rmsmap)
    return labels, labelled_data
开发者ID:hughbg,项目名称:tkp,代码行数:7,代码来源:pyse.py


示例5: extract_sources

def extract_sources(image_path, parset):
    """
    Extract sources from an image.

    :param image_path: path to file from which to extract sources.
    :param parset: dictionary containing at least the detection and analysis
        threshold and the association radius, the last one a multiplication
        factor of the de Ruiter radius.
    :returns: list of source measurements.
    """
    logger.info("Extracting image: %s" % image_path)
    accessor = tkp.accessors.open(image_path)
    logger.debug("Detecting sources in image %s at detection threshold %s",
                 image_path, parset['detection_threshold'])
    data_image = sourcefinder_image_from_accessor(accessor,
                            margin=parset['margin'],
                            radius=parset['radius'],
                            detection_threshold=parset['detection_threshold'],
                            analysis_threshold=parset['analysis_threshold'],
                            ra_sys_err=parset['ra_sys_err'],
                            dec_sys_err=parset['dec_sys_err'],
                            force_beam=parset['force_beam'])

    logger.debug("Employing margin: %s extraction radius: %s deblend: %s deblend_nthresh: %s",
            parset['margin'],
            parset['radius'],
            parset['deblend'],
            parset['deblend_nthresh']
    )

    results = data_image.extract()  # "blind" extraction of sources
    logger.info("Detected %d sources in image %s" % (len(results), image_path))
    return [r.serialize() for r in results]
开发者ID:jdswinbank,项目名称:tkp,代码行数:33,代码来源:source_extraction.py


示例6: testSingleSourceExtraction

    def testSingleSourceExtraction(self):
        """
        Single source extaction

        From visual inspection we only expect a single source in the image,
        at around 5 or 6 sigma detection level."""

        known_result = (
            136.89603241069054, 14.022184792492785, #RA, DEC
            0.0005341819139061954, 0.0013428186757078464, #Err, Err
            0.0007226590529214518, 0.00010918184742211533, #Peak flux, err
            0.0006067963179204716, 0.00017037685531724465, #Integrated flux, err
            6.192259965962862, 25.516190123153514, #Significance level, Beam semimajor-axis width (arcsec)
            10.718798843620489, 178.62899212789304, #Beam semiminor-axis width (arcsec), Beam parallactic angle
            0.0, 0.0 #ra_sys_err, dec_sys_err
        )
        self.image = accessors.sourcefinder_image_from_accessor(
                       accessors.FitsImage(os.path.join(DATAPATH,
                                        'GRB120422A/GRB120422A-120429.fits')))

        results = self.image.extract(det=5, anl=3)
        results = [result.serialize() for result in results]
        self.assertEqual(len(results), 1)
        r = results[0]
        self.assertEqual(len(r), len(known_result))
        for i in range(len(r)):
            self.assertAlmostEqual(r[i], known_result[i], places=5)
开发者ID:jdswinbank,项目名称:tkp,代码行数:27,代码来源:test_image.py


示例7: testMaskedBackgroundBlind

 def testMaskedBackgroundBlind(self):
     self.image = accessors.sourcefinder_image_from_accessor(
         accessors.open(os.path.join(DATAPATH, "L41391_0.img.restored.corr.fits")),
         radius=1.0,
     )
     result = self.image.extract()
     self.assertFalse(result)
开发者ID:jdswinbank,项目名称:tkp,代码行数:7,代码来源:test_image.py


示例8: forced_fits

def forced_fits(image_path, positions, extraction_params):
    """
    Perform forced source measurements on an image based on a list of
    positions.

    :param image_path: path to image for measurements.
    :param positions: list of (ra, dec) pairs for measurement.
    :param extraction_params: source extraction parameters, as a dictionary.
    """
    logger.info("Forced fitting in image: %s" % (image_path))
    fitsimage = tkp.accessors.open(image_path)

    data_image = sourcefinder_image_from_accessor(fitsimage,
                    margin=extraction_params['margin'],
                    radius=extraction_params['extraction_radius_pix'],
                    back_size_x=extraction_params['back_size_x'],
                    back_size_y=extraction_params['back_size_y'])

    if len(positions):
        boxsize = extraction_params['box_in_beampix'] * max(data_image.beam[0],
                                                 data_image.beam[1])
        forced_fits = data_image.fit_fixed_positions(positions, boxsize)
        return [
            forced_fit.serialize(
                extraction_params['ew_sys_err'], extraction_params['ns_sys_err']
            ) for forced_fit in forced_fits
        ]
    else:
        return []
开发者ID:hughbg,项目名称:tkp,代码行数:29,代码来源:source_extraction.py


示例9: testMaskedBackgroundForcedFit

 def testMaskedBackgroundForcedFit(self):
     """
     Background at forced fit is masked
     """
     self.image = accessors.sourcefinder_image_from_accessor(
         accessors.open(fits_file), radius=1.0)
     result = self.image.fit_to_point(256, 256, 10, 0, None)
     self.assertFalse(result)
开发者ID:ajstewart,项目名称:tkp,代码行数:8,代码来源:test_image.py


示例10: test_casaimage

    def test_casaimage(self):
        results = self.accessor.extract_metadata()
        sfimage = accessors.sourcefinder_image_from_accessor(self.accessor)

        known_bmaj, known_bmin, known_bpa = 4.4586, 4.458, 0
        bmaj, bmin, bpa = self.accessor.beam
        self.assertAlmostEqual(known_bmaj, bmaj, 2)
        self.assertAlmostEqual(known_bmin, bmin, 2)
        self.assertAlmostEqual(known_bpa, bpa, 2)
开发者ID:Error323,项目名称:tkp,代码行数:9,代码来源:test_aartfaaccasatable.py


示例11: setUpClass

 def setUpClass(cls):
     cls.temp_dir = tempfile.mkdtemp()
     cls.start_dir = os.getcwd()
     os.chdir(cls.temp_dir)
     cls.filename = os.path.join(cls.temp_dir, 'playground.fits')
     shutil.copy(orig_fits_file, cls.filename)
     cls.fits = FitsImage(cls.filename, beam=(.5, .5, .5))
     cls.imagedata = sourcefinder_image_from_accessor(cls.fits)
     cls.sourcelist = cls.imagedata.extract()
开发者ID:jdswinbank,项目名称:tkp,代码行数:9,代码来源:test_pyse.py


示例12: test_casaimage

    def test_casaimage(self):
        self.assertEqual(self.accessor.telescope, "LOFAR")
        results = self.accessor.extract_metadata()
        sfimage = accessors.sourcefinder_image_from_accessor(self.accessor)

        known_bmaj, known_bmin, known_bpa = 2.64, 1.85, 1.11
        bmaj, bmin, bpa = self.accessor.beam
        self.assertAlmostEqual(known_bmaj, bmaj, 2)
        self.assertAlmostEqual(known_bmin, bmin, 2)
        self.assertAlmostEqual(known_bpa, bpa, 2)
开发者ID:pombredanne,项目名称:tkp,代码行数:10,代码来源:test_lofarcasatable.py


示例13: test_casaimage

    def test_casaimage(self):
        self.assertEqual(self.accessor.telescope, 'KAT-7')
        results = self.accessor.extract_metadata()
        sfimage = accessors.sourcefinder_image_from_accessor(self.accessor)

        known_bmaj, known_bmin, known_bpa = 3.33, 3.33, 0
        bmaj, bmin, bpa = self.accessor.beam
        self.assertAlmostEqual(known_bmaj, bmaj, 2)
        self.assertAlmostEqual(known_bmin, bmin, 2)
        self.assertAlmostEqual(known_bpa, bpa, 2)
开发者ID:jdswinbank,项目名称:tkp,代码行数:10,代码来源:test_kat7casatable.py


示例14: testMaskedBackgroundForcedFit

 def testMaskedBackgroundForcedFit(self):
     """
     Background at forced fit is masked
     """
     self.image = accessors.sourcefinder_image_from_accessor(
         accessors.open(os.path.join(DATAPATH, "L41391_0.img.restored.corr.fits")),
         radius=1.0,
     )
     result = self.image.fit_to_point(256, 256, 10, 0, None)
     self.assertFalse(result)
开发者ID:jdswinbank,项目名称:tkp,代码行数:10,代码来源:test_image.py


示例15: test_casaimage

    def test_casaimage(self):
        self.assertTrue(isinstance(self.accessor, LofarAccessor))
        results = self.accessor.extract_metadata()
        sfimage = accessors.sourcefinder_image_from_accessor(self.accessor)

        known_bmaj, known_bmin, known_bpa = 2.64, 1.85, 1.11
        bmaj, bmin, bpa = self.accessor.beam
        self.assertAlmostEqual(known_bmaj, bmaj, 2)
        self.assertAlmostEqual(known_bmin, bmin, 2)
        self.assertAlmostEqual(known_bpa, bpa, 2)
开发者ID:gijzelaerr,项目名称:tkp-1,代码行数:10,代码来源:test_lofarcasatable.py


示例16: testWholeSourceMasked

    def testWholeSourceMasked(self):
        """
        Source in masked region
        """

        self.image = accessors.sourcefinder_image_from_accessor(
            accessors.FitsImage(GRB120422A))
        self.image.data[250:280, 250:280] = np.ma.masked
        results = self.image.extract(det=5, anl=3)
        self.assertFalse(results)
开发者ID:ajstewart,项目名称:tkp,代码行数:10,代码来源:test_image.py


示例17: testFreqinfo

    def testFreqinfo(self):
        database = Database()
        dataset = DataSet(data={"description": "dataset"}, database=database)

        # image without frequency information
        image = FitsImage(os.path.join(DATAPATH, "VLSS.fits"))
        # The database requires frequency information
        # self.assertRaises(ValueError, accessors.dbimage_from_accessor, dataset, image)
        # But the sourcefinder does not need frequency information
        self.assertListEqual(list(accessors.sourcefinder_image_from_accessor(image).data.shape), [2048, 2048])
        tkp.db.rollback()
开发者ID:pombredanne,项目名称:tkp,代码行数:11,代码来源:test_fits.py


示例18: test_casaimage

    def test_casaimage(self):
        results = self.accessor.extract_metadata()
        sfimage = accessors.sourcefinder_image_from_accessor(self.accessor)

        known_bmaj, known_bmin, known_bpa = (4.002118682861328,
                                            2.4657058715820312,
                                            0.3598241556754317)

        bmaj, bmin, bpa = self.accessor.beam
        self.assertAlmostEqual(known_bmaj, bmaj, 2)
        self.assertAlmostEqual(known_bmin, bmin, 2)
        self.assertAlmostEqual(known_bpa, bpa, 2)
开发者ID:ajstewart,项目名称:tkp,代码行数:12,代码来源:test_amicasatable.py


示例19: testForceSourceShape

    def testForceSourceShape(self):
        """
        Force source shape to beam

        This image contains a single source (with parameters as listed under
        testSingleSourceExtraction(), above). Here we force the lengths of the
        major/minor axes to be held constant when fitting.
        """
        self.image = accessors.sourcefinder_image_from_accessor(
            accessors.FitsImage(GRB120422A))
        results = self.image.extract(det=5, anl=3, force_beam=True)
        self.assertEqual(results[0].smaj.value, self.image.beam[0])
        self.assertEqual(results[0].smin.value, self.image.beam[1])
开发者ID:ajstewart,项目名称:tkp,代码行数:13,代码来源:test_image.py


示例20: testNoLabelledIslandsCase

    def testNoLabelledIslandsCase(self):
        """
        If an image is in fact very boring and flat/empty, then we may not even
        locate any labelled islands, if the analysis threshold is set high enough.

        (We reproduce this test case, even though GRB120422A-120429 has a
        source in the image, just by setting the thresholds very high -
        this avoids requiring additional data).
        """
        self.image = accessors.sourcefinder_image_from_accessor(
            accessors.FitsImage(GRB120422A))
        results = self.image.extract(det=5e10, anl=5e10)
        results = [result.serialize() for result in results]
        self.assertEqual(len(results), 0)
开发者ID:ajstewart,项目名称:tkp,代码行数:14,代码来源:test_image.py



注:本文中的tkp.accessors.sourcefinder_image_from_accessor函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python associations.associate_extracted_sources函数代码示例发布时间:2022-05-27
下一篇:
Python ttk.Treeview类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap