The FluxEngine air-sea gas flux toolbox: simplified interface and extensions for in situ analyses and multiple sparingly soluble gases

. The flow (flux) of climate critical gases, such as carbon dioxide (CO 2 ), between the ocean 25 and the atmosphere is a fundamental component of our climate and the biogeochemical development of the oceans. Therefore, the accurate calculation of these air-sea gas fluxes is critical if we are to monitor the health of our oceans and changes to our climate. FluxEngine is an open source software toolbox that allows users to easily perform calculations of air-sea gas fluxes from model, in-situ and Earth observation data. The original development and verification of the toolbox was described in a previous publication and the toolbox is already being used by scientists across multiple disciplines. The toolbox has now been considerably updated to allow its use as a Python library, to enable simplified installation, verification of its installation, to enable the handling of multiple sparingly soluble gases and greatly expanded functionality for supporting in situ dataset analyses. This new functionality for supporting in situ analyses includes user defined grids, time periods and projections, the ability to re- analyse in situ CO 2 data to a common temperature dataset and the ability to easily calculate gas fluxes using in situ data from drifting buoys, fixed moorings and research cruises. Here we describe these new capabilities and then demonstrate their application through illustrative case studies. The first case study demonstrates the workflow for accurately calculating CO 2 fluxes using in situ data from four research cruises from the Surface Ocean CO 2 Atlas (SOCAT) database. The second case study shows that reanalysing an eight month time series of pCO 2 data collected from a fixed station in the Baltic Sea can remove errors equal to 35% of the net air-sea gas flux. The third case study demonstrates that biological surfactants could supress individual nitrous oxide sea-air gas fluxes by up to 13%. The final case study illustrates how a dissipation-based gas transfer parameterisation can be implemented and used. The updated version of the toolbox (version 3) and all documentation is now freely available. demonstrated workflow in in reanalyse_socat_driver.py

biological surfactants could supress individual nitrous oxide sea-air gas fluxes by up to 13%. The final case study illustrates how a dissipation-based gas transfer parameterisation can be implemented and used. The updated version of the toolbox (version 3) and all documentation is now freely available.

Introduction
The exchange of climate relevant gases between the oceans and atmosphere including that of carbon dioxide (CO 2 ), nitrous oxide (N 2 O) and methane (CH 4 ) is a major component of the climate system, 50 and the ability of the oceans to absorb and desorb these gases varies both temporally and spatially. The need to monitor this exchange has been the driver for international data collation initiatives such as the Surface Ocean CO 2 ATlas (SOCAT, (Bakker et al., 2016)) and the MarinE MethanE and NiTrous Oxide database (MEMENTO, Kock and Bange, 2015). These collaborative efforts are now routinely collecting, quality controlling and collating over a million new in situ data points each year.

55
FluxEngine complements these initiatives by providing a standardised tool, which can robustly calculate air-sea gas fluxes from such in situ data, with the flexibility to incorporate new data sources and methodologies. The use of common tools and methods simplifies collaborations and accelerates advancements, both within and between scientific disciplines, through eliminating methodological or implementation-driven differences and the duplication of effort.

Overview of FluxEngine
FluxEngine is a flexible open source toolbox that allows users to easily exploit Earth observation and model data, in combination with in situ data, to calculate air-sea gas fluxes . The toolbox uses plain text-format configuration files allowing the user to configure the input data sources, 65 the temporal period for the analysis, the structure of the air-sea gas flux calculation and user-defined gas transfer velocity parameterisations. Further optional features include the addition of random noise or bias to the input data. The calculation itself can be performed using fugacity, partial pressure or concentration data, using a bulk formulation or more accurate formulations that take into account vertical temperature gradients across the mass boundary layer, the very small layer at the surface over 70 which gas exchange occurs. The latter approach allows a more accurate gas flux calculation and is described in detail by  and takes the generalised form of

