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


Python Dataset.getFrames方法代码示例

本文整理汇总了Python中dataset.Dataset.getFrames方法的典型用法代码示例。如果您正苦于以下问题:Python Dataset.getFrames方法的具体用法?Python Dataset.getFrames怎么用?Python Dataset.getFrames使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dataset.Dataset的用法示例。


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

示例1: test_create_asciixyc_frame

# 需要导入模块: from dataset import Dataset [as 别名]
# 或者: from dataset.Dataset import getFrames [as 别名]
    def test_create_asciixyc_frame(self):

        self.assertEqual(1, 1)

        ## The dataset wrapper.
        ds = Dataset("testdata/ASCIIxyC")

        ## The frames from the test dataset.
        frames = ds.getFrames((51.509915, -0.142515, 34.02))

        # The tests
        #-----------
        ## The cluster finder from the first frame.
        kf = KlusterFinder(frames[0].getPixelMap(), frames[0].getWidth(), frames[0].getHeight(), frames[0].isMC())

        # The number of clusters in the first frame.
        #
        # This frame has 34 clusters.
        self.assertEqual(kf.getNumberOfKlusters(), 34)
        self.assertEqual(kf.getNumberOfGammas(), 12)
        self.assertEqual(kf.getNumberOfMonopixels(), 4)
        self.assertEqual(kf.getNumberOfBipixels(), 2)
        self.assertEqual(kf.getNumberOfTripixelGammas(), 4)
        self.assertEqual(kf.getNumberOfTetrapixelGammas(), 2)

        ## The list of clusters.
        ks = kf.getListOfKlusters()

        # Double check the number of clusters found.
        self.assertEqual(len(ks), 34)

        # The first - and largest - cluster.

        # Cluster size (number of pixels).
        self.assertEqual(ks[0].getNumberOfPixels(), 104)

        # Cluster location (raw pixels).
        self.assertEqual(ks[0].getXMin(), 141)
        self.assertEqual(ks[0].getXMax(), 153)
        self.assertEqual(ks[0].getYMin(), 230)
        self.assertEqual(ks[0].getYMax(), 244)

        # Cluster width and height.
        self.assertEqual(ks[0].getWidth(), 13)
        self.assertEqual(ks[0].getHeight(), 15)

        # Cluster properties based on the unweighted (UW) mean.

        # * Location.
        self.assertAlmostEqual(ks[0].getXUW(), 146.673077, places=6)
        self.assertAlmostEqual(ks[0].getYUW(), 237.375000, places=6)

        # * Radius and density.
        self.assertAlmostEqual(ks[0].getRadiusUW(), 8.550607, places=6)
        self.assertAlmostEqual(ks[0].getDensityUW(), 0.452782, places=6)

        # Counts.
        self.assertEqual(ks[0].getTotalCounts(), 8854)
        self.assertEqual(ks[0].getMaxCountValue(), 577)

        # Energy.
        self.assertAlmostEqual(ks[0].getTotalEnergy(), 0.0, places=6)
        self.assertAlmostEqual(ks[0].getMaxEnergy(), 0.0, places=6)

        # Linearity.
        m, c, sumR = ks[0].getLineOfBestFitValues()
        self.assertAlmostEqual(m, -0.827317, places=6)
        self.assertAlmostEqual(c, 358.720154, places=6)
        self.assertAlmostEqual(sumR, 211.088562, places=6)

        # Edge pixels.
        self.assertEqual(ks[0].getNumberOfEdgePixels(), 57)
        self.assertAlmostEqual(ks[0].getInnerPixelFraction(), 0.451923, places=6)
        self.assertAlmostEqual(ks[0].getOuterPixelFraction(), 0.548077, places=6)

        # Is it a Monte Carlo cluster?
        self.assertEqual(ks[0].isMC(), False)

        # Is it an edge cluster?
        self.assertEqual(ks[0].isEdgeCluster(), False)


        # A mid-range cluster.

        # Cluster size (number of pixels).
        self.assertEqual(ks[10].getNumberOfPixels(), 19)

        # Cluster location (raw pixels).
        self.assertEqual(ks[10].getXMin(), 167.0)
        self.assertEqual(ks[10].getXMax(), 173.0)
        self.assertEqual(ks[10].getYMin(), 196.0)
        self.assertEqual(ks[10].getYMax(), 201.0)

        # Cluster width and height.
        self.assertEqual(ks[10].getWidth(), 7.0)
        self.assertEqual(ks[10].getHeight(), 6.0)

        # Cluster properties based on the unweighted (UW) mean.

        # * Location.
