Changeset 2277
- Timestamp:
- 08/17/11 10:58:44 (13 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cmake/standalone.cmake
r2276 r2277 8 8 # 9 9 # always use libcasacore.so 10 set( USE_LIBCASACORE O FF)10 set( USE_LIBCASACORE ON ) 11 11 set( CASACORE_PATHS "/usr/local;/usr" ) 12 12 … … 17 17 set( WCSLIB_PATHS "/usr/local;/usr" ) 18 18 19 find_package (RPFITS REQUIRED)20 19 21 20 # -
trunk/python/asapplotter.py
r2276 r2277 914 914 n = min(n,self._rows*self._cols) 915 915 self._plotter.set_panels(rows=self._rows,cols=self._cols, 916 nplots=n,margin=self._margins, 917 ganged=ganged) 916 nplots=n,margin=self._margins,ganged=ganged) 918 917 else: 919 918 n = min(n,maxpanel) 920 self._plotter.set_panels(rows=n,cols=0,nplots=n, 921 margin=self._margins,ganged=ganged) 919 self._plotter.set_panels(rows=n,cols=0,nplots=n,margin=self._margins,ganged=ganged) 922 920 else: 923 921 self._plotter.set_panels(margin=self._margins) … … 974 972 975 973 #if (b > b0 or newpanel) and stackcount < nstack: 976 if stackcount < nstack and (newpanel or rowstack 977 or (a == a0 and b > b0)): 974 if stackcount < nstack and (newpanel or rowstack or (a == a0 and b > b0)): 978 975 y = [] 979 976 if len(polmodes): … … 983 980 # flag application 984 981 mr = scan._getflagrow(r) 985 #mr = False986 982 from numpy import ma, array 987 983 if mr: … … 991 987 from numpy import logical_not, logical_and 992 988 if self._maskselection and len(self._usermask) == len(m): 993 if d[self._stacking](r) in \ 994 self._maskselection[self._stacking]: 989 if d[self._stacking](r) in self._maskselection[self._stacking]: 995 990 m = logical_and(m, self._usermask) 996 y = ma.masked_array(y,mask=logical_not(array(m, 997 copy=False))) 991 y = ma.masked_array(y,mask=logical_not(array(m,copy=False))) 998 992 999 993 x = array(scan._getabcissa(r)) -
trunk/python/scantable.py
r2276 r2277 88 88 * an integer - will be used for both sides of spectra of all IFs. 89 89 e.g. 10 is converted to [10,10] 90 * an empty list/tuple [] - converted to [0, 0] and used for all 91 IFs. 90 * an empty list/tuple [] - converted to [0, 0] and used for all IFs. 92 91 * a list/tuple containing an integer - same as the above case. 93 92 e.g. [10] is converted to [10,10] … … 96 95 * a list/tuple of lists/tuples containing TWO integers - 97 96 each element of edge will be used for each IF. 98 e.g. [[5,10],[15,20]] - [5,10] for IF[0] and [15,20] for 99 IF[1]. 100 If an element contains the same integer values, the input 101 'edge' parameter can be given in a simpler shape in the 102 following cases: 97 e.g. [[5,10],[15,20]] - [5,10] for IF[0] and [15,20] for IF[1]. 98 99 If an element contains the same integer values, the input 'edge' 100 parameter can be given in a simpler shape in the following cases: 103 101 ** when len(edge)!=2 104 any elements containing the same values can be 105 replaced to single integers. 106 e.g. [[15,15]] can be simplified to [15] 107 (or [15,15] or 15 also). 108 e.g. [[1,1],[2,2],[3,3]] can be simplified to 109 [1,2,3]. 102 any elements containing the same values can be replaced 103 to single integers. 104 e.g. [[15,15]] can be simplified to [15] (or [15,15] or 15 also). 105 e.g. [[1,1],[2,2],[3,3]] can be simplified to [1,2,3]. 110 106 ** when len(edge)=2 111 107 care is needed for this case: ONLY ONE of the 112 108 elements can be a single integer, 113 109 e.g. [[5,5],[10,10]] can be simplified to [5,[10,10]] 114 or [[5,5],10], but can NOT be simplified to 115 [5,10]. 110 or [[5,5],10], but can NOT be simplified to [5,10]. 116 111 when [5,10] given, it is interpreted as 117 [[5,10],[5,10],[5,10],...] instead, as shown 118 before. 112 [[5,10],[5,10],[5,10],...] instead, as shown before. 119 113 """ 120 114 from asap import _is_sequence_or_number as _is_valid … … 187 181 #def __init__(self, filename, average=None, unit=None, getpt=None, 188 182 # antenna=None, parallactify=None): 189 def __init__(self, filename, average=None, unit=None, parallactify=None, 190 **args): 183 def __init__(self, filename, average=None, unit=None, parallactify=None, **args): 191 184 """\ 192 185 Create a scantable from a saved one or make a reference … … 215 208 216 209 antenna: for MeasurementSet input data only: 217 Antenna selection. integer (id) or string (name 218 or id). 210 Antenna selection. integer (id) or string (name or id). 219 211 220 212 parallactify: Indicate that the data had been parallatified. Default … … 310 302 * 'ASCII' (saves as ascii text file) 311 303 * 'MS2' (saves as an casacore MeasurementSet V2) 312 * 'FITS' (save as image FITS - not readable by 313 CLASS) 304 * 'FITS' (save as image FITS - not readable by class) 314 305 * 'CLASS' (save as FITS readable by CLASS) 315 306 … … 379 370 from asap import unique 380 371 if not _is_valid(scanid): 381 raise RuntimeError( 'Please specify a scanno to drop from the '\ 382 'scantable' ) 372 raise RuntimeError( 'Please specify a scanno to drop from the scantable' ) 383 373 scanid = _to_list(scanid) 384 374 allscans = unique([ self.getscan(i) for i in range(self.nrow())]) … … 862 852 asdatetime: return values as datetime objects rather than strings 863 853 864 prec: number of digits shown. Default -1 to automatic 865 calculation. 854 prec: number of digits shown. Default -1 to automatic calculation. 866 855 Note this number is equals to the digits of MVTime, 867 856 i.e., 0<prec<3: dates with hh:: only, … … 1156 1145 1157 1146 rows: list of row numbers to be flagged. Default is no row 1158 (must be explicitly specified to execute row-based 1159 flagging). 1147 (must be explicitly specified to execute row-based flagging). 1160 1148 1161 1149 unflag: if True, unflag the data. … … 1177 1165 dthres: lower threshold 1178 1166 1179 clipoutside: True for flagging data outside the range 1180 [dthres:uthres]. 1167 clipoutside: True for flagging data outside the range [dthres:uthres]. 1181 1168 False for flagging data inside the range. 1182 1169 … … 2268 2255 return [ wn ] 2269 2256 elif isinstance(wn, str): 2270 if '-' in wn: 2271 # case 'a-b' : return [a,a+1,...,b-1,b] 2257 if '-' in wn: # case 'a-b' : return [a,a+1,...,b-1,b] 2272 2258 val = wn.split('-') 2273 2259 val = [int(val[0]), int(val[1])] 2274 2260 val.sort() 2275 2261 res = [i for i in xrange(val[0], val[1]+1)] 2276 elif wn[:2] == '<=' or wn[:2] == '=<': 2277 # cases '<=a','=<a' : return [0,1,...,a-1,a] 2262 elif wn[:2] == '<=' or wn[:2] == '=<': # cases '<=a','=<a' : return [0,1,...,a-1,a] 2278 2263 val = int(wn[2:])+1 2279 2264 res = [i for i in xrange(val)] 2280 elif wn[-2:] == '>=' or wn[-2:] == '=>': 2281 # cases 'a>=','a=>' : return [0,1,...,a-1,a] 2265 elif wn[-2:] == '>=' or wn[-2:] == '=>': # cases 'a>=','a=>' : return [0,1,...,a-1,a] 2282 2266 val = int(wn[:-2])+1 2283 2267 res = [i for i in xrange(val)] 2284 elif wn[0] == '<': 2285 # case '<a' : return [0,1,...,a-2,a-1] 2268 elif wn[0] == '<': # case '<a' : return [0,1,...,a-2,a-1] 2286 2269 val = int(wn[1:]) 2287 2270 res = [i for i in xrange(val)] 2288 elif wn[-1] == '>': 2289 # case 'a>' : return [0,1,...,a-2,a-1] 2271 elif wn[-1] == '>': # case 'a>' : return [0,1,...,a-2,a-1] 2290 2272 val = int(wn[:-1]) 2291 2273 res = [i for i in xrange(val)] 2292 elif wn[:2] == '>=' or wn[:2] == '=>': 2293 # cases '>=a','=>a' : return [a,a+1,...,a_nyq] 2274 elif wn[:2] == '>=' or wn[:2] == '=>': # cases '>=a','=>a' : return [a,a+1,...,a_nyq] 2294 2275 val = int(wn[2:]) 2295 2276 res = [i for i in xrange(val, self.nchan()/2+1)] 2296 elif wn[-2:] == '<=' or wn[-2:] == '=<': 2297 # cases 'a<=','a=<' : return [a,a+1,...,a_nyq] 2277 elif wn[-2:] == '<=' or wn[-2:] == '=<': # cases 'a<=','a=<' : return [a,a+1,...,a_nyq] 2298 2278 val = int(wn[:-2]) 2299 2279 res = [i for i in xrange(val, self.nchan()/2+1)] 2300 elif wn[0] == '>': 2301 # case '>a' : return [a+1,a+2,...,a_nyq] 2280 elif wn[0] == '>': # case '>a' : return [a+1,a+2,...,a_nyq] 2302 2281 val = int(wn[1:])+1 2303 2282 res = [i for i in xrange(val, self.nchan()/2+1)] 2304 elif wn[-1] == '<': 2305 # case 'a<' : return [a+1,a+2,...,a_nyq] 2283 elif wn[-1] == '<': # case 'a<' : return [a+1,a+2,...,a_nyq] 2306 2284 val = int(wn[:-1])+1 2307 2285 res = [i for i in xrange(val, self.nchan()/2+1)] … … 2314 2292 2315 2293 @asaplog_post_dec 2316 def sinusoid_baseline(self, mask=None, insitu=None, applyfft=None,2294 def sinusoid_baseline(self, insitu=None, mask=None, applyfft=None, 2317 2295 fftmethod=None, fftthresh=None, 2318 2296 addwn=None, rejwn=None, clipthresh=None, … … 2394 2372 workscan = self.copy() 2395 2373 2396 if mask is None: mask = \ 2397 [True for i in xrange(workscan.nchan())] 2374 if mask is None: mask = [True for i in xrange(workscan.nchan())] 2398 2375 if applyfft is None: applyfft = True 2399 2376 if fftmethod is None: fftmethod = 'fft' … … 2411 2388 2412 2389 #CURRENTLY, PLOT=true is UNAVAILABLE UNTIL sinusoidal fitting is implemented as a fitter method. 2413 workscan._sinusoid_baseline(mask, applyfft, fftmethod.lower(), 2414 str(fftthresh).lower(), 2415 workscan._parse_wn(addwn), 2416 workscan._parse_wn(rejwn), clipthresh, 2417 clipniter, getresidual, 2418 pack_progress_params(showprogress, 2419 minnrow), 2420 outlog, blfile) 2390 workscan._sinusoid_baseline(mask, applyfft, fftmethod.lower(), str(fftthresh).lower(), workscan._parse_wn(addwn), workscan._parse_wn(rejwn), clipthresh, clipniter, getresidual, pack_progress_params(showprogress, minnrow), outlog, blfile) 2421 2391 workscan._add_history('sinusoid_baseline', varlist) 2422 2392 … … 2431 2401 2432 2402 @asaplog_post_dec 2433 def auto_sinusoid_baseline(self, mask=None, insitu=None, applyfft=None, 2434 fftmethod=None, fftthresh=None, 2435 addwn=None, rejwn=None, clipthresh=None, 2436 clipniter=None, edge=None, threshold=None, 2437 chan_avg_limit=None, plot=None, 2438 getresidual=None, showprogress=None, 2439 minnrow=None, 2403 def auto_sinusoid_baseline(self, insitu=None, mask=None, applyfft=None, fftmethod=None, fftthresh=None, 2404 addwn=None, rejwn=None, clipthresh=None, clipniter=None, edge=None, threshold=None, 2405 chan_avg_limit=None, plot=None, getresidual=None, showprogress=None, minnrow=None, 2440 2406 outlog=None, blfile=None): 2441 2407 """\ 2442 Return a scan which has been baselined (all rows) with sinusoidal 2443 functions. 2408 Return a scan which has been baselined (all rows) with sinusoidal functions. 2444 2409 Spectral lines are detected first using linefinder and masked out 2445 2410 to avoid them affecting the baseline solution. … … 2462 2427 given a float value, the unit is set to sigma. 2463 2428 for string values, allowed formats include: 2464 'xsigma' or 'x' (= x-sigma level. e.g., 2465 '3sigma'), or 2429 'xsigma' or 'x' (= x-sigma level. e.g., '3sigma'), or 2466 2430 'topx' (= the x strongest ones, e.g. 'top5'). 2467 2431 default is 3.0 (unit: sigma). … … 2481 2445 and rejwn will NOT be used. default is []. 2482 2446 clipthresh: Clipping threshold. (default is 3.0, unit: sigma) 2483 clipniter: maximum number of iteration of 'clipthresh'-sigma 2484 clipping (default is 0) 2447 clipniter: maximum number of iteration of 'clipthresh'-sigma clipping (default is 0) 2485 2448 edge: an optional number of channel to drop at 2486 2449 the edge of spectrum. If only one value is … … 2536 2499 workscan = self.copy() 2537 2500 2538 if mask is None: mask = \ 2539 [True for i in xrange(workscan.nchan())] 2501 if mask is None: mask = [True for i in xrange(workscan.nchan())] 2540 2502 if applyfft is None: applyfft = True 2541 2503 if fftmethod is None: fftmethod = 'fft' … … 2555 2517 if blfile is None: blfile = '' 2556 2518 2557 #CURRENTLY, PLOT=true is UNAVAILABLE UNTIL sinusoidal fitting is 2558 # implemented as a fitter method. 2559 workscan._auto_sinusoid_baseline(mask, applyfft, fftmethod.lower(), 2560 str(fftthresh).lower(), 2561 workscan._parse_wn(addwn), 2562 workscan._parse_wn(rejwn), 2563 clipthresh, clipniter, 2564 normalise_edge_param(edge), 2565 threshold, chan_avg_limit, 2566 getresidual, 2567 pack_progress_params(showprogress, 2568 minnrow), 2569 outlog, blfile) 2519 #CURRENTLY, PLOT=true is UNAVAILABLE UNTIL sinusoidal fitting is implemented as a fitter method. 2520 workscan._auto_sinusoid_baseline(mask, applyfft, fftmethod.lower(), str(fftthresh).lower(), workscan._parse_wn(addwn), workscan._parse_wn(rejwn), clipthresh, clipniter, normalise_edge_param(edge), threshold, chan_avg_limit, getresidual, pack_progress_params(showprogress, minnrow), outlog, blfile) 2570 2521 workscan._add_history("auto_sinusoid_baseline", varlist) 2571 2522 … … 2579 2530 2580 2531 @asaplog_post_dec 2581 def cspline_baseline(self, mask=None, insitu=None, npiece=None, 2582 clipthresh=None, clipniter=None, plot=None, 2583 getresidual=None, showprogress=None, minnrow=None, 2584 outlog=None, blfile=None): 2585 """\ 2586 Return a scan which has been baselined (all rows) by cubic spline 2587 function (piecewise cubic polynomial). 2532 def cspline_baseline(self, insitu=None, mask=None, npiece=None, clipthresh=None, clipniter=None, 2533 plot=None, getresidual=None, showprogress=None, minnrow=None, outlog=None, blfile=None): 2534 """\ 2535 Return a scan which has been baselined (all rows) by cubic spline function (piecewise cubic polynomial). 2588 2536 Parameters: 2589 2537 insitu: If False a new scantable is returned. … … 2593 2541 npiece: Number of pieces. (default is 2) 2594 2542 clipthresh: Clipping threshold. (default is 3.0, unit: sigma) 2595 clipniter: maximum number of iteration of 'clipthresh'-sigma 2596 clipping (default is 0) 2543 clipniter: maximum number of iteration of 'clipthresh'-sigma clipping (default is 0) 2597 2544 plot: *** CURRENTLY UNAVAILABLE, ALWAYS FALSE *** 2598 2545 plot the fit and the residual. In this each … … 2612 2559 2613 2560 Example: 2614 # return a scan baselined by a cubic spline consisting of 2 2615 # pieces (i.e., 1 internal knot), 2561 # return a scan baselined by a cubic spline consisting of 2 pieces (i.e., 1 internal knot), 2616 2562 # also with 3-sigma clipping, iteration up to 4 times 2617 2563 bscan = scan.cspline_baseline(npiece=2,clipthresh=3.0,clipniter=4) … … 2631 2577 workscan = self.copy() 2632 2578 2633 if mask is None: mask = \ 2634 [True for i in xrange(workscan.nchan())] 2579 if mask is None: mask = [True for i in xrange(workscan.nchan())] 2635 2580 if npiece is None: npiece = 2 2636 2581 if clipthresh is None: clipthresh = 3.0 … … 2644 2589 2645 2590 #CURRENTLY, PLOT=true UNAVAILABLE UNTIL cubic spline fitting is implemented as a fitter method. 2646 workscan._cspline_baseline(mask, npiece, clipthresh, clipniter, 2647 getresidual, 2648 pack_progress_params(showprogress, 2649 minnrow), 2650 outlog, blfile) 2591 workscan._cspline_baseline(mask, npiece, clipthresh, clipniter, getresidual, pack_progress_params(showprogress, minnrow), outlog, blfile) 2651 2592 workscan._add_history("cspline_baseline", varlist) 2652 2593 … … 2660 2601 2661 2602 @asaplog_post_dec 2662 def auto_cspline_baseline(self, mask=None, insitu=None, npiece=None, 2663 clipthresh=None, clipniter=None, 2664 edge=None, threshold=None, chan_avg_limit=None, 2665 getresidual=None, plot=None, 2666 showprogress=None, minnrow=None, outlog=None, 2667 blfile=None): 2603 def auto_cspline_baseline(self, insitu=None, mask=None, npiece=None, clipthresh=None, clipniter=None, 2604 edge=None, threshold=None, chan_avg_limit=None, getresidual=None, plot=None, 2605 showprogress=None, minnrow=None, outlog=None, blfile=None): 2668 2606 """\ 2669 2607 Return a scan which has been baselined (all rows) by cubic spline … … 2679 2617 npiece: Number of pieces. (default is 2) 2680 2618 clipthresh: Clipping threshold. (default is 3.0, unit: sigma) 2681 clipniter: maximum number of iteration of 'clipthresh'-sigma 2682 clipping (default is 0) 2619 clipniter: maximum number of iteration of 'clipthresh'-sigma clipping (default is 0) 2683 2620 edge: an optional number of channel to drop at 2684 2621 the edge of spectrum. If only one value is … … 2734 2671 workscan = self.copy() 2735 2672 2736 if mask is None: mask = \ 2737 [True for i in xrange(workscan.nchan())] 2673 if mask is None: mask = [True for i in xrange(workscan.nchan())] 2738 2674 if npiece is None: npiece = 2 2739 2675 if clipthresh is None: clipthresh = 3.0 … … 2749 2685 if blfile is None: blfile = '' 2750 2686 2751 #CURRENTLY, PLOT=true UNAVAILABLE UNTIL cubic spline fitting is 2752 # implemented as a fitter method. 2687 #CURRENTLY, PLOT=true UNAVAILABLE UNTIL cubic spline fitting is implemented as a fitter method. 2753 2688 workscan._auto_cspline_baseline(mask, npiece, clipthresh, 2754 2689 clipniter, … … 2812 2747 workscan = self.copy() 2813 2748 2814 if mask is None: mask = \2815 [True for i inxrange(workscan.nchan())]2749 if mask is None: mask = [True for i in \ 2750 xrange(workscan.nchan())] 2816 2751 if order is None: order = 0 2817 2752 if plot is None: plot = False … … 2948 2883 workscan = self.copy() 2949 2884 2950 if mask is None: mask = \ 2951 [True for i in xrange(workscan.nchan())] 2885 if mask is None: mask = [True for i in xrange(workscan.nchan())] 2952 2886 if order is None: order = 0 2953 2887 if edge is None: edge = (0, 0) … … 3361 3295 s = scantable(self._math._unaryop(self, other, "SUB", False)) 3362 3296 elif isinstance(other, list) or isinstance(other, numpy.ndarray): 3363 if isinstance(other[0], list) or isinstance(other[0], 3364 numpy.ndarray): 3297 if isinstance(other[0], list) or isinstance(other[0], numpy.ndarray): 3365 3298 from asapmath import _array2dOp 3366 3299 s = _array2dOp( self.copy(), other, "SUB", False ) 3367 3300 else: 3368 s = scantable( self._math._arrayop( self.copy(), other, 3369 "SUB", False ) ) 3301 s = scantable( self._math._arrayop( self.copy(), other, "SUB", False ) ) 3370 3302 else: 3371 3303 raise TypeError("Other input is not a scantable or float value") … … 3385 3317 s = scantable(self._math._unaryop(self, other, "MUL", False)) 3386 3318 elif isinstance(other, list) or isinstance(other, numpy.ndarray): 3387 if isinstance(other[0], list) or isinstance(other[0], 3388 numpy.ndarray): 3319 if isinstance(other[0], list) or isinstance(other[0], numpy.ndarray): 3389 3320 from asapmath import _array2dOp 3390 3321 s = _array2dOp( self.copy(), other, "MUL", False ) 3391 3322 else: 3392 s = scantable( self._math._arrayop( self.copy(), other, 3393 "MUL", False ) ) 3323 s = scantable( self._math._arrayop( self.copy(), other, "MUL", False ) ) 3394 3324 else: 3395 3325 raise TypeError("Other input is not a scantable or float value") … … 3412 3342 s = scantable(self._math._unaryop(self, other, "DIV", False)) 3413 3343 elif isinstance(other, list) or isinstance(other, numpy.ndarray): 3414 if isinstance(other[0], list) or isinstance(other[0], 3415 numpy.ndarray): 3344 if isinstance(other[0], list) or isinstance(other[0], numpy.ndarray): 3416 3345 from asapmath import _array2dOp 3417 3346 s = _array2dOp( self.copy(), other, "DIV", False ) 3418 3347 else: 3419 s = scantable( self._math._arrayop( self.copy(), other, 3420 "DIV", False ) ) 3348 s = scantable( self._math._arrayop( self.copy(), other, "DIV", False ) ) 3421 3349 else: 3422 3350 raise TypeError("Other input is not a scantable or float value") -
trunk/src/Scantable.cpp
r2276 r2277 1817 1817 } 1818 1818 1819 void Scantable::polyBaseline(const std::vector<bool>& mask, int order, 1820 bool getResidual, const std::string& progressInfo, 1821 const bool outLogger, const std::string& blfile) 1819 void Scantable::polyBaseline(const std::vector<bool>& mask, int order, bool getResidual, const std::string& progressInfo, const bool outLogger, const std::string& blfile) 1822 1820 { 1823 1821 try { … … 1852 1850 fitBaseline(chanMask, whichrow, fitter); 1853 1851 setSpectrum((getResidual ? fitter.getResidual() : fitter.getFit()), whichrow); 1854 outputFittingResult(outLogger, outTextFile, chanMask, whichrow, 1855 coordInfo, hasSameNchan, ofs, "polyBaseline()", 1856 fitter); 1852 outputFittingResult(outLogger, outTextFile, chanMask, whichrow, coordInfo, hasSameNchan, ofs, "polyBaseline()", fitter); 1857 1853 showProgressOnTerminal(whichrow, nRow, showProgress, minNRow); 1858 1854 }
Note:
See TracChangeset
for help on using the changeset viewer.