Changes in trunk/python/scantable.py [2435:2351]
- File:
-
- 1 edited
-
trunk/python/scantable.py (modified) (26 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/scantable.py
r2435 r2351 19 19 from asap.utils import _n_bools, mask_not, mask_and, mask_or, page 20 20 from asap.asapfitter import fitter 21 22 ###############################################################23 ### WK temporarily added these lines for testing 2011/11/28 ###24 ###############################################################25 #from asap._asap import TestClass26 27 #class testclass(TestClass):28 # def __init__(self, nelem):29 # TestClass.__init__(self, nelem)30 31 ###############################################################32 21 33 22 … … 275 264 Parameters: 276 265 277 name: the name of the outputfile. For format 'ASCII'266 name: the name of the outputfile. For format "ASCII" 278 267 this is the root file name (data in 'name'.txt 279 268 and header in 'name'_header.txt) … … 533 522 534 523 selection: a selector object (default unset the selection), or 535 any combination of 'pols', 'ifs', 'beams', 'scans',536 'cycles', 'name', 'query'524 any combination of "pols", "ifs", "beams", "scans", 525 "cycles", "name", "query" 537 526 538 527 Examples:: … … 768 757 return self._row_callback(self._gettsys, "Tsys") 769 758 770 def get_tsysspectrum(self, row=-1):771 """\772 Return the channel dependent system temperatures.773 774 Parameters:775 776 row: the rowno to get the information for. (default all rows)777 778 Returns:779 780 a list of Tsys values for the current selection781 782 """783 return self._get_column( self._gettsysspectrum, row )784 759 785 760 def get_weather(self, row=-1): … … 1202 1177 end: the end frequency or period to remove 1203 1178 1204 unit: the frequency unit (default 'MHz') or ''for1179 unit: the frequency unit (default "MHz") or "" for 1205 1180 explicit lag channels 1206 1181 … … 1264 1239 if rowno is None: 1265 1240 rowno = [] 1241 if mask is None: 1242 mask = [] 1266 1243 if isinstance(rowno, int): 1267 1244 rowno = [rowno] 1268 1245 elif not (isinstance(rowno, list) or isinstance(rowno, tuple)): 1269 1246 raise TypeError("The row number(s) must be int, list or tuple.") 1247 1270 1248 if len(rowno) == 0: rowno = [i for i in xrange(self.nrow())] 1271 1249 1272 usecommonmask = True 1273 1274 if mask is None: 1275 mask = [] 1276 if isinstance(mask, list) or isinstance(mask, tuple): 1277 if len(mask) == 0: 1278 mask = [[]] 1279 else: 1280 if isinstance(mask[0], bool): 1281 if len(mask) != self.nchan(self.getif(rowno[0])): 1282 raise ValueError("The spectra and the mask have " 1283 "different length.") 1284 mask = [mask] 1285 elif isinstance(mask[0], list) or isinstance(mask[0], tuple): 1286 usecommonmask = False 1287 if len(mask) != len(rowno): 1288 raise ValueError("When specifying masks for each " 1289 "spectrum, the numbers of them " 1290 "must be identical.") 1291 for i in xrange(mask): 1292 if len(mask[i]) != self.nchan(self.getif(rowno[i])): 1293 raise ValueError("The spectra and the mask have " 1294 "different length.") 1295 else: 1296 raise TypeError("The mask must be a boolean list or " 1297 "a list of boolean list.") 1298 else: 1250 if not (isinstance(mask, list) or isinstance(mask, tuple)): 1299 1251 raise TypeError("The mask must be a boolean list or a list of " 1300 1252 "boolean list.") 1301 1253 if len(mask) == 0: mask = [True for i in xrange(self.nchan())] 1254 if isinstance(mask[0], bool): mask = [mask] 1255 elif not (isinstance(mask[0], list) or isinstance(mask[0], tuple)): 1256 raise TypeError("The mask must be a boolean list or a list of " 1257 "boolean list.") 1258 1259 usecommonmask = (len(mask) == 1) 1260 if not usecommonmask: 1261 if len(mask) != len(rowno): 1262 raise ValueError("When specifying masks for each spectrum, " 1263 "the numbers of them must be identical.") 1264 for amask in mask: 1265 if len(amask) != self.nchan(): 1266 raise ValueError("The spectra and the mask have different " 1267 "length.") 1268 1302 1269 res = [] 1303 1270 … … 1426 1393 if not (isinstance(mask,list) or isinstance(mask, tuple)): 1427 1394 raise TypeError("The mask should be list or tuple.") 1428 if len(mask) < = 0:1429 raise TypeError("The mask elements should be > 0")1395 if len(mask) < 2: 1396 raise TypeError("The mask elements should be > 1") 1430 1397 data = self._getabcissa(row) 1431 1398 if len(data) != len(mask): … … 1467 1434 if not (isinstance(mask,list) or isinstance(mask, tuple)): 1468 1435 raise TypeError("The mask should be list or tuple.") 1469 if len(mask) < = 0:1470 raise TypeError("The mask elements should be > 0")1436 if len(mask) < 2: 1437 raise TypeError("The mask elements should be > 1") 1471 1438 istart = [] 1472 1439 iend = [] … … 1754 1721 # provided your scantable is called scan 1755 1722 selection = selector() 1756 selection.set_name( 'ORION*')1723 selection.set_name("ORION*") 1757 1724 selection.set_ifs([1]) 1758 1725 scan.set_selection(selection) … … 1995 1962 The first row of the ascii file must give the column 1996 1963 names and these MUST include columns 1997 'ELEVATION' (degrees) and 'FACTOR'(multiply data1964 "ELEVATION" (degrees) and "FACTOR" (multiply data 1998 1965 by this) somewhere. 1999 1966 The second row must give the data type of the … … 2012 1979 2013 1980 method: Interpolation method when correcting from a table. 2014 Values are 'nearest', 'linear' (default), 'cubic'2015 and 'spline'1981 Values are "nearest", "linear" (default), "cubic" 1982 and "spline" 2016 1983 2017 1984 insitu: if False a new scantable is returned. … … 2047 2014 2048 2015 method: Interpolation method for regridding the spectra. 2049 Choose from 'nearest', 'linear', 'cubic'(default)2050 and 'spline'2016 Choose from "nearest", "linear", "cubic" (default) 2017 and "spline" 2051 2018 2052 2019 insitu: if False a new scantable is returned. … … 2056 2023 """ 2057 2024 if insitu is None: insitu = rcParams["insitu"] 2058 oldInsitu = self._math._insitu()2059 2025 self._math._setinsitu(insitu) 2060 2026 varlist = vars() … … 2062 2028 s = scantable(self._math._freq_align(self, reftime, method)) 2063 2029 s._add_history("freq_align", varlist) 2064 self._math._setinsitu(oldInsitu)2065 2030 if insitu: 2066 2031 self._assign(s) … … 2138 2103 2139 2104 method: Interpolation method when correcting from a table. 2140 Values are 'nearest', 'linear', 'cubic'(default)2141 and 'spline'2105 Values are "nearest", "linear", "cubic" (default) 2106 and "spline" 2142 2107 2143 2108 insitu: if False a new scantable is returned. … … 2222 2187 2223 2188 poltype: The new polarisation type. Valid types are: 2224 'linear', 'circular', 'stokes' and 'linpol'2189 "linear", "circular", "stokes" and "linpol" 2225 2190 2226 2191 """ … … 2309 2274 2310 2275 @asaplog_post_dec 2311 def regrid_channel(self, width=5, plot=False, insitu=None):2312 """\2313 Regrid the spectra by the specified channel width2314 2315 Parameters:2316 2317 width: The channel width (float) of regridded spectra2318 in the current spectral unit.2319 2320 plot: [NOT IMPLEMENTED YET]2321 plot the original and the regridded spectra.2322 In this each indivual fit has to be approved, by2323 typing 'y' or 'n'2324 2325 insitu: if False a new scantable is returned.2326 Otherwise, the scaling is done in-situ2327 The default is taken from .asaprc (False)2328 2329 """2330 if insitu is None: insitu = rcParams['insitu']2331 varlist = vars()2332 2333 if plot:2334 asaplog.post()2335 asaplog.push("Verification plot is not implemtnetd yet.")2336 asaplog.post("WARN")2337 2338 s = self.copy()2339 s._regrid_specchan(width)2340 2341 s._add_history("regrid_channel", varlist)2342 2343 # if plot:2344 # from asap.asapplotter import new_asaplot2345 # theplot = new_asaplot(rcParams['plotter.gui'])2346 # theplot.set_panels()2347 # ylab=s._get_ordinate_label()2348 # #theplot.palette(0,["#777777","red"])2349 # for r in xrange(s.nrow()):2350 # xsm=s._getabcissa(r)2351 # ysm=s._getspectrum(r)2352 # xorg=orgscan._getabcissa(r)2353 # yorg=orgscan._getspectrum(r)2354 # theplot.clear()2355 # theplot.hold()2356 # theplot.set_axes('ylabel',ylab)2357 # theplot.set_axes('xlabel',s._getabcissalabel(r))2358 # theplot.set_axes('title',s._getsourcename(r))2359 # theplot.set_line(label='Original',color="#777777")2360 # theplot.plot(xorg,yorg)2361 # theplot.set_line(label='Smoothed',color="red")2362 # theplot.plot(xsm,ysm)2363 # ### Ugly part for legend2364 # for i in [0,1]:2365 # theplot.subplots[0]['lines'].append(2366 # [theplot.subplots[0]['axes'].lines[i]]2367 # )2368 # theplot.release()2369 # ### Ugly part for legend2370 # theplot.subplots[0]['lines']=[]2371 # res = raw_input("Accept smoothing ([y]/n): ")2372 # if res.upper() == 'N':2373 # s._setspectrum(yorg, r)2374 # theplot.quit()2375 # del theplot2376 # del orgscan2377 2378 if insitu: self._assign(s)2379 else: return s2380 2381 @asaplog_post_dec2382 2276 def _parse_wn(self, wn): 2383 2277 if isinstance(wn, list) or isinstance(wn, tuple): … … 2403 2297 val = int(wn[:-1]) 2404 2298 res = [i for i in xrange(val)] 2405 elif wn[:2] == '>=' or wn[:2] == '=>': # cases '>=a','=>a' : return [a,-999], which is 2406 # then interpreted in C++ 2407 # side as [a,a+1,...,a_nyq] 2408 # (CAS-3759) 2299 elif wn[:2] == '>=' or wn[:2] == '=>': # cases '>=a','=>a' : return [a,a+1,...,a_nyq] 2409 2300 val = int(wn[2:]) 2410 res = [val, -999] 2411 #res = [i for i in xrange(val, self.nchan()/2+1)] 2412 elif wn[-2:] == '<=' or wn[-2:] == '=<': # cases 'a<=','a=<' : return [a,-999], which is 2413 # then interpreted in C++ 2414 # side as [a,a+1,...,a_nyq] 2415 # (CAS-3759) 2301 res = [i for i in xrange(val, self.nchan()/2+1)] 2302 elif wn[-2:] == '<=' or wn[-2:] == '=<': # cases 'a<=','a=<' : return [a,a+1,...,a_nyq] 2416 2303 val = int(wn[:-2]) 2417 res = [val, -999] 2418 #res = [i for i in xrange(val, self.nchan()/2+1)] 2419 elif wn[0] == '>': # case '>a' : return [a+1,-999], which is 2420 # then interpreted in C++ 2421 # side as [a+1,a+2,...,a_nyq] 2422 # (CAS-3759) 2304 res = [i for i in xrange(val, self.nchan()/2+1)] 2305 elif wn[0] == '>': # case '>a' : return [a+1,a+2,...,a_nyq] 2423 2306 val = int(wn[1:])+1 2424 res = [val, -999] 2425 #res = [i for i in xrange(val, self.nchan()/2+1)] 2426 elif wn[-1] == '<': # case 'a<' : return [a+1,-999], which is 2427 # then interpreted in C++ 2428 # side as [a+1,a+2,...,a_nyq] 2429 # (CAS-3759) 2307 res = [i for i in xrange(val, self.nchan()/2+1)] 2308 elif wn[-1] == '<': # case 'a<' : return [a+1,a+2,...,a_nyq] 2430 2309 val = int(wn[:-1])+1 2431 res = [val, -999] 2432 #res = [i for i in xrange(val, self.nchan()/2+1)] 2310 res = [i for i in xrange(val, self.nchan()/2+1)] 2433 2311 2434 2312 return res … … 2479 2357 number corresponding to the Nyquist 2480 2358 frequency for the case of FFT). 2481 default is [ 0].2359 default is []. 2482 2360 rejwn: the wave numbers NOT to be used for fitting. 2483 2361 can be set just as addwn but has higher priority: … … 2523 2401 workscan = self.copy() 2524 2402 2525 #if mask is None: mask = [True for i in xrange(workscan.nchan())] 2526 if mask is None: mask = [] 2403 if mask is None: mask = [True for i in xrange(workscan.nchan())] 2527 2404 if applyfft is None: applyfft = True 2528 2405 if fftmethod is None: fftmethod = 'fft' 2529 2406 if fftthresh is None: fftthresh = 3.0 2530 if addwn is None: addwn = [ 0]2407 if addwn is None: addwn = [] 2531 2408 if rejwn is None: rejwn = [] 2532 2409 if clipthresh is None: clipthresh = 3.0 … … 2603 2480 number corresponding to the Nyquist 2604 2481 frequency for the case of FFT). 2605 default is [ 0].2482 default is []. 2606 2483 rejwn: the wave numbers NOT to be used for fitting. 2607 2484 can be set just as addwn but has higher priority: … … 2664 2541 workscan = self.copy() 2665 2542 2666 #if mask is None: mask = [True for i in xrange(workscan.nchan())] 2667 if mask is None: mask = [] 2543 if mask is None: mask = [True for i in xrange(workscan.nchan())] 2668 2544 if applyfft is None: applyfft = True 2669 2545 if fftmethod is None: fftmethod = 'fft' 2670 2546 if fftthresh is None: fftthresh = 3.0 2671 if addwn is None: addwn = [ 0]2547 if addwn is None: addwn = [] 2672 2548 if rejwn is None: rejwn = [] 2673 2549 if clipthresh is None: clipthresh = 3.0 … … 2760 2636 workscan = self.copy() 2761 2637 2762 #if mask is None: mask = [True for i in xrange(workscan.nchan())] 2763 if mask is None: mask = [] 2638 if mask is None: mask = [True for i in xrange(workscan.nchan())] 2764 2639 if npiece is None: npiece = 2 2765 2640 if clipthresh is None: clipthresh = 3.0 … … 2863 2738 workscan = self.copy() 2864 2739 2865 #if mask is None: mask = [True for i in xrange(workscan.nchan())] 2866 if mask is None: mask = [] 2740 if mask is None: mask = [True for i in xrange(workscan.nchan())] 2867 2741 if npiece is None: npiece = 2 2868 2742 if clipthresh is None: clipthresh = 3.0 … … 2940 2814 workscan = self.copy() 2941 2815 2942 #if mask is None: mask = [True for i in \ 2943 # xrange(workscan.nchan())] 2944 if mask is None: mask = [] 2816 if mask is None: mask = [True for i in \ 2817 xrange(workscan.nchan())] 2945 2818 if order is None: order = 0 2946 2819 if plot is None: plot = False … … 3080 2953 workscan = self.copy() 3081 2954 3082 #if mask is None: mask = [True for i in xrange(workscan.nchan())] 3083 if mask is None: mask = [] 2955 if mask is None: mask = [True for i in xrange(workscan.nchan())] 3084 2956 if order is None: order = 0 3085 2957 if edge is None: edge = (0, 0)
Note:
See TracChangeset
for help on using the changeset viewer.
