3 # Copyright 2004,2005 Free Software Foundation, Inc.
5 # This file is part of GNU Radio
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 2, or (at your option)
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.
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.
23 from gnuradio import gr, gru
24 from gnuradio import usrp
26 from gnuradio import eng_notation
27 from gnuradio.eng_option import eng_option
28 from gnuradio.wxgui import stdgui, ra_fftsink, ra_stripchartsink, ra_waterfallsink, form, slider
29 from optparse import OptionParser
37 class continuum_calibration(gr.feval_dd):
39 str = globals()["calibration_codelet"]
43 class app_flow_graph(stdgui.gui_flow_graph):
44 def __init__(self, frame, panel, vbox, argv):
45 stdgui.gui_flow_graph.__init__(self)
50 parser = OptionParser(option_class=eng_option)
51 parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=(0, 0),
52 help="select USRP Rx side A or B (default=A)")
53 parser.add_option("-d", "--decim", type="int", default=16,
54 help="set fgpa decimation rate to DECIM [default=%default]")
55 parser.add_option("-f", "--freq", type="eng_float", default=None,
56 help="set frequency to FREQ", metavar="FREQ")
57 parser.add_option("-a", "--avg", type="eng_float", default=1.0,
58 help="set spectral averaging alpha")
59 parser.add_option("-i", "--integ", type="eng_float", default=1.0,
60 help="set integration time")
61 parser.add_option("-g", "--gain", type="eng_float", default=None,
62 help="set gain in dB (default is midpoint)")
63 parser.add_option("-l", "--reflevel", type="eng_float", default=30.0,
64 help="Set Total power reference level")
65 parser.add_option("-y", "--division", type="eng_float", default=0.5,
66 help="Set Total power Y division size")
67 parser.add_option("-e", "--longitude", type="eng_float", default=-76.02, help="Set Observer Longitude")
68 parser.add_option("-c", "--latitude", type="eng_float", default=44.85, help="Set Observer Latitude")
69 parser.add_option("-o", "--observing", type="eng_float", default=0.0,
70 help="Set observing frequency")
71 parser.add_option("-x", "--ylabel", default="dB", help="Y axis label")
72 parser.add_option("-z", "--divbase", type="eng_float", default=0.025, help="Y Division increment base")
73 parser.add_option("-v", "--stripsize", type="eng_float", default=2400, help="Size of stripchart, in 2Hz samples")
74 parser.add_option("-F", "--fft_size", type="eng_float", default=1024, help="Size of FFT")
76 parser.add_option("-N", "--decln", type="eng_float", default=999.99, help="Observing declination")
77 parser.add_option("-X", "--prefix", default="./")
78 parser.add_option("-M", "--fft_rate", type="eng_float", default=8.0, help="FFT Rate")
79 parser.add_option("-A", "--calib_coeff", type="eng_float", default=1.0, help="Calibration coefficient")
80 parser.add_option("-B", "--calib_offset", type="eng_float", default=0.0, help="Calibration coefficient")
81 parser.add_option("-W", "--waterfall", action="store_true", default=False, help="Use Waterfall FFT display")
82 parser.add_option("-S", "--setimode", action="store_true", default=False, help="Enable SETI processing of spectral data")
83 parser.add_option("-K", "--setik", type="eng_float", default=1.5, help="K value for SETI analysis")
84 (options, args) = parser.parse_args()
89 self.show_debug_info = True
91 # Pick up waterfall option
92 self.waterfall = options.waterfall
95 self.setimode = options.setimode
97 self.setik = options.setik
98 # Because we force the input rate to be 250Khz, 12.5Khz is
99 # exactly 1/20th of this, which makes building decimators
101 # This also allows larger FFTs to be used without totally-gobbling
102 # CPU. With an FFT size of 16384, for example, this bandwidth
103 # yields a binwidth of 0.762Hz, and plenty of CPU left over
104 # for other things, like the SETI analysis code.
106 self.seti_fft_bandwidth = 12500
109 binwidth = self.seti_fft_bandwidth / options.fft_size
111 # Use binwidth, and knowledge of likely chirp rates to set reasonable
112 # values for SETI analysis code. We assume that SETI signals will
113 # chirp at somewhere between 0.10Hz/sec and 0.25Hz/sec.
115 # upper_limit is the "worst case"--that is, the case for which we have
116 # wait the longest to actually see any drift, due to the quantizing
118 upper_limit = binwidth / 0.10
119 self.setitimer = int(upper_limit * 2.00)
121 # Calculate the CHIRP values based on Hz/sec
122 self.CHIRP_LOWER = 0.10 * self.setitimer
123 self.CHIRP_UPPER = 0.25 * self.setitimer
125 # Reset hit counter to 0
127 # We scan through 1Mhz of bandwidth around the chosen center freq
128 self.seti_freq_range = 1.0e6
129 # Calculate lower edge
130 self.setifreq_lower = options.freq - (self.seti_freq_range/2)
131 self.setifreq_current = options.freq
132 # Calculate upper edge
133 self.setifreq_upper = options.freq + (self.seti_freq_range/2)
135 # We change center frequencies every 10 self.setitimer intervals
136 self.setifreq_timer = self.setitimer * 10
138 # Create actual timer
139 self.seti_then = time.time()
141 # The hits recording array
143 self.hits_array = Numeric.zeros((self.nhits,3), Numeric.Float64)
145 # Calibration coefficient and offset
146 self.calib_coeff = options.calib_coeff
147 self.calib_offset = options.calib_offset
149 self.integ = options.integ
150 self.avg_alpha = options.avg
151 self.gain = options.gain
152 self.decln = options.decln
154 # Set initial values for datalogging timed-output
155 self.continuum_then = time.time()
156 self.spectral_then = time.time()
161 # If SETI mode, we always run at maximum USRP decimation
166 self.u = usrp.source_c(decim_rate=options.decim)
167 self.u.set_mux(usrp.determine_rx_mux_value(self.u, options.rx_subdev_spec))
168 self.cardtype = self.u.daughterboard_id(0)
169 # Set initial declination
170 self.decln = options.decln
172 # determine the daughterboard subdevice we're using
173 self.subdev = usrp.selected_subdev(self.u, options.rx_subdev_spec)
175 input_rate = self.u.adc_freq() / self.u.decim_rate()
178 # Set prefix for data files
180 self.prefix = options.prefix
183 # The lower this number, the fewer sample frames are dropped
184 # in computing the FFT. A sampled approach is taken to
185 # computing the FFT of the incoming data, which reduces
186 # sensitivity. Increasing sensitivity inreases CPU loading.
188 self.fft_rate = options.fft_rate
190 self.fft_size = options.fft_size
192 # This buffer is used to remember the most-recent FFT display
193 # values. Used later by self.write_spectral_data() to write
194 # spectral data to datalogging files, and by the SETI analysis
197 self.fft_outbuf = Numeric.zeros(options.fft_size, Numeric.Float64)
200 # If SETI mode, only look at seti_fft_bandwidth (currently 12.5Khz)
204 self.fft_input_rate = self.seti_fft_bandwidth
207 # Build a decimating bandpass filter
209 self.fft_input_taps = gr.firdes.complex_band_pass (1.0,
211 -(int(self.fft_input_rate/2)), int(self.fft_input_rate/2), 200,
212 gr.firdes.WIN_HAMMING, 0)
215 # Compute required decimation factor
217 decimation = int(input_rate/self.fft_input_rate)
218 self.fft_bandpass = gr.fir_filter_ccc (decimation,
221 self.fft_input_rate = input_rate
224 if self.waterfall == False:
225 self.scope = ra_fftsink.ra_fft_sink_c (self, panel,
226 fft_size=int(self.fft_size), sample_rate=self.fft_input_rate,
227 fft_rate=int(self.fft_rate), title="Spectral",
228 ofunc=self.fft_outfunc, xydfunc=self.xydfunc)
230 self.scope = ra_waterfallsink.ra_waterfallsink_c (self, panel,
231 fft_size=int(self.fft_size), sample_rate=self.fft_input_rate,
232 fft_rate=int(self.fft_rate), title="Spectral", ofunc=self.fft_outfunc, xydfunc=self.xydfunc)
234 # Set up ephemeris data
235 self.locality = ephem.Observer()
236 self.locality.long = str(options.longitude)
237 self.locality.lat = str(options.latitude)
239 # Set up stripchart display
240 self.stripsize = int(options.stripsize)
241 self.chart = ra_stripchartsink.stripchart_sink_f (self, panel,
242 stripsize=self.stripsize,
244 xlabel="LMST Offset (Seconds)",
245 scaling=1.0, ylabel=options.ylabel,
246 divbase=options.divbase)
248 # Set center frequency
249 self.centerfreq = options.freq
251 # Set observing frequency (might be different from actual programmed
253 if options.observing == 0.0:
254 self.observing = options.freq
256 self.observing = options.observing
260 # We setup the first two integrators to produce a fixed integration
261 # Down to 1Hz, with output at 1 samples/sec
264 # Second stage runs on decimated output of first
267 # Create taps for first integrator
273 # Create taps for second integrator
280 # The 3rd integrator is variable, and user selectable at runtime
281 # This integrator doesn't decimate, but is used to set the
282 # final integration time based on the constant 1Hz input samples
283 # The strip chart is fed at a constant 1Hz rate as a result
287 # Call constructors for receive chains
290 # The three integrators--two FIR filters, and an IIR final filter
291 self.integrator1 = gr.fir_filter_fff (N, tapsN)
292 self.integrator2 = gr.fir_filter_fff (M, tapsM)
293 self.integrator3 = gr.single_pole_iir_filter_ff(1.0)
295 # Split complex USRP stream into a pair of floats
296 self.splitter = gr.complex_to_float (1);
298 # I squarer (detector)
299 self.multI = gr.multiply_ff();
301 # Q squarer (detector)
302 self.multQ = gr.multiply_ff();
304 # Adding squared I and Q to produce instantaneous signal power
305 self.adder = gr.add_ff();
308 self.probe = gr.probe_signal_f();
311 # Continuum calibration stuff
313 self.cal_mult = gr.multiply_const_ff(self.calib_coeff);
314 self.cal_offs = gr.add_const_ff(self.calib_offset);
316 #self.cal_eqn = continuum_calibration();
319 # Start connecting configured modules in the receive chain
322 # The scope--handle SETI mode
323 if (self.setimode == False):
324 self.connect(self.u, self.scope)
326 self.connect(self.u, self.fft_bandpass, self.scope)
329 # The head of the continuum chain
331 self.connect(self.u, self.splitter)
333 # Connect splitter outputs to multipliers
335 self.connect((self.splitter, 0), (self.multI,0))
336 self.connect((self.splitter, 0), (self.multI,1))
339 self.connect((self.splitter, 1), (self.multQ,0))
340 self.connect((self.splitter, 1), (self.multQ,1))
342 # Then sum the squares
343 self.connect(self.multI, (self.adder,0))
344 self.connect(self.multQ, (self.adder,1))
346 # Connect adder output to two-stages of FIR integrator
347 # followed by a single stage IIR integrator, and
349 self.connect(self.adder, self.integrator1,
350 self.integrator2, self.integrator3, self.cal_mult,
351 self.cal_offs, self.chart)
353 # Connect calibrator to probe
354 # SPECIAL NOTE: I'm setting the ground work here
355 # for completely changing the way local_calibrator
356 # works, including removing some horrible kludges for
358 # But for now, self.probe() will be used to display the
359 # current instantaneous integrated detector value
360 self.connect(self.cal_offs, self.probe)
362 self._build_gui(vbox)
364 # Make GUI agree with command-line
365 self.integ = options.integ
366 self.myform['integration'].set_value(int(options.integ))
367 self.myform['average'].set_value(int(options.avg))
369 # Make integrator agree with command line
370 self.set_integration(int(options.integ))
372 self.avg_alpha = options.avg
374 # Make spectral averager agree with command line
375 if options.avg != 1.0:
376 self.scope.set_avg_alpha(float(1.0/options.avg))
377 self.scope.set_average(True)
380 self.chart.set_y_per_div(options.division)
382 # Set reference(MAX) level
383 self.chart.set_ref_level(options.reflevel)
387 if options.gain is None:
388 # if no gain was specified, use the mid-point in dB
389 g = self.subdev.gain_range()
390 options.gain = float(g[0]+g[1])/2
392 if options.freq is None:
393 # if no freq was specified, use the mid-point
394 r = self.subdev.freq_range()
395 options.freq = float(r[0]+r[1])/2
397 # Set the initial gain control
398 self.set_gain(options.gain)
400 if not(self.set_freq(options.freq)):
401 self._set_status_msg("Failed to set initial frequency")
404 self.set_decln (self.decln)
407 # RF hardware information
408 self.myform['decim'].set_value(self.u.decim_rate())
409 self.myform['fs@usb'].set_value(self.u.adc_freq() / self.u.decim_rate())
410 self.myform['dbname'].set_value(self.subdev.name())
412 # Set analog baseband filtering, if DBS_RX
413 if self.cardtype == usrp_dbid.DBS_RX:
414 lbw = (self.u.adc_freq() / self.u.decim_rate()) / 2
417 self.subdev.set_bw(lbw)
419 # Start the timer for the LMST display and datalogging
420 self.lmst_timer.Start(1000)
423 def _set_status_msg(self, msg):
424 self.frame.GetStatusBar().SetStatusText(msg, 0)
426 def _build_gui(self, vbox):
428 def _form_set_freq(kv):
429 # Adjust current SETI frequency, and limits
430 self.setifreq_lower = kv['freq'] - (self.seti_freq_range/2)
431 self.setifreq_current = kv['freq']
432 self.setifreq_upper = kv['freq'] + (self.seti_freq_range/2)
434 # Reset SETI analysis timer
435 self.seti_then = time.time()
436 # Zero-out hits array when changing frequency
437 self.hits_array[:,:] = 0.0
439 return self.set_freq(kv['freq'])
441 def _form_set_decln(kv):
442 return self.set_decln(kv['decln'])
444 # Position the FFT display
445 vbox.Add(self.scope.win, 15, wx.EXPAND)
447 # Position the Total-power stripchart
448 vbox.Add(self.chart.win, 15, wx.EXPAND)
450 # add control area at the bottom
451 self.myform = myform = form.form()
452 hbox = wx.BoxSizer(wx.HORIZONTAL)
453 hbox.Add((7,0), 0, wx.EXPAND)
454 vbox1 = wx.BoxSizer(wx.VERTICAL)
455 myform['freq'] = form.float_field(
456 parent=self.panel, sizer=vbox1, label="Center freq", weight=1,
457 callback=myform.check_input_and_call(_form_set_freq, self._set_status_msg))
459 vbox1.Add((4,0), 0, 0)
461 myform['lmst_high'] = form.static_text_field(
462 parent=self.panel, sizer=vbox1, label="Current LMST", weight=1)
463 vbox1.Add((4,0), 0, 0)
465 myform['spec_data'] = form.static_text_field(
466 parent=self.panel, sizer=vbox1, label="Spectral Cursor", weight=1)
467 vbox1.Add((4,0), 0, 0)
469 vbox2 = wx.BoxSizer(wx.VERTICAL)
470 g = self.subdev.gain_range()
471 myform['gain'] = form.slider_field(parent=self.panel, sizer=vbox2, label="RF Gain",
473 min=int(g[0]), max=int(g[1]),
474 callback=self.set_gain)
476 vbox2.Add((4,0), 0, 0)
477 myform['average'] = form.slider_field(parent=self.panel, sizer=vbox2,
478 label="Spectral Averaging (FFT frames)", weight=1, min=1, max=2000, callback=self.set_averaging)
480 vbox2.Add((4,0), 0, 0)
482 myform['integration'] = form.slider_field(parent=self.panel, sizer=vbox2,
483 label="Continuum Integration Time (sec)", weight=1, min=1, max=180, callback=self.set_integration)
485 vbox2.Add((4,0), 0, 0)
486 myform['decln'] = form.float_field(
487 parent=self.panel, sizer=vbox2, label="Current Declination", weight=1,
488 callback=myform.check_input_and_call(_form_set_decln))
489 vbox2.Add((4,0), 0, 0)
491 buttonbox = wx.BoxSizer(wx.HORIZONTAL)
492 vbox.Add(buttonbox, 0, wx.CENTER)
493 hbox.Add(vbox1, 0, 0)
494 hbox.Add(vbox2, wx.ALIGN_RIGHT, 0)
495 vbox.Add(hbox, 0, wx.EXPAND)
497 self._build_subpanel(vbox)
499 self.lmst_timer = wx.PyTimer(self.lmst_timeout)
503 def _build_subpanel(self, vbox_arg):
504 # build a secondary information panel (sometimes hidden)
506 # FIXME figure out how to have this be a subpanel that is always
507 # created, but has its visibility controlled by foo.Show(True/False)
509 if not(self.show_debug_info):
516 #panel = wx.Panel(self.panel, -1)
517 #vbox = wx.BoxSizer(wx.VERTICAL)
519 hbox = wx.BoxSizer(wx.HORIZONTAL)
521 myform['decim'] = form.static_float_field(
522 parent=panel, sizer=hbox, label="Decim")
525 myform['fs@usb'] = form.static_float_field(
526 parent=panel, sizer=hbox, label="Fs@USB")
529 myform['dbname'] = form.static_text_field(
530 parent=panel, sizer=hbox)
533 myform['baseband'] = form.static_float_field(
534 parent=panel, sizer=hbox, label="Analog BB")
537 myform['ddc'] = form.static_float_field(
538 parent=panel, sizer=hbox, label="DDC")
541 vbox.Add(hbox, 0, wx.EXPAND)
545 def set_freq(self, target_freq):
547 Set the center frequency we're interested in.
549 @param target_freq: frequency in Hz
552 Tuning is a two step process. First we ask the front-end to
553 tune as close to the desired frequency as it can. Then we use
554 the result of that operation and our target_frequency to
555 determine the value for the digital down converter.
558 # Everything except BASIC_RX should support usrp.tune()
560 if not (self.cardtype == usrp_dbid.BASIC_RX):
561 r = usrp.tune(self.u, 0, self.subdev, target_freq)
563 r = self.u.set_rx_freq(0, target_freq)
564 f = self.u.rx_freq(0)
565 if abs(f-target_freq) > 2.0e3:
568 self.myform['freq'].set_value(target_freq) # update displayed value
570 # Make sure calibrator knows our target freq
573 # Remember centerfreq---used for doppler calcs
574 delta = self.centerfreq - target_freq
575 self.centerfreq = target_freq
576 self.observing -= delta
577 self.scope.set_baseband_freq (self.observing)
579 self.myform['baseband'].set_value(r.baseband_freq)
580 self.myform['ddc'].set_value(r.dxc_freq)
586 def set_decln(self, dec):
588 self.myform['decln'].set_value(dec) # update displayed value
590 def set_gain(self, gain):
591 self.myform['gain'].set_value(gain) # update displayed value
592 self.subdev.set_gain(gain)
595 def set_averaging(self, avval):
596 self.myform['average'].set_value(avval)
597 self.scope.set_avg_alpha(1.0/(avval))
598 self.scope.set_average(True)
599 self.avg_alpha = avval
601 def set_integration(self, integval):
602 self.integrator3.set_taps(1.0/integval)
603 self.myform['integration'].set_value(integval)
604 self.integ = integval
608 # Used to update LMST display, as well as current
611 # We also write external data-logging files here
613 def lmst_timeout(self):
614 self.locality.date = ephem.now()
615 x = self.probe.level()
616 sidtime = self.locality.sidereal_time()
618 s = str(ephem.hours(sidtime))
619 # Continuum detector value
621 s = s + "\nDet: " + str(sx)
622 sx = "%2d" % self.hitcounter
623 sy = "%3.1f/%3.1f" % (self.CHIRP_LOWER, self.CHIRP_UPPER)
624 s = s + "\nH: " + str(sx) + " C: " + str(sy)
625 self.myform['lmst_high'].set_value(s)
628 # Write data out to recording files
630 if self.setimode == False:
631 self.write_continuum_data(x,sidtime)
632 self.write_spectral_data(self.fft_outbuf,sidtime)
634 if self.setimode == True:
635 self.seti_analysis(self.fft_outbuf,sidtime)
637 if ((now - self.seti_then) > self.setifreq_timer):
639 self.setifreq_current = self.setifreq_current + self.fft_input_rate
640 if (self.setifreq_current > self.setifreq_upper):
641 self.setifreq_current = self.setifreq_lower
642 self.set_freq(self.setifreq_current)
643 # Make sure we zero-out the hits array when changing
645 self.hits_array[:,:] = 0.0
647 def fft_outfunc(self,data,l):
650 def write_continuum_data(self,data,sidtime):
652 # Create localtime structure for producing filename
653 foo = time.localtime()
655 filenamestr = "%s/%04d%02d%02d%02d" % (pfx, foo.tm_year,
656 foo.tm_mon, foo.tm_mday, foo.tm_hour)
658 # Open the data file, appending
659 continuum_file = open (filenamestr+".tpdat","a")
673 # If time to write full header info (saves storage this way)
675 if (now - self.continuum_then > 20):
676 self.continuum_then = now
678 continuum_file.write(str(ephem.hours(sidtime))+" "+flt+" Dn="+str(inter)+",")
679 continuum_file.write("Ti="+str(integ)+",Fc="+str(fc)+",Bw="+str(bw))
680 continuum_file.write(",Ga="+str(ga)+"\n")
682 continuum_file.write(str(ephem.hours(sidtime))+" "+flt+"\n")
684 continuum_file.close()
687 def write_spectral_data(self,data,sidtime):
692 # If time to write out spectral data
693 # We don't write this out every time, in order to
694 # save disk space. Since the spectral data are
695 # typically heavily averaged, writing this data
696 # "once in a while" is OK.
698 if (now - self.spectral_then >= delta):
699 self.spectral_then = now
701 # Get localtime structure to make filename from
702 foo = time.localtime()
705 filenamestr = "%s/%04d%02d%02d%02d" % (pfx, foo.tm_year,
706 foo.tm_mon, foo.tm_mday, foo.tm_hour)
709 spectral_file = open (filenamestr+".sdat","a")
711 # Setup data fields to be written
721 spectral_file.write("data:"+str(ephem.hours(sidtime))+" Dn="+str(inter)+",Fc="+str(fc)+",Bw="+str(bw)+",Av="+str(av))
722 spectral_file.write(" "+str(r)+"\n")
723 spectral_file.close()
728 def seti_analysis(self,fftbuf,sidtime):
732 if self.seticounter < self.setitimer:
733 self.seticounter = self.seticounter + 1
738 # Run through FFT output buffer, computing standard deviation (Sigma)
740 # First compute average
742 avg = avg + fftbuf[i]
746 # Then compute standard deviation (Sigma)
749 sigma = sigma + (d*d)
751 sigma = Numeric.sqrt(sigma/l)
754 # Snarfle through the FFT output buffer again, looking for
755 # outlying data points
757 start_f = self.observing - (self.fft_input_rate/2)
759 f_incr = self.fft_input_rate / l
764 for i in range(l/2,l):
766 # If current FFT buffer has an item that exceeds the specified
769 if ((fftbuf[i] - avg) > (self.setik * sigma)):
770 hits.append(current_f)
771 current_f = current_f + f_incr
774 for i in range(0,l/2):
776 # If current FFT buffer has an item that exceeds the specified
779 if ((fftbuf[i] - avg) > (self.setik * sigma)):
780 hits.append(current_f)
781 current_f = current_f + f_incr
786 if (len(hits) > self.nhits):
791 # Run through all three hit buffers, computing difference between
792 # frequencies found there, if they're all within the chirp limits
797 for i in range(0,min(len(hits),len(self.hits_array[:,0]))):
798 f_d1 = abs(self.hits_array[i,0] - hits[i])
799 f_d2 = abs(self.hits_array[i,1] - self.hits_array[i,0])
800 f_d3 = abs(self.hits_array[i,2] - self.hits_array[i,1])
801 if (self.seti_isahit ([f_d1, f_d2, f_d3])):
803 self.hitcounter = self.hitcounter + 1
807 self.write_hits(hits,sidtime)
809 # Save 'n shuffle hits
810 self.hits_array[:,2] = self.hits_array[:,1]
811 self.hits_array[:,1] = self.hits_array[:,0]
813 for i in range(0,len(hits)):
814 self.hits_array[i,0] = hits[i]
818 def seti_isahit(self,fdiffs):
821 for i in range(0,len(fdiffs)):
822 if (fdiffs[i] >= self.CHIRP_LOWER and fdiffs[i] <= self.CHIRP_UPPER):
823 truecount = truecount + 1
825 if truecount == len(fdiffs):
830 def write_hits(self,hits,sidtime):
831 # Create localtime structure for producing filename
832 foo = time.localtime()
834 filenamestr = "%s/%04d%02d%02d%02d" % (pfx, foo.tm_year,
835 foo.tm_mon, foo.tm_mday, foo.tm_hour)
837 # Open the data file, appending
838 hits_file = open (filenamestr+".seti","a")
839 hits_file.write(str(ephem.hours(sidtime))+" "+str(self.decln)+" "+str(hits)+"\n")
843 def xydfunc(self,xyv):
844 magn = int(Numeric.log10(self.observing))
845 if (magn == 6 or magn == 7 or magn == 8):
847 dfreq = xyv[0] * pow(10.0,magn)
848 ratio = self.observing / dfreq
857 s = "%.6f%s\n%.3fdB" % (xyv[0], xhz, xyv[1])
858 s2 = "\n%.3fkm/s" % vs
859 self.myform['spec_data'].set_value(s+s2)
861 def toggle_cal(self):
862 if (self.calstate == True):
863 self.calstate = False
864 self.u.write_io(0,0,(1<<15))
865 self.calibrator.SetLabel("Calibration Source: Off")
868 self.u.write_io(0,(1<<15),(1<<15))
869 self.calibrator.SetLabel("Calibration Source: On")
871 def toggle_annotation(self):
872 if (self.annotate_state == True):
873 self.annotate_state = False
874 self.annotation.SetLabel("Annotation: Off")
876 self.annotate_state = True
877 self.annotation.SetLabel("Annotation: On")
881 app = stdgui.stdapp(app_flow_graph, "RADIO ASTRONOMY SPECTRAL/CONTINUUM RECEIVER: $Revision$", nstatus=1)
884 if __name__ == '__main__':