Changeset 907 for trunk/python
- Timestamp:
- 03/20/06 15:17:06 (19 years ago)
- Location:
- trunk/python
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/asaplinefind.py
r889 r907 7 7 Example: 8 8 fl=linefinder() 9 fl.set_scan(sc ,edge=(50,))9 fl.set_scan(sc) 10 10 fl.set_options(threshold=3) 11 nlines=fl.find_lines( )11 nlines=fl.find_lines(edge=(50,0)) 12 12 if nlines!=0: 13 13 print "Found ",nlines," spectral lines" … … 65 65 return 66 66 67 def set_scan(self, scan , mask=None, edge=(0,0)):67 def set_scan(self, scan): 68 68 """ 69 69 Set the 'data' (scantable) to work with. 70 70 Parameters: 71 71 scan: a scantable 72 mask: an optional mask retreived from scantable 73 edge: an optional number of channel to drop at 74 the edge of spectrum. If only one value is 72 """ 73 if not scan: 74 raise RuntimeError, 'Please give a correct scan' 75 return 76 def find_lines(self,nRow=0,mask=None,edge=(0,0)): 77 """ 78 Search for spectral lines in the scan assigned in set_scan. 79 Parameters: 80 nRow: a row in the scantable to work with 81 mask: an optional mask (e.g. retreived from scantable) 82 edge: an optional number of channels to drop at 83 the edge of the spectrum. If only one value is 75 84 specified, the same number will be dropped from 76 85 both sides of the spectrum. Default is to keep 77 86 all channels 87 A number of lines found will be returned 78 88 """ 79 if not scan:80 raise RuntimeError, 'Please give a correct scan'81 if not scan._check_ifs():82 raise RuntimeError, 'IFs with different numbers of channels are not yet supported'83 84 89 if isinstance(edge,int): 85 90 edge=(edge,) … … 96 101 if mask is None: 97 102 from numarray import ones 98 self.finder.setscan(scan,ones(scan.nchan(-1)),tuple(edge))103 return self.finder.findlines(ones(scan.nchan(nRow)),list(edge),nRow) 99 104 else: 100 self.finder.setscan(scan,mask,tuple(edge)) 101 return 102 def find_lines(self,nRow=0): 103 """ 104 Search for spectral lines in the scan assigned in set_scan. 105 Current Beam/IF/Pol is used, Row is specified by parameter 106 A number of lines found will be returned 107 """ 108 return self.finder.findlines(nRow) 105 return self.finder.setscan(mask,list(edge),nRow) 109 106 def get_mask(self,invert=False): 110 107 """ -
trunk/python/scantable.py
r889 r907 1033 1033 specified, the same number will be dropped from 1034 1034 both sides of the spectrum. Default is to keep 1035 all channels 1035 all channels. Nested tuples represent individual 1036 edge selection for different IFs (a number of spectral 1037 channels can be different) 1036 1038 order: the order of the polynomial (default is 0) 1037 1039 threshold: the threshold used by line finder. It is better to … … 1051 1053 from asap import _is_sequence_or_number as _is_valid 1052 1054 1053 if not _is_valid(edge, int): 1055 # check whether edge is set up for each IF individually 1056 individualEdge = False; 1057 if len(edge)>1: 1058 if isinstance(edge[0],list) or isinstance(edge[0],tuple): 1059 individualEdge = True; 1060 1061 if not _is_valid(edge, int) and not individualEdge: 1054 1062 raise RuntimeError, "Parameter 'edge' has to be an integer or a \ 1055 pair of integers specified as a tuple" 1063 pair of integers specified as a tuple. Nested tuples are allowed \ 1064 to make individual selection for different IFs." 1065 1066 curedge = (0,0) 1067 if individualEdge: 1068 for edge_par in edge: 1069 if not _is_valid(edge,int): 1070 raise RuntimeError, "Each element of the 'edge' tuple has \ 1071 to be a pair of integers or an integer." 1072 else: 1073 curedge = edge; 1056 1074 1057 1075 # setup fitter … … 1067 1085 else: 1068 1086 workscan=self 1087 1088 fl.set_scan(workscan) 1069 1089 1070 1090 rows=range(workscan.nrow()) … … 1074 1094 msg = " Scan[%d] Beam[%d] IF[%d] Pol[%d] Cycle[%d]" % (workscan.getscan(r),workscan.getbeam(r),workscan.getif(r),workscan.getpol(r), workscan.getcycle(r)) 1075 1095 asaplog.push(msg, False) 1076 fl.set_scan(workscan, mask, edge) 1077 fl.find_lines(r) 1096 1097 # figure out edge parameter 1098 if individualEdge: 1099 if len(edge)>=workscan.getif(r): 1100 raise RuntimeError, "Number of edge elements appear to be less than the number of IFs" 1101 curedge = edge[workscan.getif(r)] 1102 1103 # setup line finder 1104 fl.find_lines(r,mask,curedge) 1078 1105 f.set_scan(workscan, fl.get_mask()) 1079 1106 f.x = workscan._getabcissa(r)
Note:
See TracChangeset
for help on using the changeset viewer.