Ejemplo n.º 1
0
    "total_sulfate": [[3], [5]],
    "k_carbonic_1": [1e-6, 1.1e-6, 1.2e-6],
    "temperature_out": 0,
}
co2nd = pyco2.sys(par1, par2, par1_type, par2_type, **kwargs)


def test_nd_misc():
    assert (np.shape(co2nd["k_carbonic_2"]) == pyco2.engine.nd.broadcast1024(
        par1, par2, par1_type, par2_type, *kwargs.values()).shape)


test_nd_misc()

# Test with all scalar inputs
co2nd_scalar = pyco2.CO2SYS_nd(2300, 2150, 1, 2)


def test_scalars():
    assert np.all([np.size(v) == 1 for v in co2nd_scalar.values()])


test_scalars()

# Test with TA/DIC grid
par1g = np.linspace(2100, 2400, 11)
par2g = np.vstack(np.linspace(2000, 2300, 11))
par1g_type = 1
par2g_type = 2
co2nd_grid = pyco2.CO2SYS_nd(par1g, par2g, par1g_type, par2g_type)
Ejemplo n.º 2
0
titrant_molinity = 0.3  # mol/kg
titrant_mass = np.arange(0, 2.51, 0.05) * 1e-3  # kg
dilution_factor = sample_mass / (sample_mass + titrant_mass)

# Dilute alkalinity etc. through the titration
alkalinity = (
    1e6
    * (sample_mass * alkalinity * 1e-6 - titrant_molinity * titrant_mass)
    / (sample_mass + titrant_mass)
)
dic *= dilution_factor
for k in ["total_borate", "total_fluoride", "total_sulfate"]:
    kwargs[k] *= dilution_factor

# Solve for pH, no phosphate
results_pH = pyco2.CO2SYS_nd(alkalinity, dic, 1, 2, **kwargs)
pH = results_pH["pH_free"]

# And again, with phosphate
kwargs.update(
    {
        "total_phosphate": 10 * dilution_factor,
        "k_phosphate_1": 1 / 5.68e1,
        "k_phosphate_2": 8e-7,
        "k_phosphate_3": 1.32e-15 / 8e-7,
    }
)
pH_phosphate = pyco2.CO2SYS_nd(alkalinity, dic, 1, 2, **kwargs)["pH_free"]

# Compare with D81's tables
d81_pH = np.genfromtxt(