75
where F is the sea-to-air flux of a sparingly soluble gas G, k is the gas transfer velocity (cm h -1 ), α S and α W are the solubilities of the gas above and below the surface water interface and fG A and fG W are the respective fugacities. Here we use 'p' and 'f' prefixes to refer to partial pressure and fugacity of a gas, respectively. Gas transfer velocity is driven by turbulence at ocean surface, caused by wind stress and wave breaking, amongst other processes. Because of the wide availability of high quality wind data 80 products and the relative difficulty of directly measuring turbulence, it is commonplace to estimate k using a statistical relationship with wind speed, e.g. (Ho et al., 2006;Nightingale et al., 2000;Wanninkhof, 2014 Concentration of the gas is determined by its solubility and fugacity (or partial pressure). Equation (1) 85 can therefore be rewritten as a product of the gas transfer velocity and the difference in gas concentrations, Version 1.0 of FluxEngine was introduced and described by , which included a 100 full description of the calculations, the flexibility of the toolbox, and the extensive verification of the different calculations along with examples of its use. Since its original release the toolbox has continued to be developed and extended based on feedback from the user communities and the needs of specific scientific studies (e.g. Ashton et al., 2016). These developments have considerably extended the functionality of the toolbox and broadened the range of possible applications to which it can be 105 applied. At the time of writing the toolbox and resulting data have been used to quantify regional method uncertainties (e.g. Wrobel and Piskozub, 2016;Wrobel, 2017), evaluate the impact of gas transfer processes on regional and global gas exchange (e.g. Ashton et al., 2016;Pereira et al., 2018), evaluate the European shelf sea CO 2 gas-fluxes and sink  and investigate biological and physical controls of air-sea exchange (Henson et al., 2018). FluxEngine has also been 110 used to identify shortfalls of current modelling approaches through the inclusion of FluxEngine outputs within an international inter-comparison (Rödenbeck et al., 2015) (Ardhuin et al., 2018)) and to verify our understanding of vertical temperature profiles and concentration gradients (as described by Woolf et al., 2016) 120 through the analysis of a novel fiducial reference dataset. The results from these studies will be reported elsewhere, but their needs have driven some of the advancements presented here.

135
Section 2 describes the structural extensions and changes, including the automatic software installers and verification tools (allowing users to verify the integrity of their installation). It explains how the toolbox can now be used as a command line tool or as a Python library. Section 3 then presents the case studies, while section 4 outlines the future direction and developments for the toolbox and section 5 gives conclusions. To aid the user the Appendices of this paper provide a list all of the toolbox utilities 140 (Sect. 6) and details of all data sets used (Sect. 7).

New capabilities
The following sections describe the extensions to the FluxEngine toolbox that are now contained within version 3. successfully installed. These verification utilities run standard global sea-to-air CO 2 gas flux calculations and net integrated fluxes using the (Takahashi et al., 2009) sea-to-air CO 2 flux climatology

155
(for year 2000) and the Woolf et al., (in-review) Surface Ocean CO 2 Atlas (SOCAT, Bakker et al., 2016) derived sea-to-air CO 2 flux reference dataset (for year 2010). The results are then evaluated against the published reference data provided by Holding et al., (2018) and the installation is deemed successful if all results are identical to the reference dataset within a precision of 5 decimal places. An additional utility (run_full_verification.py) enables the user to perform a more detailed verification 160 against both of these climatologies by executing a suite of 12 different configurations and scenarios, the justification for which are described within Woolf et al., (in-review). Owing to the large volume of data required to execute and verify all of these scenarios, the verification data are not packaged with the standard FluxEngine download, but are all freely available and contained within Holding et al., (2018).

165
FluxEngine is now implemented as a Python module available on a creative commons license via http://github.com/oceanflux-ghg/FluxEngine. This means that FluxEngine and its accompanying utilities can be used as command line tools (stand-alone tools or called from another piece of software) or imported as a Python module and easily integrated with other software. This approach offers a larger degree of flexibility than offered by version 1 of the toolbox and supports advanced exploitation. For approximately double the execution time, whilst doubling the resolution of both spatial dimensions will lead to a factor of four increase in execution time.

