measure.py 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  1. from collections import namedtuple, defaultdict
  2. import sqlite3
  3. from datetime import datetime
  4. import time
  5. import rpyc
  6. import numpy as np
  7. from scipy.misc import pilutil
  8. import scipy.ndimage.filters as image_filters
  9. import scipy.ndimage as ndimage
  10. from utils.path import path
  11. from utils import getPyPlot
  12. fmtts = lambda ts: str(datetime.fromtimestamp(ts)).split('.')[0]
  13. UTC_OFFSET = 3600 * 2 # 2 hours summertime
  14. WISPY_OFFSET = 0.7
  15. CHANNELS = range(1, 15)
  16. BURST_PERIOD = 6.0
  17. ZERO_PERIOD = 6.0
  18. CHANNELS_B = {
  19. #~ 0: (2401, 2495),
  20. 1: (2401, 2423), 2: (2406, 2428), 3: (2411, 2433),
  21. 4: (2416, 2438), 5: (2421, 2443), 6: (2426, 2448),
  22. 7: (2431, 2453), 8: (2436, 2458), 9: (2441, 2463),
  23. 10: (2446, 2468), 11: (2451, 2473), 12: (2456, 2478),
  24. 13: (2461, 2483), 14: (2473, 2495)
  25. }
  26. #~ CHANNELS_B = dict([(e[0], (e[1][0] + 7, e[1][1] - 7)) for e in CHANNELS_B.items()])
  27. BURST_STATIONS = {
  28. '107': ('127.0.0.1', 18107),
  29. '108': ('127.0.0.1', 18108),
  30. '110': ('127.0.0.1', 18110),
  31. }
  32. def runBurst(station):
  33. ''' connect to AP and send bursts over different channels'''
  34. host, port = BURST_STATIONS[station]
  35. channel2ts = {}
  36. conn = rpyc.classic.connect(host, port=port)
  37. conn.modules.sys.path.append('/sbin')
  38. chaburst = conn.modules.chaburst
  39. try:
  40. chaburst.stopDefaultWifi()
  41. chaburst.startBurstDevice()
  42. for chan in CHANNELS:
  43. print 'measure channel %s' % chan
  44. chaburst.setChannel(chan)
  45. ts1 = time.time()
  46. chaburst.sendBurst(BURST_PERIOD)
  47. channel2ts[chan] = (ts1, time.time())
  48. finally:
  49. chaburst.startDefaultWifi()
  50. conn.close()
  51. print 'measure zero channel'
  52. # store timestamps for a period without traffic at fake channel 0
  53. #~ ts1 = time.time()
  54. #~ time.sleep(ZERO_PERIOD)
  55. #~ channel2ts[0] = (ts1, time.time())
  56. return channel2ts
  57. def gatherTimestampsForPositions(stations):
  58. ''' collect measurements at different locations interactivly
  59. '''
  60. print 'Enter first location index:',
  61. loc2ts = {} # key (station, location), value {channel: (ts_start, ts_end)}
  62. while True:
  63. try:
  64. loc = raw_input()
  65. loc = int(loc)
  66. except ValueError:
  67. if loc == 'q':
  68. print 'done...'
  69. break
  70. else:
  71. print 'need a int value for location!'
  72. continue
  73. ts1 = time.time()
  74. for station in stations:
  75. print 'start measure %s for location %s at station %s' % (fmtts(ts1), loc, station)
  76. #~ print 'end measurement with [return]',
  77. #~ raw_input()
  78. try:
  79. channel2ts = runBurst(station)
  80. except Exception, KeyboardInterrupt:
  81. print 'error during running burst'
  82. continue
  83. #~ ts2 = time.time()
  84. loc2ts[(station, loc)] = channel2ts
  85. print 'continue with next location: ',
  86. print 'got the following locations'
  87. for (loc, station), ts in loc2ts.items():
  88. print loc, station, ts
  89. return loc2ts
  90. def getSignalStrength(data):
  91. '''estimate the paramters of a 1d GMM with 2 modes'''
  92. from scikits.learn.mixture import GMM
  93. # assume 2 modes - one gaussian for the noise, and one for the signal
  94. clf = GMM(n_states=2, cvtype='full')
  95. clf.fit(np.array(data).reshape(len(data), 1))
  96. # assume the larger mean is our signal
  97. signalStrengthMax = max(clf.means)
  98. idx = list(clf.means).index(signalStrengthMax)
  99. varianceMax = list(clf.covars)[idx]
  100. signalStrengthMin = min(clf.means)
  101. return signalStrengthMax, varianceMax, signalStrengthMin
  102. def updateSignalData(locations, ssid, wispy_db, loc2ts):
  103. ''' update Location() data in locations with measured rssi values for given ssid
  104. the values are extracted from the wispy_db file by using timestamps from measurements_file
  105. '''
  106. # currently only first ts is used
  107. for locid, (ts1, ts2) in loc2ts.items():
  108. loc2ts[locid] = ts1
  109. # now use these timestamps to extract signals from wispy-db
  110. firstts, lastts = min(loc2ts.values()), max(loc2ts.values())
  111. res = {}
  112. with sqlite3.connect(wispy_db) as conn:
  113. c = conn.cursor()
  114. sql = '''select
  115. rssi,
  116. milliseconds_since_epoch
  117. from
  118. network_data
  119. where
  120. milliseconds_since_epoch > ?
  121. and milliseconds_since_epoch < ?
  122. and ssid = ?'''
  123. c.execute(sql, ((firstts - 10 + UTC_OFFSET) * 1000, (lastts + 10 + UTC_OFFSET) * 1000, ssid))
  124. ts2rssi = {}
  125. for row in c:
  126. ts = row[1] / 1000 - UTC_OFFSET
  127. ts2rssi[ts] = row[0]
  128. #~ print datetime.fromtimestamp(ts)
  129. for loc, ts in loc2ts.items():
  130. # iterate over all stored rssi values
  131. # and pick that one with the minimum timestamp delta (thats not fast but should be ok)
  132. delttats, key = min([(abs(ts - e), e) for e in ts2rssi.keys()])
  133. #~ print '%s at location %s with rssi: %s [delta %.2f sec]' % (fmtts(ts), loc, ts2rssi[key], delttats)
  134. locations[loc] = locations[loc]._replace(rssi=ts2rssi[key], ts=ts)
  135. def ts2dbts(ts):
  136. ''' convert ts to milliseconds_since_epoch '''
  137. return (ts + UTC_OFFSET) * 1000
  138. def dbts2ts(dbts):
  139. return dbts / 1000.0 - UTC_OFFSET
  140. def rasterize(xs, ys, zs, readings_per_sweep, destfile):
  141. first_ts = np.min(xs)
  142. last_ts = np.max(xs)
  143. delta = last_ts - first_ts
  144. #~ print delta
  145. resolution_x = len(set(xs))
  146. resolution_y = readings_per_sweep
  147. data = np.zeros((resolution_x, resolution_y))
  148. for x, y, z in zip(xs, ys, zs):
  149. _x = int(round((x - first_ts) / float(delta) * (resolution_x - 1)))
  150. data[_x][y] = z
  151. data = pilutil.imresize(data, (1000, resolution_y))
  152. data = data.transpose()
  153. pilutil.imsave(destfile, data)
  154. Location = namedtuple('Location', 'id x y z rssi ts')
  155. def loadLocations(f):
  156. print 'loading locations from %s' % f.abspath()
  157. lines = [l for l in f.lines() if l.strip() and not l.strip().startswith('#')]
  158. res = {}
  159. for l in lines:
  160. i, x, y, z = [float(e.strip()) for e in l.split()]
  161. i = int(i)
  162. res[i] = Location(i, x, y, z, None, None)
  163. return res
  164. def loadMeasurements():
  165. ''' return a list of locations with measured rssi signal strengths '''
  166. p = path(r'D:\loco-dev\maps\whs19\experiment\measure_locs.txt')
  167. locs = loadLocations(p)
  168. wispy_db = path('d:/loco-dev/maps/whs19/experiment/measure.wsx')
  169. run_file = path('d:/loco-dev/maps/whs19/experiment/run1.txt')
  170. updateSignalData(locs, 'CS31', wispy_db, run_file)
  171. return locs
  172. Sweep = namedtuple('Sweep', 'dt data setting channel')
  173. Setting = namedtuple('Setting', 'id starting_frequency frequency_resolution readings_per_sweep amplitude_offset amplitude_resolution rssi_max')
  174. class Measure(object):
  175. def __init__(self, location_file, wispy_db, plotpath, loc2tsfile):
  176. self.location_file = location_file
  177. self.wispy_db = wispy_db
  178. self.loc2tsfile = loc2tsfile
  179. if not self.loc2tsfile.exists():
  180. self.loc2tsfile.touch()
  181. # contents wispy_db setting table
  182. self.settings = {} # key: setting id, value: Setting()
  183. # load data into self.settings
  184. self.loadWiSpySettings()
  185. self.loc2ts = defaultdict(list) # key: location id, values: list of dicts containing timestamps for each channel
  186. # load data into self.loc2ts
  187. self.loadMeasurements()
  188. self.plotpath = plotpath
  189. if not plotpath.exists():
  190. plotpath.makedirs()
  191. def loadWiSpySettings(self):
  192. self.settings.clear()
  193. with sqlite3.connect(self.wispy_db) as conn:
  194. c = conn.cursor()
  195. # load all settings
  196. sql = '''select
  197. id,
  198. starting_frequency,
  199. frequency_resolution,
  200. readings_per_sweep,
  201. amplitude_offset,
  202. amplitude_resolution,
  203. rssi_max
  204. from
  205. setting
  206. '''
  207. c.execute(sql)
  208. for row in c:
  209. self.settings[row[0]] = Setting(*row)
  210. def loadSweepDataForLocation(self, locid, station):
  211. sweeps = defaultdict(list) # keys: measure_idx, values: [Sweep(), ]
  212. with sqlite3.connect(self.wispy_db) as conn:
  213. c = conn.cursor()
  214. channeldata = self.loc2ts[(locid, station)]
  215. for measure_idx, channel2ts in enumerate(channeldata):
  216. allts = []
  217. for ts1, ts2 in channel2ts.values():
  218. allts.extend([ts1, ts2])
  219. fromts, untilts = min(allts), max(allts)
  220. # load sweep data from firsts to lastts
  221. sql = '''select
  222. sweep_data,
  223. milliseconds_since_epoch,
  224. setting_id
  225. from
  226. sweep
  227. where
  228. milliseconds_since_epoch > ?
  229. and milliseconds_since_epoch < ?
  230. order by
  231. milliseconds_since_epoch
  232. '''
  233. MORE_SECONDS = 10 # fetch more seconds at the left/right side of intervall
  234. c.execute(sql, ((fromts - MORE_SECONDS + UTC_OFFSET) * 1000, (untilts + MORE_SECONDS + UTC_OFFSET) * 1000))
  235. for row in c:
  236. ts = dbts2ts(row[1])
  237. for channel, (ts1, ts2) in channel2ts.items():
  238. if ts1 <= ts <= ts2:
  239. sweep = Sweep(datetime.fromtimestamp(ts), row[0], row[2], channel)
  240. sweeps[measure_idx].append(sweep)
  241. # check if we found any data in wispy db
  242. if not measure_idx in sweeps:
  243. print datetime.fromtimestamp(fromts - MORE_SECONDS)
  244. print 'got no sweep data from wispy db for measurement %s at location %s' % (measure_idx, locid)
  245. #~ print sweeps
  246. return sweeps
  247. def combineWispyDBs(self, source, dest, clear=False):
  248. if clear:
  249. with sqlite3.connect(dest) as conn:
  250. c = conn.cursor()
  251. c.execute('delete from network_data')
  252. c.execute('delete from sweep')
  253. c.execute('delete from setting')
  254. with sqlite3.connect(source) as conn:
  255. c = conn.cursor()
  256. # select last setting
  257. sql = '''select
  258. id,
  259. device,
  260. start_time_msepoch,
  261. starting_frequency,
  262. frequency_resolution,
  263. readings_per_sweep,
  264. amplitude_offset,
  265. amplitude_resolution,
  266. rssi_max
  267. from
  268. setting
  269. order by
  270. id desc'''
  271. setting = list(c.execute(sql))[-1]
  272. sql = '''select
  273. milliseconds_since_epoch,
  274. sweep_data
  275. from
  276. sweep
  277. where
  278. setting_id = ?'''
  279. sweeps = list(c.execute(sql, str(setting[0])))
  280. print 'got %s sweeps' % len(sweeps)
  281. sql = '''select
  282. ssid,
  283. channel,
  284. encryption,
  285. mac,
  286. rssi,
  287. supported_rates,
  288. signal_quality,
  289. mode,
  290. milliseconds_since_epoch
  291. from
  292. network_data'''
  293. network_data = list(c.execute(sql))
  294. print 'inserting data into %s' % dest
  295. with sqlite3.connect(dest) as conn:
  296. c = conn.cursor()
  297. sql = '''select max(id) from setting'''
  298. try:
  299. setting_id = list(c.execute(sql))[0][0] + 1
  300. except Exception:
  301. setting_id = 0
  302. print 'using new setting id %s' % setting_id
  303. sql = '''insert into setting (id, device, start_time_msepoch, starting_frequency,
  304. frequency_resolution, readings_per_sweep, amplitude_offset, amplitude_resolution, rssi_max)
  305. values(?, ?, ?, ?, ?, ?, ?, ?, ?)'''
  306. c.execute(sql, [setting_id] + list(setting[1:]))
  307. sql = '''select max(id) from sweep'''
  308. try:
  309. next_sweep_id = list(c.execute(sql))[0][0] + 1
  310. except Exception:
  311. next_sweep_id = 0
  312. sql = '''insert into sweep (id, setting_id, milliseconds_since_epoch, sweep_data)
  313. values(?, ?, ?, ?)'''
  314. for s_id, sweep in enumerate(sweeps, next_sweep_id):
  315. c.execute(sql, [s_id, setting_id] + list(sweep))
  316. sql = '''select max(id) from network_data'''
  317. try:
  318. next_nd_id = list(c.execute(sql))[0][0] + 1
  319. except Exception:
  320. next_nd_id = 0
  321. sql = '''insert into network_data (id, ssid, channel, encryption, mac, rssi, supported_rates,
  322. signal_quality, mode, milliseconds_since_epoch)
  323. values(?, ?, ?, ?, ?, ? , ?, ?, ?, ?)'''
  324. for nd_id, nd in enumerate(network_data, next_nd_id):
  325. c.execute(sql, [nd_id] + list(nd))
  326. def runMeasurement(self, stations):
  327. ## check if stations are reachable
  328. for s in stations:
  329. try:
  330. conn = rpyc.classic.connect(BURST_STATIONS[s][0], port=BURST_STATIONS[s][1])
  331. except:
  332. raise RuntimeError('station %s is not reachable' % s)
  333. else:
  334. print 'station %s is reachable' % s
  335. conn.close()
  336. loc2ts = gatherTimestampsForPositions(stations)
  337. s = '\n'.join('%s/%s %r' % (station, locid, channel2ts) for (station, locid), channel2ts in loc2ts.items())
  338. print 'storing measurements result to %s' % self.loc2tsfile.abspath()
  339. self.loc2tsfile.write_text('run from %s at locations %s\n%s\n\n' % (datetime.now(), ','.join(str(e) for e in loc2ts), s), append=True)
  340. # refresh self.loc2ts
  341. self.loadMeasurements()
  342. self.loadWiSpySettings()
  343. print 'please save wispy db now!',
  344. raw_input()
  345. def loadMeasurements(self):
  346. ''' load measurements from loc2tsfile (next to location_file) and return
  347. dict with keys: location id, values: list of dicts that contain (start/end) timestamps for each channel
  348. '''
  349. self.loc2ts.clear()
  350. print 'loading measurements from %s' % self.loc2tsfile.abspath()
  351. for line in [l for l in self.loc2tsfile.lines() if l.strip()]:
  352. if line.startswith('run from'):
  353. continue
  354. #line format: 107/1 {1: (1315234649.809, 1315234651.031), 2: (1315234651 ...
  355. l = line.split()
  356. station, locid = l[0].split('/')
  357. locid = int(locid)
  358. channel2ts = eval(' '.join(l[1:]))
  359. self.loc2ts[(locid, station)].append(channel2ts)
  360. # adjust wispy timestamp offset (empirically determined!)
  361. for channeldata in self.loc2ts.values():
  362. for channel2ts in channeldata:
  363. for chanid, (ts1, ts2) in channel2ts.items():
  364. channel2ts[chanid] = (ts1 + WISPY_OFFSET, ts2 + WISPY_OFFSET)
  365. def analyzeMeasurements(self, locid, measure_idx, station):
  366. #~ locs = loadLocations(self.location_file)
  367. sweep = self.loadSweepDataForLocation(locid, station)
  368. self.drawMeasure(sweep[measure_idx], locid, station, measure_idx)
  369. avg_sig = self.analyzeBurst(sweep[measure_idx], locid, measure_idx, draw=True)
  370. print 'got avg sig %.2f' % avg_sig
  371. def buildOptimizeFile(self, optimizefile, station):
  372. measure_idx = 0
  373. locs = loadLocations(self.location_file)
  374. loc2sig = []
  375. for locid, loc in locs.items():
  376. sweep = self.loadSweepDataForLocation(locid, station)
  377. avg_sig = self.analyzeBurst(sweep[measure_idx], locid, measure_idx)
  378. if avg_sig is not None:
  379. loc2sig.append((loc, avg_sig))
  380. s = '\n'.join('%s %s %s %s %.2f' % (loc.id, loc.x, loc.y, loc.z, avg_sig) for loc, avg_sig in loc2sig)
  381. optimizefile = path(optimizefile % station)
  382. print 'storing optimize file to %s' % optimizefile.abspath()
  383. optimizefile.write_text(s)
  384. def drawMeasure(self, sweeps, locid, station, measure_idx):
  385. channel2ts = self.loc2ts[(locid, station)][measure_idx]
  386. plt, mlab, dates, font_manager, ticker = getPyPlot()
  387. width = 1200
  388. aspectRatio = 0.5
  389. dpi = 70
  390. figsize = width / float(dpi), width / float(dpi) * aspectRatio
  391. fig = plt.figure(figsize=figsize)
  392. ax1 = plt.axes([0.08, 0.21, 0.85, 0.75])
  393. # assert all Sweep() instances are from the same wispy setting
  394. assert len(set([s.setting for s in sweeps])) == 1
  395. setting = self.settings[sweeps[0].setting]
  396. starting_frequency = setting.starting_frequency
  397. frequency_resolution = setting.frequency_resolution / 1000
  398. amplitude_offset = setting.amplitude_offset
  399. amplitude_resolution = setting.amplitude_resolution
  400. readings_per_sweep = setting.readings_per_sweep
  401. xs, ys, zs = [], [], []
  402. for sweep in sweeps:
  403. assert len(sweep.data) == readings_per_sweep
  404. for i, c in enumerate(sweep.data):
  405. # TODO: is this correct?
  406. amplitude = amplitude_offset + ord(c) * amplitude_resolution
  407. #~ print amplitude
  408. if amplitude > -100:
  409. xs.append(sweep.dt)
  410. y = (starting_frequency + (i * frequency_resolution)) / 1000.0
  411. #~ print starting_frequency, i, frequency_resolution
  412. ys.append(i)
  413. zs.append(ord(c))
  414. xs = mlab.date2num(xs)
  415. _ys = np.array(ys)
  416. _ys = ((_ys * frequency_resolution) + starting_frequency) / 1000
  417. ax1.scatter(xs, _ys , s=2, c='#AAAACC', linewidths=0)
  418. for channel, (ts1, ts2) in channel2ts.items():
  419. _xs = mlab.date2num([datetime.fromtimestamp(ts) for ts in (ts1, ts2)])
  420. ax1.plot(_xs, [CHANNELS_B[channel]] * 2, c='#7766FF')
  421. ax1.xaxis_date()
  422. ax1.xaxis.set_major_formatter(dates.DateFormatter('%H:%M:%S'))
  423. fig.savefig(self.plotpath.joinpath('full_%s_%s.png' % (locid, measure_idx)), format='png', dpi=dpi)
  424. plt.close(fig)
  425. rasterize(xs, ys, zs, readings_per_sweep, self.plotpath.joinpath('rast_%s_%s.png' % (locid, measure_idx)))
  426. def default_analyzer(self, channeldata):
  427. sigstrenghts = {}
  428. for c, cdata in channeldata.items():
  429. if c == 0:
  430. continue
  431. sigstrenghts[c] = getSignalStrength(cdata)
  432. MIN_STRENGTH = 3 # ignore signals that are too near at sig0
  433. all_sigs = [sig for sig, variance, sig0 in sigstrenghts.values() if sig > sig0 + MIN_STRENGTH and variance < 50]
  434. if len(all_sigs) > 0:
  435. avg_sig = sum(all_sigs) / float(len(all_sigs))
  436. else:
  437. avg_sig = -100
  438. return sigstrenghts, avg_sig
  439. def analyzeBurst(self, sweeps, locid, measure_idx, draw=False):
  440. c = len(set([s.setting for s in sweeps]))
  441. if c != 1:
  442. print 'anticipated exactly one setting for locid %s, measure_idx %s, but got %s' % (locid, measure_idx, c)
  443. return
  444. setting = self.settings[sweeps[0].setting]
  445. #~ y = (starting_frequency + (i * frequency_resolution)) / 1000.0
  446. channeldata = defaultdict(list)
  447. for sweep in sweeps:
  448. minfreq , maxfreq = CHANNELS_B[sweep.channel]
  449. _toidx = lambda f: int((f - (setting.starting_frequency / 1000.0)) / (setting.frequency_resolution / 10.0**6))
  450. minidx = _toidx(minfreq)
  451. maxidx = _toidx(maxfreq)
  452. for c in sweep.data[minidx:maxidx]:
  453. ampl = setting.amplitude_offset + ord(c) * setting.amplitude_resolution
  454. channeldata[sweep.channel].append(ampl)
  455. sigstrenghts, avg_sig = default_analyzer(channeldata)
  456. if draw:
  457. plt, mlab, dates, font_manager, ticker = getPyPlot()
  458. for c, cdata in channeldata.items():
  459. if c == 0:
  460. continue
  461. fig = plt.figure(figsize=(12, 6))
  462. ax = plt.axes()
  463. r, BIN_WIDTH = (-120, 0), 2
  464. bins = [e for e in range(r[0], r[1], BIN_WIDTH)]
  465. ax.hist(cdata, bins=bins)
  466. ax.set_xlim(r)
  467. sig, variance, sig0 = sigstrenghts[c]
  468. ax.axvline(sig)
  469. ax.axvline(sig0, color='red')
  470. ax.axvline(avg_sig, color='green', linewidth=2.0)
  471. ax1 = ax.twinx()
  472. ax1.plot(range(-120, 50), [mlab.normpdf(x, sig, variance)[0][0] for x in range(-120, 50)])
  473. ax1.set_xlim(r)
  474. plt.title('loc %s, run %s, chan %s [mu: %.1f, sigma: %.1f, mu0: %.1f, mu_total: %.2f]' % (locid, measure_idx, c, sig, variance, sig0, avg_sig))
  475. fig.savefig(self.plotpath.joinpath('channel_%02d_%02d_%02d.png' % (locid, measure_idx, c)), dpi=80)
  476. plt.close(fig)
  477. return avg_sig
  478. if __name__ == '__main__':
  479. #python /usr/lib/python2.6/site-packages/rpyc/scripts/rpyc_classic.py -m forking -p 20001
  480. #~ wispy_db = path('d:/loco-dev/maps/whs19/experiment/measure.wsx')
  481. #~ location_file = path(r'D:\loco-dev\maps\whs19\experiment\measure_locs.txt')
  482. location_file = path(r'D:\loco-dev\maps\umic\experiment\locations.txt')
  483. wispy_db = path('d:/loco-dev/maps/umic/experiment/measure.wsx')
  484. loc2tsfile = path(r'D:\loco-dev\maps\umic\experiment\loc2ts.txt')
  485. plotpath = path('r:/')
  486. optimizefile = path('d:/loco-dev/maps/umic/experiment/measure_%s.txt')
  487. m = Measure(location_file, wispy_db, plotpath, loc2tsfile)
  488. stations = ['107', '108', '110']
  489. #~ stations = ['110']
  490. #~ stations = ['110']
  491. #~ m.runMeasurement(stations)
  492. m.combineWispyDBs('d:/loco-dev/maps/umic/experiment/measure1.wsx', 'd:/loco-dev/maps/umic/experiment/measure.wsx', clear=True)
  493. m.combineWispyDBs('d:/loco-dev/maps/umic/experiment/measure2.wsx', 'd:/loco-dev/maps/umic/experiment/measure.wsx')
  494. m.combineWispyDBs('d:/loco-dev/maps/umic/experiment/measure3.wsx', 'd:/loco-dev/maps/umic/experiment/measure.wsx')
  495. m.combineWispyDBs('d:/loco-dev/maps/umic/experiment/measure5.wsx', 'd:/loco-dev/maps/umic/experiment/measure.wsx',)
  496. #~ m.combineWispyDBs('d:/loco-dev/maps/umic/experiment/measure4.wsx', 'd:/loco-dev/maps/umic/experiment/measure.wsx')
  497. #~ m.combineWispyDBs('d:/loco-dev/maps/umic/experiment/measure6.wsx', 'd:/loco-dev/maps/umic/experiment/measure.wsx')
  498. #~ for i in range(1, 12):
  499. #~ m.analyzeMeasurements(i, 0)
  500. #~ m.analyzeMeasurements(3, 0, '110')
  501. #~ m.analyzeMeasurements(4, 0, '110')
  502. #~ m.analyzeMeasurements(15, 0, '110')
  503. for s in stations:
  504. m.buildOptimizeFile(optimizefile, s)