Changeset 1883 for trunk/python
- Timestamp:
- 08/20/10 18:03:31 (14 years ago)
- Location:
- trunk/python
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/asapmath.py
r1880 r1883 1 from asap.scantable import scantable 1 from asap.scantable import scantable, is_ms 2 2 from asap.parameters import rcParams 3 3 from asap.logging import asaplog, asaplog_post_dec … … 957 957 raise IOError(s) 958 958 # 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): 962 963 s = "File '%s' is not a Measurement set." % (filename) 963 964 raise IOError(s) … … 996 997 tb.open(tablename=filename,nomodify=True) 997 998 ant1=tb.getcol('ANTENNA1',0,-1,1) 999 tb.close() 998 1000 tmpname='asapmath.splitant.tmp' 999 1001 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) 1003 1006 tbsel.close() 1007 tb.close() 1004 1008 del tbsel 1005 1009 scan=scantable(tmpname,average=False,getpt=True,antenna=int(antid)) -
trunk/python/scantable.py
r1875 r1883 37 37 38 38 """ 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 56 def 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 44 77 class scantable(Scantable): 45 78 """\ … … 87 120 if antenna is not None: 88 121 asaplog.push("Antenna selection currently unsupported." 89 "Using ' 0'")122 "Using ''") 90 123 asaplog.post('WARN') 91 124 if antenna is None: … … 123 156 # do not reset to the default freqframe 124 157 #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: 127 163 msg = "The given file '%s'is not a valid " \ 128 164 "asap table." % (filename) 129 165 raise IOError(msg) 130 else:131 self._fill([filename], unit, average, getpt, antenna)132 166 elif (isinstance(filename, list) or isinstance(filename, tuple)) \ 133 167 and isinstance(filename[-1], str):
Note:
See TracChangeset
for help on using the changeset viewer.