Flexible input data specification
Previous versions of FluxEngine required the user to make changes to the underlying software in order 185 to use new or differently formatted sources of input data. This required additional (and time consuming) testing and verification after modifications were made, making FluxEngine less accessible to those unfamiliar to Python programming. Two features have been added in version 3.0 to address this issue: i) file pattern matching (through standard Unix glob patterns and custom date/time tokens, described fully in FluxEngineV3_instructions.pdf) allows input file name format and directory structure 190 to be customised using the plain text configuration file, ii) optional pre-processing functions can be used to manipulate input data after the data have been read into memory. These features can be specified for each input variable in the configuration file and FluxEngine contains a selection of common pre-processing functions, such as unit conversions or matrix transformation of the input data.
Additional custom pre-processing functions can be added and tested easily by the user without the need 195 to modify the core FluxEngine software, through copying and then completing the Python template function provided within the source code (data_preprocessing.py). Storing the completed function into the data_preprocessing.py file will then result in the custom pre-processing function being automatically available for use in any configuration files.

200
These features make it possible to use any observational netCDF dataset by specifying the file path and, if required, appropriate pre-processing functions. For example a custom pre-processing function could resample the input files, followed by a transformation to change the projection. This flexibility is conceptualised by the diagram in Fig. 1

Extensive support for in situ data analyses
Version 1 of FluxEngine required that all input data be supplied as monthly 1° × 1° global grids. These constraints precluded its application to regional analyses and in situ analyses, where sub-daily or sub-210 km resolutions are often more appropriate. The spatial resolution and extent can now be fully specified by the user and regional masks can be used in conjunction with the ofluxghg_flux_budgets.py tool to calculate regional net integrated fluxes. In addition, flexible start and stop times and user-specified temporal resolution allows gas fluxes to be calculated for specific time intervals, e.g. the calculation can be configured to match the temporal resolution of the in situ data. Furthermore, a new 215 configuration option allows output from multiple time points to be grouped into a single netCDF file (rather than multiple files, one for each time point). This feature is designed to enable the calculation of gas fluxes from fixed research stations and other scenarios in which it is more convenient to provide results as a single time-series.

220
Improvements have been made to the bundled file conversion utilities, which convert between plain text data formats and the netCDF format used by FluxEngine. By default, these tools use the SOCAT format (Bakker et al., 2016) for convenience, but now offer a high degree of flexibility to reflect the variety of data formats and conventions used for storing in situ data. This means that the tools can be used with virtually any text formatted in situ data files, avoiding the need for the user to convert their 225 data to a fixed format with predefined column names.
The new utility, append2insitu.py, is designed specifically for use with in situ data and appends FluxEngine output as new columns within the original in situ data (achieved by matching spatial and temporal coordinates). For example, this means that users can use SOCAT (or custom) formatted in 230 situ data as input to FluxEngine and then the results can be placed into a copy of the original input file, allowing the user to study the calculated fluxes, gas transfer rates, gas concentrations etc. alongside (and aligned with) their original in situ data. This functionality is demonstrated in case studies one and three within this paper.