#.........这里部分代码省略.........
开发者ID:gridpp,项目名称:dirac-getting-started,代码行数:103,代码来源:test_kluster.py

示例2: test_create_asciixyc_frame

# 需要导入模块: from dataset import Dataset [as 别名]
# 或者: from dataset.Dataset import getFrames [as 别名]
    def test_create_asciixyc_frame(self):

        self.assertEqual(1, 1)

        ## The dataset wrapper.
        ds = Dataset("testdata/ASCIIxyC")

        ## The frames from the dataset.
        frames = ds.getFrames((51.509915, -0.142515, 34.02))

        # The tests
        #-----------
        #
        # The number of frames.
        self.assertEqual(len(frames), 5)
        #
        # Spatial information.
        self.assertEqual(frames[0].getLatitude(), 51.509915)
        self.assertEqual(frames[0].getLongitude(), -0.142515)
        self.assertEqual(frames[0].getAltitude(), 34.02)
        #
        self.assertEqual(frames[0].getRoll(), 0.0)
        self.assertEqual(frames[0].getPitch(), 0.0)
        self.assertEqual(frames[0].getYaw(), 0.0)
        #
        self.assertEqual(frames[0].getOmegax(), 0.0)
        self.assertEqual(frames[0].getOmegay(), 0.0)
        self.assertEqual(frames[0].getOmegaz(), 0.0)
        #
        # Temporal information.
        self.assertEqual(frames[0].getStartTime(), 1371575424.293207)
        self.assertEqual(frames[0].getStartTimeSec(), 1371575424)
        self.assertEqual(frames[0].getStartTimeSubSec(), 293207)
        self.assertEqual(frames[0].getEndTime(), 1371575425.293207)
        self.assertEqual(frames[0].getEndTimeSec(), 1371575425)
        self.assertEqual(frames[0].getEndTimeSubSec(), 293207)
        self.assertEqual(frames[0].getAcqTime(), 1.0)
        #
        # Detector information.
        self.assertEqual(frames[0].getChipId(), "B06-W0212")
        #
        self.assertEqual(frames[0].getBiasVoltage(), 18.0)
        self.assertEqual(frames[0].getIKrum(), 1)
        #
        self.assertEqual(frames[0].getDetx(), 0.0)
        self.assertEqual(frames[0].getDety(), 0.0)
        self.assertEqual(frames[0].getDetz(), 0.0)
        self.assertEqual(frames[0].getDetEulera(), 0.0)
        self.assertEqual(frames[0].getDetEulerb(), 0.0)
        self.assertEqual(frames[0].getDetEulerc(), 0.0)
        #
        # Payload information.
        self.assertEqual(frames[0].getWidth(), 256)
        self.assertEqual(frames[0].getHeight(), 256)
        self.assertEqual(frames[0].getFormat(), 4114)
        self.assertEqual(frames[0].getRawNumberOfPixels(), 735)
        self.assertEqual(frames[0].getOccupancy(), 735)
        self.assertAlmostEqual(frames[0].getOccupancyPc(), 0.011215, places=6)
        self.assertEqual(frames[0].getNumberOfUnmaskedPixels(), 735)
        self.assertEqual(frames[0].getNumberOfMaskedPixels(), 0)
        #
        self.assertEqual(frames[0].isMC(), False)
        #
        # Cluster information.
        self.assertEqual(frames[0].getNumberOfKlusters(), 34)
        self.assertEqual(frames[0].getNumberOfGammas(), 12)
        self.assertEqual(frames[0].getNumberOfMonopixels(), 4)
        self.assertEqual(frames[0].getNumberOfBipixels(), 2)
        self.assertEqual(frames[0].getNumberOfTripixelGammas(), 4)
        self.assertEqual(frames[0].getNumberOfTetrapixelGammas(), 2)
        self.assertEqual(frames[0].getNumberOfNonGammas(), 22)
开发者ID:CERNatschool,项目名称:cluster-sorter,代码行数:73,代码来源:test_frame.py

示例3: test_create_asciixyc_frame

