Documentation

Core Functions

bgcArgoDMQC.core.calc_fixed_doxy_adjusted_error(floatdict, fix_err=10)

Calculate DOXY_ADJUSTED_ERROR for fixed partial pressure of 10 mbar PPOX_DOXY.

bgcArgoDMQC.core.calc_gain(data, ref, inair=True, zlim=25.0, verbose=True)

Calculate the gain for each profile by comparing float oxygen data to a reference data set, either NCEP for in-air or WOA surface data if in-air comparison is not available.

Parameters
  • data – float data dict object, output from load_argo()

  • ref – reference data set, either NCEP pO2 or WOA O2sat

  • inair – boolean flag to indicate if comparison to NCEP in-air data or WOA surface data should be done, default to in-air, but function also performs check

  • zlim – lower limit to define as ‘surface’ and take mean within, default value 25 dbar, for use only when inair is False

Returns

vector of gains surf_data: array of float surface stats (cycle, N, mean, std)

Return type

g

Author:

Christopher Gordon Fisheries and Oceans Canada chris.gordon@dfo-mpo.gc.ca

Last update: 2020-04-23

Change log:

bgcArgoDMQC.core.calc_gain_with_carryover(pO2_opt_air, pO2_ref_air, pO2_opt_water)

Calculate gain with carryover parameter, following Bittig et al. (2018).

Parameters
  • pO2_opt_air (array-like) – partial pressure measured by the oxygen optode in-air

  • pO2_ref_air (array-like) – partial pressure in-air from a reference dataset such as NCEP

  • pO2_opt_water (array-like) – partial pressure of oxygen measured by the optode just below the surface

Returns

need to run this by Henry and see if I’m doing it right

Derive the O2 slope including a correction for ‘carry-over’ effect, to account for the observation that optode in-air data do not represent pure air but show a bias by in-water O2 saturation excess/deficiency (Bittig and Kortzinger 2015). Johnson et al. (2015) confirm the ‘carry-over’ effect for optodes close to the surface (~20cm).

Carry-over effect is recommended to be account for Argo floats using in-air measurements, if enough surfacings are available (N > 20). It both removes an identified bias (which is most relevant for cases with strong super-/undersaturation and/or carry-overs) and reduces uncertainty on the O2 slope factor. The equation for linear regression is as follows (see, e.g., Bittig et al., 2018):

m*pO2^{optode}_{surf in-air} - pO2^{reference}_{in-air}

= c*(m*pO2^{optode}_{surf in-water} - pO2^{reference}_{in-air})

where:
  • m is the O2 slope factor: m = pO2_adjusted / pO2

  • pO2^{optode}_{surf in-air} is the oxygen partial pressure observed by

the optode in-air (i.e., close to the water surface), e.g., MC = X+11 - pO2^{reference}_{in-air} is the reference oxygen partial pressure in-air, e.g., from re-analysis data - pO2^{optode}_{surf in-water} is the oxygen partial pressure observed by the optode at the water surface (in-water), e.g., MC = X+10 or profile MC = X–10 - c is the slope of the ‘carry-over’ effect, i.e., the water-fraction of the observed optode in-air data.

Above equation can be used for linear regression to obtain m and c from data of the partial pressures (from several cycles together). See Thierry Virginie, Bittig Henry, The Argo-Bgc Team (2018). Argo quality control manual for dissolved oxygen concentration. https://doi.org/10.13155/46542

bgcArgoDMQC.core.get_config_dirs()

Get previously set local directories to look for Argo, WOA, and NCEP data.

bgcArgoDMQC.core.get_index(index='bgc', **kwargs)

Get the global, biogeochemical, synthetic, or metadata Argo index.

Parameters

index (str) – bgc for the biogeochemical Argo index, global for the core index, synthetic for the synthetic index, or meta for the metadata index

bgcArgoDMQC.core.load_argo(local_path, wmo, grid=False, verbose=True)

