示例#1
0
    def testCreate2Polygons(self):

        mergedRows = [(19, 25), (41, 43)]
        imageWidth = 40
        imageOffset = 5

        regions = makePolygons(imageWidth, imageOffset, mergedRows)
        self.assertEquals(len(regions), 2)
        self.assertTrue(
            regionfile.Polygon([1, 36, 41, 36, 41, 40, 1, 40]) in regions)
        self.assertTrue(
            regionfile.Polygon([1, 14, 41, 14, 41, 22, 1, 22]) in regions)
示例#2
0
    def testMakePolygons(self):

        mergedRows = [(41, 43)]
        imageWidth = 40
        imageOffset = 5

        self.assertEquals(makePolygons(imageWidth, imageOffset, mergedRows),
                          [regionfile.Polygon([1, 36, 41, 36, 41, 40, 1, 40])])
示例#3
0
    def testAddBuffer(self):
        mergedRows = [(41, 43)]
        imageWidth = 40
        imageOffset = 5
        buffer = 3

        self.assertEquals(
            makePolygons(imageWidth, imageOffset, mergedRows, buffer=buffer),
            [regionfile.Polygon([1, 34, 41, 34, 41, 42, 1, 42])])
示例#4
0
    def testYDirection(self):

        mergedRows = [(41, 43)]
        imageWidth = 40
        imageOffset = 5

        self.assertEquals(
            makePolygons(imageWidth, imageOffset, mergedRows, vertical=True),
            [regionfile.Polygon([36, 1, 40, 1, 40, 41, 36, 41])])
示例#5
0
    def testYDirectionChip(self):

        image = numpy.ones((30, 50))
        overscan = OverscanInfo()
        overscan.setYOverscanDir()
        overscan.addChip(1)
        overscan.setMin(1, 20)
        overscan.setMax(1, 29)
        overscan.setOffset(1, 5)

        image[20:, 10:14] *= 5
        regions = maskOverscanLines(image, overscan, 1)

        self.assertEquals(regions,
                          [regionfile.Polygon([5, 1, 10, 1, 10, 31, 5, 31])])
示例#6
0
    def testXDirectionChip(self):

        image = numpy.ones((50, 30))
        overscan = OverscanInfo()
        overscan.setXOverscanDir()
        overscan.addChip(1)
        overscan.setMin(1, 0)
        overscan.setMax(1, 9)
        overscan.setOffset(1, 5)

        image[10:14, 0:10] *= 5
        regions = maskOverscanLines(image, overscan, 1)

        self.assertEquals(regions,
                          [regionfile.Polygon([1, 5, 31, 5, 31, 10, 1, 10])])
示例#7
0
def makePolygons(imageWidth, imageOffset, ranges, buffer=1, vertical=False):
    def makeHorizontalBox(arange):
        return [
            0, arange[0] - imageOffset - buffer, imageWidth,
            arange[0] - imageOffset - buffer, imageWidth,
            arange[1] - imageOffset + buffer, 0,
            arange[1] - imageOffset + buffer
        ]

    ###

    def makeVerticalBox(arange):
        return [
            arange[0] - imageOffset - buffer, 0,
            arange[1] - imageOffset + buffer, 0,
            arange[1] - imageOffset + buffer, imageWidth,
            arange[0] - imageOffset - buffer, imageWidth
        ]

    ###

    def applyFitsStartsat1Offset(box):
        return [x + 1 for x in box]

    ###

    makeBox = makeHorizontalBox
    if vertical:
        makeBox = makeVerticalBox

    regions = []

    for arange in ranges:
        regions.append(regionfile.Polygon(applyFitsStartsat1Offset(   \
                    makeBox(arange)) ) )

    return regions
示例#8
0
'''

#########################

if len(sys.argv) != 3:
    print usage
    BonnLogger.updateStatus(__bonn_logger_id__, 1)
    sys.exit(1)

maindir = sys.argv[1]
dir = sys.argv[2]

maskListFilename = '%s/autotracker_mask' % maindir
regDir = '%s/%s/reg' % (maindir, dir)

autotrackerMask = regionfile.Polygon(
    [-1, 3650, 2010, 3650, 2010, 4081, -1, 4081])

if not os.path.exists(maskListFilename):
    print 'Nothing to do.'
    BonnLogger.updateStatus(__bonn_logger_id__, 0)
    sys.exit(0)

input = open(maskListFilename)
for image in input:
    image = image.strip()
    regFilename = '%s/%s.reg' % (regDir, image)

    regionfile.writeRegionFile(regFilename, [autotrackerMask])

input.close()