From ec80d4ea9250cacf8eff7b49916e38fb7095d835 Mon Sep 17 00:00:00 2001 From: Lee de Mora Date: Tue, 14 Nov 2023 16:51:28 +0000 Subject: [PATCH 1/2] Fix for andrews --- bgcval2/functions/globalVolMean.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/bgcval2/functions/globalVolMean.py b/bgcval2/functions/globalVolMean.py index 5d7f9ebb..b267a779 100644 --- a/bgcval2/functions/globalVolMean.py +++ b/bgcval2/functions/globalVolMean.py @@ -31,18 +31,28 @@ import numpy as np from bgcval2.functions.standard_functions import choose_best_var +from bgcval2.functions.standard_functions import find_best_var +#def calc_vol(nc): +# """ +# Calculate volume from the (grid-T) netcdf file. +# """ +# area = nc.variables['area'][:] +# thkcello = nc.variables['thkcello'][:] +# area = area[None, None,:, :] +# return thkcello * area def calc_vol(nc): """ Calculate volume from the (grid-T) netcdf file. """ - area = nc.variables['area'][:] - thkcello = nc.variables['thkcello'][:] + area_key = find_best_var(nc, ['area', 'area_grid_T']) + thkcello_key = find_best_var(nc, ['thkcello', 'thkcello_grid_T']) + area = nc.variables[area_key][:] + thkcello = nc.variables[thkcello_key][:] area = area[None, None,:, :] return thkcello * area - def globalVolumeMean(nc, keys, **kwargs): """ Calculate the global volume mean. From f06826ee455d87c0d3fcecdd3f69ddc9cd639f70 Mon Sep 17 00:00:00 2001 From: Lee de Mora Date: Wed, 15 Nov 2023 10:55:39 +0000 Subject: [PATCH 2/2] An offering of sacrificial comment lines to appease @valeriupredoi. --- bgcval2/functions/globalVolMean.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/bgcval2/functions/globalVolMean.py b/bgcval2/functions/globalVolMean.py index b267a779..310de500 100644 --- a/bgcval2/functions/globalVolMean.py +++ b/bgcval2/functions/globalVolMean.py @@ -33,14 +33,6 @@ from bgcval2.functions.standard_functions import choose_best_var from bgcval2.functions.standard_functions import find_best_var -#def calc_vol(nc): -# """ -# Calculate volume from the (grid-T) netcdf file. -# """ -# area = nc.variables['area'][:] -# thkcello = nc.variables['thkcello'][:] -# area = area[None, None,:, :] -# return thkcello * area def calc_vol(nc): """ @@ -53,6 +45,7 @@ def calc_vol(nc): area = area[None, None,:, :] return thkcello * area + def globalVolumeMean(nc, keys, **kwargs): """ Calculate the global volume mean.