235
In situ fCO 2 measurements are often made using water sampled from differing depths and/or a range of different instrument setups. A second new utility, reanalyse_socat_driver.py enables fCO 2 measurements to be re-analysed to a consistent temperature field at a consistent depth. This reanalysis tool is CO 2 specific and is required for an accurate gas flux calculation as it allows the in situ gas concentration to then be calculated at the bottom or top of the mass boundary layer, rather than 240 assuming that the gas concentration at some depth is representative of that at the sea surface . This reanalysis is especially important if the in situ data consist of a collated dataset originating from multiple instruments, sampling strategies or sources. In this situation the in situ measurements are more likely to be collected from a range of different depths. It is worth noting that ship draught, and thus underway measurement intake depth, can even vary on a single vessel due to 245 changes in sea state, ballasting or cargo. A more detailed justification of the method and a full description of the approach are described in Goddijn-Murphy et al., (2015). Whilst the reanalysis method and utility is CO 2 specific, its applicability to alternative gases (including unreactive N 2 O and CH 4 ) is discussed and shown in Table 1 of . The impact of not performing this reanalysis on a relatively large time series of CO 2 measurements through the north and south Atlantic is 250 demonstrated within case study one.
A typical workflow for calculating sea-to-air gas fluxes from in situ data using FluxEngine, and the tools used at each step, is illustrated in Fig

Custom gas transfer velocity parameterisation
The processes that govern exchange, their relative importance and how gas exchange should be parameterised are all active areas of research. For example, a recent comparative study using 260 FluxEngine highlighted a difference of up to 65% in global net CO 2 flux caused simply by using different wind-based gas transfer velocities (Wrobel and Piskozub, 2016).
FluxEngine has always allowed users to select or define different (mostly wind-based) transfer velocity parameterisations. However, version 3.0 adopts a modular approach to specifying the flux calculation,  which is used to assess the impact of biological surfactants on the N 2 O gas fluxes. Case study four 285 (Sect 3.4) utilises a gas transfer velocity parameterisation that uses turbulent kinetic energy dissipation and provides an example of using additional input data.

Extensions for other sparingly soluble gases
The toolbox now supports the handling of two other sparingly soluble gases, (CH 4 and N 2 O), and so 290 gas specific data can be substituted into Eq. (1) or Eq. (2)  concentrations can be provided directly as an input.

Case study examples of the new capabilities
The following sections describe the application and results from four case studies that illustrate the new capabilities. Use of a custom gas transfer parameterisation which includes the specification of an additional input data layer (Sect. 2.4).

315
Here we illustrate the procedure for calculating sea-to-air gas fluxes from in situ data collected during four different sampling campaigns. These in situ data (Kitidis and Brown, 2017;Schuster, 2016;Steinhoff et al., 2016;Wanninkhof et al., 2016) were all collected in the north Atlantic during October 2013. For convenience these are referred to as cruises 1-4, respectively. The in situ data were first

