source: trunk/python/selector.py@ 944

Last change on this file since 944 was 932, checked in by mar637, 19 years ago

python warpper for c++ selector class

File size: 4.1 KB
Line 
1from asap._asap import selector as _selector
2class selector(_selector):
3 def __init(self):
4 _selector.__init__(self)
5
6 def reset(self):
7 """
8 Unset all selections.
9 """
10 self._reset()
11
12
13 def set_polarisations(self, pols=[]):
14 """
15 Set the polarisations to be selected in the scantable.
16 Parameters:
17 pols: a list of integers of 0-3, or strings, e.g ["I","Q"].
18 Default [] is no selection
19 Example:
20 sel = selector()
21 # These are equivalent if data is 'linear'
22 sel.set_polarisations(["XX","Re(XY)"])
23 sel.set_polarisations([0,2])
24 # reset the polarisation selection
25 sel.set_polarisations()
26
27 """
28 vec = _to_list(pols, str) and _to_list(pols, int)
29 if vec: # is an empty and/or valid vector
30 if len(vec) and isinstance(vec[-1],str):
31 self._setpolstrings(self, vec)
32 return
33 self._setpols(vec)
34 else:
35 raise TypeError('Unknown pol type. Please use [0,1...] or ["XX","YY"...]')
36
37 def set_ifs(self, ifs=[]):
38 """
39 Set a sequence of IF numbers (0-based).
40 Parameters:
41 ifs: a list of integers. Default [] is to unset the selection.
42 """
43 vec = _to_list(ifs, int)
44 if vec:
45 self._setifs(vec)
46 else:
47 raise TypeError('Unknown IFno type. Use lists of integers.')
48
49 def set_scans(self, scans=[]):
50 """
51 Set a sequence of Scan numbers (0-based).
52 Parameters:
53 scans: a list of integers. Default [] is to unset the selection.
54 """
55 vec = _to_list(scans, int)
56 if vec:
57 self._setscans(vec)
58 else:
59 raise TypeError('Unknown Scan number type. Use lists of integers.')
60
61 def set_beams(self, beams=[]):
62 """
63 Set a sequence of Beam numbers (0-based).
64 Parameters:
65 beams: a list of integers. Default [] is to unset the selection.
66 """
67 vec = _to_list(beams, int)
68 if vec:
69 self._setbeams(vec)
70 else:
71 raise TypeError('Unknown Beam number type. Use lists of integers.')
72
73 def set_cycles(self, cycles=[]):
74 """
75 Set a sequence of IF numbers (0-based).
76 Parameters:
77 cycless: a list of integers. Default [] is to unset the selection.
78 """
79 vec = _to_list(cycles, int)
80 if vec:
81 self._setcycles(vec)
82 else:
83 raise TypeError('Unknown Cycle number type. Use lists of integers.')
84
85
86 def set_name(self, name):
87 """
88 Set a selection based on a name. This can be a unix pattern , e.g. "*_R"
89 Parameters:
90 name: a string containing a source name or pattern
91 Examples:
92 # select all reference scans which start with "Orion"
93 selection.set_name("Orion*_R")
94 """
95 if isinstance(name, str):
96 self._setame(name)
97 else:
98 raise TypeError('name must be a string')
99
100 def set_tsys(self, tsysmin=0.0, tsysmax=None):
101 """
102 Select by Tsys range.
103 Parameters:
104 tsysmin: the lower threshold. Default 0.0
105 tsysmax: the upper threshold. Default None.
106 Examples:
107 # select all spectra with Tsys <= 500.0
108 selection.set_tsys(tsysmax=500.0)
109
110 """
111 taql = "SELECT FROM $1 WHERE TSYS >= %f" % (tsysmin)
112 if isinstance(tsysmax, float):
113 taql = taql + " AND TSYS <= %f" % ( tsysmax)
114 self._settaql(taql)
115
116 def set_query(self, query):
117 """
118 Select by Column query. Power users only!
119 Example:
120 # select all off scans with integration times over 60 seconds.
121 selection.set_query("SRCTYPE == 1 AND INTERVAL > 60.0")
122 """
123 taql = "SELECT FROM $1 WHERE " + query
124 self._settaql(taql)
125
Note: See TracBrowser for help on using the repository browser.