diff --git a/esmvalcore/cmor/tables/custom/CMOR_gtfgco2.dat b/esmvalcore/cmor/tables/custom/CMOR_gtfgco2.dat deleted file mode 100644 index dba2aa00c6..0000000000 --- a/esmvalcore/cmor/tables/custom/CMOR_gtfgco2.dat +++ /dev/null @@ -1,21 +0,0 @@ -SOURCE: CMIP5 -!============ -variable_entry: gtfgco2 -!============ -modeling_realm: ocnBgchem -!---------------------------------- -! Variable attributes: -!---------------------------------- -standard_name: -units: kg s-1 -cell_methods: time: mean area: where sea -cell_measures: area: areacello -long_name: Global Total Surface Downward CO2 Flux -comment: Gas exchange flux of CO2 (positive into ocean) -!---------------------------------- -! Additional variable information: -!---------------------------------- -dimensions: time -type: real -!---------------------------------- -! diff --git a/esmvalcore/preprocessor/_derive/gtfgco2.py b/esmvalcore/preprocessor/_derive/gtfgco2.py deleted file mode 100644 index 64efd558b1..0000000000 --- a/esmvalcore/preprocessor/_derive/gtfgco2.py +++ /dev/null @@ -1,96 +0,0 @@ -"""Derivation of variable `gtfgco2`.""" -import iris -import numpy as np - -from ._baseclass import DerivedVariableBase - - -def calculate_total_flux(fgco2_cube, cube_area): - """ - Calculate the area of unmasked cube cells. - - Requires a cube with two spacial dimensions. (no depth coordinate). - - Parameters - ---------- - cube: iris.cube.Cube - Data Cube - cube_area: iris.cube.Cube - Cell area Cube - - Returns - ------- - numpy.array: - An numpy array containing the total flux of CO2. - - """ - data = [] - times = fgco2_cube.coord('time') - - fgco2_cube.data = np.ma.array(fgco2_cube.data) - for time_itr in np.arange(len(times.points)): - - total_flux = fgco2_cube[time_itr].data * cube_area.data - - total_flux = np.ma.masked_where(fgco2_cube[time_itr].data.mask, - total_flux) - data.append(total_flux.sum()) - - ###### - # Create a small dummy output array - data = np.array(data) - return data - - -class DerivedVariable(DerivedVariableBase): - """Derivation of variable `gtfgco2`.""" - - @staticmethod - def required(project): - """Declare the variables needed for derivation.""" - required = [ - { - 'short_name': 'fgco2', - 'mip': 'Omon' - }, - { - 'short_name': 'areacello', - 'mip': 'fx' - }, - ] - if project == 'CMIP6': - required = [ - { - 'short_name': 'fgco2', - 'mip': 'Omon' - }, - { - 'short_name': 'areacello', - 'mip': 'Ofx' - }, - ] - return required - - @staticmethod - def calculate(cubes): - """Compute longwave cloud radiative effect.""" - fgco2_cube = cubes.extract_strict( - iris.Constraint(name='surface_downward_mass_flux_of_carbon_dioxide' - '_expressed_as_carbon')) - - try: - cube_area = cubes.extract_strict(iris.Constraint(name='cell_area')) - except iris.exceptions.ConstraintMismatchError: - pass - - total_flux = calculate_total_flux(fgco2_cube, cube_area) - - # Dummy result cube - result = fgco2_cube.collapsed( - ['latitude', 'longitude'], - iris.analysis.MEAN, - ) - result.units = fgco2_cube.units * cube_area.units - - result.data = total_flux - return result