messageboard-2020-06-23-0812.py
01234567890123456789012345678901234567890123456789012345678901234567890123456789









365366367368369370371372373374375376377378379380381382383384 385 386387388389390391392393394395396397398399400401402403404405








503450355036503750385039504050415042504350445045504650475048504950505051505250535054  50555056505750585059506050615062506350645065506650675068506950705071507250735074











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




AIRCRAFT_LENGTH['Canadair Challenger 350 (twin-jet)'] = 20.9
AIRCRAFT_LENGTH['Cessna Caravan (single-turboprop)'] = 11.46
AIRCRAFT_LENGTH['Cessna Citation CJ2+ (twin-jet)'] = 14.53
AIRCRAFT_LENGTH['Cessna Citation CJ3 (twin-jet)'] = 15.59
AIRCRAFT_LENGTH['Cessna Citation Excel/XLS (twin-jet)'] = 16.0
AIRCRAFT_LENGTH['Cessna Citation II (twin-jet)'] = 14.54
AIRCRAFT_LENGTH['Cessna Citation Latitude (twin-jet)'] = 18.97
AIRCRAFT_LENGTH['Cessna Citation Sovereign (twin-jet)'] = 19.35
AIRCRAFT_LENGTH['Cessna Citation V (twin-jet)'] = 14.91
AIRCRAFT_LENGTH['Cessna Citation X (twin-jet)'] = 22.04
AIRCRAFT_LENGTH['Cessna Citation Mustang (twin-jet)'] = 12.37
AIRCRAFT_LENGTH['Cessna Skyhawk (piston-single)'] = 8.28
AIRCRAFT_LENGTH['Cessna Skylane (piston-single)'] = 8.84
AIRCRAFT_LENGTH['Cessna T206 Turbo Stationair (piston-single)'] = 8.61
AIRCRAFT_LENGTH['Dassault Falcon 900 (tri-jet)'] = 20.21
AIRCRAFT_LENGTH['Embraer 170/175 (twin-jet)'] = (29.90 + 31.68) / 2
AIRCRAFT_LENGTH['Embraer Phenom 300 (twin-jet)'] = 15.9
AIRCRAFT_LENGTH['EMBRAER 175 (long wing) (twin-jet)'] = 31.68
AIRCRAFT_LENGTH['Embraer ERJ-135 (twin-jet)'] = 26.33
AIRCRAFT_LENGTH['Gulfstream Aerospace Gulfstream G550 (twin-jet)'] = 29.39

AIRCRAFT_LENGTH['Learjet 45 (twin-jet)'] = 17.68

AIRCRAFT_LENGTH['Pilatus PC-12 (single-turboprop)'] = 14.4


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




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




        histogram_settings['histogram'],
        histogram_settings['histogram_history'],
        filename_prefix=HISTOGRAM_IMAGE_PREFIX + epoch_string,
        heartbeat=heartbeat)
    histogram_id_sequence = [
        'origin', 'destination',
        'day_of_month', 'day_of_week', 'hour',
        'bearing', 'distance', 'speed', 'vert_rate', 'altitude',
        'airline', 'aircraft', 'aircraft_length']
    path = WEBSERVER_PATH + WEBSERVER_IMAGE_RELATIVE_FOLDER
    files = os.listdir(path)
    lines = [
        '<head>',
        '<title>Flight Tracker: Histograms</title>',
        '</head>',
        '<body>',
        '<?php include "nav.html" ?>',
        '<div class="resp-iframe">'
    ]
    for histogram_id in histogram_id_sequence:
      matching_files = sorted([f for f in files if histogram_id in f])


      # save the most recent; delete the others
      lines.append('<img id="%s" src="images/%s"><p>' % (
          histogram_id, matching_files[-1]))
      for f in matching_files[:-1]:
        RemoveFile(
            os.path.join(WEBSERVER_PATH, WEBSERVER_IMAGE_RELATIVE_FOLDER, f))

    lines.extend(['</div>', '</body>'])
    html = '\n'.join(lines)
    WriteFile(HISTOGRAM_IMAGE_HTML, html)

  return histogram_messages


