messageboard-2021-06-23-1844.py
01234567890123456789012345678901234567890123456789012345678901234567890123456789









462463464465466467468469470471472473474475476477478479480481   482483484485486487488489490491492493494495496497498499500501








409941004101410241034104410541064107410841094110411141124113411441154116411741184119 41204121412241234124412541264127412841294130413141324133413441354136413741384139








530953105311531253135314531553165317531853195320532153225323532453255326532753285329   533053315332 5333   53345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356











                            <----SKIPPED LINES---->




AIRCRAFT_LENGTH['Raytheon Hawker 800 (twin-jet)'] = 15.60
AIRCRAFT_LENGTH['Raytheon Hawker 800XP (twin-jet)'] = 15.60
AIRCRAFT_LENGTH['Raytheon Hawker 850XP (twin-jet)'] = 15.60
AIRCRAFT_LENGTH['Raytheon Hawker 1000 (twin-jet)'] = 16.08
AIRCRAFT_LENGTH['Rockwell Turbo Commander 690 (twin-turboprop)'] = 11.22
for mixed_case_plane in list(AIRCRAFT_LENGTH.keys()):  # pylint: disable=C0201
  AIRCRAFT_LENGTH[mixed_case_plane.upper()] = AIRCRAFT_LENGTH[mixed_case_plane]
  AIRCRAFT_LENGTH.pop(mixed_case_plane)

# pylint: disable=line-too-long
SHORTER_AIRCRAFT_NAME = {}
SHORTER_AIRCRAFT_NAME['Boeing 787-9 Dreamliner (twin-jet)'] = 'Boeing 787-9 (twin-jet)'
SHORTER_AIRCRAFT_NAME['BOEING 787-10 Dreamliner (twin-jet)'] = 'Boeing 787-10 (twin-jet)'
SHORTER_AIRCRAFT_NAME['Gulfstream Aerospace Gulfstream 3 (twin-jet)'] = 'Gulfstream 3 (twin-jet)'
SHORTER_AIRCRAFT_NAME['Gulfstream Aerospace Gulfstream G450 (twin-jet)'] = 'Gulfstream G450 (twin-jet)'
SHORTER_AIRCRAFT_NAME['Gulfstream Aerospace Gulfstream G550 (twin-jet)'] = 'Gulfstream G550 (twin-jet)'
SHORTER_AIRCRAFT_NAME['Gulfstream Aerospace Gulfstream IV (twin-jet)'] = 'Gulfstream IV (twin-jet)'
SHORTER_AIRCRAFT_NAME['Gulfstream Aerospace Gulfstream V (twin-jet)'] = 'Gulfstream V (twin-jet)'
# pylint: enable=line-too-long





