Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Developments for TF AMOC analysis #136

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
71f19b1
fixed a bug in area of T vs V grids.
ledm Jun 21, 2024
812b8ee
minor fixes and commenting out prints.
ledm Jun 25, 2024
91f51cb
WIP sending to hgithub
ledm Jun 26, 2024
6b3ee42
Update fov.yml
ledm Jun 26, 2024
41a841e
working here
ledm Jun 27, 2024
85f9e4e
added remaining parts
ledm Jun 27, 2024
d4d62ed
Added Fov
ledm Jun 28, 2024
e8b716a
Added comments
ledm Jun 28, 2024
7bc1596
Working version, but with the wrong fov.
ledm Jul 3, 2024
c0bba2a
revised foc calculation
ledm Jul 3, 2024
6b61057
Merge branch 'dev_somesatr' of github.com:valeriupredoi/bgcval2 into …
ledm Jul 3, 2024
dabf4c8
additional code for Andrew
ledm Jul 19, 2024
d88acab
New analysis for TF papers
ledm Jul 19, 2024
5fe6a94
debugging;
ledm Jul 30, 2024
4486319
Added Gulf Stream
ledm Aug 1, 2024
7c075fe
work in progress
ledm Sep 20, 2024
00c9be2
So many changes about the AMOC paper - it is a lot.
ledm Oct 8, 2024
1a801a3
added 55N to heat flux
ledm Oct 10, 2024
dd0460b
Added new TF aMOC fields
ledm Oct 23, 2024
375f6ff
Merge remote-tracking branch 'origin/main' into dev_somesatr
ledm Oct 23, 2024
995ad5e
Merge remote-tracking branch 'origin/main' into dev_somesatr
ledm Oct 23, 2024
5953cc4
Added new regions
ledm Nov 19, 2024
7faa0e7
Added heat flux in y direction
ledm Nov 20, 2024
808d412
Added AMOC 40N and AMOC 55N
ledm Nov 20, 2024
7c80e41
pre merge
ledm Nov 20, 2024
d7a8aa0
Merge branch 'dev_somesatr' of github.com:valeriupredoi/bgcval2 into …
ledm Nov 20, 2024
b95efd6
Debugged new AMOCs
ledm Nov 20, 2024
4ff85c0
bug fix and new regions
ledm Nov 21, 2024
ee10e84
Added NorthEastAtlantic region
ledm Nov 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bgcval2/analysis_compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -732,10 +732,10 @@ def main():
compare_ymls = args.compare_yml

for compare_yml in compare_ymls:
print(f"analysis_timeseries: Comparison config file {compare_yml}")
print(f"analysis_compare: Comparison config file {compare_yml}")

if not os.path.isfile(compare_yml):
print(f"analysis_timeseries: Could not find comparison config file {compare_yml}")
print(f"analysis_compare: Could not find comparison config file {compare_yml}")
sys.exit(1)
skip_timeseries = args.skip_timeseries
load_yml_and_run(compare_yml, config_user, skip_timeseries)
Expand Down
2 changes: 1 addition & 1 deletion bgcval2/batch_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def main():

if not os.path.isfile(compare_yml):
print(f"analysis_timeseries: Could not find comparison config file {compare_yml}")
sys.exit(1)
sys.exit()
dry_run = args.dry_run
submits_lotus(compare_yml, config_user, dry_run)

