Ejemplo n.º 1
0
    def __get_grid_parameters(self, calc=False):
        # CAS-5410 Use private tools inside task scripts
        qa = qatool()

        (nx,ny) = self.__get_mapsize()
        mapcenter = sdutil.get_map_center(self.center)
        (cellx,celly) = sdutil.get_cellx_celly(self.cell)
        if calc and \
               ((mapcenter.split() != 3) or not qa.compare(cellx, "rad")):
            #(mapcenter,cellx,celly) = self.__calc_center_and_cell(mapcenter, cellx, celly)
            (mapcenter,cellx,celly) = self.__get_center_and_cell(nx, ny, mapcenter, cellx, celly)
        return (nx,ny,cellx,celly,mapcenter)
Ejemplo n.º 2
0
    def __get_grid_parameters(self, calc=False):
        # CAS-5410 Use private tools inside task scripts
        qa = qatool()

        (nx, ny) = self.__get_mapsize()
        mapcenter = sdutil.get_map_center(self.center)
        (cellx, celly) = sdutil.get_cellx_celly(self.cell)
        if calc and \
               ((mapcenter.split() != 3) or not qa.compare(cellx, "rad")):
            #(mapcenter,cellx,celly) = self.__calc_center_and_cell(mapcenter, cellx, celly)
            (mapcenter, cellx,
             celly) = self.__get_center_and_cell(nx, ny, mapcenter, cellx,
                                                 celly)
        return (nx, ny, cellx, celly, mapcenter)
Ejemplo n.º 3
0
    def __compile(self):
        # infiles
        if isinstance(self.infiles, str):
            self.infiles = [self.infiles]

        # scantable for temporary use
        tmpst = sd.scantable(self.infiles[0], False)

        # scanlist
        #self.scans = sdutil._to_list(self.scanlist, int)
        self.scans = tmpst.parse_idx_selection("SCAN", self.scanno)

        # pollist
        #self.pols = sdutil._to_list(self.pollist, int)
        self.pols = tmpst.parse_idx_selection("POL", self.polno)

        # spw
        if (self.spw.strip() == '-1'):
            self.ifno = tmpst.getif(0)
        else:
            masklist = tmpst.parse_spw_selection(self.spw)
            if len(masklist) == 0:
                raise ValueError, "Invalid spectral window selection. Selection contains no data."
            self.ifno = masklist.keys()[0]
        
        # outfile
        self.outname = sdutil.get_default_outfile_name(self.infiles[0],
                                                       self.outfile,
                                                       self.suffix)
        sdutil.assert_outfile_canoverwrite_or_nonexistent(self.outname,
                                                          'ASAP',
                                                          self.overwrite)
        
        # nx and ny
        (self.nx, self.ny) = sdutil.get_nx_ny(self.npix)

        # cellx and celly
        (self.cellx, self.celly) = sdutil.get_cellx_celly(self.cell)

        # map center
        self.mapcenter = sdutil.get_map_center(self.center)

        del tmpst
Ejemplo n.º 4
0
    def __compile(self):
        # infiles
        if isinstance(self.infiles, str):
            self.infiles = [self.infiles]

        # scantable for temporary use
        tmpst = sd.scantable(self.infiles[0], False)

        # scanlist
        #self.scans = sdutil._to_list(self.scanlist, int)
        self.scans = tmpst.parse_idx_selection("SCAN", self.scanno)

        # pollist
        #self.pols = sdutil._to_list(self.pollist, int)
        self.pols = tmpst.parse_idx_selection("POL", self.polno)

        # spw
        if (self.spw.strip() == '-1'):
            self.ifno = tmpst.getif(0)
        else:
            masklist = tmpst.parse_spw_selection(self.spw)
            if len(masklist) == 0:
                raise ValueError, "Invalid spectral window selection. Selection contains no data."
            self.ifno = masklist.keys()[0]

        # outfile
        self.outname = sdutil.get_default_outfile_name(self.infiles[0],
                                                       self.outfile,
                                                       self.suffix)
        sdutil.assert_outfile_canoverwrite_or_nonexistent(
            self.outname, 'ASAP', self.overwrite)

        # nx and ny
        (self.nx, self.ny) = sdutil.get_nx_ny(self.npix)

        # cellx and celly
        (self.cellx, self.celly) = sdutil.get_cellx_celly(self.cell)

        # map center
        self.mapcenter = sdutil.get_map_center(self.center)

        del tmpst
