当前位置: 首页>>代码示例>>Python>>正文


Python accessors.sourcefinder_image_from_accessor函数代码示例

本文整理汇总了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函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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