Function to load in all data from a single float, using BRtraj, meta, and Sprof files.

Parameters
  • local_path – local path of float data

  • wmo – float ID number

Returns

python dict() object with the following fields
  • floatName: WMO number, from input

  • floatType: Kind of float (APEX, ARVOR, etc.)

  • N_LEVELS: Number of depth levels, Argo dimension N_LEVELS

  • N_PROF: Number of profiles, Argo dimension N_PROF

  • LATITUDE: Latitude (-90, 90) for each profile

  • LONGITUDE: Longitude (-180, 180) for each profile

  • SDN: Serial Date Number for each profile

  • PRES: Pressure (dbar), compressed to vector (1D array)

  • TEMP: Temperature (deg C)

  • PSAL: Salinity (psu)

if the variables are available, it will also contain:
  • DOXY: Dissolved Oxygen (micromole/kg)

  • O2sat: Oxygen percent saturation (%)

  • PPOX_DOXY: Oxygen partial pressure (mbar) [if avail.]

  • TRAJ_CYCLE: Cycle number for PPOX_DOXY [if avail.]

  • inair: Boolean to indicate if in-air data exists

for all the variables listen above, there will also exist <PARAM>_QC fields for quality flags, and <PARAM>_ADJUSTED fields if they exist.

CYCLES, LATITUDE, LONGITUDE, and SDN all also have analogous <VAR>_GRID fields that match the dimension of PRES, TEMP, PSAL, DOXY, and O2SAT

Return type

floatData

Author:

Christopher Gordon Fisheries and Oceans Canada chris.gordon@dfo-mpo.gc.ca

Acknowledgement: this code is adapted from the SOCCOM SAGE_O2Argo matlab code, available via https://github.com/SOCCOM-BGCArgo/ARGO_PROCESSING, written by Tanya Maurer & Josh Plant

Change log:

  • 2020-04-22: updated so that pressure mask determines all variables - need to add all quality flags to output

  • 2020-04-29: switched file/path handling from os module to pathlib

  • 2020-10-28: read variable DOXY from BRtraj file and convert to PPOX_DOXY if PPOX_DOXY not in file

bgcArgoDMQC.core.ncep_to_float_track(varname, track, local_path='./')

Function to load NCEP reanalysis data for comparison with autonomous floats. Data to be interpolated along the provided track (t, lat, lon). Combines function load_ncep_data() and interp_ncep_data() for convenience, see documentation for those funcions for more detail.

Parameters
  • varname – either ‘pres’ (pressure) or ‘rhum’ (relative humidity)

  • track – array with the columns (SDN, lat, lon)

Returns

WOA depth array woa_interp: 2D array of requested WOA parameter (depth x time)

Return type

z

Author:

Christopher Gordon Fisheries and Oceans Canada chris.gordon@dfo-mpo.gc.ca

Last update: 2020-04-29

Change log:

bgcArgoDMQC.core.organize_files(files)

Sort files according to time they were recorded.

bgcArgoDMQC.core.read_all_variables(nc)

Read all variables and dimensions from an Argo netCDF file.

Parameters

nc – a netCDF file object

Returns

python dict with all variable and dimension names

Return type

floatData

bgcArgoDMQC.core.read_sprof_gridded_variables(nc)

Read all variables and dimensions from an Argo Sprof file, do not flatten arrays, keep as 2D arrays.

Parameters

nc – a netCDF file object

Returns

python dict with all variable and dimension names

Return type

floatData

bgcArgoDMQC.core.set_dirs(argo_path='./', woa_path=None, ncep_path=None)

Set local directories to look for Argo, WOA, and NCEP data.

Parameters
  • argo_path (str or path-like) – location of local Argo data

  • ncep_data (str or path-like) – location of local NCEP data

  • woa_path (str or path-like) – location of local World Ocean Atlas data

class bgcArgoDMQC.core.sprof(wmo, keep_fillvalue=False, rcheck=True, verbose=False)

