Loading __pycache__/codesp.cpython-311.pyc +9 B (2.45 KiB) File changed.No diff preview for this file type. View original file View changed file codesp.py +2 −2 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ import ephem # print("❌ Jinja2 测试失败:", e) #模拟恒星轨迹,且将结果保存为可视化图片 def simulate_star_trajectory(semi_major_axis, eccentricity, period, start_date, end_date, step_days): # Initialize observer location (e.g., Earth location) Loading Loading @@ -63,7 +63,7 @@ def simulate_star_trajectory(semi_major_axis, eccentricity, period, start_date, plt.legend() plt.grid() plt.show() plt.savefig("star_trajectory.png") plt.savefig("../input/star_trajectory.png") print("图像已保存为 star_trajectory.png") # try: Loading run.py +32 −20 Original line number Diff line number Diff line Loading @@ -8,30 +8,42 @@ from codesp import simulate_star_trajectory def main(): # test() simulate_star_trajectory(semi_major_axis=1.0, eccentricity=0.1, period=365.25, start_date='2023/1/1', end_date='2024/1/1', step_days=10) # # 定义初始路径和目标路径 # source_dir = '/workspace/input/' # target_dir = '/workspace/output/' # # 确保源路径存在 # if not os.path.exists(source_dir): # print(f"错误:源路径 {source_dir} 不存在。") # else: # # 创建目标路径(如果不存在) # os.makedirs(target_dir, exist_ok=True) # 定义初始路径和目标路径 source_dir = '/workspace/input/' source_file='/workspace/input/star_trajectory.png' target_dir = '/workspace/output/' # # 获取源路径下的所有文件(不递归子目录) # for file_name in os.listdir(source_dir): # source_file = os.path.join(source_dir, file_name) # target_file = os.path.join(target_dir, file_name) # 判断文件是否存在 if os.path.exists(source_file): # 满足条件,删除文件 os.remove(source_file) print(f"文件 {source_file} 已删除。") else: print(f"文件 {source_file} 不存在,无需删除。") # # 只拷贝文件,忽略子目录 # if os.path.isfile(source_file): # shutil.copy2(source_file, target_file) # copy2 保留元数据(如修改时间) # print(f"已拷贝: {source_file} -> {target_file}") #模拟恒星轨迹,且将结果保存为可视化图片star_trajectory.png simulate_star_trajectory(semi_major_axis=1.0, eccentricity=0.1, period=365.25, start_date='2023/1/1', end_date='2024/1/1', step_days=10) # print("拷贝完成。") #将生成的star_trajectory.png图片拷贝到output路径下查看 # 确保源路径存在 if not os.path.exists(source_dir): print(f"错误:源路径 {source_dir} 不存在。") else: # 创建目标路径(如果不存在) os.makedirs(target_dir, exist_ok=True) # 获取源路径下的所有文件(不递归子目录) for file_name in os.listdir(source_dir): source_file = os.path.join(source_dir, file_name) target_file = os.path.join(target_dir, file_name) # 只拷贝文件,忽略子目录 if os.path.isfile(source_file): shutil.copy2(source_file, target_file) # copy2 保留元数据(如修改时间) print(f"已拷贝: {source_file} -> {target_file}") print("拷贝完成。") if __name__ == '__main__': main() star_trajectory.pngdeleted 100644 → 0 −31.1 KiB Loading image diff... Loading
__pycache__/codesp.cpython-311.pyc +9 B (2.45 KiB) File changed.No diff preview for this file type. View original file View changed file
codesp.py +2 −2 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ import ephem # print("❌ Jinja2 测试失败:", e) #模拟恒星轨迹,且将结果保存为可视化图片 def simulate_star_trajectory(semi_major_axis, eccentricity, period, start_date, end_date, step_days): # Initialize observer location (e.g., Earth location) Loading Loading @@ -63,7 +63,7 @@ def simulate_star_trajectory(semi_major_axis, eccentricity, period, start_date, plt.legend() plt.grid() plt.show() plt.savefig("star_trajectory.png") plt.savefig("../input/star_trajectory.png") print("图像已保存为 star_trajectory.png") # try: Loading
run.py +32 −20 Original line number Diff line number Diff line Loading @@ -8,30 +8,42 @@ from codesp import simulate_star_trajectory def main(): # test() simulate_star_trajectory(semi_major_axis=1.0, eccentricity=0.1, period=365.25, start_date='2023/1/1', end_date='2024/1/1', step_days=10) # # 定义初始路径和目标路径 # source_dir = '/workspace/input/' # target_dir = '/workspace/output/' # # 确保源路径存在 # if not os.path.exists(source_dir): # print(f"错误:源路径 {source_dir} 不存在。") # else: # # 创建目标路径(如果不存在) # os.makedirs(target_dir, exist_ok=True) # 定义初始路径和目标路径 source_dir = '/workspace/input/' source_file='/workspace/input/star_trajectory.png' target_dir = '/workspace/output/' # # 获取源路径下的所有文件(不递归子目录) # for file_name in os.listdir(source_dir): # source_file = os.path.join(source_dir, file_name) # target_file = os.path.join(target_dir, file_name) # 判断文件是否存在 if os.path.exists(source_file): # 满足条件,删除文件 os.remove(source_file) print(f"文件 {source_file} 已删除。") else: print(f"文件 {source_file} 不存在,无需删除。") # # 只拷贝文件,忽略子目录 # if os.path.isfile(source_file): # shutil.copy2(source_file, target_file) # copy2 保留元数据(如修改时间) # print(f"已拷贝: {source_file} -> {target_file}") #模拟恒星轨迹,且将结果保存为可视化图片star_trajectory.png simulate_star_trajectory(semi_major_axis=1.0, eccentricity=0.1, period=365.25, start_date='2023/1/1', end_date='2024/1/1', step_days=10) # print("拷贝完成。") #将生成的star_trajectory.png图片拷贝到output路径下查看 # 确保源路径存在 if not os.path.exists(source_dir): print(f"错误:源路径 {source_dir} 不存在。") else: # 创建目标路径(如果不存在) os.makedirs(target_dir, exist_ok=True) # 获取源路径下的所有文件(不递归子目录) for file_name in os.listdir(source_dir): source_file = os.path.join(source_dir, file_name) target_file = os.path.join(target_dir, file_name) # 只拷贝文件,忽略子目录 if os.path.isfile(source_file): shutil.copy2(source_file, target_file) # copy2 保留元数据(如修改时间) print(f"已拷贝: {source_file} -> {target_file}") print("拷贝完成。") if __name__ == '__main__': main()