diff --git a/test/prsim_plot.py b/test/prsim_plot.py index 3064344..0cad3e5 100755 --- a/test/prsim_plot.py +++ b/test/prsim_plot.py @@ -53,6 +53,20 @@ Use -exclude='regex' to specify signals to exclude (or -ex).""") else: raise Exception("Unknown colour given. I cba to code up general colours atm.") + # Check if start time given + for arg in argv: + r = re.findall(r'-t0=(\d+)', arg) + if len(r) >= 1: + print(f"Filtering by start time t0 = {r[0]}") + entries = [e for e in entries if int(e[0]) >= int(r[0])] + + # Check if end time given + for arg in argv: + r = re.findall(r'-t1=(\d+)', arg) + if len(r) >= 1: + print(f"Filtering by start time t0 = {r[0]}") + entries = [e for e in entries if int(e[0]) <= int(r[0])] + # Check if user gave an include filter include_given = False @@ -72,6 +86,18 @@ Use -exclude='regex' to specify signals to exclude (or -ex).""") exclude_given = True exclude_re = r[0][1] + # Check if user gave "keep all times" flag + # This is so you can look at certain signals only + # without them all bunching up. + include_all_times = False + for arg in argv: + r = re.findall(r'(-alltimes?)', arg) + if len(r) >= 1: + include_all_times = True + + # Get list of all times (before filtering) + unique_times = np.unique([int(e[0]) for e in entries]) + assert not (exclude_given and include_given), "Can't give include and exclude re simultaneously." if include_given: print(f"Including signals that match regex {include_re}") if exclude_given: print(f"Excluding signals that match regex {exclude_re}") @@ -82,27 +108,15 @@ Use -exclude='regex' to specify signals to exclude (or -ex).""") if exclude_given: entries = [e for e in entries if re.search(exclude_re, e[1]) == None] - # Check if start time given - for arg in argv: - r = re.findall(r'-t0=(\d+)', arg) - if len(r) >= 1: - print(f"Filtering by start time t0 = {r[0]}") - entries = [e for e in entries if int(e[0]) >= int(r[0])] - - # Check if end time given - for arg in argv: - r = re.findall(r'-t1=(\d+)', arg) - if len(r) >= 1: - print(f"Filtering by start time t0 = {r[0]}") - entries = [e for e in entries if int(e[0]) <= int(r[0])] - assert len(entries) >= 1, "No valid entries in prsim.out!" - # Get list of all sigs and times - times = np.array([int(e[0]) for e in entries]) - unique_times = np.unique(times) num_times = unique_times.shape[0] + # Get list of all times (after filtering) + times = np.array([int(e[0]) for e in entries]) + if not include_all_times: unique_times = np.unique(times) + + # Get list of all sigs sigs = np.array([e[1] for e in entries]) unique_sigs = np.unique(sigs) num_sigs = unique_sigs.shape[0]