import pandas as pd
import [Link] as plt
from [Link] import FuncAnimation
import time
start_time = [Link]()
# Define the path to the directory containing [Link] files
profile_path = 'f://output_r-7624N/reduced/20Msun/work59-20-NJ-5-REDUCED-def_50k/
LOGS/'
# Generate the list of profile file names with their full paths
profile_files = [profile_path + f"profile{i}.data" for i in range(1, 75)]
# Print the list of file paths
#print(profile_files)
#-------------------------------------------
# Create an empty list to store the profile data
profiles = []
# Define the parameters for reading the [Link] file
data_start_row = 5 #5 #4 # Assuming data starts at row 5 (0-based index)
extra_rows = [2, 3] # Additional rows to read
sep = r'\s+|,|;|\t'
#-------------------------------------------------
# Read and process each profile file
for profile_path in profile_files:
profile = pd.read_csv(profile_path, skiprows=data_start_row, sep=sep,
engine='python')
#[Link] = pd.
# Create the figure and axes objects with a specific figure size
fig, ax1 = [Link](figsize=(12, 8))
# Create the second y-axis
ax2 = [Link]()
ax3 = [Link]()
ax4 = [Link]()
ax5 = [Link]()
ax6 = [Link]()
ax7 = [Link]()
ax8 = [Link]()
ax9 = [Link]()
# Move the third y-axis to the right
#[Link]['right'].set_position(('outward', 100))
#[Link]['right'].set_position(('outward', 80))
# Move the fourth y-axis to the right
[Link]['right'].set_position(('outward', 60))
[Link].set_label_position('right')
[Link].set_ticks_position('right')
# Move the fourth y-axis to the right
[Link]['right'].set_position(('outward', 120))
[Link].set_label_position('right')
[Link].set_ticks_position('right')
# Move the fifth y-axis to the right
[Link]['right'].set_position(('outward', 180))
[Link].set_label_position('right')
[Link].set_ticks_position('right')
# Move the sixth y-axis to the right
[Link]['right'].set_position(('outward', 240))
[Link].set_label_position('right')
[Link].set_ticks_position('right')
# Move the seventh y-axis to the right
[Link]['right'].set_position(('outward', 300))
[Link].set_label_position('right')
[Link].set_ticks_position('right')
# Move the eighth y-axis to the right
[Link]['right'].set_position(('outward', 360))
[Link].set_label_position('right')
[Link].set_ticks_position('right')
# Move the nineth y-axis to the right
[Link]['right'].set_position(('outward', 420))
[Link].set_label_position('right')
[Link].set_ticks_position('right')
# Create an empty list to store the line plots
#lines1 = []
#lines2 = []
#lines3 = []
# Set the color for each y-axis
color1 = 'blue'
color2 = 'red'
color3 = 'green'
color4 = 'purple'
color5 = 'orange'
color6 = 'yellow'
color7 = 'cyan'
color8 = 'black'
color9 = 'olive'
#-------------------------------------------
# Define the animation function
def animate(i):
[Link]()
[Link]()
[Link]()
[Link]()
[Link]()
[Link]()
[Link]()
[Link]()
[Link]()
line1, = [Link](profiles[i]['mass'], profiles[i]['cno'], label=f'Profile {i +
1} - cno', color=color1, lw=2.5)
line2, = [Link](profiles[i]['mass'], profiles[i]['tri_alfa'], label=f'Profile
{i + 1} - tri_alfa', color=color2, lw=2.5)
line3, = [Link](profiles[i]['mass'], profiles[i]['burn_c'], label=f'Profile
{i + 1} - burn_c', color=color3, lw=2.5)
line4, = [Link](profiles[i]['mass'], profiles[i]['burn_n'], label=f'Profile
{i + 1} - burn_n', color=color4, lw=2.5)
line5, = [Link](profiles[i]['mass'], profiles[i]['burn_o'], label=f'Profile
{i + 1} - burn_o', color=color5, lw=2.5)
line6, = [Link](profiles[i]['mass'], profiles[i]['burn_ne'], label=f'Profile
{i + 1} - burn_ne', color=color6, lw=2.5)
line7, = [Link](profiles[i]['mass'], profiles[i]['burn_na'], label=f'Profile
{i + 1} - burn_na', color=color7, lw=2.5)
line8, = [Link](profiles[i]['mass'], profiles[i]['burn_mg'], label=f'Profile
{i + 1} - burn_mg', color=color8, lw=2.5)
line9, = [Link](profiles[i]['mass'], profiles[i]['burn_si'], label=f'Profile
{i + 1} - burn_si', color=color9, lw=2.5)
ax1.set_xlabel('Mass')
ax1.set_ylabel('cno', color=color1)
ax2.set_ylabel('tri_alfa', color=color2)
ax3.set_ylabel('burn_c', color=color3)
ax4.set_ylabel('burn_n', color=color4)
ax5.set_ylabel('burn_o', color=color5)
ax6.set_ylabel('burn_ne', color=color6)
ax7.set_ylabel('burn_na', color=color7)
ax8.set_ylabel('burn_mg', color=color8)
ax9.set_ylabel('burn_si', color=color9)
ax1.set_title(f'Profile {i + 1} - {profile_files[i]}')
# Set the colors for the y-axis scales
ax1.tick_params(axis='y', colors=color1)
ax2.tick_params(axis='y', colors=color2)
ax3.tick_params(axis='y', colors=color3)
ax4.tick_params(axis='y', colors=color4)
ax5.tick_params(axis='y', colors=color5)
ax6.tick_params(axis='y', colors=color6)
ax7.tick_params(axis='y', colors=color7)
ax8.tick_params(axis='y', colors=color8)
ax9.tick_params(axis='y', colors=color9)
# Create a unified legend for all the lines
lines = [line1, line2, line3, line4, line5, line6, line7, line8, line9]
labels = [line.get_label() for line in lines]
[Link](lines, labels, loc='upper right')
# Create the animation
ani = FuncAnimation(fig, animate, frames=len(profiles), interval=500, repeat=False)
# Save the animation as an MP4 video file
[Link]('20msun-eta-5xxxx.mp4')
end_time = [Link]()
execution_time = end_time - start_time
print(f"Execution time: {execution_time} seconds")