added flag to plot all times

This commit is contained in:
alexmadison 2022-02-28 17:56:12 +01:00
parent 225d481ae1
commit 5bae88d56f
1 changed files with 31 additions and 17 deletions

View File

@ -53,6 +53,20 @@ Use -exclude='regex' to specify signals to exclude (or -ex).""")
else: else:
raise Exception("Unknown colour given. I cba to code up general colours atm.") 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 # Check if user gave an include filter
include_given = False include_given = False
@ -72,6 +86,18 @@ Use -exclude='regex' to specify signals to exclude (or -ex).""")
exclude_given = True exclude_given = True
exclude_re = r[0][1] 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." 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 include_given: print(f"Including signals that match regex {include_re}")
if exclude_given: print(f"Excluding signals that match regex {exclude_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: if exclude_given:
entries = [e for e in entries if re.search(exclude_re, e[1]) == None] 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!" 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] 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]) sigs = np.array([e[1] for e in entries])
unique_sigs = np.unique(sigs) unique_sigs = np.unique(sigs)
num_sigs = unique_sigs.shape[0] num_sigs = unique_sigs.shape[0]