Expand Down
5 changes: 5 additions & 0 deletions bgcval2/bgcval2_make_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -1479,14 +1479,19 @@ def newImageLocation(fn):
# of the comparison report
physicsKM = [
'AMOC_26N',
'AMOC_depth',
'ADRC_26N',
'GulfStream',
'GulfStream_depth',
'AtmosCO2',
'DrakePassage',
'GlobalMeanTemperature',
'GlobalMeanSalinity',
'NorthernTotalIceExtent',
'SouthernTotalIceExtent',
'Temperature_Global_Surface',
'Temperature_NorthernHemisphere_Surface',
'Temperature_SouthernHemisphere_Surface',
'Salinty_Global_Surface',
'AtlanticSubtropicalSalinity',
'FreshwaterFlux_Global',
Expand Down
77 changes: 45 additions & 32 deletions bgcval2/bgcvaltools/generic_map_legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,26 +132,33 @@ def add_region(fig, ax, lons, lats, data):
ax.add_feature(cfeature.LAND, zorder=10, edgecolor='black')
return fig, ax, im

ncfn = 'mesh_mask_eORCA1_wrk.nc'
nc = Dataset(ncfn, 'r')
dat = nc.variables['mbathy'][:].squeeze()
lats = nc.variables['nav_lat'][:].squeeze()
lons = nc.variables['nav_lon'][:].squeeze()
lons = bvt.makeLonSafeArr(lons)
nc.close()


def make_figure(region):
fig_fn = bvt.folder('images/regions')+region+'.png'
#if os.path.exists(fig_fn): return

fig = pyplot.figure()

paths_dict, config_user = get_run_configuration("defaults")
# paths_dict, config_user = get_run_configuration("defaults")
# filter paths dict into an object that's usable below
paths = paths_setter(paths_dict)
# paths = paths_setter(paths_dict)
#ncfn = paths.orcaGridfn
ncfn = 'mesh_mask_eORCA1_wrk.nc'

nc = Dataset(ncfn, 'r')
print(ncfn)
# ncfn = 'mesh_mask_eORCA1_wrk.nc'

dat = nc.variables['mbathy'][:].squeeze()
lats = nc.variables['nav_lat'][:].squeeze()
lons = nc.variables['nav_lon'][:].squeeze()
lons = bvt.makeLonSafeArr(lons)
# nc = Dataset(ncfn, 'r')
# #print(ncfn)
# dat = nc.variables['mbathy'][:].squeeze()
# lats = nc.variables['nav_lat'][:].squeeze()
# lons = nc.variables['nav_lon'][:].squeeze()
# lons = bvt.makeLonSafeArr(lons)

old_mask = np.ma.masked_where(dat.mask + dat ==0, dat).mask

Expand Down Expand Up @@ -186,7 +193,7 @@ def make_figure(region):
hspace=0.30,
wspace=0.30,)

print('lats:', new_lat.mean(), 'lon:', new_lon.mean(), 'data:', new_dat.min(), new_dat.max())
print('\''+region+'\': {\'lats\'', new_lat.mean(), 'lon:', new_lon.mean()) #data:', new_dat.min(), new_dat.max())

ortho_pro=ccrs.Orthographic(new_lon.mean(), new_lat.mean(),)
ax_globe = fig.add_subplot(spec2[0, 0], projection=ortho_pro)
Expand Down Expand Up @@ -218,30 +225,36 @@ def make_figure(region):


def main():
# paths_dict, config_user = get_run_configuration("defaults")

regions = [
'Ascension',
'ITCZ',
'TristandaCunha',
'Pitcairn',
'Cornwall',
'SubtropicNorthAtlantic',
'SPNA',
'STNA',
'SouthernOcean',
'ArcticOcean',
'Equator10',
'NorthPacificOcean',
'SouthPacificOcean',
'NorthAtlanticOcean',
'SouthAtlanticOcean',
'GINseas',
'LabradorSea',
'EquatorialAtlanticOcean',
'Global',
'ignoreInlandSeas',
'LIseas',
'LIGINseas',
'GLINseas',
# 'Ascension',
# 'ITCZ',
# 'TristandaCunha',
# 'Pitcairn',
# 'Cornwall',
'SubtropicNorthAtlantic',
'SPNA',
'STNA',
# 'SouthernOcean',
# 'ArcticOcean',
# 'Equator10',
# 'NorthPacificOcean',
# 'SouthPacificOcean',
'NorthAtlanticOcean',
# 'SouthAtlanticOcean',
'GINseas',
'LabradorSea',
'IrmingerSea',
# 'EquatorialAtlanticOcean',
# 'Global',
# 'ignoreInlandSeas',
]
for region in regions[:]:
make_figure(region)
make_figure(region)

if __name__ == "__main__":
main()
81 changes: 75 additions & 6 deletions bgcval2/bgcvaltools/makeMask.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ def makeMask(name, newSlice, xt, xz, xy, xx, xd, debug=False):

if newSlice == 'AMM':
return np.ma.masked_outside(bvt.makeLonSafeArr(xx), -20., 13.).mask + np.ma.masked_outside(xy, 40., 65.).mask

if newSlice == 'NorthEastAtlantic':