def SaveFlightsByAltitudeDistanceCSV(
    flights,
    max_days=0,
    filename='flights_by_alt_dist.csv',
    precision=100):
  """Generates CSV of hour of day, altitude, and distance.




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





01234567890123456789012345678901234567890123456789012345678901234567890123456789









365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407








5036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078











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




AIRCRAFT_LENGTH['Canadair Challenger 350 (twin-jet)'] = 20.9
AIRCRAFT_LENGTH['Cessna Caravan (single-turboprop)'] = 11.46
AIRCRAFT_LENGTH['Cessna Citation CJ2+ (twin-jet)'] = 14.53
AIRCRAFT_LENGTH['Cessna Citation CJ3 (twin-jet)'] = 15.59
AIRCRAFT_LENGTH['Cessna Citation Excel/XLS (twin-jet)'] = 16.0
AIRCRAFT_LENGTH['Cessna Citation II (twin-jet)'] = 14.54
AIRCRAFT_LENGTH['Cessna Citation Latitude (twin-jet)'] = 18.97
AIRCRAFT_LENGTH['Cessna Citation Sovereign (twin-jet)'] = 19.35
AIRCRAFT_LENGTH['Cessna Citation V (twin-jet)'] = 14.91
AIRCRAFT_LENGTH['Cessna Citation X (twin-jet)'] = 22.04
AIRCRAFT_LENGTH['Cessna Citation Mustang (twin-jet)'] = 12.37
AIRCRAFT_LENGTH['Cessna Skyhawk (piston-single)'] = 8.28
AIRCRAFT_LENGTH['Cessna Skylane (piston-single)'] = 8.84
AIRCRAFT_LENGTH['Cessna T206 Turbo Stationair (piston-single)'] = 8.61
AIRCRAFT_LENGTH['Dassault Falcon 900 (tri-jet)'] = 20.21
AIRCRAFT_LENGTH['Embraer 170/175 (twin-jet)'] = (29.90 + 31.68) / 2
AIRCRAFT_LENGTH['Embraer Phenom 300 (twin-jet)'] = 15.9
AIRCRAFT_LENGTH['EMBRAER 175 (long wing) (twin-jet)'] = 31.68
AIRCRAFT_LENGTH['Embraer ERJ-135 (twin-jet)'] = 26.33
AIRCRAFT_LENGTH['Gulfstream Aerospace Gulfstream G550 (twin-jet)'] = 29.39
AIRCRAFT_LENGTH['Gulfstream Aerospace Gulfstream IV (twin-jet)'] = 26.92
AIRCRAFT_LENGTH['Learjet 45 (twin-jet)'] = 17.68
AIRCRAFT_LENGTH['McDonnell Douglas MD-11 (tri-jet)'] = 61.6
AIRCRAFT_LENGTH['Pilatus PC-12 (single-turboprop)'] = 14.4


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




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




        histogram_settings['histogram'],
        histogram_settings['histogram_history'],
        filename_prefix=HISTOGRAM_IMAGE_PREFIX + epoch_string,
        heartbeat=heartbeat)
    histogram_id_sequence = [
        'origin', 'destination',
        'day_of_month', 'day_of_week', 'hour',
        'bearing', 'distance', 'speed', 'vert_rate', 'altitude',
        'airline', 'aircraft', 'aircraft_length']
    path = WEBSERVER_PATH + WEBSERVER_IMAGE_RELATIVE_FOLDER
    files = os.listdir(path)
    lines = [
        '<head>',
        '<title>Flight Tracker: Histograms</title>',
        '</head>',
        '<body>',
        '<?php include "nav.html" ?>',
        '<div class="resp-iframe">'
    ]
    for histogram_id in histogram_id_sequence:
      pattern = re.compile('histogram[0-9_]*%s.png' % histogram_id)
      matching_files = sorted(
          [f for f in files if pattern.match(f)])
      # save the most recent; delete the others
      lines.append('<img id="%s" src="images/%s"><p>' % (
          histogram_id, matching_files[-1]))
      for f in matching_files[:-1]:
        RemoveFile(
            os.path.join(WEBSERVER_PATH, WEBSERVER_IMAGE_RELATIVE_FOLDER, f))

    lines.extend(['</div>', '</body>'])
    html = '\n'.join(lines)
    WriteFile(HISTOGRAM_IMAGE_HTML, html)

  return histogram_messages


def SaveFlightsByAltitudeDistanceCSV(
    flights,
    max_days=0,
    filename='flights_by_alt_dist.csv',
    precision=100):
  """Generates CSV of hour of day, altitude, and distance.




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