### imports
import pandas as pd
import matplotlib.pyplot as plt
### definitions
e12_series = [1.0, 1.2, 1.5, 1.8, 2.2, 2.7, 3.3, 3.9, 4.7, 5.6, 6.8, 8.2]
def mppc_volt(r1, r2):
return 1.175 * (1 + r1/r2)
def gen_df(series):
l = []
for r1 in series:
for r2 in series:
l.append((r1, r2, mppc_volt(r1, r2)))
return pd.DataFrame(l, columns=["r1", "r2", "v_mppc"])
### generate df and plot
df = gen_df(e12_series)
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(13, 5))
for v in e12_series:
filt = df['r1'] == v
df.where(filt).dropna().plot(ax=ax1, x='v_mppc', y='r2', kind='line', label=v, marker='x')
if v in e12_series[-3:]:
df.where(filt).dropna().plot(ax=ax2, x='v_mppc', y='r2', kind='line', label=v, marker='x', logy=True)
### approximate solar panel voltage
r_sel = 8.2
dfs = df.round(2).where(df['r1'] == r_sel).dropna()
dfs['v_sol'] = dfs.v_mppc.apply(lambda row: round(row/0.75, 2))
dfs
r1 | r2 | v_mppc | v_sol |
8.2 | 1.0 | 10.81 | 14.41 |
8.2 | 1.2 | 9.20 | 12.27 |
8.2 | 1.5 | 7.60 | 10.13 |
8.2 | 1.8 | 6.53 | 8.71 |
8.2 | 2.2 | 5.55 | 7.40 |
8.2 | 2.7 | 4.74 | 6.32 |
8.2 | 3.3 | 4.09 | 5.45 |
8.2 | 3.9 | 3.65 | 4.87 |
8.2 | 4.7 | 3.22 | 4.29 |
8.2 | 5.6 | 2.90 | 3.87 |
8.2 | 6.8 | 2.59 | 3.45 |
8.2 | 8.2 | 2.35 | 3.13 |