-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from caefleury/matplotlib-data-analysis
feat: first test plot with mathplotlib
- Loading branch information
Showing
11 changed files
with
132 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
__pycache__ | ||
.pytest_cache | ||
.venv | ||
.env | ||
.env | ||
src/data/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM python:3 AS build | ||
|
||
# Copy your utility scripts or modules into the utils directory | ||
COPY . . | ||
|
||
RUN pip install -r requirements.txt | ||
|
||
# Set the PYTHONPATH environment variable to include the utils directory | ||
ENV PYTHONPATH="${PYTHONPATH}:/src/utils" | ||
|
||
# Your application's entrypoint or command | ||
CMD ["python", "src/main.py"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
version: '3' | ||
services: | ||
app: | ||
build: . | ||
command: tail -f /dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
flake8 | ||
autopep8 | ||
pytest | ||
pytest | ||
matplotlib | ||
numpy | ||
mplcursors |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import numpy as np | ||
import matplotlib.pyplot as plt | ||
import mplcursors | ||
|
||
# Certifique-se de adicionar os arquivos das simulações na pasta data | ||
# Alterar o caminho dos arquivos de dados. | ||
|
||
strain = 'strain-x' | ||
simulation_data = f'pristine/{strain}/2/stress_strain.dat' | ||
strain_no_gold = np.genfromtxt(f'src/data/no_gold_final_simulation/{simulation_data}') | ||
strain_gold = np.genfromtxt(f'src/data/gold_substrate_final_simulation/{simulation_data}') | ||
|
||
# Criar figura com dois graficos | ||
fig, axs = plt.subplots(2, figsize=(18, 10)) | ||
|
||
def moving_average(x, window_size): | ||
return np.convolve(x, np.ones(window_size), 'valid') / window_size | ||
|
||
window_size = 1 | ||
|
||
if strain == 'strain-x': | ||
# Deformacao em x de simulação sem o substrato de ouro | ||
smoothed_stress_no_gold = moving_average(strain_no_gold[:, 1], window_size) | ||
line1, = axs[0].plot(strain_no_gold[:len(smoothed_stress_no_gold), 0], smoothed_stress_no_gold, label='Ex. strain-x simulation without gold substrate') | ||
axs[0].set_xlabel('Strain (x)') | ||
axs[0].set_ylabel('Stress (y)') | ||
axs[0].legend() | ||
|
||
# Deformacao em x de simulação com o substrato de ouro | ||
smoothed_stress_gold = moving_average(strain_gold[:, 1], window_size) | ||
line2, = axs[1].plot(strain_gold[:len(smoothed_stress_gold), 0], smoothed_stress_gold, label='Ex. strain-x simulation with gold substrate') | ||
axs[1].set_xlabel('Strain (x)') | ||
axs[1].set_ylabel('Stress (y)') | ||
axs[1].legend() | ||
|
||
elif strain == 'strain-y': | ||
# Deformacao em y de simulação sem o substrato de ouro | ||
smoothed_stress_no_gold = moving_average(strain_no_gold[:, 2], window_size) | ||
line1, = axs[0].plot(strain_no_gold[:len(smoothed_stress_no_gold), 0], smoothed_stress_no_gold, label='Ex. strain-y simulation without gold substrate') | ||
axs[0].set_xlabel('Strain (x)') | ||
axs[0].set_ylabel('Stress (y)') | ||
axs[0].legend() | ||
|
||
# Deformacao em y de simulação com o substrato de ouro | ||
smoothed_stress_gold = moving_average(strain_gold[:, 2], window_size) | ||
line2, = axs[1].plot(strain_gold[:len(smoothed_stress_gold), 0], smoothed_stress_gold, label='Ex. strain-y simulation with gold substrate') | ||
axs[1].set_xlabel('Strain (x)') | ||
axs[1].set_ylabel('Stress (y)') | ||
axs[1].legend() | ||
|
||
# Adicionando tooltips interativos | ||
cursor1 = mplcursors.cursor(line1, hover=True) | ||
cursor2 = mplcursors.cursor(line2, hover=True) | ||
|
||
@cursor1.connect("add") | ||
def on_add1(sel): | ||
x, y = sel.target | ||
sel.annotation.set(text=f'Strain(x): {x:.4f}\nStress(y): {y:.4f}') | ||
|
||
@cursor2.connect("add") | ||
def on_add2(sel): | ||
x, y = sel.target | ||
sel.annotation.set(text=f'Strain(x): {x:.4f}\nStress(y): {y:.4f}') | ||
|
||
# Ajustar layout e plotar | ||
plt.tight_layout() | ||
|
||
# Ativar a barra de ferramentas de navegação | ||
plt.get_current_fig_manager().toolbar.pan() | ||
plt.get_current_fig_manager().toolbar.zoom() | ||
|
||
plt.show() |