From 1f416411c7608875eb4e21e81b8800cf3aeef98f Mon Sep 17 00:00:00 2001 From: Midgard Date: Sun, 17 Nov 2024 23:05:03 +0100 Subject: [PATCH] Stuff I did a while ago --- plot_numberdealers.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/plot_numberdealers.py b/plot_numberdealers.py index 4ec7024..9b16397 100755 --- a/plot_numberdealers.py +++ b/plot_numberdealers.py @@ -36,11 +36,13 @@ def main(): print("Usage: plot_numberdealers.py ") return 1 with open(sys.argv[1], encoding="utf-8") as fh: - numbers_og, _errors = parse_numberdealers.parse(fh) + numbers_og, _errors = parse_numberdealers.parse(fh, parse_numberdealers.ErrorStyle.NUMBERDEALERS) with open(sys.argv[2], encoding="utf-8") as fh: - numbers_ng, _errors = parse_numberdealers.parse(fh) + numbers_ng, _errors = parse_numberdealers.parse(fh, parse_numberdealers.ErrorStyle.NUMBERDEALERS_NG) - start_of_current_slope = find(numbers_og, lambda msg: msg.create_at >= numbers_ng[0].create_at) + start_at_numberdealers_ng_number = 1 + + start_of_current_slope = find(numbers_og, lambda msg: msg.create_at >= numbers_ng[start_at_numberdealers_ng_number].create_at) # a = (y2-y1) / (x2-x1) slope_og = ( numbers_og[-1].recognized_number - numbers_og[start_of_current_slope].recognized_number @@ -51,9 +53,9 @@ def main(): intercept_og = numbers_og[-1].recognized_number - slope_og * numbers_og[-1].create_at/1000 slope_ng = ( - numbers_ng[-1].recognized_number - numbers_ng[0].recognized_number + numbers_ng[-1].recognized_number - numbers_ng[start_at_numberdealers_ng_number].recognized_number ) / ( - numbers_ng[-1].create_at/1000 - numbers_ng[0].create_at/1000 + numbers_ng[-1].create_at/1000 - numbers_ng[start_at_numberdealers_ng_number].create_at/1000 ) intercept_ng = numbers_ng[-1].recognized_number - slope_ng * numbers_ng[-1].create_at/1000 @@ -78,6 +80,7 @@ def main(): # func = lambda x: x < intercept_x # locs = np.append(locs[func(locs)][:-1], [intercept_x]) labels = ["{:%Y-%m-%d}".format(datetime.fromtimestamp(x, timezone.utc)) for x in locs] + labels[-2] = "" plt.xticks(locs, labels) plt.grid()