<commit_before>"""
File: plot_log.py
Author: <NAME>
6/22/2016
---
Plots data from log files produced by 
the CAN Arduino programs.
"""

import matplotlib.pyplot as plt
import numpy as np
import sys


def plot_data(file_path):
    
    with open(file_path, 'r') as f:
        entries = f.read().splitlines() # read all the lines into a list
        start = float(entries[0].split(':')[0]) # get first second
        end = float(entries[-1].split(':')[0]) # get last second

        values = []
        for entry in entries:
            values.append(int(entry.split(':')[1]))

        plt.plot(values)
        plt.axis([start, end, min(values)-10, max(values)+10])
        plt.ylabel('Quantity of Received CAN Messages')
        plt.xlabel('Time (s)')
        plt.title('Real-time Operation of \nSimulative Controlled Area Network \n(Control Group)')
        

if __name__ == '__main__':
    if len(sys.argv) < 2:
        print('Usage: python plot_log.py <logfile-path>')
        sys.exit(1)
    elif len(sys.argv) == 3:
        plot_data(sys.argv[1])
        plot_data(sys.argv[2])
    plt.show()<commit_msg>Updated command-line arg parsing so number of log files given is not limited<commit_after>"""
File: plot_log.py
Author: <NAME>
6/22/2016
---
Plots data from log files produced by 
the CAN Arduino programs.
"""

import matplotlib.pyplot as plt
import numpy as np
import sys


def plot_data(file_path):
    
    with open(file_path, 'r') as f:
        entries = f.read().splitlines() # read all the lines into a list
        start = float(entries[0].split(':')[0]) # get first second
        end = float(entries[-1].split(':')[0]) # get last second

        values = []
        for entry in entries:
            values.append(int(entry.split(':')[1]))

        plt.plot(values)
        plt.axis([start, end, min(values)-10, max(values)+10])
        plt.ylabel('Quantity of Received CAN Messages')
        plt.xlabel('Time (s)')
        plt.title('Real-time Operation of \nSimulative Controlled Area Network \n(Control Group)')
        

if __name__ == '__main__':
    if len(sys.argv) < 2:
        print('Usage: python plot_log.py <logfile-path>')
        sys.exit(1)
    else:
        for i in range(1, len(sys.argv)):
            plot_data(sys.argv[i])
    plt.show()
{'fraction_non_alphanumeric': 0.1432967032967033, 'fraction_numerical': 0.017582417582417582, 'mean_word_length': 2.6591639871382635, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6158512', 'n_tokens_mistral': 766, 'n_tokens_neox': 741, 'n_words': 207}