Commit 03e19b12 authored by Jenni Rinker's avatar Jenni Rinker
Browse files

fixing bug in h2turb_to_df

parent ea016cb0
Pipeline #13708 passed with stage
in 1 minute and 38 seconds
......@@ -193,5 +193,5 @@ def h2turb_to_df(spat_df, path, nt=600, dt=1, prefix=''):
comp_df = pd.DataFrame(arr.reshape(nx, ny*nz),
index=t).add_prefix(f'{c}_p')
turb_df = turb_df.join(comp_df, how='outer')
turb_df = turb_df[[f'{c}_p{i}' for i in range(2) for c in 'uvw']]
turb_df = turb_df[[f'{c}_p{i}' for i in range(ny*nz) for c in 'uvw']]
return turb_df
......@@ -14,12 +14,13 @@ def test_pctdf_to_h2turb():
"""save PyConTurb dataframe as HAWC2 binary file and load again"""
# given
path = '.'
spat_df = gen_spat_grid(0, [50, 70])
z = np.array([50, 70, 80])
spat_df = gen_spat_grid(0, z)
nt, dt = 100, 0.2
t = np.arange(nt) * dt
turb_df = pd.DataFrame(np.random.rand(nt, 6),
turb_df = pd.DataFrame(np.random.rand(nt, 3*z.size),
index=t,
columns=[f'{c}_p{i}' for i in range(2) for c in 'uvw'])
columns=[f'{c}_p{i}' for i in range(z.size) for c in 'uvw'])
# when
df_to_h2turb(turb_df, spat_df, '.')
test_df = h2turb_to_df(spat_df, path, nt=nt, dt=dt)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment