Added support for --switch_mode, along with an external switcher interface via a...
[debian/gnuradio] / gr-radio-astronomy / src / python / usrp_ra_receiver.py
1 #!/usr/bin/env python
2 #
3 # Copyright 2004,2005,2007 Free Software Foundation, Inc.
4
5 # This file is part of GNU Radio
6
7 # GNU Radio is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3, or (at your option)
10 # any later version.
11
12 # GNU Radio is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16
17 # You should have received a copy of the GNU General Public License
18 # along with GNU Radio; see the file COPYING.  If not, write to
19 # the Free Software Foundation, Inc., 51 Franklin Street,
20 # Boston, MA 02110-1301, USA.
21
22
23 from gnuradio import gr, gru
24 from gnuradio import usrp
25 from usrpm import usrp_dbid
26 from gnuradio import eng_notation
27 from gnuradio.eng_option import eng_option
28 from gnuradio.wxgui import stdgui2, ra_fftsink, ra_stripchartsink, ra_waterfallsink, form, slider
29 from optparse import OptionParser
30 import wx
31 import sys
32 import Numeric 
33 import time
34 import numpy.fft
35 import ephem
36
37 class app_flow_graph(stdgui2.std_top_block):
38         def __init__(self, frame, panel, vbox, argv):
39                 stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv)
40
41                 self.frame = frame
42                 self.panel = panel
43                 
44                 parser = OptionParser(option_class=eng_option)
45                 parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=(0, 0),
46                         help="select USRP Rx side A or B (default=A)")
47                 parser.add_option("-d", "--decim", type="int", default=16,
48                         help="set fgpa decimation rate to DECIM [default=%default]")
49                 parser.add_option("-f", "--freq", type="eng_float", default=None,
50                         help="set frequency to FREQ", metavar="FREQ")
51                 parser.add_option("-a", "--avg", type="eng_float", default=1.0,
52                         help="set spectral averaging alpha")
53                 parser.add_option("-i", "--integ", type="eng_float", default=1.0,
54                         help="set integration time")
55                 parser.add_option("-g", "--gain", type="eng_float", default=None,
56                         help="set gain in dB (default is midpoint)")
57                 parser.add_option("-l", "--reflevel", type="eng_float", default=30.0,
58                         help="Set Total power reference level")
59                 parser.add_option("-y", "--division", type="eng_float", default=0.5,
60                         help="Set Total power Y division size")
61                 parser.add_option("-e", "--longitude", type="eng_float", default=-76.02,help="Set Observer Longitude")
62                 parser.add_option("-c", "--latitude", type="eng_float", default=44.85,help="Set Observer Latitude")
63                 parser.add_option("-o", "--observing", type="eng_float", default=0.0,
64                         help="Set observing frequency")
65                 parser.add_option("-x", "--ylabel", default="dB", help="Y axis label") 
66                 parser.add_option("-z", "--divbase", type="eng_float", default=0.025, help="Y Division increment base") 
67                 parser.add_option("-v", "--stripsize", type="eng_float", default=2400, help="Size of stripchart, in 2Hz samples") 
68                 parser.add_option("-F", "--fft_size", type="eng_float", default=1024, help="Size of FFT")
69                 parser.add_option("-N", "--decln", type="eng_float", default=999.99, help="Observing declination")
70                 parser.add_option("-X", "--prefix", default="./")
71                 parser.add_option("-M", "--fft_rate", type="eng_float", default=8.0, help="FFT Rate")
72                 parser.add_option("-A", "--calib_coeff", type="eng_float", default=1.0, help="Calibration coefficient")
73                 parser.add_option("-B", "--calib_offset", type="eng_float", default=0.0, help="Calibration coefficient")
74                 parser.add_option("-W", "--waterfall", action="store_true", default=False, help="Use Waterfall FFT display")
75                 parser.add_option("-S", "--setimode", action="store_true", default=False, help="Enable SETI processing of spectral data")
76                 parser.add_option("-K", "--setik", type="eng_float", default=1.5, help="K value for SETI analysis")
77                 parser.add_option("-T", "--setibandwidth", type="eng_float", default=12500, help="Instantaneous SETI observing bandwidth--must be divisor of 250Khz")
78                 parser.add_option("-Q", "--seti_range", type="eng_float", default=1.0e6, help="Total scan width, in Hz for SETI scans")
79                 parser.add_option("-Z", "--dual_mode", action="store_true",
80                         default=False, help="Dual-polarization mode")
81                 parser.add_option("-I", "--interferometer", action="store_true", default=False, help="Interferometer mode")
82                 parser.add_option("-D", "--switch_mode", action="store_true", default=False, help="Dicke Switching mode")
83                 parser.add_option("-P", "--reference_divisor", type="eng_float", default=1.0, help="Reference Divisor")
84                 parser.add_option("-U", "--ref_fifo", default="@@@@")
85                 (options, args) = parser.parse_args()
86
87                 self.setimode = options.setimode
88                 self.dual_mode = options.dual_mode
89                 self.interferometer = options.interferometer
90                 self.normal_mode = False
91                 self.switch_mode = options.switch_mode
92                 self.switch_state = 0
93                 self.reference_divisor = options.reference_divisor
94                 self.ref_fifo = options.ref_fifo
95                 
96                 if (self.ref_fifo != "@@@@"):
97                         self.ref_fifo_file = open (self.ref_fifo, "w")
98                 
99                 modecount = 0
100                 for modes in (self.dual_mode, self.interferometer):
101                         if (modes == True):
102                                 modecount = modecount + 1
103                                 
104                 if (modecount > 1):
105                         print "must select only 1 of --dual_mode, or --interferometer"
106                         sys.exit(1)
107                         
108                 self.chartneeded = True
109                 
110                 if (self.setimode == True):
111                         self.chartneeded = False
112                         
113                 if (self.setimode == True and self.interferometer == True):
114                         print "can't pick both --setimode and --interferometer"
115                         sys.exit(1)
116                         
117                 if (self.setimode == True and self.switch_mode == True):
118                         print "can't pick both --setimode and --switch_mode"
119                         sys.exit(1)
120                 
121                 if (self.interferometer == True and self.switch_mode == True):
122                         print "can't pick both --interferometer and --switch_mode"
123                         sys.exit(1)
124                 
125                 if (modecount == 0):
126                         self.normal_mode = True
127
128                 self.show_debug_info = True
129                 
130                 # Pick up waterfall option
131                 self.waterfall = options.waterfall
132
133                 # SETI mode stuff
134                 self.setimode = options.setimode
135                 self.seticounter = 0
136                 self.setik = options.setik
137                 self.seti_fft_bandwidth = int(options.setibandwidth)
138
139                 # Calculate binwidth
140                 binwidth = self.seti_fft_bandwidth / options.fft_size
141
142                 # Use binwidth, and knowledge of likely chirp rates to set reasonable
143                 #  values for SETI analysis code.       We assume that SETI signals will
144                 #  chirp at somewhere between 0.10Hz/sec and 0.25Hz/sec.
145                 #
146                 # upper_limit is the "worst case"--that is, the case for which we have
147                 #  to wait the longest to actually see any drift, due to the quantizing
148                 #  on FFT bins.
149                 upper_limit = binwidth / 0.10
150                 self.setitimer = int(upper_limit * 2.00)
151                 self.scanning = True
152
153                 # Calculate the CHIRP values based on Hz/sec
154                 self.CHIRP_LOWER = 0.10 * self.setitimer
155                 self.CHIRP_UPPER = 0.25 * self.setitimer
156
157                 # Reset hit counters to 0
158                 self.hitcounter = 0
159                 self.s1hitcounter = 0
160                 self.s2hitcounter = 0
161                 self.avgdelta = 0
162                 # We scan through 2Mhz of bandwidth around the chosen center freq
163                 self.seti_freq_range = options.seti_range
164                 # Calculate lower edge
165                 self.setifreq_lower = options.freq - (self.seti_freq_range/2)
166                 self.setifreq_current = options.freq
167                 # Calculate upper edge
168                 self.setifreq_upper = options.freq + (self.seti_freq_range/2)
169
170                 # Maximum "hits" in a line
171                 self.nhits = 20
172
173                 # Number of lines for analysis
174                 self.nhitlines = 4
175
176                 # We change center frequencies based on nhitlines and setitimer
177                 self.setifreq_timer = self.setitimer * (self.nhitlines * 5)
178
179                 # Create actual timer
180                 self.seti_then = time.time()
181
182                 # The hits recording array
183                 self.hits_array = Numeric.zeros((self.nhits,self.nhitlines), Numeric.Float64)
184                 self.hit_intensities = Numeric.zeros((self.nhits,self.nhitlines), Numeric.Float64)
185                 # Calibration coefficient and offset
186                 self.calib_coeff = options.calib_coeff
187                 self.calib_offset = options.calib_offset
188                 if self.calib_offset < -750:
189                         self.calib_offset = -750
190                 if self.calib_offset > 750:
191                         self.calib_offset = 750
192
193                 if self.calib_coeff < 1:
194                         self.calib_coeff = 1
195                 if self.calib_coeff > 100:
196                         self.calib_coeff = 100
197
198                 self.integ = options.integ
199                 self.avg_alpha = options.avg
200                 self.gain = options.gain
201                 self.decln = options.decln
202
203                 # Set initial values for datalogging timed-output
204                 self.continuum_then = time.time()
205                 self.spectral_then = time.time()
206                 
207           
208                 # build the graph
209
210                 self.subdev = [(0, 0), (0,0)]
211                 
212                 #
213                 # If SETI mode, we always run at maximum USRP decimation
214                 #
215                 if (self.setimode):
216                         options.decim = 256
217
218                 if (self.dual_mode == False and self.interferometer == False):
219                         self.u = usrp.source_c(decim_rate=options.decim)
220                         self.u.set_mux(usrp.determine_rx_mux_value(self.u, options.rx_subdev_spec))
221                         # determine the daughterboard subdevice we're using
222                         self.subdev[0] = usrp.selected_subdev(self.u, options.rx_subdev_spec)
223                         self.subdev[1] = self.subdev[0]
224                         self.cardtype = self.subdev[0].dbid()
225                 else:
226                         self.u=usrp.source_c(decim_rate=options.decim, nchan=2)
227                         self.subdev[0] = usrp.selected_subdev(self.u, (0, 0))
228                         self.subdev[1] = usrp.selected_subdev(self.u, (1, 0))
229                         self.cardtype = self.subdev[0].dbid()
230                         self.u.set_mux(0x32103210)
231                         c1 = self.subdev[0].name()
232                         c2 = self.subdev[1].name()
233                         if (c1 != c2):
234                                 print "Must have identical cardtypes for --dual_mode or --interferometer"
235                                 sys.exit(1)
236                 #
237                 # Set 8-bit mode
238                 #
239                 width = 8
240                 shift = 8
241                 format = self.u.make_format(width, shift)
242                 r = self.u.set_format(format)
243                 
244                 # Set initial declination
245                 self.decln = options.decln
246
247                 input_rate = self.u.adc_freq() / self.u.decim_rate()
248
249                 #
250                 # Set prefix for data files
251                 #
252                 self.prefix = options.prefix
253
254                 #
255                 # The lower this number, the fewer sample frames are dropped
256                 #  in computing the FFT.  A sampled approach is taken to
257                 #  computing the FFT of the incoming data, which reduces
258                 #  sensitivity.  Increasing sensitivity inreases CPU loading.
259                 #
260                 self.fft_rate = options.fft_rate
261
262                 self.fft_size = int(options.fft_size)
263
264                 # This buffer is used to remember the most-recent FFT display
265                 #       values.  Used later by self.write_spectral_data() to write
266                 #       spectral data to datalogging files, and by the SETI analysis
267                 #       function.
268                 #
269                 self.fft_outbuf = Numeric.zeros(self.fft_size, Numeric.Float64)
270
271                 #
272                 # If SETI mode, only look at seti_fft_bandwidth
273                 #       at a time.
274                 #
275                 if (self.setimode):
276                         self.fft_input_rate = self.seti_fft_bandwidth
277
278                         #
279                         # Build a decimating bandpass filter
280                         #
281                         self.fft_input_taps = gr.firdes.complex_band_pass (1.0,
282                            input_rate,
283                            -(int(self.fft_input_rate/2)), int(self.fft_input_rate/2), 200,
284                            gr.firdes.WIN_HAMMING, 0)
285
286                         #
287                         # Compute required decimation factor
288                         #
289                         decimation = int(input_rate/self.fft_input_rate)
290                         self.fft_bandpass = gr.fir_filter_ccc (decimation, 
291                                 self.fft_input_taps)
292                 else:
293                         self.fft_input_rate = input_rate
294
295                 # Set up FFT display
296                 if self.waterfall == False:
297                    self.scope = ra_fftsink.ra_fft_sink_c (panel, 
298                            fft_size=int(self.fft_size), sample_rate=self.fft_input_rate,
299                            fft_rate=int(self.fft_rate), title="Spectral",  
300                            ofunc=self.fft_outfunc, xydfunc=self.xydfunc)
301                 else:
302                         self.scope = ra_waterfallsink.waterfall_sink_c (panel,
303                                 fft_size=int(self.fft_size), sample_rate=self.fft_input_rate,
304                                 fft_rate=int(self.fft_rate), title="Spectral", ofunc=self.fft_outfunc, size=(1100, 600), xydfunc=self.xydfunc, ref_level=0, span=10)
305
306                 # Set up ephemeris data
307                 self.locality = ephem.Observer()
308                 self.locality.long = str(options.longitude)
309                 self.locality.lat = str(options.latitude)
310                 
311                 # We make notes about Sunset/Sunrise in Continuum log files
312                 self.sun = ephem.Sun()
313                 self.sunstate = "??"
314
315                 # Set up stripchart display
316                 tit = "Continuum"
317                 if (self.dual_mode != False):
318                         tit = "H+V Continuum"
319                 if (self.interferometer != False):
320                         tit = "East x West Correlation"
321                 self.stripsize = int(options.stripsize)
322                 if self.chartneeded == True:
323                         self.chart = ra_stripchartsink.stripchart_sink_f (panel,
324                                 stripsize=self.stripsize,
325                                 title=tit,
326                                 xlabel="LMST Offset (Seconds)",
327                                 scaling=1.0, ylabel=options.ylabel,
328                                 divbase=options.divbase)
329
330                 # Set center frequency
331                 self.centerfreq = options.freq
332
333                 # Set observing frequency (might be different from actual programmed
334                 #        RF frequency)
335                 if options.observing == 0.0:
336                         self.observing = options.freq
337                 else:
338                         self.observing = options.observing
339
340                 # Remember our input bandwidth
341                 self.bw = input_rate
342
343                 #
344                 # 
345                 # The strip chart is fed at a constant 1Hz rate
346                 #
347
348                 #
349                 # Call constructors for receive chains
350                 #
351                 
352                 if (self.dual_mode == True):
353                         self.setup_dual (self.setimode)
354                         
355                 if (self.interferometer == True):
356                         self.setup_interferometer(self.setimode)
357                                 
358                 if (self.normal_mode == True):
359                         self.setup_normal(self.setimode)
360                         
361                 if (self.setimode == True):
362                         self.setup_seti()
363
364                 self._build_gui(vbox)
365
366                 # Make GUI agree with command-line
367                 self.integ = options.integ
368                 if self.setimode == False:
369                         self.myform['integration'].set_value(int(options.integ))
370                         self.myform['offset'].set_value(self.calib_offset)
371                         self.myform['dcgain'].set_value(self.calib_coeff)
372                 self.myform['average'].set_value(int(options.avg))
373
374
375                 if self.setimode == False:
376                         # Make integrator agree with command line
377                         self.set_integration(int(options.integ))
378
379                 self.avg_alpha = options.avg
380
381                 # Make spectral averager agree with command line
382                 if options.avg != 1.0:
383                         self.scope.set_avg_alpha(float(1.0/options.avg))
384                         self.scope.set_average(True)
385
386                 if self.setimode == False:
387                         # Set division size
388                         self.chart.set_y_per_div(options.division)
389                         # Set reference(MAX) level
390                         self.chart.set_ref_level(options.reflevel)
391
392                 # set initial values
393
394                 if options.gain is None:
395                         # if no gain was specified, use the mid-point in dB
396                         g = self.subdev[0].gain_range()
397                         options.gain = float(g[0]+g[1])/2
398
399                 if options.freq is None:
400                         # if no freq was specified, use the mid-point
401                         r = self.subdev[0].freq_range()
402                         options.freq = float(r[0]+r[1])/2
403
404                 # Set the initial gain control
405                 self.set_gain(options.gain)
406
407                 if not(self.set_freq(options.freq)):
408                         self._set_status_msg("Failed to set initial frequency")
409
410                 # Set declination
411                 self.set_decln (self.decln)
412
413
414                 # RF hardware information
415                 self.myform['decim'].set_value(self.u.decim_rate())
416                 self.myform['USB BW'].set_value(self.u.adc_freq() / self.u.decim_rate())
417                 if (self.dual_mode == True):
418                         self.myform['dbname'].set_value(self.subdev[0].name()+'/'+self.subdev[1].name())
419                 else:
420                         self.myform['dbname'].set_value(self.subdev[0].name())
421
422                 # Set analog baseband filtering, if DBS_RX
423                 if self.cardtype in (usrp_dbid.DBS_RX, usrp_dbid.DBS_RX_REV_2_1):
424                         lbw = (self.u.adc_freq() / self.u.decim_rate()) / 2
425                         if lbw < 1.0e6:
426                                 lbw = 1.0e6
427                         self.subdev[0].set_bw(lbw)
428                         self.subdev[1].set_bw(lbw)
429                         
430                 # Start the timer for the LMST display and datalogging
431                 self.lmst_timer.Start(1000)
432                 if (self.switch_mode == True):
433                         self.other_timer.Start(330)
434
435
436         def _set_status_msg(self, msg):
437                 self.frame.GetStatusBar().SetStatusText(msg, 0)
438
439         def _build_gui(self, vbox):
440
441                 def _form_set_freq(kv):
442                         # Adjust current SETI frequency, and limits
443                         self.setifreq_lower = kv['freq'] - (self.seti_freq_range/2)
444                         self.setifreq_current = kv['freq']
445                         self.setifreq_upper = kv['freq'] + (self.seti_freq_range/2)
446
447                         # Reset SETI analysis timer
448                         self.seti_then = time.time()
449                         # Zero-out hits array when changing frequency
450                         self.hits_array[:,:] = 0.0
451                         self.hit_intensities[:,:] = -60.0
452
453                         return self.set_freq(kv['freq'])
454
455                 def _form_set_decln(kv):
456                         return self.set_decln(kv['decln'])
457
458                 # Position the FFT display
459                 vbox.Add(self.scope.win, 15, wx.EXPAND)
460
461                 if self.setimode == False:
462                         # Position the Total-power stripchart
463                         vbox.Add(self.chart.win, 15, wx.EXPAND)
464                 
465                 # add control area at the bottom
466                 self.myform = myform = form.form()
467                 hbox = wx.BoxSizer(wx.HORIZONTAL)
468                 hbox.Add((7,0), 0, wx.EXPAND)
469                 vbox1 = wx.BoxSizer(wx.VERTICAL)
470                 myform['freq'] = form.float_field(
471                         parent=self.panel, sizer=vbox1, label="Center freq", weight=1,
472                         callback=myform.check_input_and_call(_form_set_freq, self._set_status_msg))
473
474                 vbox1.Add((4,0), 0, 0)
475
476                 myform['lmst_high'] = form.static_text_field(
477                         parent=self.panel, sizer=vbox1, label="Current LMST", weight=1)
478                 vbox1.Add((4,0), 0, 0)
479
480                 if self.setimode == False:
481                         myform['spec_data'] = form.static_text_field(
482                                 parent=self.panel, sizer=vbox1, label="Spectral Cursor", weight=1)
483                         vbox1.Add((4,0), 0, 0)
484
485                 vbox2 = wx.BoxSizer(wx.VERTICAL)
486                 if self.setimode == False:
487                         vbox3 = wx.BoxSizer(wx.VERTICAL)
488                 g = self.subdev[0].gain_range()
489                 myform['gain'] = form.slider_field(parent=self.panel, sizer=vbox2, label="RF Gain",
490                                                                                    weight=1,
491                                                                                    min=int(g[0]), max=int(g[1]),
492                                                                                    callback=self.set_gain)
493
494                 vbox2.Add((4,0), 0, 0)
495                 if self.setimode == True:
496                         max_savg = 100
497                 else:
498                         max_savg = 3000
499                 myform['average'] = form.slider_field(parent=self.panel, sizer=vbox2, 
500                                         label="Spectral Averaging (FFT frames)", weight=1, min=1, max=max_savg, callback=self.set_averaging)
501
502                 # Set up scan control button when in SETI mode
503                 if (self.setimode == True):
504                         # SETI scanning control
505                         buttonbox = wx.BoxSizer(wx.HORIZONTAL)
506                         self.scan_control = form.button_with_callback(self.panel,
507                                   label="Scan: On ",
508                                   callback=self.toggle_scanning)
509         
510                         buttonbox.Add(self.scan_control, 0, wx.CENTER)
511                         vbox2.Add(buttonbox, 0, wx.CENTER)
512
513                 vbox2.Add((4,0), 0, 0)
514
515                 if self.setimode == False:
516                         myform['integration'] = form.slider_field(parent=self.panel, sizer=vbox2,
517                                    label="Continuum Integration Time (sec)", weight=1, min=1, max=180, callback=self.set_integration)
518
519                         vbox2.Add((4,0), 0, 0)
520
521                 myform['decln'] = form.float_field(
522                         parent=self.panel, sizer=vbox2, label="Current Declination", weight=1,
523                         callback=myform.check_input_and_call(_form_set_decln))
524                 vbox2.Add((4,0), 0, 0)
525
526                 if self.setimode == False:
527                         myform['offset'] = form.slider_field(parent=self.panel, sizer=vbox3,
528                                 label="Post-Detector Offset", weight=1, min=-750, max=750, 
529                                 callback=self.set_pd_offset)
530                         vbox3.Add((2,0), 0, 0)
531                         myform['dcgain'] = form.slider_field(parent=self.panel, sizer=vbox3,
532                                 label="Post-Detector Gain", weight=1, min=1, max=100, 
533                                 callback=self.set_pd_gain)
534                         vbox3.Add((2,0), 0, 0)
535                 hbox.Add(vbox1, 0, 0)
536                 hbox.Add(vbox2, wx.ALIGN_RIGHT, 0)
537
538                 if self.setimode == False:
539                         hbox.Add(vbox3, wx.ALIGN_RIGHT, 0)
540
541                 vbox.Add(hbox, 0, wx.EXPAND)
542
543                 self._build_subpanel(vbox)
544
545                 self.lmst_timer = wx.PyTimer(self.lmst_timeout)
546                 self.other_timer = wx.PyTimer(self.other_timeout)
547
548
549         def _build_subpanel(self, vbox_arg):
550                 # build a secondary information panel (sometimes hidden)
551
552                 # FIXME figure out how to have this be a subpanel that is always
553                 # created, but has its visibility controlled by foo.Show(True/False)
554                 
555                 if not(self.show_debug_info):
556                         return
557
558                 panel = self.panel
559                 vbox = vbox_arg
560                 myform = self.myform
561
562                 #panel = wx.Panel(self.panel, -1)
563                 #vbox = wx.BoxSizer(wx.VERTICAL)
564
565                 hbox = wx.BoxSizer(wx.HORIZONTAL)
566                 hbox.Add((5,0), 0)
567                 myform['decim'] = form.static_float_field(
568                         parent=panel, sizer=hbox, label="Decim")
569
570                 hbox.Add((5,0), 1)
571                 myform['USB BW'] = form.static_float_field(
572                         parent=panel, sizer=hbox, label="USB BW")
573
574                 hbox.Add((5,0), 1)
575                 myform['dbname'] = form.static_text_field(
576                         parent=panel, sizer=hbox)
577
578                 hbox.Add((5,0), 1)
579                 myform['baseband'] = form.static_float_field(
580                         parent=panel, sizer=hbox, label="Analog BB")
581
582                 hbox.Add((5,0), 1)
583                 myform['ddc'] = form.static_float_field(
584                         parent=panel, sizer=hbox, label="DDC")
585
586                 hbox.Add((5,0), 0)
587                 vbox.Add(hbox, 0, wx.EXPAND)
588
589                 
590                 
591         def set_freq(self, target_freq):
592                 """
593                 Set the center frequency we're interested in.
594
595                 @param target_freq: frequency in Hz
596                 @rypte: bool
597
598                 Tuning is a two step process.  First we ask the front-end to
599                 tune as close to the desired frequency as it can.  Then we use
600                 the result of that operation and our target_frequency to
601                 determine the value for the digital down converter.
602                 """
603                 #
604                 # Everything except BASIC_RX should support usrp.tune()
605                 #
606                 if not (self.cardtype == usrp_dbid.BASIC_RX):
607                         r = usrp.tune(self.u, self.subdev[0]._which, self.subdev[0], target_freq)
608                         r = usrp.tune(self.u, self.subdev[1]._which, self.subdev[1], target_freq)
609                 else:
610                         r = self.u.set_rx_freq(0, target_freq)
611                         f = self.u.rx_freq(0)
612                         if abs(f-target_freq) > 2.0e3:
613                                 r = 0
614                 if r:
615                         self.myform['freq'].set_value(target_freq)         # update displayed value
616                         #
617                         # Make sure calibrator knows our target freq
618                         #
619
620                         # Remember centerfreq---used for doppler calcs
621                         delta = self.centerfreq - target_freq
622                         self.centerfreq = target_freq
623                         self.observing -= delta
624                         self.scope.set_baseband_freq (self.observing)
625
626                         self.myform['baseband'].set_value(r.baseband_freq)
627                         self.myform['ddc'].set_value(r.dxc_freq)
628
629                         return True
630
631                 return False
632
633         def set_decln(self, dec):
634                 self.decln = dec
635                 self.myform['decln'].set_value(dec)             # update displayed value
636
637         def set_gain(self, gain):
638                 self.myform['gain'].set_value(gain)             # update displayed value
639                 self.subdev[0].set_gain(gain)
640                 self.subdev[1].set_gain(gain)
641                 self.gain = gain
642
643         def set_averaging(self, avval):
644                 self.myform['average'].set_value(avval)
645                 self.scope.set_avg_alpha(1.0/(avval))
646                 self.scope.set_average(True)
647                 self.avg_alpha = avval
648
649         def set_integration(self, integval):
650                 if self.setimode == False:
651                         self.integrator.set_taps(1.0/((integval)*(self.bw/2)))
652                 self.myform['integration'].set_value(integval)
653                 self.integ = integval
654
655         #
656         # Timeout function
657         # Used to update LMST display, as well as current
658         #  continuum value
659         #
660         # We also write external data-logging files here
661         #
662         def lmst_timeout(self):
663                 self.locality.date = ephem.now()
664                 if self.setimode == False:
665                  x = self.probe.level()
666                 sidtime = self.locality.sidereal_time()
667                 # LMST
668                 s = str(ephem.hours(sidtime)) + " " + self.sunstate
669                 # Continuum detector value
670                 if self.setimode == False:
671                  sx = "%7.4f" % x
672                  s = s + "\nDet: " + str(sx)
673                 else:
674                  sx = "%2d" % self.hitcounter
675                  s1 = "%2d" % self.s1hitcounter
676                  s2 = "%2d" % self.s2hitcounter
677                  sa = "%4.2f" % self.avgdelta
678                  sy = "%3.1f-%3.1f" % (self.CHIRP_LOWER, self.CHIRP_UPPER)
679                  s = s + "\nHits: " + str(sx) + "\nS1:" + str(s1) + " S2:" + str(s2)
680                  s = s + "\nAv D: " + str(sa) + "\nCh lim: " + str(sy)
681
682                 self.myform['lmst_high'].set_value(s)
683
684                 #
685                 # Write data out to recording files
686                 #
687                 if self.setimode == False:
688                  self.write_continuum_data(x,sidtime)
689                  self.write_spectral_data(self.fft_outbuf,sidtime)
690
691                 else:
692                  self.seti_analysis(self.fft_outbuf,sidtime)
693                  now = time.time()
694                  if ((self.scanning == True) and ((now - self.seti_then) > self.setifreq_timer)):
695                          self.seti_then = now
696                          self.setifreq_current = self.setifreq_current + self.fft_input_rate
697                          if (self.setifreq_current > self.setifreq_upper):
698                                  self.setifreq_current = self.setifreq_lower
699                          self.set_freq(self.setifreq_current)
700                          # Make sure we zero-out the hits array when changing
701                          #       frequency.
702                          self.hits_array[:,:] = 0.0
703                          self.hit_intensities[:,:] = 0.0
704         
705         def other_timeout(self):
706                 if (self.switch_state == 0):
707                         self.switch_state = 1
708                         
709                 elif (self.switch_state == 1):
710                         self.switch_state = 0
711                         
712                 if (self.switch_state == 0):
713                         self.mute.set_n(1)
714                         self.cmute.set_n(int(1.0e9))
715                         
716                 elif (self.switch_state == 1):
717                         self.mute.set_n(int(1.0e9))
718                         self.cmute.set_n(1)
719                         
720                 if (self.ref_fifo != "@@@@"):
721                         self.ref_fifo_file.write(str(self.switch_state)+"\n")
722                         self.ref_fifo_file.flush()
723
724                 self.avg_reference_value = self.cprobe.level()
725                         
726                 #
727                 # Set reference value
728                 #
729                 self.reference_level.set_k(-1.0 * (self.avg_reference_value/self.reference_divisor))
730
731         def fft_outfunc(self,data,l):
732                 self.fft_outbuf=data
733
734         def write_continuum_data(self,data,sidtime):
735         
736                 # Create localtime structure for producing filename
737                 foo = time.localtime()
738                 pfx = self.prefix
739                 filenamestr = "%s/%04d%02d%02d%02d" % (pfx, foo.tm_year, 
740                    foo.tm_mon, foo.tm_mday, foo.tm_hour)
741         
742                 # Open the data file, appending
743                 continuum_file = open (filenamestr+".tpdat","a")
744           
745                 flt = "%6.3f" % data
746                 inter = self.decln
747                 integ = self.integ
748                 fc = self.observing
749                 fc = fc / 1000000
750                 bw = self.bw
751                 bw = bw / 1000000
752                 ga = self.gain
753         
754                 now = time.time()
755         
756                 #
757                 # If time to write full header info (saves storage this way)
758                 #
759                 if (now - self.continuum_then > 20):
760                         self.sun.compute(self.locality)
761                         enow = ephem.now()
762                         sun_insky = "Down"
763                         self.sunstate = "Dn"
764                         if ((self.sun.rise_time < enow) and (enow < self.sun.set_time)):
765                            sun_insky = "Up"
766                            self.sunstate = "Up"
767                         self.continuum_then = now
768                 
769                         continuum_file.write(str(ephem.hours(sidtime))+" "+flt+" Dn="+str(inter)+",")
770                         continuum_file.write("Ti="+str(integ)+",Fc="+str(fc)+",Bw="+str(bw))
771                         continuum_file.write(",Ga="+str(ga)+",Sun="+str(sun_insky)+"\n")
772                 else:
773                         continuum_file.write(str(ephem.hours(sidtime))+" "+flt+"\n")
774         
775                 continuum_file.close()
776                 return(data)
777
778         def write_spectral_data(self,data,sidtime):
779         
780                 now = time.time()
781                 delta = 10
782                         
783                 # If time to write out spectral data
784                 # We don't write this out every time, in order to
785                 #       save disk space.  Since the spectral data are
786                 #       typically heavily averaged, writing this data
787                 #       "once in a while" is OK.
788                 #
789                 if (now - self.spectral_then >= delta):
790                         self.spectral_then = now
791
792                         # Get localtime structure to make filename from
793                         foo = time.localtime()
794                 
795                         pfx = self.prefix
796                         filenamestr = "%s/%04d%02d%02d%02d" % (pfx, foo.tm_year, 
797                            foo.tm_mon, foo.tm_mday, foo.tm_hour)
798         
799                         # Open the file
800                         spectral_file = open (filenamestr+".sdat","a")
801           
802                         # Setup data fields to be written
803                         r = data
804                         inter = self.decln
805                         fc = self.observing
806                         fc = fc / 1000000
807                         bw = self.bw
808                         bw = bw / 1000000
809                         av = self.avg_alpha
810
811                         # Write those fields
812                         spectral_file.write("data:"+str(ephem.hours(sidtime))+" Dn="+str(inter)+",Fc="+str(fc)+",Bw="+str(bw)+",Av="+str(av))
813                         spectral_file.write (" [ ")
814                         for r in data:
815                                 spectral_file.write(" "+str(r))
816
817                         spectral_file.write(" ]\n")
818                         spectral_file.close()
819                         return(data)
820         
821                 return(data)
822
823         def seti_analysis(self,fftbuf,sidtime):
824                 l = len(fftbuf)
825                 x = 0
826                 hits = []
827                 hit_intensities = []
828                 if self.seticounter < self.setitimer:
829                         self.seticounter = self.seticounter + 1
830                         return
831                 else:
832                         self.seticounter = 0
833
834                 # Run through FFT output buffer, computing standard deviation (Sigma)
835                 avg = 0
836                 # First compute average
837                 for i in range(0,l):
838                         avg = avg + fftbuf[i]
839                 avg = avg / l
840
841                 sigma = 0.0
842                 # Then compute standard deviation (Sigma)
843                 for i in range(0,l):
844                         d = fftbuf[i] - avg
845                         sigma = sigma + (d*d)
846
847                 sigma = Numeric.sqrt(sigma/l)
848
849                 #
850                 # Snarfle through the FFT output buffer again, looking for
851                 #        outlying data points
852
853                 start_f = self.observing - (self.fft_input_rate/2)
854                 current_f = start_f
855                 l = len(fftbuf)
856                 f_incr = self.fft_input_rate / l
857                 hit = -1
858
859                 # -nyquist to DC
860                 for i in range(l/2,l):
861                         #
862                         # If current FFT buffer has an item that exceeds the specified
863                         #  sigma
864                         #
865                         if ((fftbuf[i] - avg) > (self.setik * sigma)):
866                                 hits.append(current_f)
867                                 hit_intensities.append(fftbuf[i])
868                         current_f = current_f + f_incr
869
870                 # DC to nyquist
871                 for i in range(0,l/2):
872                         #
873                         # If current FFT buffer has an item that exceeds the specified
874                         #  sigma
875                         #
876                         if ((fftbuf[i] - avg) > (self.setik * sigma)):
877                                 hits.append(current_f)
878                                 hit_intensities.append(fftbuf[i])
879                         current_f = current_f + f_incr
880
881                 # No hits
882                 if (len(hits) <= 0):
883                         return
884
885
886                 #
887                 # OK, so we have some hits in the FFT buffer
888                 #       They'll have a rather substantial gauntlet to run before
889                 #       being declared a real "hit"
890                 #
891
892                 # Update stats
893                 self.s1hitcounter = self.s1hitcounter + len(hits)
894
895                 # Weed out buffers with an excessive number of
896                 #       signals above Sigma
897                 if (len(hits) > self.nhits):
898                         return
899
900
901                 # Weed out FFT buffers with apparent multiple narrowband signals
902                 #       separated significantly in frequency.  This means that a
903                 #       single signal spanning multiple bins is OK, but a buffer that
904                 #       has multiple, apparently-separate, signals isn't OK.
905                 #
906                 last = hits[0]
907                 ns2 = 1
908                 for i in range(1,len(hits)):
909                         if ((hits[i] - last) > (f_incr*3.0)):
910                                 return
911                         last = hits[i]
912                         ns2 = ns2 + 1
913
914                 self.s2hitcounter = self.s2hitcounter + ns2
915
916                 #
917                 # Run through all available hit buffers, computing difference between
918                 #       frequencies found there, if they're all within the chirp limits
919                 #       declare a good hit
920                 #
921                 good_hit = False
922                 f_ds = Numeric.zeros(self.nhitlines, Numeric.Float64)
923                 avg_delta = 0
924                 k = 0
925                 for i in range(0,min(len(hits),len(self.hits_array[:,0]))):
926                         f_ds[0] = abs(self.hits_array[i,0] - hits[i])
927                         for j in range(1,len(f_ds)):
928                            f_ds[j] = abs(self.hits_array[i,j] - self.hits_array[i,0])
929                            avg_delta = avg_delta + f_ds[j]
930                            k = k + 1
931
932                         if (self.seti_isahit (f_ds)):
933                                 good_hit = True
934                                 self.hitcounter = self.hitcounter + 1
935                                 break
936
937                 if (avg_delta/k < (self.seti_fft_bandwidth/2)):
938                         self.avgdelta = avg_delta / k
939
940                 # Save 'n shuffle hits
941                 #  Old hit buffers percolate through the hit buffers
942                 #  (there are self.nhitlines of these buffers)
943                 #  and then drop off the end
944                 #  A consequence is that while the nhitlines buffers are filling,
945                 #  you can get some absurd values for self.avgdelta, because some
946                 #  of the buffers are full of zeros
947                 for i in range(self.nhitlines,1):
948                         self.hits_array[:,i] = self.hits_array[:,i-1]
949                         self.hit_intensities[:,i] = self.hit_intensities[:,i-1]
950
951                 for i in range(0,len(hits)):
952                         self.hits_array[i,0] = hits[i]
953                         self.hit_intensities[i,0] = hit_intensities[i]
954
955                 # Finally, write the hits/intensities buffer
956                 if (good_hit):
957                         self.write_hits(sidtime)
958
959                 return
960
961         def seti_isahit(self,fdiffs):
962                 truecount = 0
963
964                 for i in range(0,len(fdiffs)):
965                         if (fdiffs[i] >= self.CHIRP_LOWER and fdiffs[i] <= self.CHIRP_UPPER):
966                                 truecount = truecount + 1
967
968                 if truecount == len(fdiffs):
969                         return (True)
970                 else:
971                         return (False)
972
973         def write_hits(self,sidtime):
974                 # Create localtime structure for producing filename
975                 foo = time.localtime()
976                 pfx = self.prefix
977                 filenamestr = "%s/%04d%02d%02d%02d" % (pfx, foo.tm_year, 
978                    foo.tm_mon, foo.tm_mday, foo.tm_hour)
979         
980                 # Open the data file, appending
981                 hits_file = open (filenamestr+".seti","a")
982
983                 # Write sidtime first
984                 hits_file.write(str(ephem.hours(sidtime))+" "+str(self.decln)+" ")
985
986                 #
987                 # Then write the hits/hit intensities buffers with enough
988                 #       "syntax" to allow parsing by external (not yet written!)
989                 #       "stuff".
990                 #
991                 for i in range(0,self.nhitlines):
992                         hits_file.write(" ")
993                         for j in range(0,self.nhits):
994                                 hits_file.write(str(self.hits_array[j,i])+":")
995                                 hits_file.write(str(self.hit_intensities[j,i])+",")
996                 hits_file.write("\n")
997                 hits_file.close()
998                 return
999
1000         def xydfunc(self,xyv):
1001                 if self.setimode == True:
1002                         return
1003                 magn = int(Numeric.log10(self.observing))
1004                 if (magn == 6 or magn == 7 or magn == 8):
1005                         magn = 6
1006                 dfreq = xyv[0] * pow(10.0,magn)
1007                 ratio = self.observing / dfreq
1008                 vs = 1.0 - ratio
1009                 vs *= 299792.0
1010                 if magn >= 9:
1011                    xhz = "Ghz"
1012                 elif magn >= 6:
1013                    xhz = "Mhz"
1014                 elif magn <= 5:
1015                    xhz =  "Khz"
1016                 s = "%.6f%s\n%.3fdB" % (xyv[0], xhz, xyv[1])
1017                 s2 = "\n%.3fkm/s" % vs
1018                 self.myform['spec_data'].set_value(s+s2)
1019
1020         def xydfunc_waterfall(self,pos):
1021                 lower = self.observing - (self.seti_fft_bandwidth / 2)
1022                 upper = self.observing + (self.seti_fft_bandwidth / 2)
1023                 binwidth = self.seti_fft_bandwidth / 1024
1024                 s = "%.6fMHz" % ((lower + (pos.x*binwidth)) / 1.0e6)
1025                 self.myform['spec_data'].set_value(s)
1026
1027         def toggle_cal(self):
1028                 if (self.calstate == True):
1029                   self.calstate = False
1030                   self.u.write_io(0,0,(1<<15))
1031                   self.calibrator.SetLabel("Calibration Source: Off")
1032                 else:
1033                   self.calstate = True
1034                   self.u.write_io(0,(1<<15),(1<<15))
1035                   self.calibrator.SetLabel("Calibration Source: On")
1036
1037         def toggle_annotation(self):
1038                 if (self.annotate_state == True):
1039                   self.annotate_state = False
1040                   self.annotation.SetLabel("Annotation: Off")
1041                 else:
1042                   self.annotate_state = True
1043                   self.annotation.SetLabel("Annotation: On")
1044         #
1045         # Turn scanning on/off
1046         # Called-back by "Recording" button
1047         #
1048         def toggle_scanning(self):
1049                 # Current scanning?      Flip state
1050                 if (self.scanning == True):
1051                   self.scanning = False
1052                   self.scan_control.SetLabel("Scan: Off")
1053                 # Not scanning
1054                 else:
1055                   self.scanning = True
1056                   self.scan_control.SetLabel("Scan: On ")
1057
1058         def set_pd_offset(self,offs):
1059                  self.myform['offset'].set_value(offs)
1060                  self.calib_offset=offs
1061                  x = self.calib_coeff / 100.0
1062                  self.cal_offs.set_k(offs*(x*8000))
1063
1064         def set_pd_gain(self,gain):
1065                  self.myform['dcgain'].set_value(gain)
1066                  self.cal_mult.set_k(gain*0.01)
1067                  self.calib_coeff = gain
1068                  x = gain/100.0
1069                  self.cal_offs.set_k(self.calib_offset*(x*8000))
1070
1071         def compute_notch_taps(self,notchlist):
1072                  NOTCH_TAPS = 256
1073                  tmptaps = Numeric.zeros(NOTCH_TAPS,Numeric.Complex64)
1074                  binwidth = self.bw / NOTCH_TAPS
1075  
1076                  for i in range(0,NOTCH_TAPS):
1077                          tmptaps[i] = complex(1.0,0.0)
1078  
1079                  for i in notchlist:
1080                          diff = i - self.observing
1081                          if i == 0:
1082                                  break
1083                          if (diff > 0):
1084                                  idx = diff / binwidth
1085                                  idx = int(idx)
1086                                  if (idx < 0 or idx > (NOTCH_TAPS/2)):
1087                                          break
1088                                  tmptaps[idx] = complex(0.0, 0.0)
1089
1090                          if (diff < 0):
1091                                  idx = -diff / binwidth
1092                                  idx = (NOTCH_TAPS/2) - idx
1093                                  idx = int(idx+(NOTCH_TAPS/2))
1094                                  if (idx < 0 or idx > (NOTCH_TAPS)):
1095                                          break
1096                                  tmptaps[idx] = complex(0.0, 0.0)
1097
1098                  self.notch_taps = numpy.fft.ifft(tmptaps)
1099         
1100         #
1101         # Setup common pieces of radiometer mode
1102         #
1103         def setup_radiometer_common(self):
1104                 # The IIR integration filter for post-detection
1105                 self.integrator = gr.single_pole_iir_filter_ff(1.0)
1106                 self.integrator.set_taps (1.0/self.bw)
1107
1108                 # Signal probe
1109                 self.probe = gr.probe_signal_f()
1110
1111                 #
1112                 # Continuum calibration stuff
1113                 #
1114                 x = self.calib_coeff/100.0
1115                 self.cal_mult = gr.multiply_const_ff(self.calib_coeff/100.0)
1116                 self.cal_offs = gr.add_const_ff(self.calib_offset*(x*8000))
1117                 
1118                 #
1119                 # Mega decimator after IIR filter
1120                 #
1121                 if (self.switch_mode == False):
1122                         self.keepn = gr.keep_one_in_n(gr.sizeof_float, self.bw)
1123                 else:
1124                         self.keepn = gr.keep_one_in_n(gr.sizeof_float, int(self.bw/2))
1125                 
1126                 #
1127                 # For the Dicke-switching scheme
1128                 #
1129                 self.switch = gr.multiply_const_ff(1.0)
1130                 
1131                 #
1132                 if (self.switch_mode == True):
1133                         self.vector = gr.vector_sink_f()
1134                         self.swkeep = gr.keep_one_in_n(gr.sizeof_float, int(self.bw/3))
1135                         self.mute = gr.keep_one_in_n(gr.sizeof_float, 1)
1136                         self.cmute = gr.keep_one_in_n(gr.sizeof_float, int(1.0e9))
1137                         self.cintegrator = gr.single_pole_iir_filter_ff(1.0/(self.bw/2))        
1138                         self.cprobe = gr.probe_signal_f()
1139                 else:
1140                         self.mute = gr.multiply_const_ff(1.0)
1141                         
1142                         
1143                 self.avg_reference_value = 0.0
1144                 self.reference_level = gr.add_const_ff(0.0)
1145                 
1146         #
1147         # Setup ordinary single-channel radiometer mode
1148         #        
1149         def setup_normal(self, setimode):
1150                 
1151                 self.head = self.u
1152                 self.shead = self.u
1153                 
1154                 if setimode == False:
1155                         self.detector = gr.complex_to_mag_squared()
1156                         self.setup_radiometer_common()  
1157                         self.connect(self.shead, self.scope)
1158
1159                         self.connect(self.head, self.detector, self.mute, self.reference_level,
1160                                 self.integrator, self.keepn, self.cal_mult, self.cal_offs, self.chart)
1161                                 
1162                         self.connect(self.cal_offs, self.probe)
1163                         
1164                         #
1165                         # Add a side-chain detector chain, with a different integrator, for sampling
1166                         #   The reference channel data
1167                         # This is used to derive the offset value for self.reference_level, used above
1168                         #
1169                         if (self.switch_mode == True):          
1170                                 self.connect(self.detector, self.cmute, self.cintegrator, self.swkeep, self.cprobe)
1171                         
1172                 return
1173         
1174         #
1175         # Setup dual-channel (two antenna, usual orthogonal polarity probes in the same waveguide)
1176         #
1177         def setup_dual(self, setimode):
1178                 
1179                 self.di = gr.deinterleave(gr.sizeof_gr_complex)
1180                 self.addchans = gr.add_cc ()
1181                 self.detector = gr.add_ff ()
1182                 self.h_power = gr.complex_to_mag_squared()
1183                 self.v_power = gr.complex_to_mag_squared()
1184                 self.connect (self.u, self.di)
1185                 
1186                 #
1187                 # For spectral, adding the two channels works, assuming no gross
1188                 #       phase or amplitude error
1189                 self.connect ((self.di, 0), (self.addchans, 0))
1190                 self.connect ((self.di, 1), (self.addchans, 1))
1191                 
1192                 #
1193                 # Connect heads of spectral and total-power chains
1194                 #
1195                 self.head = self.di
1196                 self.shead = self.addchans
1197                 
1198                 if (setimode == False):
1199                         
1200                         self.setup_radiometer_common()
1201                 
1202                         #
1203                         # For dual-polarization mode, we compute the sum of the
1204                         #       powers on each channel, after they've been detected
1205                         #
1206                         self.detector = gr.add_ff()
1207                         
1208                         #
1209                         # In dual-polarization mode, we compute things a little differently
1210                         # In effect, we have two radiometer chains, terminating in an adder
1211                         #
1212                         self.connect((self.di, 0), self.h_power)
1213                         self.connect((self.di, 1), self.v_power)
1214                         self.connect(self.h_power, (self.detector, 0))
1215                         self.connect(self.v_power, (self.detector, 1))
1216                         self.connect(self.detector, self.mute, self.reference_level,
1217                                 self.integrator, self.keepn, self.cal_mult, self.cal_offs, self.chart)
1218                         self.connect(self.cal_offs, self.probe)
1219                         self.connect(self.shead, self.scope)
1220                         
1221                         #
1222                         # Add a side-chain detector chain, with a different integrator, for sampling
1223                         #   The reference channel data
1224                         # This is used to derive the offset value for self.reference_level, used above
1225                         #
1226                         if (self.switch_mode == True):
1227                                 self.connect(self.detector, self.cmute, self.cintegrator, self.swkeep, self.cprobe)                     
1228                 return
1229         
1230         #
1231         # Setup correlating interferometer mode
1232         #
1233         def setup_interferometer(self, setimode):
1234                 self.setup_radiometer_common()
1235                 
1236                 self.di = gr.deinterleave(gr.sizeof_gr_complex)
1237                 self.connect (self.u, self.di)
1238                 self.corr = gr.multiply_cc()
1239                 self.c2f = gr.complex_to_float()
1240                 
1241                 self.shead = (self.di, 0)
1242                 
1243                 # Channel 0 to multiply port 0
1244                 # Channel 1 to multiply port 1
1245                 self.connect((self.di, 0), (self.corr, 0))
1246                 self.connect((self.di, 1), (self.corr, 1))
1247                 
1248                 #
1249                 # Multiplier (correlator) to complex-to-float, followed by integrator, etc
1250                 #
1251                 self.connect(self.corr, self.c2f, self.switch, self.integrator, self.keepn, self.cal_mult, self.cal_offs, self.chart)
1252                 
1253                 #
1254                 # FFT scope gets only 1 channel
1255                 #  FIX THIS, by cross-correlating the *outputs* of two different FFTs, then display
1256                 #  Funky!
1257                 #
1258                 self.connect(self.shead, self.scope)
1259                 
1260                 #
1261                 # Output of correlator/integrator chain to probe
1262                 #
1263                 self.connect(self.cal_offs, self.probe)
1264                 
1265                 return
1266         
1267         #
1268         # Setup SETI mode
1269         #
1270         def setup_seti(self):
1271                 self.connect (self.shead, self.fft_bandpass, self.scope)
1272                 return
1273
1274                 
1275
1276 def main ():
1277         app = stdgui2.stdapp(app_flow_graph, "RADIO ASTRONOMY SPECTRAL/CONTINUUM RECEIVER: $Revision$", nstatus=1)
1278         app.MainLoop()
1279
1280 if __name__ == '__main__':
1281         main ()