- Timestamp:
- 02/28/05 15:29:06 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/asaplinefind.py
r371 r514 122 122 return self.finder.getlinerangesinchannels() 123 123 124 def auto_poly_baseline(scan, mask=None, edge=(0,0), order=0,125 threshold=3,insitu=None):126 """127 Return a scan which has been baselined (all rows) by a polynomial.128 Spectral lines are detected first using linefinder and masked out129 to avoid them affecting the baseline solution.130 131 Parameters:132 scan: a scantable133 mask: an optional mask retreived from scantable134 edge: an optional number of channel to drop at135 the edge of spectrum. If only one value is136 specified, the same number will be dropped from137 both sides of the spectrum. Default is to keep138 all channels139 order: the order of the polynomial (default is 0)140 threshold: the threshold used by line finder. It is better to141 keep it large as only strong lines affect the142 baseline solution.143 insitu: if False a new scantable is returned.144 Otherwise, the scaling is done in-situ145 The default is taken from .asaprc (False)146 147 Example:148 sc2=auto_poly_baseline(sc,order=7)149 """150 from asap.asapfitter import fitter151 from asap import scantable152 153 # setup fitter154 155 f = fitter()156 f._verbose(True)157 f.set_function(poly=order)158 159 # setup line finder160 161 fl=linefinder()162 fl.set_options(threshold=threshold)163 164 if not insitu:165 workscan=scan.copy()166 else:167 workscan=scan168 169 vb=workscan._vb170 # remember the verbose parameter and selection171 workscan._vb=False172 sel=workscan.get_cursor()173 rows=range(workscan.nrow())174 for i in range(workscan.nbeam()):175 workscan.setbeam(i)176 for j in range(workscan.nif()):177 workscan.setif(j)178 for k in range(workscan.npol()):179 workscan.setpol(k)180 if f._vb:181 print "Processing:"182 print 'Beam[%d], IF[%d], Pol[%d]' % (i,j,k)183 for iRow in rows:184 fl.set_scan(workscan,mask,edge)185 fl.find_lines(iRow)186 f.set_scan(workscan, fl.get_mask())187 f.x=workscan._getabcissa(iRow)188 f.y=workscan._getspectrum(iRow)189 f.data=None190 f.fit()191 x=f.get_parameters()192 workscan._setspectrum(f.fitter.getresidual(),iRow)193 workscan.set_cursor(sel[0],sel[1],sel[2])194 workscan._vb = vb195 if not insitu:196 return workscan
Note:
See TracChangeset
for help on using the changeset viewer.