ISTools.py
Go to the documentation of this file.
1 import json
2 import os
3 import numpy as np
4 import time as systime
5 from pylab import plt
6 from sys import platform
7 
8 import pylib.ISToolsDataSorted as itd
9 import pylib.ISToolsPlot as itp
10 import pylib.ISDataAnalytics as ida
11 import pylib.newISDataAnalytics as newida
12 
13 class cObj:
14  def __init__(self):
15  return
16 
17 
18 def plotdata(opt, pe, settings_file):
19 
20  log = None
21 
22  # if opt['use_settings_file']:
23  if settings_file is not None:
24  with open(settings_file) as data_file:
25  data = json.load(data_file)
26  directory = data['dataInfo']['dataDirectory']
27  subdir = data['processData']['datasets'][0]['folder']
28  serialNumbers = data['processData']['datasets'][0]['SerialNumbers']
29  else:
30  directory = opt['directory']
31  serialNumbers = opt['serials']
32  subdir = ""
33  print("Directory: %s" % directory)
34  print("Folder: %s" % subdir)
35  print("Serial Numbers: %s" % serialNumbers)
36  # else:
37  # directory = opt['directory']
38  # serialNumbers = opt['serials']
39  # subdir = None
40  #
41  if subdir:
42  directory += subdir
43 
44  # Set Reference LLA (deg, deg, m) used for NED - Salem, UT
45  itd.setRefLla( np.r_[ 40.0557114, -111.6585476, 1426.77 ] )
46 
47  if pe['postProcess']==1:
48  # Temporarily Turn off certain plots for reference
49  googleEarthTemp = pe['googleEarth']
50  pe['googleEarth'] = 0
51 
52  if opt['showReference'] or pe['postProcess']==0:
53  # Load Reference INS Data
54  log = _load(directory, opt)
55 
56  if pe['postProcess']==1:
57  directory += '/post_processed'
58  pe['googleEarth'] = googleEarthTemp
59 
60  # Load Reference INS Data
61  log = _load(directory, opt)
62 
63  # Check Raw GPS observation counts
64  if opt['checkRawDataDrop']:
65  ida.checkRawDataDrop(log)
66 
67  # Turn on plots
68  if opt['showFigs']:
69  plotlog(log, directory, serialNumbers, opt, pe)
70 
71  # RMS Accuracies
72  if opt['rmsCalc'] and not opt['showReference']:
73  newida.calcRMS(log, directory, subdir)
74 
75  return (log, directory)
76 
77 
78 def _load(directory, opt):
79 
80  cwd = os.getcwd()
81 
82  try:
83  tru = itd.cDevices()
84  tru.loadData(refIns=1)
85  except:
86  tru = None
87 
88  # Load Log Data
89  log = itd.cDevices()
90  log.loadData(directory, startDev=opt['start'], devCount=opt['count'])
91 
92  os.chdir(cwd)
93 
94  return log
95 
96 
97 def plotlog(log, directory, serialNumbers, opt, pe):
98 
99  # Profiling
100  timePlotStart = systime.time()
101 
102 # basename = os.path.basename(directory)
103 # dst = os.path.join(directory,subdir)
104  dst = os.path.join(directory,"figures")
105  if pe['postProcess']==1:
106  dst = os.path.join(dst,'post_processed')
107  if opt['saveFigs']:
108  if not os.path.exists(dst):
109  os.makedirs(dst)
110 
111  # Plot Data
112  figNum = 0
113  for device2 in log.devices:
114  if device2.serialNumber not in serialNumbers and not "ALL" in serialNumbers and serialNumbers != []:
115  continue
116 
117  referencePlot = False
118 # if pe['postProcess==1:
119 # referencePlot = True # Color reference plots one color
120 
121  f = itp.IsLoggerPlot( pe, device2, startFigure=figNum, saveFigs=opt['saveFigs'], saveFigsDirectory=dst, referencePlot=referencePlot, numDevs=len(log.devices))
122 
123  if opt['combinePlots']==0:
124  figNum += f
125  print("Total times: Load %.2fs Plot %.2fs" % (log.loadTime, systime.time()-timePlotStart))
126 
127 
128 def end():
129  plt.show() # Do this last
130 
def plotdata(opt, pe, settings_file)
Definition: ISTools.py:18
def plotlog(log, directory, serialNumbers, opt, pe)
Definition: ISTools.py:97
def _load(directory, opt)
Definition: ISTools.py:78


inertial_sense_ros
Author(s):
autogenerated on Sun Feb 28 2021 03:17:57