325
The majority of the measurements needed for the sea-to-air CO 2 gas flux calculation were measured in situ and exist within the downloaded datasets. However, wind speed (for the gas transfer parameterisation) was missing in all cases. Therefore to complement these in situ data, multi-sensor merged wind speed data at 10 m were downloaded (Cross-Calibrated Multi-Platform, CCMPv2, 6 hour temporal resolution, 0.25 o × 0.25 o spatial grid (Atlas, et al., 2011)). These wind speed data were 330 appended to the in situ data by matching each in situ measurement to the closest temporal and spatial grid point. This same process was used to add columns for the second and third moments of wind speed, which were estimated by taking the second and third power of wind speed, respectively.
Two datasets (Schuster, 2016;Steinhoff, et al., 2016) were missing molar fraction of CO 2 in dry air 335 (xCO 2 ) data, and so the same method of matching temporal and spatial grid points was used to fill in these fields using the GLOBALVIEW CO 2 dataset from the US National Oceanic and Atmospheric Administration (NOAA) Earth System Research Laboratory (ESRL) (GLOBALVIEW-CO2, 2013).
For ease, these additional wind speed and xCO 2 data were downloaded, extracted and then inserted into the tab delimited in situ file using some simple custom python scripts but the same process could be 340 performed manually. These scripts are not part of FluxEngine but the functionality they provide will likely be available as part of the planned interactive Jupyter tutorials, see Sect. 4.
The in situ data were collected from different ships and underway systems, all sampling water at different and unknown depths. These measurements are typically collected from a few metres below 345 the water surface, whereas the CO 2 concentration (combination of fCO 2 and solubility) either side of the mass boundary layer is required for an accurate gas flux calculation. Before these data from multiple sources can be used for an accurate gas flux calculation, they need to be reanalysed to a common temperature dataset and depth (Goddijn-Murphy et al., 2015;Woolf et al., 2016). Therefore the reanalyse_socat_driver.py tool was first used to reanalyse all fCO 2 data to a consistent temperature 350 and depth.
In the absence of coincident in situ skin (or sub-skin) temperature data, the slow re-equilibrium time of CO 2 in seawater (i.e. on the order of months for CO 2 to equilibrate with the atmosphere) ensure that monthly mean, or rolling monthly mean (centred on the day of interest) skin or sub-skin sea surface 355 temperature (SST) values are suitable for re-analysing the in situ data. Arguably a robust daily skin or sub-skin SST value would be better, even if that is obtained by a seasonal curve fitted to the monthly values and interpolated to the day of interest. Here for simplicity monthly mean sea surface temperatures from the Reynolds Optimally Interpolated Sea Surface Temperature dataset (OISST, Reynolds et al., 2007) were used as the reference subskin temperature dataset, resulting in reanalysed 360 fCO 2 that are valid for the bottom of the mass boundary layer (termed sub-skin within Woolf et al., 2016).
The reanalysed fCO 2 were then inserted into the tab-delimited in situ dataset producing a single dataset.
The tab-delimited file was then converted into a netCDF format file using the text2ncdf.py tool. This 365 tool groups all data according to a user-specified spatial sampling grid, calculating the mean value and standard deviation for each cell within the grid as well as the number of data that were used to calculate these statistics. Here, for simplicity, the spatial resolution was defined as The sea-to-air CO 2 fluxes were then calculated using the rapid model (see Eq. (1) and Woolf et al., 375 2016) and was run using a quadratic wind speed based gas transfer velocity parameterisation . To identify the impact of the fCO 2 reanalysis stage, the sea-to-air CO 2 flux calculation was repeated using the original in situ fCO 2 .

395
The append2insitu.py tool was then used to append FluxEngine output to the original input data file for the Kitidis and Brown (2017) dataset. The output from this tool enables the user to visualise FluxEngine output (including any additional input data such as the CCMP wind speed data) as a time series alongside all other measured in situ data. Figure 4 shows the time series of sea surface temperature, fCO 2 , and xCO 2 (from the in situ data) alongside the corresponding CCMP wind speed 400 and the calculated concentrations and fluxes using the original and reanalysed fCO 2 data. The new FluxEngine support for calculating gas fluxes from fixed stations uses the temporal dimension of the input files, creating output files of the same dimension that can be easily visualised as a time series. Data for the Östergarnsholm monitoring station covering a period from 28 th January 2015 to the 415 9 th September 2015 were downloaded from the data repository (Rutgersson, 2017). These data contain in situ measurements for fCO 2 , salinity and temperature, model reanalysis air pressure at sea level from the National Center for Environmental Prediction, National Center for Atmospheric Research (NCEP/NCAR) dataset (Kalnay et al., 1996), xCO 2 from the NOAA ESRL GLOBALVIEW dataset (GLOBALVIEW-CO2, 2013) and World Ocean Atlas salinity data (Boyer et al., 2013). CCMP wind 420 speed data were extracted and added to the tab delimited in situ dataset using the same method as used in case study 1 (Sect. 3.1). For gridded input data a single grid point containing the Östergarnsholm station location was selected from a global 1° × 1° projected grid.
The text2ncdf.py tool was configured to convert the text formatted data file into a single netCDF file 425 using a temporal resolution of one day. This produced a netCDF file with a temporal dimension size of 246 (days), containing the daily mean value for each of the 246 days covered by the dataset.
FluxEngine was configured to use this file as input, and to index into the temporal dimension appropriately. The fCO 2 data were reanalysed using the same method and data as used in case study 1 to determine fCO 2 at the bottom of the mass boundary layer.