Class that loads Argo synthetic profile data for a given float ID number (wmo).

Uses locally downloaded files, which should be setup using the set_dirs method:

sprof.set_dirs(
    argo_path='/data/path/Argo',
    ncep_path='/data/path/NCEP',
    woa_path='/data/path/WOA18'
)

Then, load the individual variables into fields in the class, for example:

syn = sprof(wmo)
print(syn.DOXY)
add_independent_data(date=None, lat=None, lon=None, data_dict=None, label=None, **kwargs)

Add independent data in order to easily plot and compare.

Parameters
  • date (optional, str, float, or date) – Date as a string (‘YYYY-MM-DD’), serial datenumber, or python date object.

  • data_dict (optional, dict) – Dictionary containing variables to be added, key names should match the naming convention to Argo variables

  • label (optional, str) – Label or name of the dataset being added, important when adding more than one source of independent data

  • **kwargs – Argo variable names and their values, essentailly the same as inputting a dictionary without having to actually build one

Returns

None

Example::

syn = sprof(wmo_number) df = pd.read_csv(‘my_winkler_data.csv’)

syn.add_independent_data(

date=’2020-10-04’, # metadata arguments, optional, if no date matches to first profile label=’Winkler’ # label to classify the data - for if you have more than one source PRES=df.pressure, # data arguments, match naming to Argo variables DOXY=df.dissolved_oxygen, LATITUDE=df.lat, LONGITUDE=df.lon, # again, optional

)

data = dict(PRES=df.PRES, DOXY=df.DOXY) syn.add_independent_data(data_dict=data, date=’2020-10-04’)

assign(floatdict)

Assign variables from float dictionary (output of load_argo(…)) to synthetic profile sprof() object.

calc_gains(ref='NCEP', zlim=25.0, verbose=True)

Calculate gain values using NCEP or WOA reference data. Uses function calc_gain().

check_range(key, verbose=False)

Performs a range check for variables that have a RTQC range available. Replaces values outside the range with NaN values. Takes string input to do the range check on that variable. Available variables are PRES, TEMP, PSAL, and DOXY. Can also take input ‘all’ to do the range check on all four variables, or a list of strings to do each of those variables.

clean(bad_flags=None)

Remove bad data from all variables, using <PARAM>_QC to determine bad data. Optional input bad_flags can be used to specify which flag values are bad, with a default bad flags set to be 4, 6, 7.

compare_independent_data(fmt='*', **kwargs)

Plot the independent data overtop of the nearest profile in time

describe()

Describe the dataframe of data stored in the sprof object.

get_ncep(verbose=True)

Loads NCEP data along the float track

get_track()

Creates a track array with columns:

[serial datenum, latitude, longitude]

the track array is used for the interpolation of reference data along the float track.

get_woa(verbose=True)

Loads WOA data along the float track

reset()

Reset all variables back to original loaded variables. Undoes the effect of clean(), rm_fillvalue(), check_range().

rm_fillvalue()

Remove FillValue from all variables.

set_dirs(woa_path=None, ncep_path=None)

Set local directories to look for Argo, WOA, and NCEP data.

Parameters
  • argo_path (str or path-like) – location of local Argo data

  • ncep_data (str or path-like) – location of local NCEP data

  • woa_path (str or path-like) – location of local World Ocean Atlas data

to_dataframe()

Returns a pandas dataframe containing data from the synthetic oxygen profile file.

to_dict()

Returns a deepcopy of __floatdict__, which is the currect active dictionary (i.e. subject to the effects of clean(), reset(), etc.)

class bgcArgoDMQC.core.traj(wmo, keep_fillvalue=False, verbose=False)

Class that loads Argo trajectory file data for a given float ID number (wmo).

bgcArgoDMQC.core.woa_to_float_track(track, param, zlim=(0, 1000), local_path='./', verbose=True)

Function to load WOA18 climatological data for comparison with autonomous floats. Data to be interpolated along the provided track (t, lat, lon). Combines function load_woa_data() and interp_woa_data() for convenience, see documentation for those funcions for more detail.

