Skip to content

Commit

Permalink
Added Gulf Stream
Browse files Browse the repository at this point in the history
  • Loading branch information
ledm committed Aug 1, 2024
1 parent 5fe6a94 commit 4486319
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 2 deletions.
1 change: 1 addition & 0 deletions bgcval2/bgcval2_make_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -1480,6 +1480,7 @@ def newImageLocation(fn):
physicsKM = [
'AMOC_26N',
'ADRC_26N',
'GulfStream',
'AtmosCO2',
'DrakePassage',
'GlobalMeanTemperature',
Expand Down
2 changes: 2 additions & 0 deletions bgcval2/bgcvaltools/pftnames.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ def makeLongNameDict():
lnd['AMOC_26N_nomexico'] = "AMOC 26N (excluding Gulf of Mexico)"
lnd['AMOC_32S'] = "AMOC 32S"
lnd['ADRC_26N'] = "Atlantic Deep Return Current at 26N"
lnd['GulfStream'] = "Gulf Stream at 26N"


lnd['ZonalCurrent'] = "Zonal Current"
lnd['MeridionalCurrent'] = "Meridional Current"
Expand Down
69 changes: 69 additions & 0 deletions bgcval2/functions/circulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@

#eORCA1_latslice26N = slice(227,228)
eORCA1_latslice26Nnm = slice(228,229)
eORCA1_lonslice_GS = slice(228,229)


eORCA1_latslice32S = slice(137,138)

eORCA025_latslice26Nnm = slice(794,795)
Expand Down Expand Up @@ -312,6 +315,72 @@ def TwentySixNorth(nc,keys,**kwargs):
return atlmoc


def gulfstream(nc, keys, **kwargs):
"""
This function calculates the Gulf Stream at 26N.
This is the sum of Northbound current between
nc: a netcdf openned as a dataset.
keys: a list of keys to use in this function.
"""
areafile = get_kwarg_file(kwargs, 'areafile')
maskname = kwargs.get('maskname', 'tmask')
grid = kwargs.get('grid', 'eORCA1')
maxdepth = np.abs(kwargs.get('maxdepth', 2000. ))


if not loadedArea:
loadDataMask(areafile, maskname, grid)

if grid == 'eORCA1':
latslice26Nnm = eORCA1_latslice26Nnm

#data=[-80.5011659 , -79.50119298, -78.50121829, -77.50124181,
# -76.50126349, -75.50128329, -74.50130118, -73.50131712,
# -72.50133107, -71.50134301, -70.50135293, -69.50136079,
# -68.50136658],
lonslice_70W = slice(207, 220)

altmaskfile = get_kwarg_file(kwargs, 'altmaskfile', default = 'bgcval2/data/basinlandmask_eORCA1.nc')
if not loadedAltMask:
loadAtlanticMask(altmaskfile, maskname='tmaskatl', grid=grid)
elif grid == 'eORCA025':
latslice26Nnm = eORCA025_latslice26Nnm

else:
# grid not recognised.
raise ValueError('TwentySixNorth: grid not recognised: %s', grid)

if not loadedAltMask:
# Atlantic Mask not loaded
raise ValueError('TwentySixNorth: Mask not loaded: ed: %s', grid)
assert 0

lats = nc.variables['nav_lat'][latslice26Nnm, lonslice_70W]
lons = nc.variables['nav_lon'][latslice26Nnm, lonslice_70W]
vo = np.ma.array(nc.variables[keys[0]][0, :, latslice26Nnm, lonslice_70W]) # m/s
vo = np.ma.masked_where(vo.mask + (vo <= 0.), vo)

thickness = nc.variables['thkcello'][0,:,latslice26Nnm, lonslice_70W]
depth = np.abs(np.cumsum(thickness, axis=0))# depth array
#print(vo.shape, thickness.shape, e1v_AMOC26N.shape)
gs = 0.
for (z, la, lo), v in np.ndenumerate(vo):
if depth[z, la,lo] > maxdepth:
continue
if v <= 0:
continue
#print((z, la, lo),'depth:', depth[z, la,lo], (lats[la, lo],'N', lons[la, lo], 'E'), 'v:', v, 'thickness:', thickness[z, la, lo], 'width:', e1v_AMOC26N[la, lo])
gs += v * thickness[z, la, lo] * e1v_AMOC26N[la, lo] / 1.E06

print('Gulf Stream:', gs) # expecting a value of 32Sv ish.
# https://www.sciencedirect.com/science/article/pii/S0079661114001694

return gs



def twentysixnorth025(nc,keys,**kwargs):
"""
This function loads the AMOC array that is used for eORCA025
Expand Down
3 changes: 2 additions & 1 deletion bgcval2/timeseries/timeseriesAnalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,11 @@ def loadModel(self):
# load and calculate the model info
if len(glob.glob(self.shelvefn+'*')): # shelve files have .bak .dat .dir files now
with shOpen(self.shelvefn) as sh:
print('Shelf opens fine:', self.shelvefn)
print('Opening Shelf file:', self.shelvefn)
print (sh.keys())
readFiles = sh['readFiles']
modeldataD = sh['modeldata']

else:
print('Does not exist', self.shelvefn)
readFiles = []
Expand Down
2 changes: 1 addition & 1 deletion key_lists/physics.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ keys:
# ZonalCurrent: True # Zonal Veloctity
# MeridionalCurrent: True # Meridional Veloctity
# VerticalCurrent: True # Vertical Veloctity

GulfStream: True

somesatr: True # salt flow # Work in progress in debug

Expand Down

0 comments on commit 4486319

Please sign in to comment.