Changeset 1859 for trunk/python/asapmath.py
- Timestamp:
- 08/05/10 14:40:38 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/asapmath.py
r1827 r1859 67 67 if not isinstance(s,scantable): 68 68 msg = "Please give a list of scantables" 69 if rcParams['verbose']: 70 #print msg 71 asaplog.push(msg) 72 print_log('ERROR') 73 return 74 else: 75 raise TypeError(msg) 69 raise TypeError(msg) 76 70 if scanav: scanav = "SCAN" 77 71 else: scanav = "NONE" … … 96 90 s = scantable(stm._new_average(alignedlst, compel, mask, weight.upper(), scanav)) 97 91 s._add_history("average_time",varlist) 98 print_log() 92 99 93 return s 100 94 95 @print_log_dec 101 96 def quotient(source, reference, preserve=True): 102 97 """ … … 119 114 s = scantable(stm._quotient(source, reference, preserve)) 120 115 s._add_history("quotient",varlist) 121 print_log()122 116 return s 123 117 … … 138 132 s = scantable(stm._dototalpower(calon, caloff, tcalval)) 139 133 s._add_history("dototalpower",varlist) 140 print_log()141 134 return s 142 135 … … 159 152 s = scantable(stm._dosigref(sig, ref, smooth, tsysval, tauval)) 160 153 s._add_history("dosigref",varlist) 161 print_log()162 154 return s 163 155 … … 190 182 ## if s is None: 191 183 ## msg = "The input data appear to contain no position-switch mode data." 192 ## if rcParams['verbose']: 193 ## #print msg 194 ## asaplog.push(msg) 195 ## print_log('ERROR') 196 ## return 197 ## else: 198 ## raise TypeError(msg) 184 ## raise TypeError(msg) 199 185 s = scantab.copy() 200 186 from asap._asap import srctype … … 205 191 except Exception, e: 206 192 msg = "The input data appear to contain no position-switch mode data." 207 if rcParams['verbose']: 208 #print msg 209 asaplog.push(msg) 210 print_log('ERROR') 211 return 212 else: 213 raise TypeError(msg) 193 raise TypeError(msg) 214 194 s.set_selection() 215 195 sel.reset() … … 217 197 if ssub is None: 218 198 msg = "No data was found with given scan numbers!" 219 if rcParams['verbose']: 220 #print msg 221 asaplog.push(msg) 222 print_log('ERROR') 223 return 224 else: 225 raise TypeError(msg) 199 raise TypeError(msg) 226 200 #ssubon = ssub.get_scan('*calon') 227 201 #ssuboff = ssub.get_scan('*[^calon]') … … 238 212 if ssubon.nrow() != ssuboff.nrow(): 239 213 msg = "mismatch in numbers of CAL on/off scans. Cannot calibrate. Check the scan numbers." 240 if rcParams['verbose']: 241 #print msg 242 asaplog.push(msg) 243 print_log('ERROR') 244 return 245 else: 246 raise TypeError(msg) 214 raise TypeError(msg) 247 215 cals = dototalpower(ssubon, ssuboff, tcalval) 248 216 #sig = cals.get_scan('*ps') … … 260 228 if sig.nscan() != ref.nscan(): 261 229 msg = "mismatch in numbers of on/off scans. Cannot calibrate. Check the scan numbers." 262 if rcParams['verbose']: 263 #print msg 264 asaplog.push(msg) 265 print_log('ERROR') 266 return 267 else: 268 raise TypeError(msg) 230 raise TypeError(msg) 269 231 270 232 #for user supplied Tsys … … 272 234 if tauval<=0.0: 273 235 msg = "Need to supply a valid tau to use the supplied Tsys" 274 if rcParams['verbose']: 275 #print msg 276 asaplog.push(msg) 277 print_log('ERROR') 278 return 279 else: 280 raise TypeError(msg) 236 raise TypeError(msg) 281 237 else: 282 238 sig.recalc_azel() 283 239 ref.recalc_azel() 284 240 #msg = "Use of user specified Tsys is not fully implemented yet." 285 #if rcParams['verbose']: 286 # print msg 287 # return 288 #else: 289 # raise TypeError(msg) 241 #raise TypeError(msg) 290 242 # use get_elevation to get elevation and 291 243 # calculate a scaling factor using the formula … … 442 394 ### 443 395 ress._add_history("calps", varlist) 444 print_log()445 396 return ress 446 397 … … 469 420 ## if s is None: 470 421 ## msg = "The input data appear to contain no Nod observing mode data." 471 ## if rcParams['verbose']: 472 ## #print msg 473 ## asaplog.push(msg) 474 ## print_log('ERROR') 475 ## return 476 ## else: 477 ## raise TypeError(msg) 422 ## raise TypeError(msg) 478 423 s = scantab.copy() 479 424 sel = selector() … … 483 428 except Exception, e: 484 429 msg = "The input data appear to contain no Nod observing mode data." 485 if rcParams['verbose']: 486 #print msg 487 asaplog.push(msg) 488 print_log('ERROR') 489 return 490 else: 491 raise TypeError(msg) 430 raise TypeError(msg) 492 431 sel.reset() 493 432 del sel … … 511 450 #if len(scannos)>2: 512 451 # msg = "calnod can only process a pair of nod scans at time." 513 # if rcParams['verbose']: 514 # print msg 515 # return 516 # else: 517 # raise TypeError(msg) 452 # raise TypeError(msg) 518 453 # 519 454 #if len(scannos)==2: … … 525 460 if tauval<=0.0: 526 461 msg = "Need to supply a valid tau to use the supplied Tsys" 527 if rcParams['verbose']: 528 #print msg 529 asaplog.push(msg) 530 print_log('ERROR') 531 return 532 else: 533 raise TypeError(msg) 462 raise TypeError(msg) 534 463 else: 535 464 scantab.recalc_azel() … … 683 612 ### 684 613 resspec._add_history("calnod",varlist) 685 print_log()686 614 return resspec 687 615 … … 716 644 # if check is None: 717 645 # msg = "The input data appear to contain no Nod observing mode data." 718 # if rcParams['verbose']: 719 # print msg 720 # return 721 # else: 722 # raise TypeError(msg) 646 # raise TypeError(msg) 723 647 s = scantab.get_scan(scannos) 724 648 del scantab … … 891 815 ### 892 816 resspec._add_history("calfs",varlist) 893 print_log()894 817 return resspec 895 818 … … 921 844 if not isinstance(s,scantable): 922 845 msg = "Please give a list of scantables" 923 if rcParams['verbose']: 924 #print msg 925 asaplog.push(msg) 926 print_log('ERROR') 927 return 928 else: 929 raise TypeError(msg) 846 raise TypeError(msg) 930 847 s = scantable(stm._merge(lst)) 931 848 s._add_history("merge", varlist) 932 print_log()933 849 return s 934 850 851 @print_log_dec 935 852 def calibrate( scantab, scannos=[], calmode='none', verify=None ): 936 853 """ … … 946 863 if ( calmode == 'nod' ): 947 864 asaplog.push( 'Calibrating nod data.' ) 948 print_log()949 865 scal = calnod( scantab, scannos=scannos, verify=verify ) 950 866 elif ( calmode == 'quotient' ): 951 867 asaplog.push( 'Calibrating using quotient.' ) 952 print_log()953 868 scal = scantab.auto_quotient( verify=verify ) 954 869 elif ( calmode == 'ps' ): 955 870 asaplog.push( 'Calibrating %s position-switched data.' % antname ) 956 print_log()957 871 if ( antname.find( 'APEX' ) != -1 ): 958 872 scal = apexcal( scantab, scannos, calmode, verify ) … … 963 877 elif ( calmode == 'fs' or calmode == 'fsotf' ): 964 878 asaplog.push( 'Calibrating %s frequency-switched data.' % antname ) 965 print_log()966 879 if ( antname.find( 'APEX' ) != -1 ): 967 880 scal = apexcal( scantab, scannos, calmode, verify ) … … 972 885 elif ( calmode == 'otf' ): 973 886 asaplog.push( 'Calibrating %s On-The-Fly data.' % antname ) 974 print_log()975 887 scal = almacal( scantab, scannos, calmode, verify ) 976 888 else: … … 1015 927 return scal 1016 928 929 @print_log_dec 1017 930 def splitant(filename, outprefix='',overwrite=False): 1018 931 """ … … 1032 945 """ 1033 946 # Import the table toolkit from CASA 1034 try: 1035 import casac 1036 except ImportError: 1037 if rcParams['verbose']: 1038 #print "failed to load casa" 1039 print_log() 1040 asaplog.push("failed to load casa") 1041 print_log('ERROR') 1042 else: raise 1043 return False 1044 try: 1045 tbtool = casac.homefinder.find_home_by_name('tableHome') 1046 tb = tbtool.create() 1047 tb2 = tbtool.create() 1048 except: 1049 if rcParams['verbose']: 1050 #print "failed to load a table tool:\n", e 1051 print_log() 1052 asaplog.push("failed to load table tool") 1053 print_log('ERROR') 1054 else: raise 1055 return False 947 948 import casac 949 tbtool = casac.homefinder.find_home_by_name('tableHome') 950 tb = tbtool.create() 951 tb2 = tbtool.create() 1056 952 # Check the input filename 1057 953 if isinstance(filename, str): … … 1061 957 if not os.path.exists(filename): 1062 958 s = "File '%s' not found." % (filename) 1063 if rcParams['verbose']:1064 print_log()1065 asaplog.push(s)1066 print_log('ERROR')1067 return1068 959 raise IOError(s) 1069 960 # check if input file is MS … … 1072 963 or not os.path.exists(filename+'/table.f1'): 1073 964 s = "File '%s' is not a Measurement set." % (filename) 1074 if rcParams['verbose']:1075 print_log()1076 asaplog.push(s)1077 print_log('ERROR')1078 return1079 965 raise IOError(s) 1080 966 else: 1081 967 s = "The filename should be string. " 1082 if rcParams['verbose']:1083 print_log()1084 asaplog.push(s)1085 print_log('ERROR')1086 return1087 968 raise TypeError(s) 1088 969 # Check out put file name … … 1110 991 return outfiles 1111 992 993 @print_log_dec 1112 994 def _array2dOp( scan, value, mode="ADD", tsys=False ): 1113 995 """ … … 1128 1010 del stm 1129 1011 elif len( value ) != nrow: 1130 asaplog.push( 'len(value) must be 1 or conform to scan.nrow()' ) 1131 print_log( 'ERROR' ) 1012 raise ValueError( 'len(value) must be 1 or conform to scan.nrow()' ) 1132 1013 else: 1133 1014 from asap._asap import stmath
Note: See TracChangeset
for help on using the changeset viewer.