Ejemplo n.º 5
0
    def __calc_center_and_cell(self, center, cellx, celly):
        from numpy import array
        # CAS-5410 Use private tools inside task scripts
        qa = qatool()

        # Get map extent (in radian)
        dirarr = array(self.scan.get_directionval()).transpose()
        xmin = dirarr[0].min()
        xmax = dirarr[0].max()
        ymin = dirarr[1].min()
        ymax = dirarr[1].max()
        del dirarr
        # center of directions
        dircent = [0.5*(xmax + xmin), 0.5*(ymax + ymin)]
        centx = None
        centy = None
        # center is not specified
        if center.split() != 3:
            # set map center (string) to center of directions
            center = sdutil.get_map_center(dircent, unit= "rad")
            # direction center in unit of radian
            (centx, centy) = dircent
        # cell is not specified
        if not qa.compare(cellx, "rad"):
            if not centx:
                # center is given. Get the value in radian
                lcent = center.split()
                centx = qa.convert(qa.toangle(lcent[1]), "rad")
                centy = qa.convert(qa.toangle(lcent[2]), "rad")
                # make sure centx is in +-pi of pointing center
                rotnum = round(abs(centx - dircent[0])/(2*pi))
                if centx < dircent[0]: rotnum *= -1
                centx -= rotnum*2*pi
            wx = 2. * max(abs(xmax-centx), abs(xmin-centx))
            wy = 2. * max(abs(ymax-centy), abs(ymin-centy))
            #print "mapsize = [%frad, %frad]" % (wx, wy)
            from numpy import cos
            (nx,ny) = self.__get_mapsize()
            cellx = qa.quantity(wx/float(max(nx-1,1))*cos(centy), "rad")
            celly = qa.quantity(wy/float(max(ny-1,1)), "rad")
        return (center, qa.tos(cellx), qa.tos(celly))
Ejemplo n.º 6
0
    def __calc_center_and_cell(self, center, cellx, celly):
        from numpy import array
        # CAS-5410 Use private tools inside task scripts
        qa = qatool()

        # Get map extent (in radian)
        dirarr = array(self.scan.get_directionval()).transpose()
        xmin = dirarr[0].min()
        xmax = dirarr[0].max()
        ymin = dirarr[1].min()
        ymax = dirarr[1].max()
        del dirarr
        # center of directions
        dircent = [0.5 * (xmax + xmin), 0.5 * (ymax + ymin)]
        centx = None
        centy = None
        # center is not specified
        if center.split() != 3:
            # set map center (string) to center of directions
            center = sdutil.get_map_center(dircent, unit="rad")
            # direction center in unit of radian
            (centx, centy) = dircent
        # cell is not specified
        if not qa.compare(cellx, "rad"):
            if not centx:
                # center is given. Get the value in radian
                lcent = center.split()
                centx = qa.convert(qa.toangle(lcent[1]), "rad")
                centy = qa.convert(qa.toangle(lcent[2]), "rad")
                # make sure centx is in +-pi of pointing center
                rotnum = round(abs(centx - dircent[0]) / (2 * pi))
                if centx < dircent[0]: rotnum *= -1
                centx -= rotnum * 2 * pi
            wx = 2. * max(abs(xmax - centx), abs(xmin - centx))
            wy = 2. * max(abs(ymax - centy), abs(ymin - centy))
            #print "mapsize = [%frad, %frad]" % (wx, wy)
            from numpy import cos
            (nx, ny) = self.__get_mapsize()
            cellx = qa.quantity(wx / float(max(nx - 1, 1)) * cos(centy), "rad")
            celly = qa.quantity(wy / float(max(ny - 1, 1)), "rad")
        return (center, qa.tos(cellx), qa.tos(celly))