Changeset 1924 for branches/polybatch/python
- Timestamp:
- 09/14/10 12:17:16 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/polybatch/python/scantable.py
r1920 r1924 1158 1158 return msk 1159 1159 1160 def get_masklist(self, mask=None, row=0 ):1160 def get_masklist(self, mask=None, row=0, silent=False): 1161 1161 """\ 1162 1162 Compute and return a list of mask windows, [min, max]. … … 1192 1192 if not i: 1193 1193 msg += "\nThis mask is only valid for IF=%d" % (self.getif(i)) 1194 asaplog.push(msg) 1194 if not silent: 1195 asaplog.push(msg) 1195 1196 masklist=[] 1196 1197 ist, ien = None, None … … 1934 1935 workscan._setspectrum(f.fitter.getresidual(), r) 1935 1936 self.blpars.append(f.get_parameters()) 1936 self.masklists.append(workscan.get_masklist(f.mask, row=r ))1937 self.masklists.append(workscan.get_masklist(f.mask, row=r, silent=True)) 1937 1938 self.actualmask.append(f.mask) 1938 1939 … … 1949 1950 raise RuntimeError(msg) 1950 1951 1951 1952 def poly_baseline(self, mask=None, order=0, plot=False, batch=False, insitu=None, rows=None): 1952 @asaplog_post_dec 1953 def poly_baseline(self, mask=None, order=0, plot=False, batch=False, 1954 insitu=None, rows=None): 1953 1955 """\ 1954 1956 Return a scan which has been baselined (all rows) by a polynomial. … … 1973 1975 """ 1974 1976 if insitu is None: insitu = rcParams["insitu"] 1977 varlist = vars() 1975 1978 if insitu: 1976 1979 workscan = self … … 1978 1981 workscan = self.copy() 1979 1982 1980 varlist = vars()1981 1983 nchan = workscan.nchan() 1982 1984 … … 1991 1993 1992 1994 if len(rows) > 0: 1993 self.blpars = []1994 self.masklists = []1995 self.actualmask = []1995 workscan.blpars = [] 1996 workscan.masklists = [] 1997 workscan.actualmask = [] 1996 1998 1997 1999 if batch: 1998 for r in rows: 1999 workscan._poly_baseline_batch(mask, order, r) 2000 workscan._poly_baseline_batch(mask, order) 2000 2001 elif plot: 2001 2002 f = fitter() … … 2016 2017 continue 2017 2018 workscan._setspectrum(f.fitter.getresidual(), r) 2018 self.blpars.append(f.get_parameters())2019 self.masklists.append(workscan.get_masklist(f.mask, row=r))2020 self.actualmask.append(f.mask)2019 workscan.blpars.append(f.get_parameters()) 2020 workscan.masklists.append(workscan.get_masklist(f.mask, row=r)) 2021 workscan.actualmask.append(f.mask) 2021 2022 2022 2023 f._p.unmap() 2023 2024 f._p = None 2024 2025 else: 2025 import array2026 2026 for r in rows: 2027 pars = array.array("f", [0.0 for i in range(order+1)]) 2028 pars_adr = pars.buffer_info()[0] 2029 pars_len = pars.buffer_info()[1] 2027 fitparams = workscan._poly_baseline(mask, order, r) 2028 params = fitparams.getparameters() 2029 fmtd = ", ".join(["p%d = %3.6f" % (i, v) for i, v in enumerate(params)]) 2030 errors = fitparams.geterrors() 2031 fmask = mask_and(mask, workscan._getmask(r)) 2032 2033 workscan.blpars.append({"params":params, 2034 "fixed": fitparams.getfixedparameters(), 2035 "formatted":fmtd, "errors":errors}) 2036 workscan.masklists.append(workscan.get_masklist(fmask, r, silent=True)) 2037 workscan.actualmask.append(fmask) 2030 2038 2031 errs = array.array("f", [0.0 for i in range(order+1)]) 2032 errs_adr = errs.buffer_info()[0] 2033 errs_len = errs.buffer_info()[1] 2034 2035 fmsk = array.array("i", [1 for i in range(nchan)]) 2036 fmsk_adr = fmsk.buffer_info()[0] 2037 fmsk_len = fmsk.buffer_info()[1] 2038 2039 workscan._poly_baseline(mask, order, r, pars_adr, pars_len, errs_adr, errs_len, fmsk_adr, fmsk_len) 2040 2041 params = pars.tolist() 2042 fmtd = "" 2043 for i in xrange(len(params)): fmtd += " p%d= %3.6f," % (i, params[i]) 2044 fmtd = fmtd[:-1] # remove trailing "," 2045 errors = errs.tolist() 2046 fmask = fmsk.tolist() 2047 for i in xrange(len(fmask)): fmask[i] = (fmask[i] > 0) # transform (1/0) -> (True/False) 2048 2049 self.blpars.append({"params":params, "fixed":[], "formatted":fmtd, "errors":errors}) 2050 self.masklists.append(workscan.get_masklist(fmask, r)) 2051 self.actualmask.append(fmask) 2052 2053 asaplog.push(str(fmtd)) 2039 asaplog.push(fmtd) 2054 2040 2055 2041 workscan._add_history("poly_baseline", varlist) … … 2202 2188 2203 2189 # Show mask list 2204 masklist=workscan.get_masklist(f.mask, row=r )2190 masklist=workscan.get_masklist(f.mask, row=r, silent=True) 2205 2191 msg = "mask range: "+str(masklist) 2206 2192 asaplog.push(msg, False)
Note:
See TracChangeset
for help on using the changeset viewer.