430
The flux calculation used the rapid model  with the Nightingale et al. (2000) wind based gas transfer velocity parameterisation and was performed separately using the reanalysed fCO 2 and original fCO 2 data. The temporal resolution was set to provide daily calculations for each of the 246 days allowing seasonal variations to be observed, but not diurnal variations. FluxEngine supports 435 arbitrary temporal resolutions to within minute precision and the choice predominantly depends on the resolution of the available data and the particular research questions to be addressed. FluxEngine was configured to write output into a single netCDF file as a time series. Figure 5 shows the time series of SST, wind speed, xCO 2 , fCO 2 , concentration of CO 2 and calculated sea-to-air CO 2 flux. FluxEngine output produced by using the reanalysed fCO 2 are plotted in red. There was a mean increase of 0.022 g 440 C m -2 day -1 in sea to air CO 2 flux (a 35% increase in outgassing) when using the reanalysed fCO 2 .

Case study 3: Surfactant suppression of N 2 O gas fluxes using the MEMENTO database
Nitrous oxide (N 2 O) and methane (CH 4 ) are both climatically important gases. In the troposphere, they act as greenhouse gases (IPCC, 2013), whereas stratospheric N 2 O is the major source for NO radicals 445 which are involved in one of the main ozone reaction cycles (Ravishankara et al., 2009) the atmosphere and, consequently, make only a relatively small contribution to overall oceanic emissions, whereas biologically productive regions (e.g., estuaries, shelf and coastal upwelling areas) 450 appear to be responsible for the major fraction of the N 2 O and CH 4 emissions (Bakker et al., 2014).
Surfactants are surface-active compounds that can suppress turbulence at the sea surface thus altering air-sea gas exchange (McKenna and Bock, 2006;Pereira et al., 2016;Salter et al., 2011). There is growing evidence from field and laboratory studies that naturally occurring surfactants can 455 significantly reduce the flux of N 2 O across the water/atmosphere interface (Kock et al., 2012;Mesarchaki et al., 2015).
Previous work, which studied CO 2 fluxes, found that surfactants potentially reduce the annual net integrated CO 2 flux by up to 9% in the Atlantic Ocean (Pereira et al., 2018). Here, we use FluxEngine

