Skip to content

Commit

Permalink
Revert "Karlstad commit"
Browse files Browse the repository at this point in the history
This reverts commit 3a4740c.
  • Loading branch information
jsliacan committed Sep 20, 2024
1 parent e3c41c5 commit 7a10d4c
Show file tree
Hide file tree
Showing 6 changed files with 4,149 additions and 64 deletions.
32 changes: 16 additions & 16 deletions __main__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
"""
Script utilizing code in overtaking package
"""

#! /usr/bin/python3


# --------- modularity ----------

import os
import statistics
import matplotlib.pyplot as plt
Expand All @@ -21,12 +25,9 @@
total_num_OC = 0

for csv_file in dflist:
print("processing:", csv_file, flush=True)
print(csv_file, flush=True)
date_string = csv_file.split("/")[-1][:8]
just_filename = csv_file.split("/")[-1]
# if date_string == "20240330":
if "20240906" not in just_filename or not "fp03" in just_filename:
print("^^skipped^^", flush=True)
if date_string == "20240330":
continue
csvr = util.read_csv(csv_file)
ldata = box.make_ldata(csvr) # CSV data as a list
Expand All @@ -40,7 +41,7 @@
b_partitions, a_partitions, b_modularities, a_modularities = mod.get_partitions(ldata, press_starts, press_lengths)

for j, b_parts in enumerate(b_partitions):

if b_modularities[j] == -1: # it's an oncoming case
continue

Expand All @@ -51,7 +52,7 @@
press_gap = sum([s for s, p in part_and_size_pairs])
lat_dists = [ldata[ps-x][4] for x in range(press_gap)]
dispersion_score = mod.dispersion_score(lat_dists)

plt.scatter(range(len(lat_dists)), lat_dists, c='b')

# ---- process the partition -----
Expand All @@ -61,9 +62,9 @@
lp.sort() # should already be sorted

# skip the maxed-out readings
if min([lat_dists[x] for x in p]) > 500:
if min([lat_dists[x] for x in p]) > 450:
continue

# skip the readings stuck too low
if max([lat_dists[x] for x in p]) < 50:
continue
Expand All @@ -88,27 +89,26 @@
# make sure the vertex we include with the clique doesn't have a very small degree
if lat_dists[u] > v_ball[0] and lat_dists[u] < v_ball[1] and G.degree(u) > 0.8*len(mc):
additional_vertices.add(u)

ot = list(mc)+list(additional_vertices)

# if we ended up with a part that's too small, go to the next one
# unless it starts with index 0, then it could be overlapping with press: keep it
if ot[0] > 0 and len(ot) < 4:
continue

#len_diff = len1 - len(lat_dists)

ot_event = [date_string, ps, dispersion_score, pmod, len(ot), ot]
ot_events.append(ot_event)
lds.append([lat_dists[x] for x in ot])

#plt.scatter([len_diff + x for x in ot], [lat_dists[x] for x in ot], c='r')
plt.scatter(ot, [lat_dists[x] for x in ot], c='r')

# --- end of max clique ----

break # after getting to the OT event

plt.ylim([0,700])
plt.savefig(os.path.join("out", "karlstad-study", date_string+"_ld_"+str(press_starts[j])+"_"+"{:.6f}".format(pmod)+"_disp="+str(dispersion_score)+"_clique.png"))
plt.savefig(os.path.join("out", "mod", date_string+"_ld_"+str(press_starts[j])+"_"+"{:.6f}".format(pmod)+"_disp="+str(dispersion_score)+"_clique.png"))
plt.clf()

print("Number of OT events:", len(ot_events))
Expand Down
Loading

0 comments on commit 7a10d4c

Please sign in to comment.