Changeset 2269
- Timestamp:
- 08/11/11 12:19:57 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/scantable.py
r2189 r2269 2173 2173 2174 2174 @asaplog_post_dec 2175 def smooth(self, kernel="hanning", width=5.0, order=2, plot=False, insitu=None): 2175 def smooth(self, kernel="hanning", width=5.0, order=2, plot=False, 2176 insitu=None): 2176 2177 """\ 2177 2178 Smooth the spectrum by the specified kernel (conserving flux). … … 2291 2292 2292 2293 @asaplog_post_dec 2293 def sinusoid_baseline(self, insitu=None, mask=None, applyfft=None, fftmethod=None, fftthresh=None, 2294 addwn=None, rejwn=None, clipthresh=None, clipniter=None, plot=None, 2295 getresidual=None, showprogress=None, minnrow=None, outlog=None, blfile=None): 2294 def sinusoid_baseline(self, insitu=None, mask=None, applyfft=None, 2295 fftmethod=None, fftthresh=None, 2296 addwn=None, rejwn=None, clipthresh=None, 2297 clipniter=None, plot=None, 2298 getresidual=None, showprogress=None, 2299 minnrow=None, outlog=None, blfile=None): 2296 2300 """\ 2297 2301 Return a scan which has been baselined (all rows) with sinusoidal functions. … … 2682 2686 2683 2687 #CURRENTLY, PLOT=true UNAVAILABLE UNTIL cubic spline fitting is implemented as a fitter method. 2684 workscan._auto_cspline_baseline(mask, npiece, clipthresh, clipniter, normalise_edge_param(edge), threshold, chan_avg_limit, getresidual, pack_progress_params(showprogress, minnrow), outlog, blfile) 2688 workscan._auto_cspline_baseline(mask, npiece, clipthresh, 2689 clipniter, 2690 normalise_edge_param(edge), 2691 threshold, 2692 chan_avg_limit, getresidual, 2693 pack_progress_params(showprogress, 2694 minnrow), 2695 outlog, blfile) 2685 2696 workscan._add_history("auto_cspline_baseline", varlist) 2686 2697 … … 2694 2705 2695 2706 @asaplog_post_dec 2696 def poly_baseline(self, insitu=None, mask=None, order=None, plot=None, getresidual=None, 2697 showprogress=None, minnrow=None, outlog=None, blfile=None): 2707 def poly_baseline(self, mask=None, order=None, insitu=None, plot=None, 2708 getresidual=None, showprogress=None, minnrow=None, 2709 outlog=None, blfile=None): 2698 2710 """\ 2699 2711 Return a scan which has been baselined (all rows) by a polynomial. … … 2728 2740 varlist = vars() 2729 2741 2730 if insitu is None: insitu = rcParams["insitu"] 2742 if insitu is None: 2743 insitu = rcParams["insitu"] 2731 2744 if insitu: 2732 2745 workscan = self … … 2734 2747 workscan = self.copy() 2735 2748 2736 if mask is None: mask = [True for i in xrange(workscan.nchan())] 2749 if mask is None: mask = [True for i in \ 2750 xrange(workscan.nchan())] 2737 2751 if order is None: order = 0 2738 2752 if plot is None: plot = False … … 2744 2758 2745 2759 if plot: 2746 outblfile = (blfile != "") and os.path.exists(os.path.expanduser(os.path.expandvars(blfile))) 2747 if outblfile: blf = open(blfile, "a") 2760 outblfile = (blfile != "") and \ 2761 os.path.exists(os.path.expanduser(os.path.expandvars(blfile))) 2762 if outblfile: 2763 blf = open(blfile, "a") 2748 2764 2749 2765 f = fitter() … … 2769 2785 masklist = workscan.get_masklist(f.mask, row=r, silent=True) 2770 2786 #workscan._append_blinfo(blpars, masklist, f.mask) 2771 workscan._setspectrum((f.fitter.getresidual() if getresidual else f.fitter.getfit()), r) 2787 workscan._setspectrum((f.fitter.getresidual() 2788 if getresidual else f.fitter.getfit()), r) 2772 2789 2773 2790 if outblfile: 2774 2791 rms = workscan.get_rms(f.mask, r) 2775 dataout = workscan.format_blparams_row(blpars["params"], blpars["fixed"], rms, str(masklist), r, True) 2792 dataout = \ 2793 workscan.format_blparams_row(blpars["params"], 2794 blpars["fixed"], 2795 rms, str(masklist), 2796 r, True) 2776 2797 blf.write(dataout) 2777 2798 … … 2781 2802 if outblfile: blf.close() 2782 2803 else: 2783 workscan._poly_baseline(mask, order, getresidual, pack_progress_params(showprogress, minnrow), outlog, blfile) 2804 workscan._poly_baseline(mask, order, getresidual, 2805 pack_progress_params(showprogress, 2806 minnrow), 2807 outlog, blfile) 2784 2808 2785 2809 workscan._add_history("poly_baseline", varlist) … … 2794 2818 2795 2819 @asaplog_post_dec 2796 def auto_poly_baseline(self, insitu=None, mask=None, order=None, edge=None, threshold=None, chan_avg_limit=None, 2797 plot=None, getresidual=None, showprogress=None, minnrow=None, outlog=None, blfile=None): 2820 def auto_poly_baseline(self, mask=None, order=None, edge=None, 2821 threshold=None, chan_avg_limit=None, 2822 plot=None, insitu=None, 2823 getresidual=None, showprogress=None, 2824 minnrow=None, outlog=None, blfile=None): 2798 2825 """\ 2799 2826 Return a scan which has been baselined (all rows) by a polynomial. … … 2849 2876 varlist = vars() 2850 2877 2851 if insitu is None: insitu = rcParams['insitu'] 2878 if insitu is None: 2879 insitu = rcParams['insitu'] 2852 2880 if insitu: 2853 2881 workscan = self … … 2870 2898 2871 2899 if plot: 2872 outblfile = (blfile != "") and os.path.exists(os.path.expanduser(os.path.expandvars(blfile))) 2900 outblfile = (blfile != "") and \ 2901 os.path.exists(os.path.expanduser(os.path.expandvars(blfile))) 2873 2902 if outblfile: blf = open(blfile, "a") 2874 2903 2875 2904 from asap.asaplinefind import linefinder 2876 2905 fl = linefinder() 2877 fl.set_options(threshold=threshold, avg_limit=chan_avg_limit)2906 fl.set_options(threshold=threshold, avg_limit=chan_avg_limit) 2878 2907 fl.set_scan(workscan) 2879 2908 … … 2886 2915 for r in rows: 2887 2916 idx = 2*workscan.getif(r) 2888 fl.find_lines(r, mask_and(mask, workscan._getmask(r)), edge[idx:idx+2]) # (CAS-1434) 2917 fl.find_lines(r, mask_and(mask, workscan._getmask(r)), 2918 edge[idx:idx+2]) # (CAS-1434) 2889 2919 2890 2920 f.x = workscan._getabcissa(r) … … 2903 2933 masklist = workscan.get_masklist(f.mask, row=r, silent=True) 2904 2934 #workscan._append_blinfo(blpars, masklist, f.mask) 2905 workscan._setspectrum((f.fitter.getresidual() if getresidual else f.fitter.getfit()), r) 2935 workscan._setspectrum((f.fitter.getresidual() \ 2936 if getresidual else f.fitter.getfit()), r) 2906 2937 2907 2938 if outblfile: 2908 2939 rms = workscan.get_rms(f.mask, r) 2909 dataout = workscan.format_blparams_row(blpars["params"], blpars["fixed"], rms, str(masklist), r, True) 2940 dataout = \ 2941 workscan.format_blparams_row(blpars["params"], 2942 blpars["fixed"], 2943 rms, str(masklist), 2944 r, True) 2910 2945 blf.write(dataout) 2911 2946 … … 2915 2950 if outblfile: blf.close() 2916 2951 else: 2917 workscan._auto_poly_baseline(mask, order, edge, threshold, chan_avg_limit, getresidual, pack_progress_params(showprogress, minnrow), outlog, blfile) 2952 workscan._auto_poly_baseline(mask, order, edge, threshold, 2953 chan_avg_limit, getresidual, 2954 pack_progress_params(showprogress, 2955 minnrow), 2956 outlog, blfile) 2918 2957 2919 2958 workscan._add_history("auto_poly_baseline", varlist)
Note:
See TracChangeset
for help on using the changeset viewer.