Changeset 1653
- Timestamp:
- 10/22/09 20:47:17 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/alma/python/scantable.py
r1649 r1653 1471 1471 return s 1472 1472 1473 def smooth(self, kernel="hanning", width=5.0, insitu=None): 1473 #def smooth(self, kernel="hanning", width=5.0, insitu=None): 1474 def smooth(self, kernel="hanning", width=5.0, plot=False, insitu=None): 1474 1475 """ 1475 1476 Smooth the spectrum by the specified kernel (conserving flux). … … 1483 1484 Maximum. For 'boxcar' it is the full width. 1484 1485 For 'rmedian' it is the half width. 1486 plot: plot the original and the smoothed spectra. 1487 In this each indivual fit has to be approved, by 1488 typing 'y' or 'n' 1485 1489 insitu: if False a new scantable is returned. 1486 1490 Otherwise, the scaling is done in-situ … … 1492 1496 self._math._setinsitu(insitu) 1493 1497 varlist = vars() 1498 1499 if plot: orgscan = self.copy() 1500 1494 1501 s = scantable(self._math._smooth(self, kernel.lower(), width)) 1495 1502 s._add_history("smooth", varlist) 1503 1504 if plot: 1505 if rcParams['plotter.gui']: 1506 from asap.asaplotgui import asaplotgui as asaplot 1507 else: 1508 from asap.asaplot import asaplot 1509 self._p=asaplot() 1510 self._p.set_panels() 1511 ylab=s._get_ordinate_label() 1512 #self._p.palette(0,["#777777","red"]) 1513 for r in xrange(s.nrow()): 1514 xsm=s._getabcissa(r) 1515 ysm=s._getspectrum(r) 1516 xorg=orgscan._getabcissa(r) 1517 yorg=orgscan._getspectrum(r) 1518 self._p.clear() 1519 self._p.hold() 1520 self._p.set_axes('ylabel',ylab) 1521 self._p.set_axes('xlabel',s._getabcissalabel(r)) 1522 self._p.set_axes('title',s._getsourcename(r)) 1523 self._p.set_line(label='Original',color="#777777") 1524 self._p.plot(xorg,yorg) 1525 self._p.set_line(label='Smoothed',color="red") 1526 self._p.plot(xsm,ysm) 1527 ### Ugly part for legend 1528 for i in [0,1]: 1529 self._p.subplots[0]['lines'].append([self._p.subplots[0]['axes'].lines[i]]) 1530 self._p.release() 1531 ### Ugly part for legend 1532 self._p.subplots[0]['lines']=[] 1533 res = raw_input("Accept smoothing ([y]/n): ") 1534 if res.upper() == 'N': 1535 s._setspectrum(yorg, r) 1536 self._p.unmap() 1537 self._p = None 1538 del orgscan 1539 1496 1540 print_log() 1497 1541 if insitu: self._assign(s) … … 1555 1599 f.data = None 1556 1600 f.fit() 1601 fpar = f.get_parameters() 1602 if plot: 1603 f.plot(residual=True) 1604 x = raw_input("Accept fit ( [y]/n ): ") 1605 if x.upper() == 'N': 1606 self.blpars.append(None) 1607 continue 1557 1608 workscan._setspectrum(f.fitter.getresidual(), r) 1558 fpar = f.get_parameters()1559 1609 self.blpars.append(fpar) 1560 1610 if plot: 1611 f._p.unmap() 1612 f._p = None 1561 1613 #f.set_scan(self, mask) 1562 1614 #s = f.auto_fit(insitu, plot=plot)
Note:
See TracChangeset
for help on using the changeset viewer.