In [1]:
%reload_ext autotime
import pandas as pd
import plotly.express as px
import numpy as np
from scipy.optimize import curve_fit
df = pd.read_csv("Data_for_Generating_AI/LabData.csv",sep=";").ffill()
df
✔️ 470 ms (2024-11-14T10:10:48/2024-11-14T10:10:48)
Out[1]:
Dataset | Experiment | SLR | ΩHs | WR | |
---|---|---|---|---|---|
0 | Atkinson (smallest scale) | A1 | 0.050 | 0.0417 | -0.13760 |
1 | Atkinson (smallest scale) | A2 | 0.035 | 0.0616 | 0.13600 |
2 | Atkinson (smallest scale) | A3 | 0.035 | 0.0616 | 0.05220 |
3 | Atkinson (smallest scale) | E1 | 0.065 | 0.3523 | 0.29160 |
4 | Atkinson (smallest scale) | E2 | 0.065 | 0.3250 | 0.50245 |
5 | Atkinson (smallest scale) | E3 | 0.065 | 0.3250 | 0.48090 |
6 | Atkinson (smallest scale) | E4 | -0.065 | 0.3250 | -0.02170 |
7 | Atkinson (smallest scale) | E5 | 0.050 | 0.5424 | 0.40295 |
8 | Atkinson (smallest scale) | E6 | 0.065 | 0.3523 | 0.41485 |
9 | Beuzen (slightly larger scale) | E11 | 0.015 | 0.4500 | 0.12420 |
10 | Beuzen (slightly larger scale) | E12 | 0.015 | 0.4500 | 0.08560 |
11 | Beuzen (slightly larger scale) | E13 | 0.015 | 0.4500 | 0.12640 |
12 | Beuzen (slightly larger scale) | E14 | 0.015 | 0.4500 | 0.07170 |
13 | Beuzen (slightly larger scale) | E15 | 0.015 | 0.4500 | 0.16690 |
14 | Beuzen (slightly larger scale) | E2 | 0.075 | 0.4500 | 0.64690 |
15 | Bayle (large scale) | E1 | 0.100 | 2.7040 | 1.06050 |
16 | Bayle (large scale) | E2 | 0.100 | 2.7040 | 0.95010 |
17 | Bayle (large scale) | E3 | 0.100 | 2.7040 | 0.90010 |
18 | Bayle (large scale) | E4 | 0.100 | 2.7040 | 1.67000 |
In [2]:
x = df.SLR
y = df['ΩHs']
z = df.WR
px.scatter_3d(df, "SLR", "ΩHs", "WR", color="Dataset")
✔️ 336 ms (2024-11-14T10:10:48/2024-11-14T10:10:49)
In [3]:
def func(xy, a, b, c, d, e, f):
x, y = xy
return a + b*x + c*y + d*x**2 + e*y**2 + f*x*y
popt, pcov = curve_fit(func, (x, y), z)
X, Y = np.meshgrid(np.linspace(x.min(), x.max(), 10), np.linspace(y.min(), y.max(), 10))
Z = func((X, Y), *popt)
✔️ 7.28 ms (2024-11-14T10:10:49/2024-11-14T10:10:49)
In [4]:
dfs = []
for i in range(len(X)):
dfs.append(pd.DataFrame({"SLR": X[i], "ΩHs": Y[i], "WR": Z[i], "Dataset":"generated"}))
gen_df = pd.concat(dfs)
gen_df = gen_df[gen_df["WR"] > df["WR"].min()]
px.scatter_3d(pd.concat((df, gen_df)), x="SLR", y="ΩHs", z="WR", color="Dataset", opacity=.5)
✔️ 59.8 ms (2024-11-14T10:10:49/2024-11-14T10:10:49)
In [5]:
gen_df.to_csv("generated.csv", index=False)
✔️ 5.93 ms (2024-11-14T10:10:49/2024-11-14T10:10:49)
In [6]:
df = pd.read_csv("NonDimens_Data_for_Generating_AI_csv/NonDimLabData.csv").ffill()
df
✔️ 10.5 ms (2024-11-14T10:10:49/2024-11-14T10:10:49)
Out[6]:
Dataset | Experiment | SLR/d | ΩHs/Lo | Non-Dim WR | |
---|---|---|---|---|---|
0 | Atkinson (smallest scale) | A1 | 0.083333 | 0.015367 | -0.135185 |
1 | Atkinson (smallest scale) | A2 | 0.058333 | 0.012099 | 0.092442 |
2 | Atkinson (smallest scale) | A3 | 0.058333 | 0.012099 | 0.045138 |
3 | Atkinson (smallest scale) | E1 | 0.108333 | 0.192451 | 0.234558 |
4 | Atkinson (smallest scale) | E2 | 0.108333 | 0.177932 | 0.276475 |
5 | Atkinson (smallest scale) | E3 | 0.108333 | 0.177932 | 0.214309 |
6 | Atkinson (smallest scale) | E4 | -0.097744 | 0.174332 | -0.060000 |
7 | Atkinson (smallest scale) | E5 | 0.083333 | 0.349585 | 0.193251 |
8 | Atkinson (smallest scale) | E6 | 0.015000 | 0.175322 | 0.045963 |
9 | Beuzen (slightly larger scale) | E11 | 0.014778 | 0.174910 | 0.032018 |
10 | Beuzen (slightly larger scale) | E12 | 0.014563 | 0.174513 | 0.033441 |
11 | Beuzen (slightly larger scale) | E13 | 0.014354 | 0.174136 | 0.032897 |
12 | Beuzen (slightly larger scale) | E14 | 0.014151 | 0.173783 | 0.048792 |
13 | Beuzen (slightly larger scale) | E15 | 0.075000 | 0.175322 | 0.200677 |
14 | Beuzen (slightly larger scale) | E2 | 0.025000 | 0.048139 | 0.043728 |
15 | Bayle (large scale) | E1 | 0.024390 | 0.048518 | 0.040084 |
16 | Bayle (large scale) | E2 | 0.023810 | 0.048880 | 0.065592 |
17 | Bayle (large scale) | E3 | 0.023256 | 0.049228 | 0.052838 |
18 | Bayle (large scale) | E4 | 0.023256 | 0.049228 | 0.052838 |
In [7]:
x = df["SLR/d"]
y = df['ΩHs/Lo']
z = df["Non-Dim WR"]
px.scatter_3d(df, x, y, z, color="Dataset")
✔️ 42.4 ms (2024-11-14T10:10:49/2024-11-14T10:10:49)
In [8]:
def func(xy, a, b, c, d, e, f):
x, y = xy
return a + b*x + c*y + d*x**2 + e*y**2 + f*x*y
popt, pcov = curve_fit(func, (x, y), z)
X, Y = np.meshgrid(np.linspace(x.min(), x.max(), 10), np.linspace(y.min(), y.max(), 10))
Z = func((X, Y), *popt)
✔️ 5.11 ms (2024-11-14T10:10:49/2024-11-14T10:10:49)
In [9]:
dfs = []
for i in range(len(X)):
dfs.append(pd.DataFrame({"SLR/d": X[i], "ΩHs/Lo": Y[i], "Non-Dim WR": Z[i], "Dataset":"generated"}))
gen_df = pd.concat(dfs)
gen_df = gen_df[gen_df["Non-Dim WR"] > df["Non-Dim WR"].min()]
px.scatter_3d(pd.concat((df, gen_df)), x="SLR/d", y="ΩHs/Lo", z="Non-Dim WR", color="Dataset", opacity=.5)
✔️ 49.6 ms (2024-11-14T10:10:50/2024-11-14T10:10:50)
In [10]:
gen_df.to_csv("generated_nondim.csv", index=False)
✔️ 4.1 ms (2024-11-14T10:10:50/2024-11-14T10:10:50)