예제 #1
0
    def makeGrid(self, side=80, outfile=None):
        '''
        Make a grid in R.A., Dec. made of boxes with the given side (in arcsec). The
        grid will be parallel to the axes of the CCD.
        '''
        # Get coordinates of the center
        ra_c, dec_c = self.wcs.wcs.crval

        # Now build the grid aligned with the R.A.,Dec. axis
        # Start from the center, and move of 'side' step
        #    boxes                     = []
        #    PNside                    = 30.0 #arcmin
        #    Nside                     = int(numpy.ceil(PNside*60.0/float(side)))
        #    #Nside                     = 1
        #
        #    #sky                       = self.xy2sky([[self.xmin,self.ymin]])
        #    #ra_corner,dec_corner      = sky[0]
        #
        #    ra_corner                 = ra_c - (PNside/60.0/2.0)
        #    dec_corner                = dec_c - (PNside/60.0/2.0)
        #
        #    for i in range(Nside):
        #      for j in range(Nside):
        #        boxes.append(Box(ra_corner+i*(side/3600.0),dec_corner+j*(side/3600.0),side,side,0,'fk5'))
        #      pass
        #    pass

        side_pix = side / 0.05

        xs = numpy.arange(self.xmin, self.xmax, side_pix / 2.0)
        ys = numpy.arange(self.ymin, self.ymax, side_pix / 2.0)
        grid_ = numpy.meshgrid(xs, ys)
        centers_pix = zip(*(x.flat for x in grid_))

        regionsDs9 = []
        boxes = []

        for i, (x, y) in enumerate(centers_pix):
            box = Box(x, y, side / 0.05, side / 0.05, 0, 'physical')
            boxes.append(box)
            regionsDs9.append(box.getDs9Region()[-1])

        pass

        if (outfile != None):
            with open(outfile, "w+") as f:
                f.write("physical\n")
                f.write("\n".join(regionsDs9))

        return boxes