460
to apply the methodology of Pereira et al., (2018) to in situ data from the MEMENTO (MarinE MethanE and NiTrous Oxide) database (Kock and Bange, 2015) in order to estimate the equivalent suppression effect on the exchange of N 2 O between ocean and atmosphere.
While FluxEngine is able to calculate sea-to-air fluxes of both N 2 O and CH 4 , we confined our analysis 465 to N 2 O because of the sparsity of CH 4 data. In situ and 1° x 1° gridded monthly mean atmospheric and ocean partial pressure of N 2 O, sea surface temperature and salinity were obtained from the MEMENTO database for the Atlantic Meridional Transect (AMT) cruise (AMT-24, JR303), which took place between September and November 2014 (Brown and Rees, 2018). These data were supplemented with Earth observation wind speed, U 10 , from the CCMP dataset and modelled air pressure from the 470 European Centre for Medium-Range Weather Forecasts (ECMWF). All input data were gridded to monthly means with a 1° x 1° resolution. While sea surface temperature measured from pumped water samples collected at some depth are used here, recent AMT cruises (from 2016) have included an Infrared Sea Surface Temperature Autonomous Radiometer (ISAR) (Donlon et al., 2008) and therefore future AMT datasets will include direct sea skin temperature measurements. Using skin temperature 475 measurements are likely to further increase the accuracy of the flux calculation.
A custom gas transfer velocity parameterisation was implemented following the template provided in the toolbox to calculate the gas transfer suppression due to biological surfactants in surface waters. This parameterisation uses the gas transfer velocity of (Nightingale et al., 2000) combined with an estimate 480 of the degree of surfactant suppression from (Pereira et al., 2018). FluxEngine was configured to use the rapid flux model  and run once with the standard Nightingale et al., (2000) gas transfer parameterisation (no suppression case) and then again using the Pereira et al., (2018) parameterisation (suppression case). This new gas transfer parameterisation is now freely available within the FluxEngine (and can be selected by specifying 485 k_Nightingale2000_with_surfactant_suppression for the k_parameterisation option).
The calculated sea-to-air N 2 O flux for each grid cell (within which at least one in situ measurement exists) are shown in Fig. 6a, while the difference in sea-to-air flux due to surfactant suppression is shown in Fig. 6b. The largest fluxes in both directions occur in the tropics and sub-tropical part of the 490 AMT cruise track (Fig. 6a). Suppression of the gas transfer reduces the magnitude of the air-sea flux (regardless of direction of flux) and the largest absolute suppression is seen in the tropics and subtropical part of both ( Fig. 6a and Fig. 6b).
The append2insitu.py utility was used to combine FluxEngine output with the original in situ data. The 495 time series are shown in Fig. 6c for SST, wind speed, atmospheric and aqueous N 2 O, and sea-to-air N 2 O flux. The net fluxes along the transect are generally small and in both directions. The overall mean flux was negative but small, -2.4×10 -3 ± 2.5×10 -2 g N 2 O m -2 day -1 (no suppression) and -1.9×10 -3 (±2.0×10 -2 ) g N 2 O m -2 day -1 (suppression), indicating in both cases a small net flux into the ocean.
There was a mean flux suppression due to surfactants of 13% for the entire dataset, while there was an  The gas transfer velocity, k in equation 1 and 2, is determined by the turbulent mixing near the ocean 505 surface (Jähne et al., 1987). While it is common to estimate gas transfer using a polynomial relationship with wind speed, turbulence in the upper ocean is influenced by additional physical processes which are independent or not solely dependent on the wind. These include wave breaking, shear stress due to geostrophic currents, wind-wave-current interactions, bottom-generated turbulence, tidal forces and precipitation (Villas Boas et al., 2019;Zappa et al., 2007;Zhao et al., 2018).

