Changeset 931 for trunk/python
- Timestamp:
- 03/24/06 13:45:17 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/scantable.py
r919 r931 646 646 647 647 648 # def set_restfreqs(self, freqs=None, unit='Hz', lines=None, source=None, 649 # theif=None): 650 # """ 651 # Select the restfrequency for the specified source and IF OR 652 # replace for all IFs. If the 'freqs' argument holds a scalar, 653 # then that rest frequency will be applied to the selected 654 # data (and added to the list of available rest frequencies). 655 # In this way, you can set a rest frequency for each 656 # source and IF combination. If the 'freqs' argument holds 657 # a vector, then it MUST be of length the number of IFs 658 # (and the available restfrequencies will be replaced by 659 # this vector). In this case, *all* data ('source' and 660 # 'theif' are ignored) have the restfrequency set per IF according 661 # to the corresponding value you give in the 'freqs' vector. 662 # E.g. 'freqs=[1e9,2e9]' would mean IF 0 gets restfreq 1e9 and 663 # IF 1 gets restfreq 2e9. 664 # 665 # You can also specify the frequencies via known line names 666 # in the argument 'lines'. Use 'freqs' or 'lines'. 'freqs' 667 # takes precedence. See the list of known names via function 668 # scantable.lines() 669 # Parameters: 670 # freqs: list of rest frequencies 671 # unit: unit for rest frequency (default 'Hz') 672 # lines: list of known spectral lines names (alternative to freqs). 673 # See possible list via scantable.lines() 674 # source: Source name (blank means all) 675 # theif: IF (-1 means all) 676 # Example: 677 # scan.set_restfreqs(freqs=1.4e9, source='NGC253', theif=2) 678 # scan.set_restfreqs(freqs=[1.4e9,1.67e9]) 679 # """ 680 # varlist = vars() 681 # if source is None: 682 # source = "" 683 # if theif is None: 684 # theif = -1 685 # t = type(freqs) 686 # if t is int or t is float: 687 # freqs = [freqs] 688 # if freqs is None: 689 # freqs = [] 690 # t = type(lines) 691 # if t is str: 692 # lines = [lines] 693 # if lines is None: 694 # lines = [] 695 # self._setrestfreqs(freqs, unit, lines, source, theif) 696 # self._add_history("set_restfreqs", varlist) 697 # 648 def set_restfreqs(self, freqs=None, unit='Hz'): 649 """ 650 Set or replace the restfrequency specified and 651 If the 'freqs' argument holds a scalar, 652 then that rest frequency will be applied to all the selected 653 data. If the 'freqs' argument holds 654 a vector, then it MUST be of equal or smaller length than 655 the number of IFs (and the available restfrequencies will be 656 replaced by this vector). In this case, *all* data have 657 the restfrequency set per IF according 658 to the corresponding value you give in the 'freqs' vector. 659 E.g. 'freqs=[1e9,2e9]' would mean IF 0 gets restfreq 1e9 and 660 IF 1 gets restfreq 2e9. 661 You can also specify the frequencies via known line names 662 from the built-in Lovas table. 663 Parameters: 664 freqs: list of rest frequency values or string idenitfiers 665 unit: unit for rest frequency (default 'Hz') 666 667 Example: 668 # set the given restfrequency for the whole table 669 scan.set_restfreqs(freqs=1.4e9) 670 # If thee number of IFs in the data is >= 2 the IF0 gets the first 671 # value IF1 the second... 672 scan.set_restfreqs(freqs=[1.4e9,1.67e9]) 673 #set the given restfrequency for the whole table (by name) 674 scan.set_restfreqs(freqs="OH1667") 675 676 Note: 677 To do more sophisticate Restfrequency setting, e.g. on a 678 source and IF basis, use scantable.set_selection() before using 679 this function. 680 # provide your scantable is call scan 681 selection = selector() 682 selection.set_name("ORION*") 683 selection.set_ifs([1]) 684 scan.set_selection(selection) 685 scan.set_restfreqs(freqs=86.6e9) 686 687 """ 688 varlist = vars() 689 690 t = type(freqs) 691 if isinstance(freqs, int) or isinstance(freqs,float): 692 self._setrestfreqs(freqs, unit) 693 elif isinstance(freqs, list) or isinstance(freqs,tuple): 694 if isinstance(freqs[-1], int) or isinstance(freqs[-1],float): 695 from asap._asap import selector 696 sel = selector() 697 savesel = self._getselection() 698 for i in xrange(len(freqs)): 699 sel._setifs([i]) 700 self._setselection(sel) 701 self._setrestfreqs(freqs[i], unit) 702 self._setselection(savesel) 703 elif isinstance(freqs[-1], str): 704 # not yet implemented 705 pass 706 else: 707 return 708 self._add_history("set_restfreqs", varlist) 709 698 710 699 711 … … 726 738 # 727 739 728 def average_time(self, mask=None, scanav=False, weight='tint' ):740 def average_time(self, mask=None, scanav=False, weight='tint', align=False): 729 741 """ 730 742 Return the (time) average of a scan, or apply it 'insitu'. … … 742 754 (integration time weighted) or 'tintsys' (Tint/Tsys**2). 743 755 The default is 'tint' 756 align: align the spectra in velocity before averaging. It takes 757 the time of the first spectrum as reference time. 744 758 Example: 745 759 # time average the scantable without using a mask … … 753 767 else: 754 768 scanav = "NONE" 755 s = scantable(self._math._average((self,), mask, weight, scanav, False)) 769 s = scantable(self._math._average((self,), mask, weight.upper(), 770 scanav, align)) 756 771 s._add_history("average_time",varlist) 757 772 print_log() … … 842 857 else: return s 843 858 844 def freq_align(self, reftime=None, method='cubic', perif=False, 845 insitu=None): 859 def freq_align(self, reftime=None, method='cubic', insitu=None): 846 860 """ 847 861 Return a scan where all rows have been aligned in frequency/velocity. … … 854 868 Choose from "nearest", "linear", "cubic" (default) 855 869 and "spline" 856 perif: Generate aligners per freqID (no doppler tracking) or857 per IF (scan-based doppler tracking)858 870 insitu: if False a new scantable is returned. 859 871 Otherwise, the scaling is done in-situ 860 872 The default is taken from .asaprc (False) 861 873 """ 862 print "Not yet implemented" 863 return 864 if insitu is None: insitu = rcParams['insitu'] 874 if insitu is None: insitu = rcParams["insitu"] 865 875 self._math._setinsitu(insitu) 866 876 varlist = vars() 867 if reftime is None: reftime = '' 868 perfreqid = not perif 869 s = scantable(self._math._freqalign(self, reftime, method, perfreqid)) 877 if reftime is None: reftime = "" 878 s = scantable(self._math._freq_align(self, reftime, method)) 870 879 s._add_history("freq_align", varlist) 871 880 print_log() … … 1020 1029 else: return s 1021 1030 1022 def auto_poly_baseline(self, mask= None, edge=(0,0), order=0,1031 def auto_poly_baseline(self, mask=[], edge=(0,0), order=0, 1023 1032 threshold=3, insitu=None): 1024 1033 """
Note:
See TracChangeset
for help on using the changeset viewer.