import numpy as np
import pandas as pd
import PyCO2SYS as pyco2
import matplotlib.pyplot as plt
n = 100
DIC = np.empty((n,1))
TEMP = np.empty((n,1))
PRES = np.empty((n,1))
PRES2 = np.empty((n,1))
SAL = np.empty((n,1))
pH = np.empty((n,1))
DIC[:] = 2300
TEMP[:] = 20
PRES[:] = 0
PRES2[:] = 4000
SAL[:] = 35
print(DIC.shape)
pH_temp = np.linspace(0,12,n)
pH[:,0] = pH_temp
results = pyco2.sys(
par1=DIC,
par2=pH,
par1_type=2,
par2_type=3,
temperature=TEMP,
pressure=PRES,
salinity=SAL,
temperature_out=25.,#*np.ones(argo_n[pres_name].shape), #fixed 25C temperature
pressure_out= PRES,
total_silicate=0,
total_phosphate=0,
opt_pH_scale = 1, #total
opt_k_carbonic=10, #Lueker et al. 2000
opt_k_bisulfate=1, # Dickson 1990 (Note, matlab co2sys combines KSO4 with TB. option 3 = KSO4 of Dickson & TB of Lee 2010)
opt_total_borate=2, # Lee et al. 2010
opt_k_fluoride=2, # Perez and Fraga 1987
opt_buffers_mode=1,
)
results2 = pyco2.sys(
par1=DIC,
par2=pH,
par1_type=2,
par2_type=3,
temperature=TEMP,
pressure=PRES2,
salinity=SAL,
temperature_out=25.,#*np.ones(argo_n[pres_name].shape), #fixed 25C temperature
pressure_out= PRES2,
total_silicate=0,
total_phosphate=0,
opt_pH_scale = 1, #total
opt_k_carbonic=10, #Lueker et al. 2000
opt_k_bisulfate=1, # Dickson 1990 (Note, matlab co2sys combines KSO4 with TB. option 3 = KSO4 of Dickson & TB of Lee 2010)
opt_total_borate=2, # Lee et al. 2010
opt_k_fluoride=2, # Perez and Fraga 1987
opt_buffers_mode=1,
)
fig = plt.figure(figsize=(8, 5), )
ax = fig.add_subplot(1,1,1)
ax.plot(pH, results['CO3_out'], label='[CO$_3$$^{2-}$]')
ax.plot(pH, results['HCO3_out'], label='[HCO$_3$$^{-}$]')
ax.plot(pH, results['aqueous_CO2'], label='[CO$_{2,aq}$]')
ax.hlines(y=DIC[0], xmax=0, xmin=12,colors='k', linestyles='--', label='[DIC]')
ax.legend()
ax.plot(pH, results2['CO3_out'], label='[CO$_3$$^{2-}$]')
ax.plot(pH, results2['HCO3_out'], label='[HCO$_3$$^{-}$]')
ax.plot(pH, results2['aqueous_CO2'], label='[CO$_{2,aq}$]')
ax.set_xlabel('pH (total scale)')
ax.set_ylabel(r'log [C] ($\mu$mol kg$^{-1}$)')
ax.set_yscale('log')
ax.set_ylim(10**-6, 10**4)
plt.draw()