Link Search Menu Expand Document

Python

Documentation to start using Kgen in Python.

Installation

PyPI version

Kgen is available for installation from the PyPI package manager:

pip install Kgen

This will install Kgen and its dependencies, including pymyami.

Getting Started

Two functions are available in Python, calc_Ks for returning all available Ks, and calc_K for returning a single K.

from kgen import calc_Ks, calc_K

calc_Ks(temp_c=20, sal=35, p_bar=0, magnesium=0.3, calcium=None)

Where temp_c is the temperature in degrees Celsius, sal is the salinity in PSU, p_bar is the pressure in bars, and magnesium and calcium are the magnesium and calcium concentrations in average seawater in mol kg-1.

The inputs to these parameters may be single numbers or arrays of numbers, but where they are arrays the shape of the array must be the same.

If any value is not specified, or is None, it defaults back to ‘standard’ conditions of 25 Celcius, 35 PSU, and 0 bar, with Mg and Ca at modern ocean concentrations (0.0528171 and 0.0102821 mol kg-1).

You can specify whether to calculate Mg and Ca correction factors directly or use the polynomial approximation by specifying the MyAMI_mode parameter to either 'calculate' or 'approximate'.