Oxygen Calculation Tools — pyrotoolbox documentation

# Oxygen Calculation Tools

A collection of functions to re-calculate results from measurements.

## Function to calculate oxygen partial pressure from raw data

The following functions can be used to calculate oxygen partial pressures from the phase angle dphi. All other oxygen units can be calculated from the partial pressure.

Module containing functions for oxygen unit conversions.

pyrotoolbox.oxygen.calculate_pO2(dphi, temperature, dphi0, dphi100, temp0, temp100, pressure, humidity, percentO2, f, m, kt, tt, mt, ft=0, freq=4000, **kwargs)

  Calculate pO2 in hPa for a given phase-angle and temperature.

  Parameters:

    - dphi – phase angle in °

    - temperature – in °C

    - dphi0 – phase angle at zero calibration point in °

    - dphi100 – phase angle at the upper calibration point in !

    - temp0 – temperature at zero calibration point in °C

    - temp100 – temperature at the upper calibration point in °C

    - pressure – pressure at the upper calibration point in mbar/hPa

    - humidity – relative humidity at the upper calibration point in %

    - percentO2 – oxygen content in the dry calibration gas (upper calibration point) in %

    - f – sensor constant

    - m – sensor constant

    - kt – sensor constant (in 1/K)

    - tt – sensor constant (in 1/K)

    - mt – sensor constant (in 1/K)

    - ft – sensor constant (in 1/K)

    - freq – modulation frequency in Hz

    - kwargs – to accept additional unused parameters. (allow passing **calibration without an error)

  Returns:

    pO2 in hPa

pyrotoolbox.oxygen.calculate_pO2_from_calibration(dphi, temperature, calibration: dict)

  Calculate pO2 in hPa for a given dphi, temperature and calibration.

  Params dphi:

    phase angle in °

  Parameters:

    - temperature – in °C

    - calibration – dictionary as generated by the parser functions (metadata[‘calibration’]).

  Expected entries:

    - dphi0 [°]

    - dphi100 [°]

    - temp0 [°C]

    - temp100 [°C]

    - pressure [mbar]

    - humidity [%]

    - percentO2 [%]

    - f

    - m

    - kt [1/K]

    - tt [1/K]

    - mt [1/K]

    - ft [1/K]

## Functions for unit conversions

The following functions are used to convert between oxygen units. The partial pressure of oxygen (in hPa) is the central unit. All units can be converted toward pO2 and all units can be calculated from pO2. It is also the measured unit on all devices.

Module containing functions for oxygen unit conversions.

pyrotoolbox.oxygen.i_only_think_in_hpa(df: DataFrame, m: dict) → Series

  Convert any oxygen data to hPa.

  Useful for people like me who prefer to look at oxygen data in hPa. This function takes the dataframe and metadata dict of the parser functions and returns the oxygen data in hPa. If you want to change the conditions of the conversions (e.g. assuming the experiment setup was wrong) use the convert_to_hPa function.

  Parameters:

    - df – DataFrame as generated by the parser functions.

    - m – metadata-dict as generated by the parser functions.

  Returns:

    Series with oxygen data in hPa.

pyrotoolbox.oxygen.i_have_a_fireplate_and_still_only_think_in_hPa(df: DataFrame, m: dict) → DataFrame

  A copy of the popular “i_only_think_in_hpa” function for fireplate data.

  This was separated due to different format of fireplate data, but works very similar.

  Parameters:

    - df – DataFrame as generated by the read_fireplate_workbench function.

    - m – metadata-dict as generated by the read_fireplate_workbench function.

  Returns:

    DataFrame with oxygen data in hPa.

pyrotoolbox.oxygen.convert_to_hPa(data: Series, unit: str, temperature=None, pressure=None, salinity=None) → Series

  Convert any oxygen unit to hPa.

  Parameters:

    - data – any oxygen data produced by a pyroscience device.

    - unit – unit of the data. Has to be one of (‘oxygen_hPa’, ‘oxygen_torr’, ‘oxygen_%O2’, ‘oxygen_%airsat’, ‘oxygen_µM’, ‘oxygen_µg/L’, ‘oxygen_mg/L’, ‘oxygen_mL/L’).

    - temperature – sample temperature. Used for all units except ‘oxygen_hPa’, ‘oxygen_torr’ and ‘oxygen_%O2’.

    - pressure – gas-pressure of or above the sample. Used for all units except ‘oxygen_hPa’ and ‘oxygen_torr’

    - salinity – salinity of the sample in g/L. Used for all dissolved oxygen units.

pyrotoolbox.oxygen.hPa_to_torr(data)

  Convert hPa to torr.

  Parameters:

    data – hPa data to convert.

pyrotoolbox.oxygen.hPa_to_percentO2(data, pressure)

  Convert hPa to %O2.

  Parameters:

    - data – hPa data to convert.

    - pressure – gas pressure of the sample in hPa.

pyrotoolbox.oxygen.hPa_to_percent_airsat(data, pressure, temperature)

  Convert hPa to %airsat. This is a unit for water samples and assumes 100% relative humidity.

  Parameters:

    - data – hPa data to convert.

    - pressure – gas pressure above the sample in hPa.

    - temperature – temperature of the sample in °C.

pyrotoolbox.oxygen.hPa_to_uM(data, temperature, salinity)

  Convert hPa to µM. This is a unit for water sample.

  Parameters:

    - data – hPa data to convert.

    - temperature – temperature of the sample in °C.

    - salinity – salinity of the sample in g/L.

pyrotoolbox.oxygen.hPa_to_mgL(data, temperature, salinity)

  Convert hPa to mg/L. This is a unit for water sample.

  Parameters:

    - data – hPa data to convert.

    - temperature – temperature of the sample in °C.

    - salinity – salinity of the sample in g/L.

## Helper functions for oxygen calculations

The following functions are implemented do to the above documented calculations. They might still be useful for your own unit conversions

Module containing functions for oxygen unit conversions.

pyrotoolbox.oxygen.vapour_pressure_water(temperature)

  Calculates the vapour pressure of water at given Temperature (°C), return in hPa

  #This is Equation (6) from Murray, F.W. 1967. On the computation of saturation vapour pressure. J. Applied Meteorology 6: 203-204

  Parameters:

    temperature – Temperature in °C

  Returns:

    vapour pressure in hPa

pyrotoolbox.oxygen.calc_oxygen_solubility(temperature, salinity)

  Calculate the oxygen solubility in µM for water with given temperature and salinity.

  The formula and constants from “From Garcia 1992: Oxygen solubility in seawater: better fitting equations” are used.

  Parameters:

    - temperature – water temperature (°C)

    - salinity – salinity of water (g/L)

  Returns:

    oxygen solubility in µM

pyrotoolbox.oxygen.calc_pressure_and_water_corrected_pO2(pressure, T, water_sat, percentO2=20.95)

  calculate the partial pressure of oxygen in air with a given water saturation and total pressure

  Parameters:

    - pressure – ambient pressure in hPa

    - T – Temperature in °C

    - water_sat – water saturation of the air in % (0-100)

    - percentO2 – percentage of oxygen in air in % (0-100). Default 20.95

  Returns:

    partial pressure of oxygen in hPa

## Examples

- Load AquapHOx-L data and recalculate dissolved oxygen with different salinity

- Oxygen unit conversions
  - Load data
  - convert input unit (%O2) to hPa
    - alternative:
  - convert hPa to all other oxygen units
  - unit conversion mg/L for different environmental conditions