Ejemplo n.º 1
0
    def initialize_scan(self):
        isScantable = is_scantable(self.infile)

        #load the data without time/pol averaging
        sorg = sd.scantable(self.infile,
                            average=self.scanaverage,
                            antenna=self.antenna)

        rfset = (self.restfreq != '') and (self.restfreq != [])
        doCopy = (self.frame != '') or (self.doppler != '') or rfset \
                 or (self.fluxunit != '' and self.fluxunit != sorg.get_fluxunit()) \
                 or (self.specunit != '' and self.specunit != sorg.get_unit())
        doCopy = doCopy and isScantable

        # check spw
        self.assert_no_channel_selection_in_spw('warn')

        # A scantable selection
        sel = self.get_selector(sorg)
        if len(self.raster) > 0:
            sel = self.select_by_raster(sel, sorg)
        sorg.set_selection(sel)
        self.ssel = sel.__str__()
        del sel

        # Copy scantable when usign disk storage not to modify
        # the original table.
        if doCopy and self.is_disk_storage:
            self.scan = sorg.copy()
        else:
            self.scan = sorg
        del sorg
Ejemplo n.º 2
0
    def initialize_scan(self):
        isScantable = is_scantable(self.infile)

        #load the data without time/pol averaging
        sorg = sd.scantable(self.infile,average=self.scanaverage,antenna=self.antenna)

        rfset = (self.restfreq != '') and (self.restfreq != [])
        doCopy = (self.frame != '') or (self.doppler != '') or rfset \
                 or (self.fluxunit != '' and self.fluxunit != sorg.get_fluxunit()) \
                 or (self.specunit != '' and self.specunit != sorg.get_unit())
        doCopy = doCopy and isScantable

        # check spw
        self.assert_no_channel_selection_in_spw('warn')
        
        # A scantable selection
        sel = self.get_selector(sorg)
        if len(self.raster) > 0:
            sel = self.select_by_raster(sel, sorg)
        sorg.set_selection(sel)
        self.ssel=sel.__str__()
        del sel

        # Copy scantable when usign disk storage not to modify
        # the original table.
        if doCopy and self.is_disk_storage:
            self.scan = sorg.copy()
        else:
            self.scan = sorg
        del sorg
Ejemplo n.º 3
0
 def __get_outform(self):
     if is_scantable(self.infile):
         outform = 'ASAP'
     elif is_ms(infile):
         outform = 'MS2'
     else:
         outform = 'SDFITS'
     return outform
Ejemplo n.º 4
0
 def __get_outform(self):
     if is_scantable(self.infile):
         outform = 'ASAP'
     elif is_ms(infile):
         outform = 'MS2'
     else:
         outform = 'SDFITS'
     return outform
Ejemplo n.º 5
0
    def execute(self):
        if self.splitant:
            for work_scan in self.scans:
                #Apply averaging
                #                self.original_scan = work_scan
                #                work_scan = sdutil.doaverage(self.original_scan, self.scanaverage,
                #                            self.timeaverage, self.tweight,
                #                            self.polaverage, self.pweight)

                # channel range selection
                self.__dochannelrange(work_scan)

                # set rest frequency
                casalog.post('restore=%s' % (self.restore))
                if self.rfset:
                    work_scan.set_restfreqs(
                        sdutil.normalise_restfreq(self.restfreq))

        else:
            # Apply averaging
            #           self.original_scan = self.scan
            #           self.scan = sdutil.doaverage(self.original_scan, self.scanaverage,
            #                                        self.timeaverage, self.tweight,
            #                                        self.polaverage, self.pweight)
            self.original_scan = self.scan

            if is_scantable(self.infile) and self.is_disk_storage:
                self.scan = self.original_scan.copy()

            if self.original_scan == self.scan and self.rfset \
                   and is_scantable(self.infile) \
                   and self.is_disk_storage:
                self.molids = self.original_scan._getmolidcol_list()
                self.restore = True

            # channel range selection
            self.__dochannelrange(self.scan)

            # set rest frequency
            casalog.post('restore=%s' % (self.restore))
            if self.rfset:
                self.scan.set_restfreqs(
                    sdutil.normalise_restfreq(self.restfreq))
Ejemplo n.º 6
0
    def execute(self):
        if self.splitant:
            for work_scan in self.scans:
                #Apply averaging
