Example #1
0
 def __init__(self):
     utility.print_debug('CAL  __init__')
     param_man = param_manager.ParamManager()
     calc_map = param_man.get('field_map')
     min_dist = 1e10
     with open(calc_map, 'r') as f:
         for line in f:
             if '#' in line:
                 continue
             # utility.print_info(f'CAL  {line}')
             columns = line.split()
             p = (numpy.round(float(columns[0]) * 1e3),
                  numpy.round(float(columns[2]) * 1e3),
                  numpy.round(-float(columns[1]) * 1e3))
             __class__.field_map[p] = [
                 float(columns[3]),
                 float(columns[5]), -float(columns[4])
             ]
             p = numpy.array([
                 float(columns[0]) * 1e3,
                 float(columns[2]) * 1e3, -float(columns[1]) * 1e3
             ])
             d = numpy.linalg.norm(p - ref_pos)
             if d < min_dist:
                 min_dist = d
                 min_pos = p
                 ref_calc = [
                     float(columns[3]),
                     float(columns[4]),
                     float(columns[5])
                 ]
     utility.print_info('CAL  initialized')
Example #2
0
    def __init__(self):
        utility.print_debug('FLD  __init__')
        param_man = param_manager.ParamManager()
        data_path = param_man.get('data_path')
        center_x = float(param_man.get('center_x'))
        center_y = float(param_man.get('center_y'))
        center_z = float(param_man.get('center_z'))
        self.field_map = dict()
        self.bscale = 1.0
        process_time_array = []
        for fname in sorted(os.listdir(data_path)):
            fname = os.path.join(data_path, fname)
            if not os.path.isfile(fname):
                continue
            if ('2019051' in fname or '2019052' in fname or '20190530' in fname
                    or '20190531_02' in fname or '20190531_03' in fname
                    or '20190531_04' in fname or '20190531_05' in fname
                    or '20190531_061407' in fname):
                #'20190530_021341' in fname):
                continue
            mtime = os.stat(fname).st_mtime
            if mtime < 1557990000:
                continue
            prev_time = None
            with open(fname) as f:
                utility.print_info(f'FLD  read {fname}')
                for line in f:
                    columns = line.split()
                    if '#' in line or len(columns) < 10:
                        continue
                    ix = int(
                        numpy.round(float(columns[3]) - center_x) / 10 + 26)
                    iy = int(
                        numpy.round(float(columns[4]) - center_y) / 10 + 26)
                    iz = int(
                        numpy.round(float(columns[5]) - center_z) / 10 + 28)
                    istep = int(float(columns[2]))
                    if abs(float(columns[10])) < 0.5:
                        continue


#          key = (ix, iy, iz)
                    key = (ix, iy, istep)
                    curr_time = self.__get_timestamp(columns)
                    columns.append(curr_time)
                    if key in self.field_map.keys() and False:
                        print('exist', self.field_map[key].data, columns)

                    else:
                        #            self.field_map[ix, iy, iz] = FieldElement(columns)
                        self.field_map[ix, iy, istep] = FieldElement(columns)
                        #print("2 step " + str(columns[2]))
                    if prev_time is not None:
                        process_time = curr_time - prev_time
                        process_time_array.append(process_time)
                        prev_time = curr_time
                    speed = numpy.mean(process_time_array)
                    #        utility.print_info(f'FLD  average speed = {speed:.3f} s')
                    self.calculate_maxwell_equation()
  #   carray[j + 5].Print(pdf_name)
  #carray[-1].Print(pdf_name + ']')
  #carray[0].Print(pdf_name + ']')
  if not ROOT.gROOT.IsBatch():
    ROOT.TPython.Prompt()

