<jupyter_start><jupyter_text>Global<jupyter_code>%matplotlib inline
importlib.reload(ut)

plt.rcParams['text.usetex'] = True
plt.style.use(['dark_background'])
plt.style.use(['default'])<jupyter_output><empty_output><jupyter_text>Data<jupyter_code># load data
data = ut.load_data(os.path.join('data', 'v8-ortho', 'forest-23*', '*.zip'))
# simulation
index = 0
simulation = list(data.keys())[index]

print('simulations:\n', '\n '.join([f'{i}: ' + (f'{x} [x]' if x == simulation else x) for i, x in enumerate(list(data.keys()))]))
# load images
df = data[simulation]['images']
df = df[df['type'] == 'monochrome']
df = df.reset_index(drop=True)

print('images:', df.shape[0])
# load parameters
parameters = data[simulation]['parameters']
parameters['images'] = df.shape[0]

print('\nparameters:', json.dumps(parameters, indent=4))<jupyter_output><empty_output><jupyter_text>Plots<jupyter_code>fig, ax = plt.subplots(figsize=(16, 16))

# plot stage image
ut.plot_image(ax, data[simulation]['stage'], 'stage')

# plot sample images
ut.plot_images(df['data'], df['name'])
df_integrate = df[:18]

# integrate images
integrated = ut.integrate_image(df_integrate, parameters, N=30)

# grayscale images
grayscaled = np.array([ut.grayscale_image(x) for x in df_integrate['data']])
image_vs_integrated = np.hstack([grayscaled, integrated]).reshape(integrated.shape * np.array([2, 1, 1]))
image_vs_integrated_labels = np.dstack([df_integrate['name'], df_integrate['name'] + '-integral']).flatten()

# plot integrated images
ut.plot_images(image_vs_integrated, image_vs_integrated_labels, rows=6, cols=6)
# integrate ground
ground, alphas = ut.integrate_ground(df, parameters)

# aggregate alphas
df_alpha = ut.aggregate_alphas(alphas, sample=None)

# calculate ground visibility
scanned = np.count_nonzero(ground[:, :, 0])
captured = np.count_nonzero(ground[:, :, 1])
visibility = captured / scanned
fig, axs = plt.subplots(1, 3, figsize=(24, 6))

# plot ground
ut.plot_heatmap(axs[0], ground[:, :, 0], 'scanned pixels (count)')
ut.plot_heatmap(axs[1], ground[:, :, 1], 'visible pixels (count)')
ut.plot_heatmap(axs[2], ut.normalize_image(ground[:, :, 1] > 0), f'visibility ({visibility:.2f})')
fig, axs = plt.subplots(1, 3, figsize=(24, 6))

# plot alpha
for i, column in enumerate(['scanned', 'visible', 'ratio']):
    df_alpha.plot(kind='line', x='alpha', y=column, label=f'{column} (mean)', ax=axs[i])
# density
density = 1 - visibility
mean = 1 - (ground[:, :, 1] > 0).mean()

print('density:', density)
print('mean:', mean)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19128043990573448, 'fraction_numerical': 0.01728201099764336, 'mean_word_length': 7.216129032258064, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '27330', 'license': 'MIT', 'n_tokens_mistral': 983, 'n_tokens_neox': 941, 'n_words': 184, 'path': 'process.ipynb', 'repo_name': 'tensorware/aos-evaluation', 'size': '2546'}