When points asked for are asked twice, the code deletes the two.
Bug report
Minimum working example
ask for a grid point twice. Can happen if a LiDAR pattern is asked to be simulated on top of a grid when generating an unconstrained wind box. The pattern may look like this :
#Circle pattern
phi = np.linspace(0,2*np.pi-2*np.pi/50,50)
y = D/2*np.sin(phi)
z = D/2*np.cos(phi)+HubHeight
#grid (small grid for speed reasons)
y1 = np.linspace(-77.5, 77.5,5) # lateral components of turbulent grid
z1 = np.linspace(41.225, 196.225,5) # vertical components of turbulent grid
y2,z2 = np.meshgrid(y1,z1)
ytemp = np.append(y2.T.ravel(),y)
ztemp = np.append(z2.T.ravel(),z)
#add spinnerlidar like pattern (here 10 points is enough to have the bug)
x = list(range(10))
phi = [2*np.pi*xi/len(x) for xi in x];
frequency1 = 5
frequency2 = 11
phase = np.pi/2
y = [77.5/2*(np.sin(frequency1*phi_ind) + np.sin(frequency2*phi_ind + phase)) for phi_ind in phi]
z = [77.5/2*(np.cos(frequency1*phi_ind) + np.cos(frequency2*phi_ind + phase)) + 118.725 for phi_ind in phi]
In order to ask this kind of pattern, a function has to be tweeked by using gen-cust_grid (custom function) instead of gen_spat_grid (meshgrid line disappears):
def gen_spat_grid(y, z, comps=[0, 1, 2]):
ys, zs = np.meshgrid(y, z) # make a meshgrid
ks = np.array(comps, dtype=int) # sanitizing
xs = np.zeros_like(ys) # all points in a plane
col_names = [f'{"uvw"[k]}_p{ip}' for ip in range(xs.size) for k in ks]
spat_arr = np.c_[np.tile(comps, xs.size),
np.repeat(np.c_[xs.T.ravel(), ys.T.ravel(), zs.T.ravel()],
ks.size, axis=0)].T # create array using numpy
return pd.DataFrame(spat_arr, index=_spat_rownames, columns=col_names)
def gen_cust_grid(ys, zs, comps=[0, 1, 2]):
ks = np.array(comps, dtype=int) # sanitizing
xs = np.zeros_like(ys) # all points in a plane
col_names = [f'{"uvw"[k]}_p{ip}' for ip in range(xs.size) for k in ks]
spat_arr = np.c_[np.tile(comps, xs.size),
np.repeat(np.c_[xs.T.ravel(), ys.T.ravel(), zs.T.ravel()],
ks.size, axis=0)].T # create array using numpy
return pd.DataFrame(spat_arr, index=_spat_rownames, columns=col_names)
Expected behavior
Turbulence is generated on all asked grid points in the order required.
Current behavior
Points that are asked for twice dissapear. (both disappear!)
PyConTurb verion
PyConTurb version: Editable installation? <Yes/No/Don't know>
Note that the version can be found by pip show pyconturb
.