# 需要导入模块: from dataset import Dataset [as 别名]
# 或者: from dataset.Dataset import getFrames [as 别名]
    def test_create_asciixyc_frame(self):

        ## The dataset wrapper.
        ds = Dataset("testdata/B06-W0212/2014-04-02-150255/ASCIIxyC/")

        ## The frame metadata.
        fmd = None
        #
        with open("testdata/B06-W0212/2014-04-02-150255/metadata.json", "r") as fmdf:
            fmd = json.load(fmdf, fmd)
        #
        lat, lon, alt = fmd[0]['lat'], fmd[0]['lon'], fmd[0]['alt']

        ## The pixel mask.
        pixel_mask = {}

        with open("testdata/B06-W0212/2014-04-02-150255/masked_pixels.txt", "r") as mpf:
            rows = mpf.readlines()
            for row in rows:
                vals = [int(val) for val in row.strip().split("\t")]
                x = vals[0]; y = vals[1]; X = (256*y) + x; C = 1
                pixel_mask[X] = C

        ## The frames from the dataset.
        frames = ds.getFrames((lat, lon, alt), pixelmask=pixel_mask)

        # The tests
        #-----------
        #
        # The number of frames.
        self.assertEqual(len(frames), 60)
        #
        # Spatial information.
        self.assertEqual(frames[0].getLatitude(),  51.261015)
        self.assertEqual(frames[0].getLongitude(), -1.084127)
        self.assertEqual(frames[0].getAltitude(),  48.0     )
        #
        self.assertEqual(frames[0].getRoll(), 0.0)
        self.assertEqual(frames[0].getPitch(), 0.0)
        self.assertEqual(frames[0].getYaw(), 0.0)
        #
        self.assertEqual(frames[0].getOmegax(), 0.0)
        self.assertEqual(frames[0].getOmegay(), 0.0)
        self.assertEqual(frames[0].getOmegaz(), 0.0)
        #
        # Temporal information.
        self.assertEqual(frames[0].getStartTime(), 1396447375.004957)
        self.assertEqual(frames[0].getStartTimeSec(), 1396447375)
        self.assertEqual(frames[0].getStartTimeSubSec(), 4957)
        self.assertEqual(frames[0].getEndTime(), 1396447435.004957)
        self.assertEqual(frames[0].getEndTimeSec(), 1396447435)
        self.assertEqual(frames[0].getEndTimeSubSec(), 4957)
        self.assertEqual(frames[0].getAcqTime(), 60.0)
        #
        # Detector information.
        self.assertEqual(frames[0].getChipId(), "B06-W0212")
        #
        self.assertEqual(frames[0].getBiasVoltage(), 95.0)
        self.assertEqual(frames[0].getIKrum(), 1)
        #
        self.assertEqual(frames[0].getDetx(), 0.0)
        self.assertEqual(frames[0].getDety(), 0.0)
        self.assertEqual(frames[0].getDetz(), 0.0)
        self.assertEqual(frames[0].getDetEulera(), 0.0)
        self.assertEqual(frames[0].getDetEulerb(), 0.0)
        self.assertEqual(frames[0].getDetEulerc(), 0.0)
        #
        # Payload information.
        self.assertEqual(frames[0].getWidth(), 256)
        self.assertEqual(frames[0].getHeight(), 256)
        self.assertEqual(frames[0].getFormat(), 4114)
        self.assertEqual(frames[0].getRawNumberOfPixels(), 57)
        self.assertEqual(frames[0].getOccupancy(), 57)
        self.assertAlmostEqual(frames[0].getOccupancyPc(), 0.000870, places=6)
        self.assertEqual(frames[0].getNumberOfUnmaskedPixels(), 57)
        self.assertEqual(frames[0].getNumberOfMaskedPixels(), 29)
        #
        self.assertEqual(frames[0].isMC(), False)

        # The masked pixels.
        self.assertEqual(frames[0].getNumberOfMaskedPixels(), 29)

        #
        # Cluster information.
        self.assertEqual(frames[0].getNumberOfKlusters(), 9)
        self.assertEqual(frames[0].getNumberOfGammas(), 5)
        self.assertEqual(frames[0].getNumberOfMonopixels(), 1)
        self.assertEqual(frames[0].getNumberOfBipixels(), 0)
        self.assertEqual(frames[0].getNumberOfTripixelGammas(), 2)
        self.assertEqual(frames[0].getNumberOfTetrapixelGammas(), 2)
        self.assertEqual(frames[0].getNumberOfNonGammas(), 4)
开发者ID:CERNatschool,项目名称:fast-cluster-analysis,代码行数:93,代码来源:test_frame.py

