Changeset 1686
- Timestamp:
- 02/08/10 16:22:11 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/alma/python/asapmath.py
r1682 r1686 950 950 # Import the table toolkit from CASA 951 951 try: 952 952 import casac 953 953 except ImportError: 954 955 956 957 958 959 960 954 if rcParams['verbose']: 955 #print "failed to load casa" 956 print_log() 957 asaplog.push("failed to load casa") 958 print_log('ERROR') 959 else: raise 960 return False 961 961 try: 962 963 964 962 tbtool = casac.homefinder.find_home_by_name('tableHome') 963 tb = tbtool.create() 964 tb2 = tbtool.create() 965 965 except: 966 967 968 969 970 971 972 966 if rcParams['verbose']: 967 #print "failed to load a table tool:\n", e 968 print_log() 969 asaplog.push("failed to load table tool") 970 print_log('ERROR') 971 else: raise 972 return False 973 973 # Check the input filename 974 974 if isinstance(filename, str): … … 1007 1007 if len(outprefix) > 0: prefix=outprefix+'.' 1008 1008 else: 1009 prefix=filename 1009 prefix=filename.rstrip('/') 1010 1010 # Now do the actual splitting. 1011 1011 outfiles=[] 1012 tmpms="temp_antsplit.ms"1013 if os.path.exists(tmpms):1014 ans=raw_input('Temporal file '+tmpms+' exists. Delete it and continue? [y/N]: ')1015 if ans.upper() == 'Y':1016 os.system('rm -rf '+tmpms)1017 asaplog.push('The file '+tmpms+' deleted.')1018 else:1019 asaplog.push('Exit without splitting.')1020 return1021 1012 tb.open(tablename=filename+'/ANTENNA',nomodify=True) 1022 1013 nant=tb.nrows() … … 1026 1017 tb.open(tablename=filename,nomodify=True) 1027 1018 ant1=tb.getcol('ANTENNA1',0,-1,1) 1019 tb.close() 1028 1020 for antid in set(ant1): 1029 qstr="ANTENNA1 == "+str(antid) 1030 stab = tb.queryC(qstr) 1031 ctab = stab.copy(tmpms,deep=True) 1032 stab.close() 1033 ctab.close() 1034 scan=scantable(tmpms,average=False,getpt=True) 1021 scan=scantable(filename,average=False,getpt=True,antenna=int(antid)) 1035 1022 outname=prefix+antnames[antid]+'.asap' 1036 1023 scan.save(outname,format='ASAP',overwrite=overwrite) 1037 # Modify scantable header 1038 tb2.open(tablename=outname,nomodify=False) 1039 tb2.putkeyword(keyword='AntennaName',value=antnames[antid]) 1040 tb2.putkeyword(keyword='AntennaPosition',value=antpos[antid]) 1041 tb2.flush() 1042 tb2.close() 1043 del scan, ctab, stab 1024 del scan 1044 1025 outfiles.append(outname) 1045 tb.close()1046 1026 del tb, tb2 1047 os.system('rm -rf '+tmpms)1048 1027 return outfiles 1049 1028
Note:
See TracChangeset
for help on using the changeset viewer.