def Log(message, file=None, rolling=None):
  """Write a message to a logfile along with a timestamp.

  Args:
    message: string message to write
    file: string representing file name and, if needed, path to the
      file to write to
    rolling: name of file that will keep only the last n files of file
  """
  # can't define as a default parameter because LOGFILE name is potentially
  # modified based on SIMULATION flag
  if not file:
    file = LOGFILE

  # special case: for the main logfile, we always keep a rolling log
  if not rolling and file == LOGFILE:
    rolling = ROLLING_LOGFILE

  try:




                            <----SKIPPED LINES---->




            percentile_high=percentile_high))

  # flight UAL1 (n=5) has a delay frequency in the 72nd %tile, with 100% of
  # flights delayed an average of 44m over the last 4d13h
  DelayTimeAndFrequencyMessage(
      (FLAG_INSIGHT_FLIGHT_DELAY_FREQUENCY, FLAG_INSIGHT_FLIGHT_DELAY_TIME),
      group_function=lambda flight: flight.get(
          'flight_number', KEY_NOT_PRESENT_STRING),
      group_label='flight',
      min_days=1,
      min_this_group_size=4,
      min_comparison_group_size=0,
      min_group_qty=0,
      percentile_low=10,
      percentile_high=90)

  # Airline United (n=5) has a delay frequency in the 72nd %tile, with 100% of
  # flights delayed an average of 44m over the last 4d13h
  DelayTimeAndFrequencyMessage(
      (FLAG_INSIGHT_AIRLINE_DELAY_FREQUENCY, FLAG_INSIGHT_AIRLINE_DELAY_TIME),
      group_function=DisplayAirline,

      group_label='airline',
      min_days=1,
      min_this_group_size=10,
      min_comparison_group_size=5,
      min_group_qty=5,
      percentile_low=10,
      percentile_high=80)

  # Destination LAX (n=5) has a delay frequency in the 72nd %tile, with 100% of
  # flights delayed an average of 44m over the last 4d13h
  DelayTimeAndFrequencyMessage(
      (FLAG_INSIGHT_DESTINATION_DELAY_FREQUENCY,
       FLAG_INSIGHT_DESTINATION_DELAY_TIME),
      group_function=DisplayDestinationFriendly,
      group_label='destination',
      min_days=1,
      min_this_group_size=10,
      min_comparison_group_size=5,
      min_group_qty=5,
      percentile_low=10,




                            <----SKIPPED LINES---->




    screen_title = screen_title.center(SPLITFLAP_CHARS_PER_LINE)
    start_index = screen*available_entries_per_screen
    end_index = min((screen+1)*available_entries_per_screen-1, len(keys)-1)
    number_of_entries = end_index - start_index + 1
    number_of_lines = math.ceil(number_of_entries / columns)

    lines = []

    lines.append(screen_title.upper())
    if data_summary:
      lines.append(summary_text.upper())
    for line_index in range(number_of_lines):
      key_value = []
      for column_index in range(columns):
        index = start_index + column_index*number_of_lines + line_index
        if index <= end_index:
          if absolute:
            value_string = format_string % values[index]
          else:
            # If the % is >=1%, display right-justified 2 digit percent, i.e. '
            # 5%' Otherwise, if it rounds to at least 0.1%, display i.e. '.5%'



            if values[index]/total*100 >= 0.95:
              value_string = '%2d' % round(values[index]/total*100)
            elif round(values[index]/total*1000)/10 >= 0.1:

              value_string = ('%.1f' % (round(values[index]/total*1000)/10))[1:]



            else:
              value_string = ' 0'
          key_value.append('%s %s%s' % (
              str(keys[index])[:column_key_width].ljust(column_key_width),
              value_string,
              printed_percent_sign))

      line = (column_divider.join(key_value)).upper()
      lines.append(line)

    split_flap_boards.append(lines)

  return split_flap_boards


def TriggerHistograms(flights, histogram_settings, heartbeat=True):
  """Triggers the text-based or web-based histograms.

  Based on the histogram settings, determines whether to generate text or image
  histograms (or both). For image histograms, also generates empty images for
  the histograms not created so that broken image links are not displayed in
  the webpage.





                            <----SKIPPED LINES---->





01234567890123456789012345678901234567890123456789012345678901234567890123456789









462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504








410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143








5313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367











                            <----SKIPPED LINES---->




AIRCRAFT_LENGTH['Raytheon Hawker 800 (twin-jet)'] = 15.60
AIRCRAFT_LENGTH['Raytheon Hawker 800XP (twin-jet)'] = 15.60
AIRCRAFT_LENGTH['Raytheon Hawker 850XP (twin-jet)'] = 15.60
AIRCRAFT_LENGTH['Raytheon Hawker 1000 (twin-jet)'] = 16.08
AIRCRAFT_LENGTH['Rockwell Turbo Commander 690 (twin-turboprop)'] = 11.22
for mixed_case_plane in list(AIRCRAFT_LENGTH.keys()):  # pylint: disable=C0201
  AIRCRAFT_LENGTH[mixed_case_plane.upper()] = AIRCRAFT_LENGTH[mixed_case_plane]
  AIRCRAFT_LENGTH.pop(mixed_case_plane)

# pylint: disable=line-too-long
SHORTER_AIRCRAFT_NAME = {}
SHORTER_AIRCRAFT_NAME['Boeing 787-9 Dreamliner (twin-jet)'] = 'Boeing 787-9 (twin-jet)'
SHORTER_AIRCRAFT_NAME['BOEING 787-10 Dreamliner (twin-jet)'] = 'Boeing 787-10 (twin-jet)'
SHORTER_AIRCRAFT_NAME['Gulfstream Aerospace Gulfstream 3 (twin-jet)'] = 'Gulfstream 3 (twin-jet)'
SHORTER_AIRCRAFT_NAME['Gulfstream Aerospace Gulfstream G450 (twin-jet)'] = 'Gulfstream G450 (twin-jet)'
SHORTER_AIRCRAFT_NAME['Gulfstream Aerospace Gulfstream G550 (twin-jet)'] = 'Gulfstream G550 (twin-jet)'
SHORTER_AIRCRAFT_NAME['Gulfstream Aerospace Gulfstream IV (twin-jet)'] = 'Gulfstream IV (twin-jet)'
SHORTER_AIRCRAFT_NAME['Gulfstream Aerospace Gulfstream V (twin-jet)'] = 'Gulfstream V (twin-jet)'
# pylint: enable=line-too-long

SHORTER_AIRLINE_NAME = {}
SHORTER_AIRLINE_NAME['WHEELS UP - GAMA AVIATION'] = 'GAMA AVIATION'


def Log(message, file=None, rolling=None):
  """Write a message to a logfile along with a timestamp.

  Args:
    message: string message to write
    file: string representing file name and, if needed, path to the
      file to write to
    rolling: name of file that will keep only the last n files of file
  """
  # can't define as a default parameter because LOGFILE name is potentially
  # modified based on SIMULATION flag
  if not file:
    file = LOGFILE

  # special case: for the main logfile, we always keep a rolling log
  if not rolling and file == LOGFILE:
    rolling = ROLLING_LOGFILE

  try:




                            <----SKIPPED LINES---->




            percentile_high=percentile_high))

  # flight UAL1 (n=5) has a delay frequency in the 72nd %tile, with 100% of
  # flights delayed an average of 44m over the last 4d13h
  DelayTimeAndFrequencyMessage(
      (FLAG_INSIGHT_FLIGHT_DELAY_FREQUENCY, FLAG_INSIGHT_FLIGHT_DELAY_TIME),
      group_function=lambda flight: flight.get(
          'flight_number', KEY_NOT_PRESENT_STRING),
      group_label='flight',
      min_days=1,
      min_this_group_size=4,
      min_comparison_group_size=0,
      min_group_qty=0,
      percentile_low=10,
      percentile_high=90)

  # Airline United (n=5) has a delay frequency in the 72nd %tile, with 100% of
  # flights delayed an average of 44m over the last 4d13h
  DelayTimeAndFrequencyMessage(
      (FLAG_INSIGHT_AIRLINE_DELAY_FREQUENCY, FLAG_INSIGHT_AIRLINE_DELAY_TIME),
      group_function=lambda flight: SHORTER_AIRLINE_NAME.get(
          DisplayAirline(flight), DisplayAirline(flight)),
      group_label='airline',
      min_days=1,
      min_this_group_size=10,
      min_comparison_group_size=5,
      min_group_qty=5,
      percentile_low=10,
      percentile_high=80)

  # Destination LAX (n=5) has a delay frequency in the 72nd %tile, with 100% of
  # flights delayed an average of 44m over the last 4d13h
  DelayTimeAndFrequencyMessage(
      (FLAG_INSIGHT_DESTINATION_DELAY_FREQUENCY,
       FLAG_INSIGHT_DESTINATION_DELAY_TIME),
      group_function=DisplayDestinationFriendly,
      group_label='destination',
      min_days=1,
      min_this_group_size=10,
      min_comparison_group_size=5,
      min_group_qty=5,
      percentile_low=10,




                            <----SKIPPED LINES---->




    screen_title = screen_title.center(SPLITFLAP_CHARS_PER_LINE)
    start_index = screen*available_entries_per_screen
    end_index = min((screen+1)*available_entries_per_screen-1, len(keys)-1)
    number_of_entries = end_index - start_index + 1
    number_of_lines = math.ceil(number_of_entries / columns)

    lines = []

    lines.append(screen_title.upper())
    if data_summary:
      lines.append(summary_text.upper())
    for line_index in range(number_of_lines):
      key_value = []
      for column_index in range(columns):
        index = start_index + column_index*number_of_lines + line_index
        if index <= end_index:
          if absolute:
            value_string = format_string % values[index]
          else:
            # If the % is >=1%, display right-justified 2 digit percent, i.e. '
            # 5%' Otherwise, if it rounds to at least 0.1%, display i.e. '.5%';
            # Otherwise, if it round to at least 0.01%, display i.e.: '.01%',
            # getting rid of the space between the label & the value (i.e.:
            # PSP.01 instead of PSP .4).
            if values[index]/total*100 >= 0.95:
              value_string = ' %2d' % round(values[index]/total*100)
            elif round(values[index]/total*1000)/10 >= 0.1:
              value_string = (
                  ' %.1f' % (round(values[index]/total*1000)/10))[1:]
            elif round(values[index]/total*1000)/10 >= 0.01:
              value_string = (
                  '%.2f' % (round(values[index]/total*10000)/100))[1:]
            else:
              value_string = '  0'
          key_value.append('%s%s%s' % (
              str(keys[index])[:column_key_width].ljust(column_key_width),
              value_string,
              printed_percent_sign))

      line = (column_divider.join(key_value)).upper()
      lines.append(line)

    split_flap_boards.append(lines)

  return split_flap_boards


def TriggerHistograms(flights, histogram_settings, heartbeat=True):
  """Triggers the text-based or web-based histograms.

  Based on the histogram settings, determines whether to generate text or image
  histograms (or both). For image histograms, also generates empty images for
  the histograms not created so that broken image links are not displayed in
  the webpage.





                            <----SKIPPED LINES---->