parameters: (routes_by_start_d, flow_d, root)
docstring: append the flow data to the given dom document
      :param routes_by_start_d:   map by start link id with route dicts as values
      :type routes_by_start_d:    dict
      :param flow_d:      vissim vehicle in-flow data
      :type flow_d:       dict
      :param root:   XML root element to append children to
  
      .. note:: *modifies/extends* XML root element
docstring_summary: append the flow data to the given dom document
      :param routes_by_start_d:   map by start link id with route dicts as values
      :type routes_by_start_d:    dict
      :param flow_d:      vissim vehicle in-flow data
      :type flow_d:       dict
      :param root:   XML root element to append children to
docstring_tokens: append the flow data to the given dom document : param routes_by_start_d : map by start link id with route dicts as values : type routes_by_start_d : dict : param flow_d : vissim vehicle in - flow data : type flow_d : dict : param root : XML root element to append children to
function: def create_flow_elems(routes_by_start_d, flow_d, root):
      """append the flow data to the given dom document
      :param routes_by_start_d:   map by start link id with route dicts as values
      :type routes_by_start_d:    dict
      :param flow_d:      vissim vehicle in-flow data
      :type flow_d:       dict
      :param root:   XML root element to append children to
  
      .. note:: *modifies/extends* XML root element
      """
      sim_end = inpx_doc.getElementsByTagName("simulation")[0].getAttribute("simPeriod")
      dom_flow_l = []
      for start_link in routes_by_start_d:
          if start_link not in flow_d:
              # we got no in-flow data for that route's start link
              print('- skipping flow gen\n'
                    '\tfor route without flow def. for VISSIM start link id:', start_link)
              continue
          if len(routes_by_start_d[start_link]) == 0:
              print('- found no routes by start link:', start_link)
              continue
          flows = flow_d[start_link]["flow"]
          # iterate over all the time frame starts from the flows
          ref_time = flows[:, 0]
          for index, time in enumerate(ref_time):
              in_flow = [fl for fl in flow_d[start_link]["flow"] if
                         fl[0] == time][0]
              if in_flow[1] > 0:
                  flow = root.ownerDocument.createElement("flow")
                  flow.setAttribute("id", "fl{}_st{}".format(start_link,
                                                             time))
                  flow.setAttribute("color", "1,1,0")
                  flow.setAttribute("begin", str(time))
                  if index < len(ref_time) - 1 and len(ref_time) > 1:
                      flow.setAttribute("end",
                                        str(time + ref_time[index + 1]))
                  else:
                      flow.setAttribute("end", sim_end)
                  flow.setAttribute("vehsPerHour", str(in_flow[1]))
                  flow.setAttribute("type", str(int(in_flow[2])))
                  flow.setAttribute('route', "_".join([start_link,
                                                       str(time)]))
                  dom_flow_l.append(flow)
      dom_flow_l = sorted(dom_flow_l,
                          key=lambda dom: float(dom.getAttribute("begin")))
      for dom_obj in dom_flow_l:
          root.appendChild(dom_obj)
function_tokens: def create_flow_elems ( routes_by_start_d , flow_d , root ) : sim_end = inpx_doc . getElementsByTagName ( "simulation" ) [ 0 ] . getAttribute ( "simPeriod" ) dom_flow_l = [ ] for start_link in routes_by_start_d : if start_link not in flow_d : # we got no in-flow data for that route's start link print ( '- skipping flow gen\n' '\tfor route without flow def. for VISSIM start link id:' , start_link ) continue if len ( routes_by_start_d [ start_link ] ) == 0 : print ( '- found no routes by start link:' , start_link ) continue flows = flow_d [ start_link ] [ "flow" ] # iterate over all the time frame starts from the flows ref_time = flows [ : , 0 ] for index , time in enumerate ( ref_time ) : in_flow = [ fl for fl in flow_d [ start_link ] [ "flow" ] if fl [ 0 ] == time ] [ 0 ] if in_flow [ 1 ] > 0 : flow = root . ownerDocument . createElement ( "flow" ) flow . setAttribute ( "id" , "fl{}_st{}" . format ( start_link , time ) ) flow . setAttribute ( "color" , "1,1,0" ) flow . setAttribute ( "begin" , str ( time ) ) if index < len ( ref_time ) - 1 and len ( ref_time ) > 1 : flow . setAttribute ( "end" , str ( time + ref_time [ index + 1 ] ) ) else : flow . setAttribute ( "end" , sim_end ) flow . setAttribute ( "vehsPerHour" , str ( in_flow [ 1 ] ) ) flow . setAttribute ( "type" , str ( int ( in_flow [ 2 ] ) ) ) flow . setAttribute ( 'route' , "_" . join ( [ start_link , str ( time ) ] ) ) dom_flow_l . append ( flow ) dom_flow_l = sorted ( dom_flow_l , key = lambda dom : float ( dom . getAttribute ( "begin" ) ) ) for dom_obj in dom_flow_l : root . appendChild ( dom_obj )