feat: dirty script to compare recenter generated blades

This commit is contained in:
Laurent FAINSIN 2023-04-14 13:09:44 +02:00
parent 4e59146e86
commit 859da1a847

37
compare_samples.py Normal file
View file

@ -0,0 +1,37 @@
from pathlib import Path
import numpy as np
import pyvista as pv
VTKFILE_NOMINAL = Path("~/data/stage-laurent-f/datasets/Rotor37/processed/nominal_blade_rotated.vtk")
# load nominal blade
nominal = pv.read(VTKFILE_NOMINAL)
# for each generated/sampled blade
gen_files = Path.cwd().glob("gen*.txt")
for gen_file in gen_files:
# load numpy txt
blade = np.loadtxt(gen_file)
# get top and bottom index (filter outliers a bit)
top = int(blade.shape[0] * 0.001)
bot = int(blade.shape[0] * 0.999)
# sort blade coordinates
sorted_blade = np.sort(blade, axis=0)
# get center of blade
center = (sorted_blade[bot, :] + sorted_blade[top, :]) / 2
# translate blade to world origin
blade -= center
# save to txt
np.savetxt(f"test_{gen_file.stem}.txt", blade)
# swap nominal points to blade points
nominal.points = blade
# save altered blade to vtk
nominal.save(f"test_{gen_file.stem}.vtk")