if newSlice == 'SouthernOcean':
Expand Down Expand Up @@ -249,17 +251,35 @@ def makeMask(name, newSlice, xt, xz, xy, xx, xd, debug=False):
if newSlice in ['SubtropicNorthAtlantic', 'STNA']:
mx = np.ma.masked_outside(xx, -80., -10.).mask + np.ma.masked_outside(
xy, 10., 40.).mask
# mx *= np.ma.masked_outside(xx, -45., 15.).mask + np.ma.masked_outside(
# xy, 60., 80.).mask
return mx

if newSlice in ['SubtropicSouthAtlantic', 'STSA']:
mx = np.ma.masked_outside(xx, -80., -10.).mask + np.ma.masked_outside(
xy, 10., 40.).mask
# mx *= np.ma.masked_outside(xx, -45., 15.).mask + np.ma.masked_outside(
# xy, 60., 80.).mask
return mx


if newSlice in ['RAPIDAtlanticTransect', ]:
mx = np.ma.masked_outside(xx, -80., -10.).mask + np.ma.masked_outside(
xy, 24.5, 28.5).mask
return mx

if newSlice in ['26N', ]:
mx = np.ma.masked_outside(
xy, 24.5, 28.5).mask
return mx
if newSlice in ['40N', ]:
mx = np.ma.masked_outside(
xy, 38., 42.).mask
return mx
if newSlice in ['55N', ]:
mx = np.ma.masked_outside(
xy, 55., 57.).mask
return mx

if newSlice in ['30S', ]:
mx = np.ma.masked_outside(
xy, -32., -28., ).mask
return mx

if newSlice in ['SubpolarNorthAtlantic', 'SPNA',]:
# Based on SPNA region here: https://www.nature.com/articles/s43247-021-00120-y#citeas
Expand All @@ -272,16 +292,49 @@ def makeMask(name, newSlice, xt, xz, xy, xx, xd, debug=False):

if newSlice in ['GINseas',]: #Greenland, icveland and norwegean seas
mx = np.ma.masked_outside(xx, -20., 15.).mask + np.ma.masked_outside(
xy, 65., 75.).mask
xy, 65., 75.).mask
return mx
#65-75:20W-15E

if newSlice in ['GLINseas',]: #Greenland, Labrador, Iceland and norwegean seas
mx = np.ma.masked_outside(xx, -20., 15.).mask + np.ma.masked_outside(
xy, 65., 75.).mask
mx *= (np.ma.masked_outside(xx, -69., -45.).mask + np.ma.masked_outside(xy, 53., 67.).mask)
return mx

if newSlice in ['LIGINseas',]: #Greenland, Labrador, Iceland and norwegean seas
mx = np.ma.masked_outside(xx, -20., 15.).mask + np.ma.masked_outside(
xy, 65., 75.).mask # GIN
mx *= (np.ma.masked_outside(xx, -69., -45.).mask + np.ma.masked_outside(xy, 53., 67.).mask) #Lab
mx *= (np.ma.masked_outside(xx, -45., -25.).mask + np.ma.masked_outside(xy, 53., 67.).mask) #Irm main
mx += ((np.ma.masked_inside(xx, -30., -25.).mask * np.ma.masked_inside(xy, 53., 58.).mask)) #Irm square
mx += ((np.ma.masked_inside(xx, -32.5, -30.).mask * np.ma.masked_inside(xy, 53., 55.5).mask)) #Irm small square left
mx += ((np.ma.masked_inside(xx, -27.5, -25.).mask * np.ma.masked_inside(xy, 58., 60.5).mask)) #Irm small square top
return mx

if newSlice in ['LIseas', ]: #Labrador & Irminger seas
mx = (np.ma.masked_outside(xx, -69., -45.).mask + np.ma.masked_outside(xy, 53., 67.).mask) #Lab
mx *= (np.ma.masked_outside(xx, -45., -25.).mask + np.ma.masked_outside(xy, 53., 67.).mask) #Irm main
mx += ((np.ma.masked_inside(xx, -30., -25.).mask * np.ma.masked_inside(xy, 53., 58.).mask)) #Irm square
mx += ((np.ma.masked_inside(xx, -32.5, -30.).mask * np.ma.masked_inside(xy, 53., 55.5).mask)) #Irm small square left
mx += ((np.ma.masked_inside(xx, -27.5, -25.).mask * np.ma.masked_inside(xy, 58., 60.5).mask)) #Irm small square top
return mx