#                self.original_scan = work_scan
#                work_scan = sdutil.doaverage(self.original_scan, self.scanaverage,
                 #                            self.timeaverage, self.tweight,
                 #                            self.polaverage, self.pweight)

                # channel range selection
                self.__dochannelrange(work_scan)
                
                # set rest frequency
                casalog.post('restore=%s'%(self.restore))
                if self.rfset:
                    work_scan.set_restfreqs(sdutil.normalise_restfreq(self.restfreq))
        
        else:
            # Apply averaging
 #           self.original_scan = self.scan
 #           self.scan = sdutil.doaverage(self.original_scan, self.scanaverage,
 #                                        self.timeaverage, self.tweight,
 #                                        self.polaverage, self.pweight)
            self.original_scan = self.scan

            if is_scantable(self.infile) and self.is_disk_storage:
                self.scan = self.original_scan.copy()

            if self.original_scan == self.scan and self.rfset \
                   and is_scantable(self.infile) \
                   and self.is_disk_storage:
                self.molids = self.original_scan._getmolidcol_list()
                self.restore = True

            # channel range selection
            self.__dochannelrange(self.scan)
                    
            # set rest frequency
            casalog.post('restore=%s'%(self.restore))
            if self.rfset:
                self.scan.set_restfreqs(sdutil.normalise_restfreq(self.restfreq))
Ejemplo n.º 7
0
    def initialize_scan(self):
        sorg = sd.scantable(self.infile, average=False, antenna=self.antenna)

        sel = self.get_selector(sorg)
        sorg.set_selection(sel)
        del sel

        # Copy scantable when using disk storage not to modify
        # the original table.
        if is_scantable(self.infile) and self.is_disk_storage:
            self.scan = sorg.copy()
        else:
            self.scan = sorg
        del sorg
Ejemplo n.º 8
0
    def initialize_scan(self):
        sorg = sd.scantable(self.infile, average=False, antenna=self.antenna)
        
        sel = self.get_selector(sorg)
        sorg.set_selection(sel)
        del sel

        # Copy scantable when using disk storage not to modify
        # the original table.
        if is_scantable(self.infile) and self.is_disk_storage:
            self.scan = sorg.copy()
        else:
            self.scan = sorg
        del sorg
Ejemplo n.º 9
0
    def initialize_scan(self):
        sorg = sd.scantable(self.infile, average=False, antenna=self.antenna)
        if not (isinstance(sorg, Scantable)):
            raise Exception, 'infile=%s is not found' % self.infile

        # A scantable selection
        #sel = self.get_selector()
        sel = self.get_selector(sorg)
        sorg.set_selection(sel)
        self.assert_no_channel_selection_in_spw('warn')

        # Copy scantable when usign disk storage not to modify
        # the original table.
        if is_scantable(self.infile) and self.is_disk_storage:
            self.scan = sorg.copy()
        else:
            self.scan = sorg
        del sorg
Ejemplo n.º 10
0
    def initialize_scan(self):
        sorg=sd.scantable(self.infile,average=False,antenna=self.antenna)
        if not (isinstance(sorg,Scantable)):
            raise Exception, 'infile=%s is not found' % self.infile

        # A scantable selection
        #sel = self.get_selector()
        sel = self.get_selector(sorg)
        sorg.set_selection(sel)
        self.assert_no_channel_selection_in_spw('warn')

        # Copy scantable when usign disk storage not to modify
        # the original table.
        if is_scantable(self.infile) and self.is_disk_storage:
            self.scan = sorg.copy()
        else:
            self.scan = sorg
        del sorg
Ejemplo n.º 11
0
    def parameter_check(self):
        # by default, the task overwrite infile
        if len(self.outfile) == 0:
            self.project = self.infile
        else:
            self.project = self.outfile

        sdutil.assert_outfile_canoverwrite_or_nonexistent(
            self.project, self.outform, self.overwrite)

        #check the format of the infile
        filename = sdutil.get_abspath(self.infile)
        if isinstance(self.infile, str):
            if is_scantable(filename):
                informat = 'ASAP'
            elif is_ms(filename):
                informat = 'MS2'
            else:
                informat = 'SDFITS'
        else:
            informat = 'UNDEFINED'

        # Check the formats of infile and outfile are identical when overwrite=True.
        # (CAS-3096). If not, print warning message and exit.
        outformat = self.outform.upper()
        if (outformat == 'MS'): outformat = 'MS2'
        if self.overwrite and os.path.exists(self.project) \
           and (sdutil.get_abspath(self.project) == sdutil.get_abspath(self.infile)) \
           and (outformat != informat):
            msg = "The input and output data format must be identical when "
            msg += "their names are identical and overwrite=True. "
            msg += "%s and %s given for input and output, respectively." % (
                informat, outformat)
            raise Exception, msg

        # check restfreq
        self.rfset = (self.restfreq != '') and (self.restfreq != [])
        self.restore = self.rfset

        if self.mode.lower()[0] not in self.valid_modes:
            raise Exception, "Invalide mode, '%s'" % self.mode

        # check whether any flag operation is done or not
        self.anyflag = False
