Changeset 1693 for branches/alma/python
- Timestamp:
- 02/10/10 19:39:06 (15 years ago)
- Location:
- branches/alma/python
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/alma/python/asapmath.py
r1686 r1693 184 184 varlist = vars() 185 185 # check for the appropriate data 186 s = scantab.get_scan('*_ps*') 187 if s is None: 186 ## s = scantab.get_scan('*_ps*') 187 ## if s is None: 188 ## msg = "The input data appear to contain no position-switch mode data." 189 ## if rcParams['verbose']: 190 ## #print msg 191 ## asaplog.push(msg) 192 ## print_log('ERROR') 193 ## return 194 ## else: 195 ## raise TypeError(msg) 196 s = scantab.copy() 197 from asap._asap import srctype 198 sel = selector() 199 sel.set_types( srctype.pson ) 200 try: 201 scantab.set_selection( sel ) 202 except Exception, e: 188 203 msg = "The input data appear to contain no position-switch mode data." 189 204 if rcParams['verbose']: … … 194 209 else: 195 210 raise TypeError(msg) 211 s.set_selection() 212 sel.reset() 196 213 ssub = s.get_scan(scannos) 197 214 if ssub is None: … … 204 221 else: 205 222 raise TypeError(msg) 206 ssubon = ssub.get_scan('*calon') 207 ssuboff = ssub.get_scan('*[^calon]') 223 #ssubon = ssub.get_scan('*calon') 224 #ssuboff = ssub.get_scan('*[^calon]') 225 sel.set_types( [srctype.poncal,srctype.poffcal] ) 226 ssub.set_selection( sel ) 227 ssubon = ssub.copy() 228 ssub.set_selection() 229 sel.reset() 230 sel.set_types( [srctype.pson,srctype.psoff] ) 231 ssub.set_selection( sel ) 232 ssuboff = ssub.copy() 233 ssub.set_selection() 234 sel.reset() 208 235 if ssubon.nrow() != ssuboff.nrow(): 209 236 msg = "mismatch in numbers of CAL on/off scans. Cannot calibrate. Check the scan numbers." … … 216 243 raise TypeError(msg) 217 244 cals = dototalpower(ssubon, ssuboff, tcalval) 218 sig = cals.get_scan('*ps') 219 ref = cals.get_scan('*psr') 245 #sig = cals.get_scan('*ps') 246 #ref = cals.get_scan('*psr') 247 sel.set_types( srctype.pson ) 248 cals.set_selection( sel ) 249 sig = cals.copy() 250 cals.set_selection() 251 sel.reset() 252 sel.set_types( srctype.psoff ) 253 cals.set_selection( sel ) 254 ref = cals.copy() 255 cals.set_selection() 256 sel.reset() 220 257 if sig.nscan() != ref.nscan(): 221 258 msg = "mismatch in numbers of on/off scans. Cannot calibrate. Check the scan numbers." … … 261 298 postcal=[] 262 299 keys=['ps','ps_calon','psr','psr_calon'] 300 types=[srctype.pson,srctype.poncal,srctype.psoff,srctype.poffcal] 263 301 ifnos=list(ssub.getifnos()) 264 302 polnos=list(ssub.getpolnos()) 265 303 sel=selector() 266 304 for i in range(2): 267 ss=ssuboff.get_scan('*'+keys[2*i])305 #ss=ssuboff.get_scan('*'+keys[2*i]) 268 306 ll=[] 269 307 for j in range(len(ifnos)): … … 271 309 sel.set_ifs(ifnos[j]) 272 310 sel.set_polarizations(polnos[k]) 311 sel.set_types(types[2*i]) 273 312 try: 274 ss.set_selection(sel) 313 #ss.set_selection(sel) 314 ssuboff.set_selection(sel) 275 315 except: 276 316 continue 277 ll.append(numpy.array(ss._getspectrum(0))) 317 #ll.append(numpy.array(ss._getspectrum(0))) 318 ll.append(numpy.array(ssuboff._getspectrum(0))) 278 319 sel.reset() 279 ss .set_selection()320 ssuboff.set_selection() 280 321 precal[keys[2*i]]=ll 281 del ss282 ss=ssubon.get_scan('*'+keys[2*i+1])322 #del ss 323 #ss=ssubon.get_scan('*'+keys[2*i+1]) 283 324 ll=[] 284 325 for j in range(len(ifnos)): … … 286 327 sel.set_ifs(ifnos[j]) 287 328 sel.set_polarizations(polnos[k]) 329 sel.set_types(types[2*i+1]) 288 330 try: 289 ss.set_selection(sel) 331 #ss.set_selection(sel) 332 ssubon.set_selection(sel) 290 333 except: 291 334 continue 292 ll.append(numpy.array(ss._getspectrum(0))) 335 #ll.append(numpy.array(ss._getspectrum(0))) 336 ll.append(numpy.array(ssubon._getspectrum(0))) 293 337 sel.reset() 294 ss .set_selection()338 ssubon.set_selection() 295 339 precal[keys[2*i+1]]=ll 296 del ss340 #del ss 297 341 for j in range(len(ifnos)): 298 342 for k in range(len(polnos)): … … 413 457 varlist = vars() 414 458 from asap._asap import stmath 459 from asap._asap import srctype 415 460 stm = stmath() 416 461 stm._setinsitu(False) 417 462 418 463 # check for the appropriate data 419 s = scantab.get_scan('*_nod*') 420 if s is None: 464 ## s = scantab.get_scan('*_nod*') 465 ## if s is None: 466 ## msg = "The input data appear to contain no Nod observing mode data." 467 ## if rcParams['verbose']: 468 ## #print msg 469 ## asaplog.push(msg) 470 ## print_log('ERROR') 471 ## return 472 ## else: 473 ## raise TypeError(msg) 474 s = scantab.copy() 475 sel = selector() 476 sel.set_types( srctype.nod ) 477 try: 478 s.set_selection( sel ) 479 except Exception, e: 421 480 msg = "The input data appear to contain no Nod observing mode data." 422 481 if rcParams['verbose']: … … 427 486 else: 428 487 raise TypeError(msg) 488 sel.reset() 489 del sel 490 del s 429 491 430 492 # need check correspondance of each beam with sig-ref ... … … 475 537 precal={} 476 538 postcal=[] 477 keys=['nod','nod_calon'] 539 keys=['','_calon'] 540 types=[srctype.nod,srctype.nodcal] 478 541 ifnos=list(scantab.getifnos()) 479 542 polnos=list(scantab.getpolnos()) 480 543 sel=selector() 544 ss = scantab.copy() 481 545 for i in range(2): 482 ss=scantab.get_scan('*'+keys[i])546 #ss=scantab.get_scan('*'+keys[i]) 483 547 ll=[] 484 548 ll2=[] … … 488 552 sel.set_polarizations(polnos[k]) 489 553 sel.set_scans(pairScans[0]) 554 sel.set_types(types[i]) 490 555 try: 491 556 ss.set_selection(sel) … … 498 563 sel.set_polarizations(polnos[k]) 499 564 sel.set_scans(pairScans[1]) 565 sel.set_types(types[i]) 500 566 try: 501 567 ss.set_selection(sel) … … 506 572 sel.reset() 507 573 ss.set_selection() 508 key='%s%s' %(pairScans[0],keys[i] .lstrip('nod'))574 key='%s%s' %(pairScans[0],keys[i]) 509 575 precal[key]=ll 510 key='%s%s' %(pairScans[1],keys[i] .lstrip('nod'))576 key='%s%s' %(pairScans[1],keys[i]) 511 577 precal[key]=ll2 512 del ss578 #del ss 513 579 keys=precal.keys() 514 580 for j in range(len(ifnos)): … … 638 704 varlist = vars() 639 705 from asap._asap import stmath 706 from asap._asap import srctype 640 707 stm = stmath() 641 708 stm._setinsitu(False) … … 657 724 # get data 658 725 ssub = s.get_scan(scannos) 659 ssubon = ssub.get_scan('*calon') 660 ssuboff = ssub.get_scan('*[^calon]') 726 #ssubon = ssub.get_scan('*calon') 727 #ssuboff = ssub.get_scan('*[^calon]') 728 sel = selector() 729 sel.set_types( [srctype.foncal,srctype.foffcal] ) 730 ssub.set_selection( sel ) 731 ssubon = ssub.copy() 732 ssub.set_selection() 733 sel.reset() 734 sel.set_types( [srctype.fson,srctype.fsoff] ) 735 ssub.set_selection( sel ) 736 ssuboff = ssub.copy() 737 ssub.set_selection() 738 sel.reset() 661 739 import numpy 662 740 precal={} 663 741 postcal=[] 664 742 keys=['fs','fs_calon','fsr','fsr_calon'] 743 types=[srctype.fson,srctype.foncal,srctype.fsoff,srctype.foffcal] 665 744 ifnos=list(ssub.getifnos()) 666 745 polnos=list(ssub.getpolnos()) 667 sel=selector()668 746 for i in range(2): 669 ss=ssuboff.get_scan('*'+keys[2*i])747 #ss=ssuboff.get_scan('*'+keys[2*i]) 670 748 ll=[] 671 749 for j in range(len(ifnos)): … … 673 751 sel.set_ifs(ifnos[j]) 674 752 sel.set_polarizations(polnos[k]) 753 sel.set_types(types[2*i]) 675 754 try: 676 ss.set_selection(sel) 755 #ss.set_selection(sel) 756 ssuboff.set_selection(sel) 677 757 except: 678 758 continue 679 759 ll.append(numpy.array(ss._getspectrum(0))) 680 760 sel.reset() 681 ss.set_selection() 761 #ss.set_selection() 762 ssuboff.set_selection() 682 763 precal[keys[2*i]]=ll 683 del ss684 ss=ssubon.get_scan('*'+keys[2*i+1])764 #del ss 765 #ss=ssubon.get_scan('*'+keys[2*i+1]) 685 766 ll=[] 686 767 for j in range(len(ifnos)): … … 688 769 sel.set_ifs(ifnos[j]) 689 770 sel.set_polarizations(polnos[k]) 771 sel.set_types(types[2*i+1]) 690 772 try: 691 ss.set_selection(sel) 773 #ss.set_selection(sel) 774 ssubon.set_selection(sel) 692 775 except: 693 776 continue 694 777 ll.append(numpy.array(ss._getspectrum(0))) 695 778 sel.reset() 696 ss.set_selection() 779 #ss.set_selection() 780 ssubon.set_selection() 697 781 precal[keys[2*i+1]]=ll 698 del ss 699 sig=resspec.get_scan('*_fs') 700 ref=resspec.get_scan('*_fsr') 782 #del ss 783 #sig=resspec.get_scan('*_fs') 784 #ref=resspec.get_scan('*_fsr') 785 sel.set_types( srctype.fson ) 786 resspec.set_selection( sel ) 787 sig=resspec.copy() 788 resspec.set_selection() 789 sel.reset() 790 sel.set_type( srctype.fsoff ) 791 resspec.set_selection( sel ) 792 ref=resspec.copy() 793 resspec.set_selection() 794 sel.reset() 701 795 for k in range(len(polnos)): 702 796 for j in range(len(ifnos)): -
branches/alma/python/selector.py
r1639 r1693 159 159 if isinstance(vec,list): 160 160 self._setrows(vec) 161 else: 162 raise TypeError('Unknown row number type. Use lists of integers.') 163 164 def set_types(self, types=[]): 165 """ 166 Set a sequence of source types. 167 Parameters: 168 types: a list of integers. Default [] is to unset the selection. 169 """ 170 vec = _to_list(types, int) 171 if isinstance(vec,list): 172 self._settypes(vec) 161 173 else: 162 174 raise TypeError('Unknown row number type. Use lists of integers.') … … 176 188 def get_order(self): 177 189 return list(self._getorder()) 190 def get_types(self): 191 return list(self._gettypes()) 178 192 def get_query(self): 179 193 prefix = "SELECT FROM $1 WHERE "
Note:
See TracChangeset
for help on using the changeset viewer.