Changeset 2411 for trunk/python
- Timestamp:
- 02/17/12 16:30:24 (13 years ago)
- File:
-
- 1 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
Note:
See TracChangeset
for help on using the changeset viewer.