parameters: (disp_name_id_d, signal_state_d, prog_list)
docstring: completes the signal tables with all duration and beginning times
      (in the VISSIm .sig files are only the beginning times of the red and
      green phases as well as the durations of the other phases given )
docstring_summary: completes the signal tables with all duration and beginning times
      (in the VISSIm .sig files are only the beginning times of the red and
      green phases as well as the durations of the other phases given )
docstring_tokens: completes the signal tables with all duration and beginning times ( in the VISSIm . sig files are only the beginning times of the red and green phases as well as the durations of the other phases given )
function: def compute_signal_tables(disp_name_id_d, signal_state_d, prog_list):
      """
      completes the signal tables with all duration and beginning times
      (in the VISSIm .sig files are only the beginning times of the red and
      green phases as well as the durations of the other phases given )
      """
      for key, program in signal_state_d.items():
          cycletime = int([prog for prog in prog_list
                           if prog["id"] == key][0]["cycletime"])
          for sig_group in program.values():
              sig_seq = sig_group["signal_sequence"]
              sig_tab = deepcopy(disp_name_id_d[sig_seq])
              # durations füllen
              for state in sig_group["durations"]:
                  itemindex = np.where(sig_tab == int(state["display"]))
                  sig_tab[itemindex[0][0]][itemindex[1][0] + 2] \
                      = int(state["duration"])
              # begins füllen
              for cmd in sig_group["begins"]:
                  itemindex = np.where(sig_tab == int(cmd["display"]))
                  sig_tab[itemindex[0][0]][itemindex[1][0] + 1] \
                      = int(cmd["begin"])
              # begin Zeiten berechnen
              # bei zufälligem begin Eintrag starten
              i = itemindex[0][0]
              check = 0
              while check != len(sig_tab):
                  if sig_tab[i - 1][1] == -1:  # duration bekannt
                      # überlauf cycletime
                      if (sig_tab[i][1] - sig_tab[i - 1][2]) < 0:
                          sig_tab[i - 1][1] = cycletime - \
                              (sig_tab[i - 1][2] - sig_tab[i][1])
                      else:
                          sig_tab[i - 1][1] = sig_tab[i][1] - sig_tab[i - 1][2]
                  elif sig_tab[i - 1][2] == -1:  # begin bekannt
                      if sig_tab[i - 1][1] > sig_tab[i][1]:  # überlauf cycletime
                          sig_tab[i - 1][2] = \
                              (cycletime - sig_tab[i - 1][1]) + sig_tab[i][1]
                      else:
                          sig_tab[i - 1][2] = sig_tab[i][1] - sig_tab[i - 1][1]
                  i -= 1
                  check += 1
              i = 0
              while i < len(sig_tab):
                  if (sig_tab[i][1] + sig_tab[i][2]) > cycletime:
                      diff = cycletime - sig_tab[i][1]
                      dur = sig_tab[i][2]
                      sig_tab[i][2] = diff
                      sig_tab = np.insert(
                          sig_tab, i, np.array(
                              (sig_tab[i][0], 0, dur - diff)), 0)
                      break
                  i += 1
              sig_tab = sig_tab[np.argsort(sig_tab[:, 1])]
              sig_group["signal_table"] = sig_tab
function_tokens: def compute_signal_tables ( disp_name_id_d , signal_state_d , prog_list ) : for key , program in signal_state_d . items ( ) : cycletime = int ( [ prog for prog in prog_list if prog [ "id" ] == key ] [ 0 ] [ "cycletime" ] ) for sig_group in program . values ( ) : sig_seq = sig_group [ "signal_sequence" ] sig_tab = deepcopy ( disp_name_id_d [ sig_seq ] ) # durations füllen for state in sig_group [ "durations" ] : itemindex = np . where ( sig_tab == int ( state [ "display" ] ) ) sig_tab [ itemindex [ 0 ] [ 0 ] ] [ itemindex [ 1 ] [ 0 ] + 2 ] = int ( state [ "duration" ] ) # begins füllen for cmd in sig_group [ "begins" ] : itemindex = np . where ( sig_tab == int ( cmd [ "display" ] ) ) sig_tab [ itemindex [ 0 ] [ 0 ] ] [ itemindex [ 1 ] [ 0 ] + 1 ] = int ( cmd [ "begin" ] ) # begin Zeiten berechnen # bei zufälligem begin Eintrag starten i = itemindex [ 0 ] [ 0 ] check = 0 while check != len ( sig_tab ) : if sig_tab [ i - 1 ] [ 1 ] == - 1 : # duration bekannt # überlauf cycletime if ( sig_tab [ i ] [ 1 ] - sig_tab [ i - 1 ] [ 2 ] ) < 0 : sig_tab [ i - 1 ] [ 1 ] = cycletime - ( sig_tab [ i - 1 ] [ 2 ] - sig_tab [ i ] [ 1 ] ) else : sig_tab [ i - 1 ] [ 1 ] = sig_tab [ i ] [ 1 ] - sig_tab [ i - 1 ] [ 2 ] elif sig_tab [ i - 1 ] [ 2 ] == - 1 : # begin bekannt if sig_tab [ i - 1 ] [ 1 ] > sig_tab [ i ] [ 1 ] : # überlauf cycletime sig_tab [ i - 1 ] [ 2 ] = ( cycletime - sig_tab [ i - 1 ] [ 1 ] ) + sig_tab [ i ] [ 1 ] else : sig_tab [ i - 1 ] [ 2 ] = sig_tab [ i ] [ 1 ] - sig_tab [ i - 1 ] [ 1 ] i -= 1 check += 1 i = 0 while i < len ( sig_tab ) : if ( sig_tab [ i ] [ 1 ] + sig_tab [ i ] [ 2 ] ) > cycletime : diff = cycletime - sig_tab [ i ] [ 1 ] dur = sig_tab [ i ] [ 2 ] sig_tab [ i ] [ 2 ] = diff sig_tab = np . insert ( sig_tab , i , np . array ( ( sig_tab [ i ] [ 0 ] , 0 , dur - diff ) ) , 0 ) break i += 1 sig_tab = sig_tab [ np . argsort ( sig_tab [ : , 1 ] ) ] sig_group [ "signal_table" ] = sig_tab