<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 pyIAST example (N$_2$, CO$_2$, H$_2$O)
data from Mason et al. here
construct models for pure-component adsorption isotherms
Step1:  binary (CO$_2$/N$_2$ adsorption)
CO$_2$ partial pressure
Step2:  ternary (CO$_2$/N$_2$/H$_2$O adsorption)
CO$_2$ partial pressure
Step3:  compare to experiment
see Fig. 6 in Mason et al.
<ASSISTANT_TASK:>
Python Code:
df_N2 = pd.read_csv("N2.csv", skiprows=1)
N2_isotherm = pyiast.ModelIsotherm(df_N2, loading_key="Loading(mmol/g)", 
                                         pressure_key="P(bar)", model='Henry')
pyiast.plot_isotherm(N2_isotherm)
N2_isotherm.print_params()
df_CO2 = pd.read_csv("CO2.csv", skiprows=1)
CO2_isotherm = pyiast.ModelIsotherm(df_CO2, loading_key="Loading(mmol/g)", 
                                         pressure_key="P(bar)", model="Langmuir")
CO2_isotherm.print_params()
pyiast.plot_isotherm(CO2_isotherm)
df_H2O = pd.read_csv("H2O.csv", skiprows=1)
H2O_isotherm = pyiast.InterpolatorIsotherm(df_H2O, loading_key="Loading(mmol/g)", 
                                         pressure_key="P(bar)", 
                                      fill_value=df_H2O["Loading(mmol/g)"].max())
pyiast.plot_isotherm(H2O_isotherm)
Explanation: pyIAST example (N$_2$, CO$_2$, H$_2$O)
data from Mason et al. here
construct models for pure-component adsorption isotherms
End of explanation
p = np.array([.166, .679]) # mbar
print("total P = ", np.sum(p))
q = pyiast.iast(p, [CO2_isotherm, N2_isotherm])
print(q)
Explanation: binary (CO$_2$/N$_2$ adsorption)
CO$_2$ partial pressure: 166 mbar
N$_2$ partial pressure: 679 mbar
End of explanation
p3 = np.array([.166, .679, .02]) # mbar 
print("total P = ", np.sum(p3))
q3 = pyiast.iast(p3, [CO2_isotherm, N2_isotherm, H2O_isotherm], verboseflag=True)
q3
Explanation: ternary (CO$_2$/N$_2$/H$_2$O adsorption)
CO$_2$ partial pressure: 166 mbar
N$_2$ partial pressure: 679 mbar
H$_2$O partial pressure: 0.02 mbar
End of explanation
p_mix = np.array([.16562, .67912])
q_mix = np.array([.34, .27])
yerr = np.array([.1, .14])
fig = plt.figure(facecolor='w')
plt.plot(df_CO2['P(bar)'], df_CO2['Loading(mmol/g)'], marker='o', color='g', label='pure CO$_2$', markersize=10)
plt.plot(df_N2['P(bar)'], df_N2['Loading(mmol/g)'], marker='*', color='b', label='pure N$_2$', markersize=12)
plt.xlabel("Pressure (bar)")
# plt.scatter(p3[:-1], q3[:-1], color='orange', marker='s',s=50,zorder=110, label='IAST')
plt.scatter(p, q, color='orange', marker='s',s=45,zorder=110, label='IAST')
plt.scatter(p_mix, q_mix, marker='x', zorder=200, color='k', s=50, label='Expt')
plt.errorbar(p_mix, q_mix,color='k', yerr=yerr, linestyle='none', markersize=50)
plt.xlim([0, 1.0])
plt.ylim([0, 2.0])
plt.ylabel("Gas uptake (mmol/g)")
plt.legend(loc='upper left')
plt.savefig('JaradMason.pdf', format='pdf',  facecolor=fig.get_facecolor())
fig = plt.figure(facecolor='w')
p_plot = np.linspace(0, 1)
plt.scatter(df_CO2['P(bar)'], df_CO2['Loading(mmol/g)'], 
            marker='o', color='g', label='pure CO$_2$', s=60)