Parameters
  • track – array with the columns (SDN, lat, lon)

  • param – requested variable, valid inputs are - T: temperature - S: salinity - O2: dissolved oxygen - O2sat: oxygen percent saturation - NO3: nitrate - Si: silicate - PO4: phosphate

  • zlim – depth bounds (upper, lower), default to (0, 1000)

  • local_path – local directory where WOA files are stored, assumes current directory if no input

Returns

WOA depth array woa_interp: 2D array of requested WOA parameter (depth x time)

Return type

z

Author:

Christopher Gordon Fisheries and Oceans Canada chris.gordon@dfo-mpo.gc.ca

Last update: 2020-04-23

Change log:

File I/O Functions

bgcArgoDMQC.io.append_variable_to_file(fn, *args)

Add an arbitrary number of variables (*args) to the existing netcdf file input fn. The input structure for each variable should be a dictionary with fields that can be passed directly to the netCDF file. If the variable name already exists, it will overwrite it with the new information.

Parameters
  • fn – string pointing to netcdf (.nc) file to be appended

  • *args – arbitrary number of python dicts with all required fields to create

  • overwrite a new netcdf variable. Example (or) –

  • = dict( (new_var) – name=’MY_NEW_VARIABLE’, # variable name, can be new or existing datatype=np.float64, # variable datatype, can be np datatype or string dimensions=(‘N’, ‘M’), # will be created with warning if they do not exist data=data_arr, # the data long_name=’The new variable’, standard_name=’my_new_var’, units=’degree_celsius’, valid_min=0, valid_max=1e9, resolution=0.001, comment=’Added by John Doe on Sept 20, 2019’

  • )

bgcArgoDMQC.io.check_index(mode=None)

Function to check age of Argo metadata and profile global index files, warn if they have not been updated in more than 1 week. Runs on import.

bgcArgoDMQC.io.copy_netcdf_except(infile, outfile, exclude_vars=[], exclude_dims=[])

Copy data from a netCDF file with the exception of dimension and variable names listed in exclude_vars and exclude_dims.

bgcArgoDMQC.io.get_argo(*args, local_path='./', url='ftp.ifremer.fr', overwrite=False, summary_overwrite=True, ftype=None, mission='CB', mode='RD', __nfiles__=None)

Function to download all data from a single float, or individual profiles

Parameters
  • *args – list of files, floats, or directories

  • local_path (optional, str or Path) – local directory to save float data, defaults to current directory

  • url (optional, str) – url of the GDAC to connect to, defaults to ifremer or the value in the configuration file

  • overwrite (optional, bool) – whether to overwrite existing local files, default False

  • ftype (optional, str) – can be ‘summary’ if the user wishes to only download Sprof, traj, meta files, default is None

  • mission (optional, str) – Argo mission, can be ‘B’ for biogeochemical or ‘C’ for core, or ‘CB’ for both, default is ‘CB’

  • mode (optional, str) – Download real-time (‘R’) or delayed-mode (‘D’) or all (‘RD’) data, default ‘RD’

Returns

ftplib.FTP object

Author: Christopher Gordon

Fisheries and Oceans Canada chris.gordon@dfo-mpo.gc.ca

Last update: 29-04-2020

Change log:

2020-10-27: add nfiles parameter to limit number of files downloaded, helpful to speed up testing/coverage runs

bgcArgoDMQC.io.get_ncep(varname, local_path='./', overwrite=False, years=[2010, 2020])

Function to download NCEP reanalysis gaussian gridded surface air pressure data

INPUT:
varname: ‘pres’ (pressure) or ‘rhum’ (relative humidity)

or ‘land’ (to get land mask)

local_path: path to save files to, defaults

to current directory

overwrite: boolean flag, if False, does not re-download

existing files, if true, will download no matter what, defaults to False

OUTPUT:

ftp: the ftplib server object