#______________________________________________________________________________
if __name__ == '__main__':
  parser = argparse.ArgumentParser()
  parser.add_argument('param_file', help='analysis parameter file')
  parser.add_argument('-b', '--batch', action='store_true',
                      help='batch flag')
  parser.add_argument('-o', '--online', action='store_true',
                      help='online flag')
  parsed, unparsed = parser.parse_known_args()
  param_man = param_manager.ParamManager()
  param_man.initialize(parsed.param_file)
  field_man = fieldmap_manager2.FieldMapManager()
  analyze()
  exit()

  # b = ROOT.kGray
  # ROOT.gStyle.SetCanvasColor(b)
  # ROOT.gStyle.SetTitleFillColor(b)
  # ROOT.gStyle.SetStatColor(b)
  # f = ROOT.kWhite
  # ROOT.gStyle.SetFrameLineColor(f)
  # ROOT.gStyle.SetGridColor(f)
  # ROOT.gStyle.SetStatTextColor(f)
  # ROOT.gStyle.SetTitleTextColor(f)
  # ROOT.gStyle.SetLabelColor(f,"xyz")
Example #4
0
 def __init__(self):
     utility.print_debug('FLD  __init__')
     param_man = param_manager.ParamManager()
     data_path = param_man.get('data_path')
     center_x = float(param_man.get('center_x'))
     center_y = float(param_man.get('center_y'))
     center_z = float(param_man.get('center_z'))
     self.field_map = dict()
     self.bscale = 1.0
     process_time_array = []
     for fname in sorted(os.listdir(data_path)):
         fname = os.path.join(data_path, fname)
         mtime = os.stat(fname).st_mtime
         if not os.path.isfile(fname):
             continue
         if mtime < 1558083682:
             continue
         # if ('20190520_061450' in fname or
         #     '20190520_063540' in fname or
         #     '20190527_060958' in fname or
         #     '20190527_061237' in fname or
         #     '20190530_021341' in fname):
         # if '20190530_021341' not in fname:
         # if '20190531_183253' not in fname:
         # if ('20190531_191821' not in fname and
         #     '20190531_193258' not in fname and
         #     '20190601_020337' not in fname):
         # if ('20190603_112806' not in fname and
         #     '20190603_121624' not in fname):
         ''' main data '''
         if not use_nmr and (
                 '201906' in fname or '20190520_061450' in fname
                 or '20190520_063540' in fname or '20190522_071913' in fname
                 or '20190527_060958' in fname or '20190527_061237' in fname
                 or '20190530_021341' in fname or '20190531_054932' in fname
                 or '20190531_054932' in fname or '20190531_06' in fname or
                 '20190531_1' in fname or '20190531_2' in fname or False):
             continue
         if (use_nmr and '20190603_112806' not in fname
                 and '20190603_121624' not in fname):
             continue
         prev_time = None
         with open(fname) as f:
             utility.print_info(f'FLD  read {fname}')
             for iline, line in enumerate(f):
                 columns = line.split()
                 if use_nmr:
                     if '#' in line or len(columns) < 14:
                         continue
                 else:
                     if '#' in line or len(columns) < 13:
                         continue
                 ix = int(
                     numpy.round(float(columns[3]) - center_x) / 10 + 26)
                 if use_nmr:
                     ix = len(self.field_map)
                 iy = int(
                     numpy.round(float(columns[4]) - center_y) / 10 + 26)
                 iz = int(
                     numpy.round(float(columns[5]) - center_z) / 10 + 28)
                 # if abs(float(columns[10])) < 0.5:
                 #   continue
                 key = (ix, iy, iz)
                 curr_time = self.__get_timestamp(columns)
                 columns.append(curr_time)
                 if key in self.field_map.keys() and False:
                     print('exist', self.field_map[key].data, columns)
                 else:
                     self.field_map[ix, iy, iz] = FieldElement(columns)
                 if prev_time is not None:
                     process_time = curr_time - prev_time
                     process_time_array.append(process_time)
                 prev_time = curr_time
     speed = numpy.mean(process_time_array)
     utility.print_info(f'FLD  average speed = {speed:.3f} s')
     self.calculate_maxwell_equation()