if newSlice == 'AtlanticSOcean':
mx = np.ma.masked_outside(xx, -40., 20.).mask + np.ma.masked_outside(
xy, -50., -75.).mask
return mx

if newSlice == 'IrmingerSea':
mx = np.ma.masked_outside(xx, -45., -25.).mask + np.ma.masked_outside(xy, 53., 67.).mask
# mx += np.ma.masked_outside(xy, 53., 67.).mask
mx += ((np.ma.masked_inside(xx, -30., -25.).mask * np.ma.masked_inside(xy, 53., 58.).mask)) #Irm
mx += ((np.ma.masked_inside(xx, -32.5, -30.).mask * np.ma.masked_inside(xy, 53., 55.5).mask)) #Irm
mx += ((np.ma.masked_inside(xx, -27.5, -25.).mask * np.ma.masked_inside(xy, 58., 60.5).mask)) #Irm

return mx


if newSlice == 'NordicSea':
mx = np.ma.masked_outside(xx, -44., -5.).mask
mx += np.ma.masked_outside(xy, 53., 65.).mask
Expand All @@ -297,6 +350,15 @@ def makeMask(name, newSlice, xt, xz, xy, xx, xd, debug=False):
mx += np.ma.masked_outside(xy, 67., 76.).mask
return mx

if newSlice == 'NorthEastAtlantic':

mx = np.ma.masked_outside(xx, -25., -2.).mask
mx += np.ma.masked_outside(xy, 53., 65.).mask
return mx
#65-75:20W-15E



if newSlice == 'Cornwall':
mx = np.ma.masked_outside(xx, -8., -4.).mask
mx += np.ma.masked_outside(xy, 49., 52.).mask
Expand Down Expand Up @@ -365,6 +427,13 @@ def makeMask(name, newSlice, xt, xz, xy, xx, xd, debug=False):
mx += np.ma.masked_outside(xy, 67., 76.).mask
return mx

if newSlice == 'subpolar':
# subpolar North Atlantic (50–70° N and 70° W–0° E)
# from https://www.nature.com/articles/s41561-024-01568-1
mx = np.ma.masked_outside(xx, -70., 0.).mask
mx += np.ma.masked_outside(xy, 50., 70.).mask
return mx

if newSlice == 'NorthernSubpolarPacific':
mx = np.ma.masked_inside(xx, -100., 120.).mask
mx += np.ma.masked_inside(xx, 260., 365.).mask
Expand Down
28 changes: 25 additions & 3 deletions bgcval2/bgcvaltools/pftnames.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,15 @@ def makeLongNameDict():
lnd['AMOC'] = "AMOC"
lnd['AMOC_26N'] = "AMOC 26N"
lnd['AMOC_26N_nomexico'] = "AMOC 26N (excluding Gulf of Mexico)"
lnd['AMOC_40N'] = "AMOC 40N"
lnd['AMOC_55N'] = "AMOC 55N"

lnd['AMOC_32S'] = "AMOC 32S"
lnd['AMOC_depth'] = "AMOC depth"
lnd['ADRC_26N'] = "Atlantic Deep Return Current at 26N"
lnd['GulfStream'] = "Gulf Stream at 26N"
lnd['GulfStream_depth'] = "Gulf Stream depth at 26N"


lnd['ZonalCurrent'] = "Zonal Current"
lnd['MeridionalCurrent'] = "Meridional Current"
Expand All @@ -248,8 +255,9 @@ def makeLongNameDict():
lnd['VolumeMeanTemperature'] = "Volume-weighted Mean Temperature"
lnd['GlobalMeanSalinity'] = "Global Volume-weighted Mean Salinity"

lnd['AtlanticSubtropicSalinity'] = 'Atlantic Subtropic Salinity'
lnd['AtlanticSubtropicSalinity'] = 'Atlantic Subtropic Salinity 0-800m'
lnd['SubtropicNorthAtlantic'] = 'Subtropic North Atlantic'
lnd['GINSalinity'] = 'GIN Salinity 0-800m'

lnd['Surfaceto100m'] = 'Surface-to-100m'
lnd['Surfaceto200m'] = 'Surface-to-200m'
Expand All @@ -269,14 +277,18 @@ def makeLongNameDict():
lnd['thetaoga'] = "Global Average Sea Water Potential Temperature"
lnd['scalarHeatContent'] = "Global heat content"

