Changeset 2707
- Timestamp:
- 12/26/12 16:35:37 (12 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/sbseparator.py
r2685 r2707 9 9 from asap.selector import selector 10 10 from asap.asapgrid import asapgrid2 11 #from asap._asap import sidebandsep 11 from asap._asap import SBSeparator 12 12 13 13 class sbseparator: … … 49 49 self.solveother = False 50 50 self.dirtol = [1.e-5, 1.e-5] # direction tolerance in rad (2 arcsec) 51 self.lo1 = 0. 51 52 52 53 self.tables = [] … … 166 167 Set shift mode and channel shift of image band. 167 168 168 mode : shift mode ['DSB'|'SSB' ]169 mode : shift mode ['DSB'|'SSB'(='2SB')] 169 170 When mode='DSB', imageshift is assumed to be equal 170 171 to the shift of signal sideband but in opposite direction. … … 172 173 each scantable. valid only mode='SSB' 173 174 """ 174 if mode.upper().startswith("S"): 175 if mode.upper().startswith("D"): 176 # DSB mode 177 self.dsbmode = True 178 self.imageShift = [] 179 else: 175 180 if not imageshift: 176 181 raise ValueError, "Need to set shift value of image sideband" … … 178 183 self.imageShift = imageshift 179 184 asaplog.push("Image sideband shift is set manually: %s" % str(self.imageShift)) 180 else:181 # DSB mode182 self.dsbmode = True183 self.imageShift = []184 185 185 186 @asaplog_post_dec … … 213 214 if flag: 214 215 asaplog.push("Expert mode: solution are obtained by subtraction of the other sideband.") 216 217 def set_lo1(self,lo1): 218 """ 219 Set LO1 frequency to calculate frequency of image sideband. 220 221 lo1 : LO1 frequency in float 222 """ 223 if isinstance(lo1, dict) and lo1["unit"] == "Hz": 224 self.lo1 = lo1["value"] 225 else: 226 self.lo1 = float(lo1) 227 if self.lo1 <= 0.: 228 asaplog.push("Got negative LO1 frequency. It will be ignored.") 229 asaplog.post("WARN") 215 230 216 231 … … 229 244 230 245 nshift = len(self.tables) 231 signaltab = self._grid_outtable(self.tables[0] .copy())246 signaltab = self._grid_outtable(self.tables[0]) 232 247 if self.getboth: 233 248 imagetab = signaltab.copy() … … 249 264 signal = self._solve_signal(spec_array, tabidx) 250 265 signaltab.set_spectrum(signal, irow) 266 267 # Solve image side side band 251 268 if self.getboth: 252 269 image = self._solve_image(spec_array, tabidx) 253 270 imagetab.set_spectrum(image, irow) 254 271 255 272 # TODO: Need to remove rejrow form scantables here 256 273 signaltab.flag_row(rejrow) … … 267 284 shutil.rmtree(signalname) 268 285 signaltab.save(signalname) 286 269 287 if self.getboth: 270 288 # Warnings … … 281 299 else: 282 300 shutil.rmtree(imagename) 301 # Update frequency information 302 sbsep = SBSeparator() 303 sbsep.set_imgtable(imagetab) 304 if self.lo1 > 0.: 305 sbsep.set_lo1(self.lo1) 306 sbsep.solve_imgfreq() 283 307 imagetab.save(imagename) 308 del sbsep 284 309 285 310 … … 340 365 gridder = asapgrid2(table) 341 366 gridder.setIF(self.baseif) 342 367 343 368 cellx = str(self.dirtol[0])+"rad" 344 369 celly = str(self.dirtol[1])+"rad" … … 346 371 mapx = dirarr[0].max() - dirarr[0].min() 347 372 mapy = dirarr[1].max() - dirarr[1].min() 348 nx = max(1, numpy.ceil(mapx/self.dirtol[0])) 373 centy = 0.5 * (dirarr[1].max() + dirarr[1].min()) 374 nx = max(1, numpy.ceil(mapx*numpy.cos(centy)/self.dirtol[0])) 349 375 ny = max(1, numpy.ceil(mapy/self.dirtol[0])) 350 376 … … 393 419 seltab = tab.copy() 394 420 seltab.set_selection(selector(rows=selrow)) 395 421 396 422 if tab.nrow() > 1: 397 423 asaplog.push("table %d - More than a spectrum selected. averaging rows..." % (itab)) … … 414 440 415 441 return spec_array[0:nspec], tabidx 416 442 417 443 418 444 @asaplog_post_dec … … 452 478 asaplog.post() 453 479 asaplog.push("IFNO is not selected. Using the first IF in the first scantable. Reference IFNO = %d" % (self.baseif)) 454 480 455 481 if not (self.baseif in valid_ifs): 456 482 asaplog.post() … … 460 486 461 487 asaplog.push("Start selecting tables and IFNOs to solve.") 462 asaplog.push("Chec hing frequency of the reference IF")488 asaplog.push("Checking frequency of the reference IF") 463 489 unit_org = stab.get_unit() 464 490 coord = stab._getcoordinfo() … … 473 499 baseinc = spx[1]-spx[0] 474 500 self.nchan = len(spx) 475 if isinstance(self.freqtol, float): 476 vftol = abs(baseinc * self.freqtol) 501 # frequency tolerance 502 if isinstance(self.freqtol, dict) and self.freqtol['unit'] == "Hz": 503 vftol = abs(self.freqtol['value']) 504 else: 505 vftol = abs(baseinc * float(self.freqtol)) 477 506 self.freqtol = dict(value=vftol, unit="Hz") 478 else: 479 vftol = abs(self.freqtol['value']) 507 # tolerance of frequency increment 480 508 inctol = abs(baseinc/float(self.nchan)) 481 509 asaplog.push("Reference frequency setup (Table = 0, IFNO = %d): nchan = %d, chan0 = %f Hz, incr = %f Hz" % (self.baseif, self.nchan, basech0, baseinc)) 482 510 asaplog.push("Allowed frequency tolerance = %f Hz ( %f channels)" % (vftol, vftol/baseinc)) 483 511 poltype0 = stab.poltype() 484 512 485 513 self.tables = [] 486 514 self.signalShift = [] … … 545 573 asaplog.post() 546 574 errmsg = "User defined channel shift of image sideband has %d elements, while selected IFNOs are %d" % (len(self.imageShift), len(self.signalShift)) 575 errmsg += "\nThe frequency tolerance (freqtol) you set may be too small." 547 576 raise RuntimeError, errmsg 548 577 … … 557 586 for itab in range(len(self.tables)): 558 587 self.tables[itab] = self.tables[itab].average_time(scanav=False, weight="tintsys") 559 588 589 # @asaplog_post_dec 590 # def _setup_image_freq(self, table): 591 # # User defined coordinate 592 # # Get from associated MS 593 # # Get from ASDM 594 # lo1 = -1. 595 # if self.lo1 > 0.: 596 # asaplog.push("Using user defined LO1 frequency %e16.12 [Hz]" % self.lo1) 597 # lo1 = self.lo1 598 # else: 599 # print "NOT IMPLEMENTED YET!!!" 560 600 561 601 # def save(self, outfile, outform="ASAP", overwrite=False): -
trunk/src/CMakeLists.txt
r2703 r2707 70 70 ${SRCDIR}/GenericEdgeDetector.cpp 71 71 ${SRCDIR}/PlotHelper.cpp 72 ${SRCDIR}/STSideBandSep.cpp 72 73 ${SRCDIR}/STApplyTable.cpp 73 74 ${SRCDIR}/STCalTsysTable.cpp … … 99 100 ${SRCDIR}/python_EdgeMarker.cpp 100 101 ${SRCDIR}/python_PlotHelper.cpp 102 ${SRCDIR}/python_STSideBandSep.cpp 101 103 ${SRCDIR}/python_asap.cpp ) 102 104 -
trunk/src/python_asap.cpp
r2689 r2707 89 89 asap::python::python_EdgeMarker(); 90 90 asap::python::python_PlotHelper(); 91 asap::python::python_STSideBandSep(); 91 92 92 93 #ifndef HAVE_LIBPYRAP -
trunk/src/python_asap.h
r2689 r2707 56 56 void python_EdgeMarker(); 57 57 void python_PlotHelper(); 58 void python_STSideBandSep(); 58 59 59 60 } // python
Note:
See TracChangeset
for help on using the changeset viewer.