Changeset 1883


Ignore:
Timestamp:
08/20/10 18:03:31 (14 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: No

Ready for Test: Yes

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: read MS in reference table

Put in Release Notes: Yes/No?

Module(s): Module Names change impacts.

Description: Describe your changes here...

Bug fix on is_scantable() and similar routine in the codes.
They are now able to recognize reference table correctly.

splitant() is working with reference table. Thus, performance
is a bit improved since deep copy is no longer necessary.


Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/external-alma/atnf/PKSIO/PKSreader.cc

    r1868 r1883  
    102102
    103103  } else if (inFile.isDirectory()) {
    104     if (File(name + "/DATA_DESCRIPTION").exists()) {
     104    Bool isMS = ( (File(name+"/table.info").exists())
     105                  && File(name+"/table.dat").exists() );
     106    if (isMS) {
     107      RegularFileIO ifs(name+"/table.info") ;
     108      char buf[128] ;
     109      ifs.read(sizeof(buf),buf,False) ;
     110      if ( strstr( buf, "Measurement Set" ) == NULL )
     111        isMS = False ;
     112    }
     113    //if (File(name + "/DATA_DESCRIPTION").exists()) {
     114    if (isMS) {
    105115      // MS version 2.
    106116      #ifdef NOPKSMS
  • trunk/python/asapmath.py

    r1880 r1883  
    1 from asap.scantable import scantable
     1from asap.scantable import scantable, is_ms
    22from asap.parameters import rcParams
    33from asap.logging import asaplog, asaplog_post_dec
     
    957957            raise IOError(s)
    958958        # check if input file is MS
    959         if not os.path.isdir(filename) \
    960                or not os.path.exists(filename+'/ANTENNA') \
    961                or not os.path.exists(filename+'/table.f1'):
     959        #if not os.path.isdir(filename) \
     960        #       or not os.path.exists(filename+'/ANTENNA') \
     961        #       or not os.path.exists(filename+'/table.f1'):
     962        if not is_ms(filename):
    962963            s = "File '%s' is not a Measurement set." % (filename)
    963964            raise IOError(s)
     
    996997    tb.open(tablename=filename,nomodify=True)
    997998    ant1=tb.getcol('ANTENNA1',0,-1,1)
     999    tb.close()
    9981000    tmpname='asapmath.splitant.tmp'
    9991001    for antid in set(ant1):
    1000         tbsel=tb.query('ANTENNA1 == %s && ANTENNA2 == %s'%(antid,antid))
    1001         tbsel.copy(tmpname,deep=True)
    1002         #tbsel=tb.query('ANTENNA1 == %s && ANTENNA2 == %s'%(antid,antid),tmpname)
     1002        tb.open(tablename=filename,nomodify=True)
     1003        #tbsel=tb.query('ANTENNA1 == %s && ANTENNA2 == %s'%(antid,antid))
     1004        #tbsel.copy(tmpname,deep=True)
     1005        tbsel=tb.query('ANTENNA1 == %s && ANTENNA2 == %s'%(antid,antid),tmpname)
    10031006        tbsel.close()
     1007        tb.close()
    10041008        del tbsel
    10051009        scan=scantable(tmpname,average=False,getpt=True,antenna=int(antid))
  • trunk/python/scantable.py

    r1875 r1883  
    3737
    3838    """
    39     return (os.path.isdir(filename)
    40             and not os.path.exists(filename+'/table.f1')
    41             and os.path.exists(filename+'/table.info'))
    42 
    43 
     39    if ( os.path.isdir(filename)
     40         and os.path.exists(filename+'/table.info')
     41         and os.path.exists(filename+'/table.dat') ):
     42        f=open(filename+'/table.info')
     43        l=f.readline()
     44        f.close()
     45        #if ( l.find('Scantable') != -1 ):
     46        if ( l.find('Measurement Set') == -1 ):
     47            return True
     48        else:
     49            return False
     50    else:
     51        return False
     52##     return (os.path.isdir(filename)
     53##             and not os.path.exists(filename+'/table.f1')
     54##             and os.path.exists(filename+'/table.info'))
     55
     56def is_ms(filename):
     57    """Is the given file a MeasurementSet?
     58
     59    Parameters:
     60
     61        filename: the name of the file/directory to test
     62
     63    """
     64    if ( os.path.isdir(filename)
     65         and os.path.exists(filename+'/table.info')
     66         and os.path.exists(filename+'/table.dat') ):
     67        f=open(filename+'/table.info')
     68        l=f.readline()
     69        f.close()
     70        if ( l.find('Measurement Set') != -1 ):
     71            return True
     72        else:
     73            return False
     74    else:
     75        return False
     76   
    4477class scantable(Scantable):
    4578    """\
     
    87120        if antenna is not None:
    88121            asaplog.push("Antenna selection currently unsupported."
    89                          "Using '0'")
     122                         "Using ''")
    90123            asaplog.post('WARN')
    91124        if antenna is None:
     
    123156                    # do not reset to the default freqframe
    124157                    #self.set_freqframe(rcParams['scantable.freqframe'])
    125                 elif os.path.isdir(filename) \
    126                          and not os.path.exists(filename+'/table.f1'):
     158                #elif os.path.isdir(filename) \
     159                #         and not os.path.exists(filename+'/table.f1'):
     160                elif is_ms(filename):
     161                    self._fill([filename], unit, average, getpt, antenna)
     162                else:
    127163                    msg = "The given file '%s'is not a valid " \
    128164                          "asap table." % (filename)
    129165                    raise IOError(msg)
    130                 else:
    131                     self._fill([filename], unit, average, getpt, antenna)
    132166            elif (isinstance(filename, list) or isinstance(filename, tuple)) \
    133167                  and isinstance(filename[-1], str):
Note: See TracChangeset for help on using the changeset viewer.