plt.plot(p_plot, CO2_isotherm.loading(p_plot), color='g')
plt.scatter(df_N2['P(bar)'], df_N2['Loading(mmol/g)'], 
            marker='s', color='b', label='pure N$_2$', s=60)
plt.plot(p_plot, N2_isotherm.loading(p_plot), color='b')
plt.xlabel("Pressure (bar)")
plt.axvline(x=0.679, linewidth=2, color='b', linestyle='--')
plt.axvline(x=0.166, linewidth=2, color='g', linestyle='--')
# plt.scatter(p3[:-1], q3[:-1], color='orange', marker='s',s=45,zorder=110, label='IAST')
# plt.scatter(p, q, color='orange', marker='s',s=45,zorder=110, label='IAST')
# plt.scatter(p_mix, q_mix, marker='x', zorder=200, color='k', s=56, label='Expt')
# plt.errorbar(p_mix, q_mix,color='k', yerr=yerr, linestyle='none')
plt.xlim([-.05, 1.0])
plt.ylim([-.1, 2.0])
plt.ylabel("Gas uptake (mmol/g)")
plt.legend(loc='upper left')
plt.tight_layout()
plt.savefig('JaradMason_N2_and_CO2.pdf', format='pdf', facecolor=fig.get_facecolor())
fig = plt.figure(facecolor='w')
plt.scatter(df_H2O['P(bar)'], df_H2O['Loading(mmol/g)'], marker='o', 
         color='r', label='pure H$_2$O', s=60)
plt.plot(np.linspace(0, .07), H2O_isotherm.loading(np.linspace(0, 0.07)), color='r')
plt.axvline(x=.02, linewidth=2, color='r', linestyle='--')
plt.xlabel("Pressure (bar)")
plt.xlim([-.05*.07, 0.07])
plt.ylim([-.05*45, 45.])
plt.ylabel("Water uptake (mmol/g)")
plt.legend(loc='upper center')
plt.tight_layout()
plt.savefig('JaradMason_H2O.pdf', format='pdf', facecolor=fig.get_facecolor())
ind = np.arange(3)  # the x locations for the groups
width = 0.35       # the width of the bars
fig, ax = plt.subplots(facecolor='w')
rects1 = ax.bar(ind, q3, width, color=['g', 'b', 'r'], hatch='*')
#  rects1 = ax.bar(np.arange(2), q, width, color=['g', 'b'], hatch='//')
rects2 = ax.bar(np.arange(2)+width, q_mix, width, color=['g', 'b', 'r'], yerr=yerr, ecolor='k')
# add some text for labels, title and axes ticks
ax.set_ylabel('Gas uptake (mmol/g)')
# ax.set_title('Sc')
ax.set_xticks(ind+width)
ax.set_xticklabels(('CO$_2$', 'N$_2$', r'H$_2$O') )
#x.legend( (rects1[0], rects2[0]), ('Exp\'t', 'IAST') , loc='upper center')
def autolabel(rects):
    # attach some text labels
    for rect in rects:
        height = rect.get_height()
        #ax.text(rect.get_x()+rect.get_width()/2., 1.05*height, '%.2f'% height,
        ax.text(rect.get_x()+rect.get_width()/2., .05, '%.2f'% height,
                ha='center', va='bottom', fontsize=15, weight='bold',
                backgroundcolor='w')
bbox_props = dict(boxstyle="round", fc="w", ec="0.5", alpha=0.9)
ax.text(2.35+rects1[0].get_width()/2., .05, 'N/A',
                ha='center', va='bottom', 
                fontsize=15, weight='bold',
                backgroundcolor='w')
plt.xlim([-.05,3-width+.05])
autolabel(rects1)
autolabel(rects2)
plt.tight_layout()
plt.savefig('JaradMason_IAST.pdf', format='pdf', facecolor=fig.get_facecolor())
plt.savefig('JaradMason_IAST.png', format='png', facecolor=fig.get_facecolor(), dpi=250)
plt.show()
Explanation: compare to experiment
see Fig. 6 in Mason et al.
End of explanation
<END_TASK>