Changeset 1845
- Timestamp:
- 08/04/10 12:36:57 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/scantable.py
r1843 r1845 1196 1196 # set the given restfrequency for the all currently selected IFs 1197 1197 scan.set_restfreqs(freqs=1.4e9) 1198 # set multiple restfrequencies to all the selected data 1198 # set restfrequencies for the n IFs (n > 1) in the order of the 1199 # list, i.e 1200 # IF0 -> 1.4e9, IF1 -> 1.41e9, IF3 -> 1.42e9 1201 # len(list_of_restfreqs) == nIF 1202 # for nIF == 1 the following will set multiple restfrequency for 1203 # that IF 1199 1204 scan.set_restfreqs(freqs=[1.4e9, 1.41e9, 1.42e9]) 1200 # If the number of IFs in the data is >= 2 the IF0 gets the first 1201 # value IF1 the second... NOTE that freqs needs to be 1202 # specified in list of list (e.g. [[],[],...] ). 1203 scan.set_restfreqs(freqs=[[1.4e9],[1.67e9]]) 1204 #set the given restfrequency for the whole table (by name) 1205 scan.set_restfreqs(freqs="OH1667") 1205 # set multiple restfrequencies per IF. as a list of lists where 1206 # the outer list has nIF elements, the inner s arbitrary 1207 scan.set_restfreqs(freqs=[[1.4e9, 1.41e9], [1.67e9]]) 1208 1206 1209 1207 1210 Note: … … 1209 1212 source and IF basis, use scantable.set_selection() before using 1210 1213 this function. 1211 # provide your scantable is called scan1214 # provided your scantable is called scan 1212 1215 selection = selector() 1213 1216 selection.set_name("ORION*") … … 1221 1224 # simple value 1222 1225 if isinstance(freqs, int) or isinstance(freqs, float): 1223 # TT mod 1224 #self._setrestfreqs(freqs, "",unit) 1225 self._setrestfreqs([freqs], [""],unit) 1226 self._setrestfreqs([freqs], [""], unit) 1226 1227 # list of values 1227 1228 elif isinstance(freqs, list) or isinstance(freqs, tuple): 1228 1229 # list values are scalars 1229 1230 if isinstance(freqs[-1], int) or isinstance(freqs[-1], float): 1230 self._setrestfreqs(freqs, [""], unit) 1231 # list values are tuples, (value, name) 1231 if len(freqs) == 1: 1232 self._setrestfreqs(freqs, [""], unit) 1233 else: 1234 # allow the 'old' mode of setting mulitple IFs 1235 sel = selector() 1236 savesel = self._getselection() 1237 iflist = self.getifnos() 1238 if len(freqs)>len(iflist): 1239 raise ValueError("number of elements in list of list " 1240 "exeeds the current IF selections") 1241 iflist = self.getifnos() 1242 for i, fval in enumerate(freqs): 1243 sel.set_ifs(iflist[i]) 1244 self._setselection(sel) 1245 self._setrestfreqs([fval], [""], unit) 1246 self._setselection(savesel) 1247 1248 # list values are dict, {'value'=, 'name'=) 1232 1249 elif isinstance(freqs[-1], dict): 1233 #sel = selector() 1234 #savesel = self._getselection() 1235 #iflist = self.getifnos() 1236 #for i in xrange(len(freqs)): 1237 # sel.set_ifs(iflist[i]) 1238 # self._setselection(sel) 1239 # self._setrestfreqs(freqs[i], "",unit) 1240 #self._setselection(savesel) 1241 self._setrestfreqs(freqs["value"], 1242 freqs["name"], unit) 1250 values = [] 1251 names = [] 1252 for d in freqs: 1253 values.append(d["value"]) 1254 names.append(d["name"]) 1255 self._setrestfreqs(values, names, unit) 1243 1256 elif isinstance(freqs[-1], list) or isinstance(freqs[-1], tuple): 1244 1257 sel = selector() … … 1246 1259 iflist = self.getifnos() 1247 1260 if len(freqs)>len(iflist): 1248 raise ValueError("number of elements in list of list exeeds the current IF selections") 1249 for i in xrange(len(freqs)): 1261 raise ValueError("number of elements in list of list exeeds" 1262 " the current IF selections") 1263 for i, fval in enumerate(freqs): 1250 1264 sel.set_ifs(iflist[i]) 1251 1265 self._setselection(sel) 1252 self._setrestfreqs(f reqs[i], [""], unit)1266 self._setrestfreqs(fval, [""], unit) 1253 1267 self._setselection(savesel) 1254 1268 # freqs are to be taken from a linecatalog … … 1259 1273 sel.set_ifs(iflist[i]) 1260 1274 self._setselection(sel) 1261 self._setrestfreqs( freqs.get_frequency(i),1262 freqs.get_name(i), "MHz")1275 self._setrestfreqs([freqs.get_frequency(i)], 1276 [freqs.get_name(i)], "MHz") 1263 1277 # ensure that we are not iterating past nIF 1264 1278 if i == self.nif()-1: break
Note:
See TracChangeset
for help on using the changeset viewer.