Things and stuff

This commit is contained in:
2023-03-18 20:00:37 +00:00
parent 3b631a94f8
commit 8550921e2e
7 changed files with 434 additions and 245 deletions
File diff suppressed because one or more lines are too long
+1 -10
View File
@@ -246,7 +246,7 @@
"execution_count": 28,
"outputs": [],
"source": [
"from notebooks.graphs import cr_n"
"from lib.graphs import cr_n"
],
"metadata": {
"collapsed": false
@@ -335,15 +335,6 @@
"metadata": {
"collapsed": false
}
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [],
"metadata": {
"collapsed": false
}
}
],
"metadata": {
-57
View File
@@ -1,57 +0,0 @@
from pathlib import Path
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import scipy
from glob import glob
def read_3d(path: str):
df = pd.read_csv(path, skipinitialspace=True)
df['N'] = df.index + 1
df['r'] = (df.x ** 2 + df.y ** 2 + df.z ** 2) ** 0.5
df['cr'] = df.r.cummax()
df['fd'] = np.log(df.N) / np.log(df.cr)
return df
def read_load_dir(load_dir: str):
paths = glob(f'{load_dir}/*.csv')
return [read_3d(path) for path in paths]
def convergent_tail_index(series, tol):
diffs = np.abs(np.ediff1d(series))
for i in range(0, len(diffs)):
if np.max(diffs[i:]) <= tol:
return i
# No convergence found
return None
def mean_of_tail(series, tol=0.05):
tail_index = convergent_tail_index(series, tol)
if tail_index is None:
raise Exception("No convergence found.")
return np.mean(series[tail_index:])
def fd_stats(dfs):
fds = [mean_of_tail(df.fd, 0.01) for df in dfs]
fds_clean = [f for f in fds if f < np.inf]
return np.mean(fds_clean), np.std(fds_clean)
df = read_3d("/Users/joshuacoles/Developer/checkouts/jc3091/CompB DLA/c-codebase/out-2.csv")
print(mean_of_tail(df.fd, 0.01))
df = read_3d("/Users/joshuacoles/Developer/checkouts/jc3091/CompB DLA/c-codebase/out-26n.csv")
print(mean_of_tail(df.fd, 0.01))
df = read_3d("/Users/joshuacoles/Developer/checkouts/jc3091/CompB DLA/c-codebase/out-26nn.csv")
print(mean_of_tail(df.fd, 0.01))
# dfs = read_load_dir("/Users/joshuacoles/Developer/checkouts/jc3091/CompB DLA/data-analysis/data/rust-3d-1/1")
# print(fd_stats(dfs))