AUTHOR: Christopher Gordon

Fisheries and Oceans Canada chris.gordon@dfo-mpo.gc.ca

LAST UPDATE: 29-04-2020

CHANGE LOG:

bgcArgoDMQC.io.get_woa18(varname, local_path='./', ftype='netcdf', overwrite=False, __nfiles__=None)

Function to download WOA data for a given variable

INPUT:
varname: woa18 variable to download data for - one of:

T: temperature S: salinity O2: dissolved oxygen O2sat: oxygen percent saturation NO3: nitrate Si: silicate PO4: phosphate

local_path: path to save files to (inside variable folder, ex.

if local_path = ‘../data/woa’, and varname = ‘T’, files will be saved in ../data/woa/temperature/*.nc. Defaults to current directory

ftype: file format to download, defaults to netcdf (.nc):

ascii: .dat csv: .csv netcdf: .nc

overwrite: boolean flag, if False, does not re-download

existing files, if true, will download no matter what, defaults to False

OUTPUT:

ftp: the ftplib server object

AUTHOR: Christopher Gordon

Fisheries and Oceans Canada chris.gordon@dfo-mpo.gc.ca

LAST UPDATE: 29-04-2020

CHANGE LOG:

bgcArgoDMQC.io.load_ncep_data(track, varname, local_path='./')

Function to load NCEP reanalysis data for comparison with autonomous float in-air data. Data to be interpolated along the provided track (t, lat, lon).

Parameters
  • track – array with the columns (SDN, lat, lon)

  • local_path – local directory where NCEP files are stored, assumes current directory if no input

Returns:

bgcArgoDMQC.io.load_woa_data(track, param, zlim=(0, 1000), local_path='./', verbose=True)

Function to load WOA18 climatological data for comparison with autonomous floats. Data to be interpolated along the provided track (t, lat, lon).

Parameters
  • track – array with the columns (SDN, lat, lon)

  • param – requested variable, valid inputs are - T: temperature - S: salinity - O2: dissolved oxygen - O2sat: oxygen percent saturation - NO3: nitrate - Si: silicate - PO4: phosphate

  • zlim – depth bounds (upper, lower), default to (0, 1000)

  • local_path – local directory where WOA files are stored, assumes current directory if no input

Returns

same as track input, but adjusted lon if the track crosses the 180/-180 meridian woa_track: list with z, lat, and lon arrays of WOA data data: gridded array of the input variable (month, z, lat, lon)

Return type

xtrack

Acknowledgement:

This code is adapted from the SOCCOM SAGE_O2Argo matlab code, available via https://github.com/SOCCOM-BGCArgo/ARGO_PROCESSING, written by Tanya Maurer & Josh Plant

Change log:

23-04-2020: changed zlim to optional input argument 29-04-2020: switched file/path handling from os module to pathlib

bgcArgoDMQC.io.read_index(mission='B', remote=False, url='ftp.ifremer.fr')

Function to read and extract information from Argo global index, then save it to a dataframe for faster access.

Parameters

mission (str) – B, C, S, or M for biogeochemical, global/core, synthetic, and metadata indices respectfully.

bgcArgoDMQC.io.update_index(ftype=None, url='ftp.ifremer.fr')

Function to access FTP server to download Argo metadata and profile global index files

Interpolation Functions

bgcArgoDMQC.interp.interp_ncep_data(track, ncep_track, data)

Function to interpolate NCEP reanalysios data along the provided track (t, lat, lon).

INPUT:

track: array with the columns (SDN, lat, lon) ncep_track: tuple with NCEP time, lat, lon arrays data: output array from load_ncep_data()

OUTPUT:

ncep_interp: 2D array of requested WOA parameter (depth x time)

AUTHOR: Christopher Gordon

Fisheries and Oceans Canada chris.gordon@dfo-mpo.gc.ca

ACKNOWLEDGEMENT: this code is adapted from the SOCCOM SAGE_O2Argo matlab code, available via https://github.com/SOCCOM-BGCArgo/ARGO_PROCESSING, written by Tanya Maurer & Josh Plant

LAST UPDATE: 23-04-2020

CHANGE LOG:

bgcArgoDMQC.interp.interp_woa_data(track, woa_track, data, verbose=True)

Function to interpolate WOA18 climatological data along the provided track (t, lat, lon).

INPUT:

track: array with the columns (SDN, lat, lon) woa_track: tuple with WOA time, lat, lon arrays data: output array from load_woa_data()

OUTPUT:

woa_interp: 2D array of requested WOA parameter (depth x time)

AUTHOR: Christopher Gordon

Fisheries and Oceans Canada chris.gordon@dfo-mpo.gc.ca

ACKNOWLEDGEMENT: this code is adapted from the SOCCOM SAGE_O2Argo matlab code, available via https://github.com/SOCCOM-BGCArgo/ARGO_PROCESSING, written by Tanya Maurer & Josh Plant

LAST UPDATE: 23-04-2020

CHANGE LOG:

Unit Conversion

bgcArgoDMQC.unit.doxy_to_pO2(O2conc, S, T, P=0)

convert molar oxygen concentration to oxygen partial pressure

inputs:

O2conc - oxygen concentration in umol L-1 T - temperature in deg C S - salinity (PSS-78) P - hydrostatic pressure in dbar (default: 0 dbar)

output:

pO2 - oxygen partial pressure in mbar

according to recommendations by SCOR WG 142 “Quality Control Procedures for Oxygen and Other Biogeochemical Sensors on Floats and Gliders”

Written in matlab by: Henry Bittig Laboratoire d’Oceanographie de Villefranche-sur-Mer, France bittig@obs-vlfr.fr 28.10.2015 19.04.2018, v1.1, fixed typo in B2 exponent

Translated to python by: Christopher Gordon Bedford Institute of Oceanography, Fisheries and Oceans Canada chris.gordon@dfo-mpo.gc.ca 02.10.2020

bgcArgoDMQC.unit.mL_per_L_to_umol_per_L(ppt, T)

Convert oxygen measured in mL L-1 to concentration in umol L-1.

Args:

Returns:

bgcArgoDMQC.unit.oxy_sol(S, T, PDEN, a4330=True)

Calculate oxygen saturation concentration in seawater as a function of S & T, in equilibrium with standard coponsition moist air at 1atm total pressure. From Garcia & Gordon (1992) eq. 8 (p. 1310) using coefficients of Benson & Krause in table 1, as used in Sarmiento & Gruber’s “Ocean Biogeochemical Dynamics” ch. 3, p. 81, table 3.2.4.

Parameters
  • S (float or array-like) – salinity, psu

  • T (float or array-like) – temperature, deg C

  • a4330 (bool) – True or False for Aanderaa 4330 optode

Returns

oxygen solubility

Return type

O2sol (float or array-like)

bgcArgoDMQC.unit.pH2O(T, S=0, unit='Pa')

Calculate vapor pressure of water

Parameters
  • T (float or array-like) – temperature, deg C

  • S (optional, float or array-like) – salinity, only necessary for mbar unit, default 0

  • unit (optional, str) – “Pa” or “mbar” for unit of vapor pressure, defauly “Pa”

Returns

vapor pressure of water, Pa or mbar

Return type

vapor_pressure

bgcArgoDMQC.unit.pO2_to_doxy(pO2, S, T, P=0)

convert oxygen partial pressure to molar oxygen concentration

Parameters
  • pO2 (float or array-like) – oxygen partial pressure in mbar

  • T (float or array-like) – temperature in deg C

  • S (float or array-like) – salinity (PSS-78)

  • P (optional, float or array-like) – hydrostatic pressure in dbar (default: 0 dbar)

Returns

oxygen concentration in umol L-1

Return type

DOXY

according to recommendations by SCOR WG 142 “Quality Control Procedures for Oxygen and Other Biogeochemical Sensors on Floats and Gliders”

Written in matlab by: Henry Bittig Laboratoire d’Oceanographie de Villefranche-sur-Mer, France bittig@obs-vlfr.fr 28.10.2015 19.04.2018, v1.1, fixed typo in B2 exponent

Translated to python by: Christopher Gordon Bedford Institute of Oceanography, Fisheries and Oceans Canada chris.gordon@dfo-mpo.gc.ca 02.10.2020

bgcArgoDMQC.unit.umol_per_sw_to_mmol_per_L(doxy, S, T, P, Pref=0, lat=None, lon=None)

Convert dissolved oxygen concentration in umol kg-1 to mmol L-1.

Parameters
  • doxy (float or array-like) – dissolved oxygen in umol kg-1

  • S (float or array-like) – salinity, array of same length as doxy or single value

  • T (float or array-like) – temperature (deg C), array of same length as doxy or single value

  • P (float or array-like) – pressure (dbar), array of same length as doxy or single value

  • Pref (optional, float) – reference pressure (dbar) for potential density calculation, default 0

  • lat (optional, float or array-like) – latitude (deg) for absolute salinity calculation, optional but highly encouraged, function will use practical salinity and produce warning without it

  • lon (optional, float or array-like) – longitude (deg) for absolute salinity calculation, optional but highly encouraged, function will use practical salinity and produce warning without it

Returns

dissolved oxygen concentration in umol L-1 (or equivalently mmol m-3)

Return type

umol_L_conc (float or array-like)

Plotting

Other Functions

bgcArgoDMQC.util.aic(data, resid)

Function to calculate the Akiake Information Criteria (AIC) as a metric for assessing the appropriate number of breakpoints in the calculation of drifts in O2 gains.

Args:

Returns:

Author:

Christopher Gordon Fisheries and Oceans Canada chris.gordon@dfo-mpo.gc.ca

Acknowledgement: this code is adapted from the SOCCOM SAGE_O2Argo matlab code, available via https://github.com/SOCCOM-BGCArgo/ARGO_PROCESSING, written by Tanya Maurer & Josh Plant

Last update: 2020-10-27

Change log:
  • 2020-10-27: fixed print output

bgcArgoDMQC.util.bic(data, resid)

Function to calculate the Bayesian Information Criteria (BIC) as a metric for assessing the appropriate number of breakpoints in the calculation of drifts in O2 gains.

Args:

Returns:

Author:

Christopher Gordon Fisheries and Oceans Canada chris.gordon@dfo-mpo.gc.ca

Acknowledgement: this code is adapted from the SOCCOM SAGE_O2Argo matlab code, available via https://github.com/SOCCOM-BGCArgo/ARGO_PROCESSING, written by Tanya Maurer & Josh Plant

Last update: 2020-10-27

Change log:
  • 2020-10-27: fixed print output

bgcArgoDMQC.util.decode_woa_var(varname)

take WOA variable name input and output relevant info

bgcArgoDMQC.util.get_lat_index(lat, lat_bounds)

function to pull appropriate WOA latitude values

bgcArgoDMQC.util.get_lon_index(lon, lon_bounds, cross180)

function to pull appropriate WOA longitude values, handles crossing 180

bgcArgoDMQC.util.get_var_by(v1, v2, float_data)

Function to calculate the mean of one variable (v1) indexed by a second variable (v2) in a float_data dictionary (output of load_argo), though it would work with any python dict

Parameters
  • v1 (str) – string input of a key in float_data

  • v2 (str) – string input of a key in float_data

  • float_data (dict) – python dict() object

Returns

1D numpy array with mean values

bgcArgoDMQC.util.haversine(c1, c2)

Calculate the distance between two coordinates using the Haversine formula.

Parameters
  • c1 (tuple) – first set of coordinates - (lat, long)

  • c2 (tuple) – second set of coordinates - (lat, long)

Returns

Distnace between c1 and c2 in kilometers