示例4: test_create_asciixyc_frame

# 需要导入模块: from dataset import Dataset [as 别名]
# 或者: from dataset.Dataset import getFrames [as 别名]
    def test_create_asciixyc_frame(self):

        ## The dataset wrapper.
        ds = Dataset("testdata/B06-W0212/2014-04-02-150255/RAW/ASCIIxyC/")

        ## The frame metadata.
        fmd = None
        #
        with open("testdata/B06-W0212/2014-04-02-150255/geo.json", "r") as fmdf:
            fmd = json.load(fmdf, fmd)
        #
        lat, lon, alt = fmd['lat'], fmd['lon'], fmd['alt']

        ## The pixel mask.
        pixel_mask = {}

        with open("testdata/B06-W0212/2014-04-02-150255/masked_pixels.txt", "r") as mpf:
            rows = mpf.readlines()
            for row in rows:
                vals = [int(val) for val in row.strip().split("\t")]
                x = vals[0]; y = vals[1]; X = (256*y) + x; C = 1
                pixel_mask[X] = C

        ## The frames from the dataset.
        frames = ds.getFrames((lat, lon, alt), pixelmask=pixel_mask)

        # The tests
        #-----------
        ## The cluster finder from the first frame.
        kf = KlusterFinder(frames[0].getPixelMap(), frames[0].getWidth(), frames[0].getHeight(), frames[0].isMC())

        # The number of clusters in the first frame.
        #
        # This frame has 34 clusters.
        self.assertEqual(kf.getNumberOfKlusters(), 9)
        self.assertEqual(kf.getNumberOfGammas(), 2)
        self.assertEqual(kf.getNumberOfMonopixels(), 1)
        self.assertEqual(kf.getNumberOfBipixels(), 0)
        self.assertEqual(kf.getNumberOfTripixelGammas(), 0)
        self.assertEqual(kf.getNumberOfTetrapixelGammas(), 1)

        ## The list of clusters.
        ks = kf.getListOfKlusters()

        # Double check the number of clusters found.
        self.assertEqual(len(ks), 9)

        # The first - and largest - cluster.

        # Cluster size (number of pixels).
        self.assertEqual(ks[0].getNumberOfPixels(), 25)

        # Cluster location (raw pixels).
        self.assertEqual(ks[0].getXMin(), 99)
        self.assertEqual(ks[0].getXMax(), 110)
        self.assertEqual(ks[0].getYMin(), 179)
        self.assertEqual(ks[0].getYMax(), 193)

        # Cluster width and height.
        self.assertEqual(ks[0].getWidth(), 12)
        self.assertEqual(ks[0].getHeight(), 15)

        # Cluster properties based on the unweighted (UW) mean.

        # * Location.
        self.assertAlmostEqual(ks[0].getXUW(), 104.16,  places=6)
        self.assertAlmostEqual(ks[0].getYUW(), 185.320, places=6)

        # * Radius and density.
        self.assertAlmostEqual(ks[0].getRadiusUW(), 8.73430, places=6)
        self.assertAlmostEqual(ks[0].getDensityUW(), 0.104312, places=6)

        # Counts.
        self.assertEqual(ks[0].getTotalCounts(), 879)
        self.assertEqual(ks[0].getMaxCountValue(), 88)

        # Energy.
        self.assertAlmostEqual(ks[0].getTotalEnergy(), 0.0, places=6)
        self.assertAlmostEqual(ks[0].getMaxEnergy(), 0.0, places=6)

        # Linearity.
        m, c, sumR = ks[0].getLineOfBestFitValues()
        self.assertAlmostEqual(m, -1.127456, places=6)
        self.assertAlmostEqual(c, 302.755829, places=6)
        self.assertAlmostEqual(sumR, 16.283415, places=6)

        # Edge pixels.
        self.assertEqual(ks[0].getNumberOfEdgePixels(), 25)
        self.assertAlmostEqual(ks[0].getInnerPixelFraction(), 0.0, places=6)
        self.assertAlmostEqual(ks[0].getOuterPixelFraction(), 1.0, places=6)

        # Is it a Monte Carlo cluster?
        self.assertEqual(ks[0].isMC(), False)

        # Is it an edge cluster?
        self.assertEqual(ks[0].isEdgeCluster(), False)
开发者ID:CERNatschool,项目名称:particle-rate-plotter,代码行数:98,代码来源:test_kluster.py


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