Skip to content

Commit 67df235

Browse files
committed
fixed a couple places where the area was incorrect.
1 parent d53a6e6 commit 67df235

3 files changed

Lines changed: 18 additions & 13 deletions

File tree

bgcval2/functions/AirSeaFluxCO2.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,13 @@
4343

4444
def load_area_and_mask(areafile):
4545
"""Load area file and its mask."""
46-
if isinstance(areafile, list) and len(areafile)==1:
46+
if 'area' in nc.variables.keys():
47+
area = nc.variables['area'][:]
48+
elif isinstance(areafile, list) and len(areafile)==1:
4749
areafile = areafile[0]
48-
nc = dataset(areafile, 'r')
49-
area = nc.variables['e2t'][:] * nc.variables['e1t'][:]
50-
nc.close()
50+
nc = dataset(areafile, 'r')
51+
area = nc.variables['e2t'][:] * nc.variables['e1t'][:]
52+
nc.close()
5153
loaded_area_and_mask = True
5254
return area
5355

bgcval2/functions/BenCa.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@
4343

4444
def load_area_and_mask(areafile):
4545
"""Load area file and its mask."""
46-
if isinstance(areafile, list) and len(areafile)==1:
46+
if 'area' in nc.variables.keys():
47+
area = nc.variables['area'][:]
48+
elif isinstance(areafile, list) and len(areafile)==1:
4749
areafile = areafile[0]
48-
else:
49-
raise ValueError(f"{areafile} must be a length=1 list containing a single file descriptor.")
50-
nc = dataset(areafile, 'r')
51-
area = nc.variables['e2t'][:] * nc.variables['e1t'][:]
52-
nc.close()
50+
nc = dataset(areafile, 'r')
51+
area = nc.variables['e2t'][:] * nc.variables['e1t'][:]
52+
nc.close()
5353
loaded_area_and_mask = True
5454
return area
5555

bgcval2/functions/InvtAlk.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,13 @@ def calc_total_invtalk(nc, keys, **kwargs):
5858
"""
5959
This function calculates the total quantity of dissolved alkalinity for the MEDUSA model on the eORCA grid.
6060
"""
61-
areafile = get_kwarg_file(kwargs, 'areafile')
61+
if 'area' in nc.variables.keys():
62+
area = nc.variables['area'][:]
63+
else:
64+
areafile = get_kwarg_file(kwargs, 'areafile')
6265

63-
if not loaded_area_and_mask:
64-
area = load_area_and_mask(areafile)
66+
if not loaded_area_and_mask:
67+
area = load_area_and_mask(areafile)
6568

6669
factor = 1. / 1.E18 # meq / m2 -> Peq
6770
try:

0 commit comments

Comments
 (0)