Ejemplo n.º 12
0
    def parameter_check(self):
        # by default, the task overwrite infile
        if len(self.outfile)==0: 
            self.project = self.infile
        else:
            self.project = self.outfile

        sdutil.assert_outfile_canoverwrite_or_nonexistent(self.project,
                                                          self.outform,
                                                          self.overwrite)
        
        #check the format of the infile
        filename = sdutil.get_abspath(self.infile)
        if isinstance(self.infile, str):
            if is_scantable(filename):
                informat = 'ASAP'
            elif is_ms(filename):
                informat = 'MS2'
            else:
                informat = 'SDFITS'
        else:
            informat = 'UNDEFINED'
                
        # Check the formats of infile and outfile are identical when overwrite=True.
        # (CAS-3096). If not, print warning message and exit.
        outformat = self.outform.upper()
        if (outformat == 'MS'): outformat = 'MS2'
        if self.overwrite and os.path.exists(self.project) \
           and (sdutil.get_abspath(self.project) == sdutil.get_abspath(self.infile)) \
           and (outformat != informat):
            msg = "The input and output data format must be identical when "
            msg += "their names are identical and overwrite=True. "
            msg += "%s and %s given for input and output, respectively." % (informat, outformat)
            raise Exception, msg

        # check restfreq
        self.rfset = (self.restfreq != '') and (self.restfreq != [])
        self.restore = self.rfset

        if self.mode.lower()[0] not in self.valid_modes:
            raise Exception, "Invalide mode, '%s'" % self.mode

        # check whether any flag operation is done or not
        self.anyflag = False
Ejemplo n.º 13
0
 def __detect_tsysspw(self):
     if len(self.tsysspw) == 0:
         if is_scantable(self.infile):
             sel_org = self.scan.get_selection()
             query_org = sel_org.get_query()
             casalog.post('original query: %s'%(query_org),priority='DEBUG')
             query_new = 'SRCTYPE == 10 && NELEMENTS(TSYS) > 1'
             if len(query_org.strip()) > 0:
                 query_new = '(%s) && (%s)'%(query_org, query_new)
             casalog.post('new query: %s'%(query_new),priority='DEBUG')
             sel = sd.selector(sel_org)
             sel.set_query(query_new)
             try:
                 self.scan.set_selection(sel)
                 self.tsysspw = ','.join(map(str,self.scan.getifnos()))
             except Exception, e:
                 casalog.post('Exception: %s'%(e))
                 self.tsysspw = ''
             finally:
                 self.scan.set_selection(sel_org)
Ejemplo n.º 14
0
    def initialize_scan(self):
        sorg = sd.scantable(self.infile, average=False, antenna=self.antenna)

        if len(self.row.strip()) > 0:
            self.rowlist = sorg.parse_idx_selection('row', self.row)

        sel = self.get_selector(sorg)

        # Copy scantable when using disk storage not to modify
        # the original table.
        if is_scantable(self.infile) and self.is_disk_storage:
            if self.keeprows:
                # copy first to keep rows
                self.scan = sorg.copy()
                self.scan.set_selection(sel)
            else:
                sorg.set_selection(sel)
                self.scan = sorg.copy()
        else:
            sorg.set_selection(sel)
            self.scan = sorg
        del sel, sorg
Ejemplo n.º 15
0
    def initialize_scan(self):
        sorg = sd.scantable(self.infile, average=False, antenna=self.antenna)

        if len(self.row.strip()) > 0:
            self.rowlist = sorg.parse_idx_selection('row', self.row)

        sel = self.get_selector(sorg)

        # Copy scantable when using disk storage not to modify
        # the original table.
        if is_scantable(self.infile) and self.is_disk_storage:
            if self.keeprows:
                # copy first to keep rows
                self.scan = sorg.copy()
                self.scan.set_selection(sel)
            else:
                sorg.set_selection(sel)
                self.scan = sorg.copy()
        else:
            sorg.set_selection(sel)
            self.scan = sorg
        del sel, sorg
Ejemplo n.º 16
0
 def check_infile(self):
     if not is_scantable(self.infile):
         raise Exception('infile must be in scantable format.')