510
In this case study we apply a turbulent kinetic energy dissipation rate (ε) based gas transfer velocity parameterisation, as developed by Zappa et al. (2007), to quantify the impact of wind-and wave-driven turbulence on sea-to-air CO 2 . Zappa et al. used direct measurements of k and ε in aquatic and shallow marine regions to derive the following relationship 515 k = 0.419Sc -0.5 (εv) 0.25 (3) where k is the gas transfer velocity (m s -1 ), Sc is the Schmidt number, ε is the turbulent kinetic energy dissipation rate (W kg -1 ) and v is the kinematic viscosity of water (m 2 s -1 ). We calculate the monthly 520 mean ε using the monthly mean wave (swell, secondary swell and wind waves) to ocean turbulent kinetic energy flux (FOC) provided by the WAVEWATCH III model re-analysis (WAVEWATCH III development group, 2016). The mean dissipation rate of turbulent kinetic energy, ε mean , is calculated using ε mean = FOC / (ρz max ), where ρ is the density of sea water (taken to be 1026 kg m -3 ) and z max is the maximum depth over which dissipation is assumed to occur (taken as 10 m from Fig. 8 of Craig and 525 Banner, 1994). This provides the mean total dissipation rate through the volume of water. Equation 3 is valid for ε measurements near the surface (of the order of 0.1 to 0.2 m) and ε is known to decrease exponentially with depth. To estimate ε at a depth of 0.2 m we first fit an exponential function to the curve of ε from fig 8 of Craig and Banner (1994) which gave: where z is depth and β=1.86×10 -3 . Normalising this function to have a mean ε equal to ε mean allows ε at any depth to be determined. This was done by fitting β to minimise the difference between ε mean calculated from FOC and ε mean calculated from equation 4 to produce separate depth relationships with 535 ε for each individual grid cell. Finally, the dissipation rate at 0.2 m was calculated by substituting z=0.2 into the final depth relationship. The process of fitting of the depth relationship and calculating ε at depth z=0.2 was implemented using a custom pre-processing function that is included as an example in the FluxEngine download. This demonstrates how pre-processing functions can be used to perform complex data processing.  Reynolds et al., 2007), salinity data from the NOAA World Ocean Atlas (Zweng et al., 2018), atmospheric molar fraction of CO 2 in dry air data from the GLOBALVIEW CO 2 dataset (GLOBALVIEW-CO2, 2013), and fCO 2 data from the SOCAT derived sea-to-air CO 2 flux reference dataset for 2010 (Woolf et al., in-review). Since the Zappa et al., (2007) relationship was parameterised in low to moderate wind speeds and in shallow marine environments, a mask was set in the 550 configuration file to constrain the calculation to grid cells with wind speeds less than 10 m s -1 and shelf sea water depths between than 20 m and 200, and 20 and 500 m. These depth ranges were chosen to be consistent with previous studies (e.g. Laruelle et al., 2018;Shutler et al., 2016).
The ofluxghg_flux_budgets.py tool was used to compute the annual integrated net sea-to-air flux in all  The FluxEngine toolbox will continue to be developed in response to new advances in research. To increase user-uptake future work will include a series of iPython Jupyter notebooks. These online and interactive iPython notebooks will allow users to investigate the toolbox without the need to install any 575 software. Users will be able to modify and re-run the notebook and immediately see the impact of any changes. This approach has been previously used for supporting collaborative research and summer school teaching. For example, Jupyter notebooks could be used to provide worked examples of: i) simple execution using custom input data ii) pre-processing of in situ data, iii) creating and testing custom gas transfer parameterisations and pre-processing functions, iv) driving FluxEngine with a 580 custom python script to perform a sensitivity analysis, or v) using the verification tools module to verify custom changes and extensions to the toolbox.

Conclusions
The Collectively these improvements have streamlined the process for extending the toolbox and will allow users to easily take advantage of newly developed gas transfer velocity parameterisations and/or new sources of input data. These new tools and the toolbox are fully compatible with the internationally 600 agreed data structures being used by the SOCAT and the MEMENTO communities.
The inclusion of the handling of CH 4 and N 2 O sea-air gas fluxes is intended to directly support those communities studying these gases. Significant international research focus and effort is now being directed to collating data on these gases towards monitoring and understanding their spatial distribution 605 and variability.
FluxEngine will continue to be updated as new approaches become available. Further development will be guided by the needs of the international research and monitoring communities, and so we welcome feedback from users on all aspects of the toolbox.

Code availability
The

ofluxghg_flux_budgets.py
Calculates total monthly and annual gas flux from FluxEngine output. Supports global and regional analysis.

ofluxghg_run.py
Commandline tool used to run FluxEngine reanalyse_socat_driver.py Uses satellite sea surface temperature to reanalyse CO 2 fugacity and partial pressure data to a consistent temperature and depth (see Goddijn-Murphy et al., 2015)

run_full_verification.py
Runs an extended verification procedure. Required additional data from (Holding et al., 2018)

text2ncdf.py
Converts text formatted data files into FluxEngine compatible netCDF format.

validation_tools.py, compare_net_budgets.py
Contains Python functions to aid verification of FluxEngine output to a reference dataset. verify_socatv4_sst_salinity_gradients_N00.py, verify_takahashi09.py Verifies that FluxEngine has been installed correctly by comparing output with a reference data from SOCAT-derived or Takahashi climatologies, respectively. Table 2: Description of the bundled tools and scripts that are included in FluxEngine. Each tool can be 620 used as a stand-alone command line tool or used as a Python package.

Appendix B: Datasets used
625 Table 3 provides details of each of the data sets that were used in the case studies.

Name
Parameter (