lnd['thkcello'] = 'Cell thickness'
lnd['sowaflup'] = "Net Upward Water Flux"
lnd['hfds'] = 'Downwards Heat Flux'
lnd['sohefldo'] = "Net Downward Heat Flux"
lnd['fsitherm'] = "Water flux due to freezing/melting"
lnd['sosafldo'] = "Downward salt flux"
lnd['sofmflup'] = "Water flux due to freezing/melting"
lnd['sosfldow'] = "Downward salt flux"
lnd['soicecov'] = "Ice Fraction"
lnd['sossheig'] = "Sea Surface Height"
lnd['FreshwaterFlux'] = "Freshwater Flux"

lnd['hfbasinatlantic'] = 'Northward Atlantic heat transport'
lnd['exportRatio'] = "Export Ratio"
lnd['LocalExportRatio'] = "Export Ratio"

Expand Down Expand Up @@ -332,11 +344,14 @@ def makeLongNameDict():
lnd['EVS'] = 'Water Evaporation flux '
lnd['Precip'] = 'Precipitation'
lnd['sowindsp'] = 'Surface wind speed'
lnd['sowflisf'] = 'Ice Shelf Melting'
lnd['sowflisf'] = 'Ice Shelf Melting'
lnd['friver'] = 'River Water Flux'
lnd['fov'] = 'AMOC Meridional freshwater transport'
lnd['fov_sa'] = 'AMOC Meridional freshwater transport (South Atlantic)'
lnd['fov_stna'] = 'AMOC Meridional freshwater transport (Subtropial North Atlantic)'
lnd['somesatr'] = 'Salt Transport in y-direction'
lnd['hfy'] = 'Heat Transport in y-direction'


lnd['AMM'] = 'Atlantic Margins'
lnd['AMM_Shelf'] = 'Atlantic Margins Shelf'
Expand Down Expand Up @@ -423,6 +438,7 @@ def makeLongNameDict():

lnd['NordicSea'] = "Nordic Sea"
lnd['LabradorSea'] = "Labrador Sea"
lnd['NorthEastAtlantic'] = "North East Atlantic"
lnd['NorwegianSea'] = "Norwegian Sea"
lnd['Cornwall'] = "Cornwall"
lnd['Ascension'] = "Ascension Island"
Expand Down Expand Up @@ -539,6 +555,9 @@ def makeLongNameDict():
lnd['SouthHemisphere'] = "South Hemisphere"
lnd['26N'] = "26N"
lnd['32S'] = "32S"
lnd['30S'] = "30S"
lnd['40N'] = "40N"
lnd['55N'] = "55N"

lnd['WeddelSea'] = "Weddel Sea"
lnd['Enderby'] = "Enderby Region" # Regions from Pierce 1995 - https://doi.org/10.1175/1520-0485(1995)025<2046:CROHAF>2.0.CO;2
Expand All @@ -558,6 +577,9 @@ def makeLongNameDict():
lnd['STSA'] = "Subtropic North Atlantic"
lnd['SubtropicSouthAtlantic'] = lnd['STSA']
lnd['GINseas'] = 'Greenland, Iceland, Norway seas'
lnd['IrmingerSea'] = 'Irminger Sea'
lnd['LIGINseas'] = 'Labrador, Irminger, Greenland, Iceland, Norway seas'
lnd['LIseas'] = 'Labrador and Irminger seas'

lnd['SubpolarNorthAtlantic'] = lnd['SPNA']
lnd['NorthernSubpolarPacific'] = "Northern Subpolar Pacific"
Expand Down
6 changes: 4 additions & 2 deletions bgcval2/functions/AirSeaFluxCO2.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ def calc_total_airseafluxco2(nc, keys, **kwargs):
This function calculated the total Air Sea FLux for the MEDUSA model in the eORCA grid.
"""
areafile = get_kwarg_file(kwargs, 'areafile')

if not loaded_area_and_mask:
area = load_area_and_mask(areafile)
if 'area' in nc.variables.keys():
area = nc.variables['area'][:]
else:
area = load_area_and_mask(areafile)

factor = 365.25 * 12. / 1000. / 1.E15
try:
Expand Down
Loading
Loading