- Timestamp:
- 02/17/12 16:30:24 (13 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/scantable.py
r2410 r2411 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 TestClass 26 27 #class testclass(TestClass): 28 # def __init__(self, nelem): 29 # TestClass.__init__(self, nelem) 30 31 ############################################################### 21 32 22 33 … … 1253 1264 if rowno is None: 1254 1265 rowno = [] 1255 if mask is None:1256 mask = []1257 1266 if isinstance(rowno, int): 1258 1267 rowno = [rowno] 1259 1268 elif not (isinstance(rowno, list) or isinstance(rowno, tuple)): 1260 1269 raise TypeError("The row number(s) must be int, list or tuple.") 1261 1262 1270 if len(rowno) == 0: rowno = [i for i in xrange(self.nrow())] 1263 1271 1264 if not (isinstance(mask, list) or isinstance(mask, tuple)): 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: 1265 1299 raise TypeError("The mask must be a boolean list or a list of " 1266 1300 "boolean list.") 1267 if len(mask) == 0: mask = [True for i in xrange(self.nchan())] 1268 if isinstance(mask[0], bool): mask = [mask] 1269 elif not (isinstance(mask[0], list) or isinstance(mask[0], tuple)): 1270 raise TypeError("The mask must be a boolean list or a list of " 1271 "boolean list.") 1272 1273 usecommonmask = (len(mask) == 1) 1274 if not usecommonmask: 1275 if len(mask) != len(rowno): 1276 raise ValueError("When specifying masks for each spectrum, " 1277 "the numbers of them must be identical.") 1278 for amask in mask: 1279 if len(amask) != self.nchan(): 1280 raise ValueError("The spectra and the mask have different " 1281 "length.") 1282 1301 1283 1302 res = [] 1284 1303 … … 2311 2330 val = int(wn[:-1]) 2312 2331 res = [i for i in xrange(val)] 2313 elif wn[:2] == '>=' or wn[:2] == '=>': # cases '>=a','=>a' : return [a,a+1,...,a_nyq] 2332 elif wn[:2] == '>=' or wn[:2] == '=>': # cases '>=a','=>a' : return [a,-999], which is 2333 # then interpreted in C++ 2334 # side as [a,a+1,...,a_nyq] 2335 # (CAS-3759) 2314 2336 val = int(wn[2:]) 2315 res = [i for i in xrange(val, self.nchan()/2+1)] 2316 elif wn[-2:] == '<=' or wn[-2:] == '=<': # cases 'a<=','a=<' : return [a,a+1,...,a_nyq] 2337 res = [val, -999] 2338 #res = [i for i in xrange(val, self.nchan()/2+1)] 2339 elif wn[-2:] == '<=' or wn[-2:] == '=<': # cases 'a<=','a=<' : return [a,-999], which is 2340 # then interpreted in C++ 2341 # side as [a,a+1,...,a_nyq] 2342 # (CAS-3759) 2317 2343 val = int(wn[:-2]) 2318 res = [i for i in xrange(val, self.nchan()/2+1)] 2319 elif wn[0] == '>': # case '>a' : return [a+1,a+2,...,a_nyq] 2344 res = [val, -999] 2345 #res = [i for i in xrange(val, self.nchan()/2+1)] 2346 elif wn[0] == '>': # case '>a' : return [a+1,-999], which is 2347 # then interpreted in C++ 2348 # side as [a+1,a+2,...,a_nyq] 2349 # (CAS-3759) 2320 2350 val = int(wn[1:])+1 2321 res = [i for i in xrange(val, self.nchan()/2+1)] 2322 elif wn[-1] == '<': # case 'a<' : return [a+1,a+2,...,a_nyq] 2351 res = [val, -999] 2352 #res = [i for i in xrange(val, self.nchan()/2+1)] 2353 elif wn[-1] == '<': # case 'a<' : return [a+1,-999], which is 2354 # then interpreted in C++ 2355 # side as [a+1,a+2,...,a_nyq] 2356 # (CAS-3759) 2323 2357 val = int(wn[:-1])+1 2324 res = [i for i in xrange(val, self.nchan()/2+1)] 2358 res = [val, -999] 2359 #res = [i for i in xrange(val, self.nchan()/2+1)] 2325 2360 2326 2361 return res … … 2371 2406 number corresponding to the Nyquist 2372 2407 frequency for the case of FFT). 2373 default is [ ].2408 default is [0]. 2374 2409 rejwn: the wave numbers NOT to be used for fitting. 2375 2410 can be set just as addwn but has higher priority: … … 2420 2455 if fftmethod is None: fftmethod = 'fft' 2421 2456 if fftthresh is None: fftthresh = 3.0 2422 if addwn is None: addwn = [ ]2457 if addwn is None: addwn = [0] 2423 2458 if rejwn is None: rejwn = [] 2424 2459 if clipthresh is None: clipthresh = 3.0 … … 2495 2530 number corresponding to the Nyquist 2496 2531 frequency for the case of FFT). 2497 default is [ ].2532 default is [0]. 2498 2533 rejwn: the wave numbers NOT to be used for fitting. 2499 2534 can be set just as addwn but has higher priority: … … 2561 2596 if fftmethod is None: fftmethod = 'fft' 2562 2597 if fftthresh is None: fftthresh = 3.0 2563 if addwn is None: addwn = [ ]2598 if addwn is None: addwn = [0] 2564 2599 if rejwn is None: rejwn = [] 2565 2600 if clipthresh is None: clipthresh = 3.0 -
trunk/src/Scantable.cpp
r2410 r2411 2697 2697 } 2698 2698 2699 addAuxWaveNumbers( addNWaves, rejectNWaves, nWaves);2699 addAuxWaveNumbers(whichrow, addNWaves, rejectNWaves, nWaves); 2700 2700 } 2701 2701 … … 2779 2779 } 2780 2780 2781 void Scantable::addAuxWaveNumbers(const std::vector<int>& addNWaves, const std::vector<int>& rejectNWaves, std::vector<int>& nWaves) 2782 { 2781 void Scantable::addAuxWaveNumbers(const int whichrow, const std::vector<int>& addNWaves, const std::vector<int>& rejectNWaves, std::vector<int>& nWaves) 2782 { 2783 std::vector<int> tempAddNWaves, tempRejectNWaves; 2783 2784 for (uInt i = 0; i < addNWaves.size(); ++i) { 2785 tempAddNWaves.push_back(addNWaves[i]); 2786 } 2787 if ((tempAddNWaves.size() == 2) && (tempAddNWaves[1] == -999)) { 2788 setWaveNumberListUptoNyquistFreq(whichrow, tempAddNWaves); 2789 } 2790 2791 for (uInt i = 0; i < rejectNWaves.size(); ++i) { 2792 tempRejectNWaves.push_back(rejectNWaves[i]); 2793 } 2794 if ((tempRejectNWaves.size() == 2) && (tempRejectNWaves[1] == -999)) { 2795 setWaveNumberListUptoNyquistFreq(whichrow, tempRejectNWaves); 2796 } 2797 2798 for (uInt i = 0; i < tempAddNWaves.size(); ++i) { 2784 2799 bool found = false; 2785 2800 for (uInt j = 0; j < nWaves.size(); ++j) { 2786 if (nWaves[j] == addNWaves[i]) {2801 if (nWaves[j] == tempAddNWaves[i]) { 2787 2802 found = true; 2788 2803 break; 2789 2804 } 2790 2805 } 2791 if (!found) nWaves.push_back( addNWaves[i]);2792 } 2793 2794 for (uInt i = 0; i < rejectNWaves.size(); ++i) {2806 if (!found) nWaves.push_back(tempAddNWaves[i]); 2807 } 2808 2809 for (uInt i = 0; i < tempRejectNWaves.size(); ++i) { 2795 2810 for (std::vector<int>::iterator j = nWaves.begin(); j != nWaves.end(); ) { 2796 if (*j == rejectNWaves[i]) {2811 if (*j == tempRejectNWaves[i]) { 2797 2812 j = nWaves.erase(j); 2798 2813 } else { … … 2805 2820 sort(nWaves.begin(), nWaves.end()); 2806 2821 unique(nWaves.begin(), nWaves.end()); 2822 } 2823 } 2824 2825 void Scantable::setWaveNumberListUptoNyquistFreq(const int whichrow, std::vector<int>& nWaves) 2826 { 2827 if ((nWaves.size() == 2)&&(nWaves[1] == -999)) { 2828 int val = nWaves[0]; 2829 int nyquistFreq = nchan(getIF(whichrow))/2+1; 2830 nWaves.clear(); 2831 if (val > nyquistFreq) { // for safety, at least nWaves contains a constant; CAS-3759 2832 nWaves.push_back(0); 2833 } 2834 while (val <= nyquistFreq) { 2835 nWaves.push_back(val); 2836 val++; 2837 } 2807 2838 } 2808 2839 } … … 2844 2875 2845 2876 //FOR DEBUGGING------------ 2877 /* 2846 2878 if (whichrow < 0) {// == nRow -1) { 2847 2879 cout << "+++ i=" << setw(3) << whichrow << ", IF=" << setw(2) << getIF(whichrow); … … 2855 2887 cout << flush; 2856 2888 } 2889 */ 2857 2890 //------------------------- 2858 2891 -
trunk/src/Scantable.h
r2357 r2411 739 739 const std::string& fftThAttr, 740 740 std::vector<int>& nWaves); 741 void addAuxWaveNumbers(const std::vector<int>& addNWaves, 741 void addAuxWaveNumbers(const int whichrow, 742 const std::vector<int>& addNWaves, 742 743 const std::vector<int>& rejectNWaves, 743 744 std::vector<int>& nWaves); 745 void setWaveNumberListUptoNyquistFreq(const int whichrow, 746 std::vector<int>& nWaves); 744 747 bool hasSameNchanOverIFs(); 745 748 std::string getMaskRangeList(const std::vector<bool>& mask,
Note:
See TracChangeset
for help on using the changeset viewer.