comparison sitesurvey.py @ 32:660a2997e720

Don't put timestamp_hex & _dec in the data file. Add fstart_mhz & fstop_mhz to format dict.
author Daniel O'Connor <darius@dons.net.au>
date Wed, 21 Sep 2011 15:34:23 +0930
parents c6c86dcb54ba
children 184ea77c10e7
comparison
equal deleted inserted replaced
31:c6c86dcb54ba 32:660a2997e720
152 xaxis = numpy.arange(fstart, fstop, (fstop - fstart) / yaxis.shape[0]) 152 xaxis = numpy.arange(fstart, fstop, (fstop - fstart) / yaxis.shape[0])
153 153
154 return xaxis, yaxis, rconf 154 return xaxis, yaxis, rconf
155 155
156 def savesweep(fname, exp, x, y): 156 def savesweep(fname, exp, x, y):
157 print " Saving to " + fname
157 f = open(fname, 'wb') 158 f = open(fname, 'wb')
158 for k in exp: 159 for k in exp:
159 f.write("%s %s\n" % (k.upper(), str(exp[k]))) 160 f.write("%s %s\n" % (k.upper(), str(exp[k])))
160 f.write("XDATA ") 161 f.write("XDATA ")
161 numpy.savetxt(f, [x], delimiter = ', ', fmt = '%.3f') # Produces a trailing \n 162 numpy.savetxt(f, [x], delimiter = ', ', fmt = '%.3f') # Produces a trailing \n
252 253
253 # Add some informative params 254 # Add some informative params
254 tsepoch = calendar.timegm(exp.last_run.utctimetuple()) 255 tsepoch = calendar.timegm(exp.last_run.utctimetuple())
255 256
256 extras = { 'timestamp' : exp.last_run, 257 extras = { 'timestamp' : exp.last_run,
257 'timestamp_hex' : '%08x' % (tsepoch),
258 'timestamp_dec' : '%d' % (tsepoch),
259 'tag' : exp.name, 258 'tag' : exp.name,
260 } 259 }
261 opts = dict(opts.items() + extras.items()) 260 opts = dict(opts.items() + extras.items())
262 fname = fnamefmt % opts 261
262 fmtextras = { 'timestamp_hex' : '%08x' % (tsepoch),
263 'timestamp_dec' : '%d' % (tsepoch),
264 'fstart_mhz' : '%.1f' % (float(opts['fstart']) / 1e6),
265 'fstop_mhz' : '%.1f' % (float(opts['fstop']) / 1e6),
266 }
267 fmtopts = dict(opts.items() + fmtextras.items())
268 fname = fnamefmt % fmtopts
263 269
264 # Save data 270 # Save data
265 savesweep(fname, opts, freqs, power) 271 savesweep(fname, opts, freqs, power)