<jupyter_start><jupyter_text>Transport across sections`mom6_tools.section_transports` collection of functions for computing and plotting time-series of transports across vertical sections.The goal of this notebook is the following:1) server as an example on how to post-process the ESM/MOM6 vertical sections defined in diag_table. The location of the current vertical sections computed online can be found at the end of [this notebook](https://gist.github.com/gustavo-marques/bd6e9bb43062dcbc2abda91b757c7c4b); 2) evaluate model experiments by comparing transports against observed estimates;3) compare model results vs. another model results (TODO).<jupyter_code>%matplotlib inline
from mom6_tools.section_transports import Transport, options
import matplotlib.pyplot as plt<jupyter_output><empty_output><jupyter_text>Define the arguments expected by class "Transport". These have been hard-coded here fow now...<jupyter_code># The following parameters must be set accordingly
######################################################
# case name - must be changed for each configuration
case_name = 'g.c2b6.GNYF.T62_t061.long_run_nuopc.001'
# Path to the run directory
path = "/glade/scratch/gmarques/g.c2b6.GNYF.T62_t061.long_run_nuopc.001/run/"
# initial and final years for computing time mean
year_start = 20
year_end = 90
# add your name and email address below
author = '<NAME> (<EMAIL>)'
######################################################
# create an empty class object
class args:
  pass

args.infile = path
args.year_start = year_start
args.year_end = year_end
args.case_name = case_name
args.label = ''
args.debug = False<jupyter_output><empty_output><jupyter_text>Observed flows, more options can be added here* Griffies et al., 2016: OMIP contribution to CMIP6: experimental and diagnostic protocol for the physical component of the Ocean Model Intercomparison Project. Geosci. Model. Dev., 9, 3231-3296. doi:10.5194/gmd-9-3231-2016<jupyter_code>observedFlows = {'Agulhas':(129.8,143.6), 'Barents Opening':2.0, 'Bering Strait':(0.7,1.1), 'Davis Strait':(-2.1,-1.1), 'Denmark Strait':(-4.8,-2.0),
                 'Drake Passage':(129.8,143.6), 'English Channel':(0.01,0.1), 'Faroe-Scotland':(0.8,1.0), 'Florida-Bahamas':(28.9,34.3),
                 'Fram Strait':(-4.7,0.7), 'Gibraltar Strait':0.11, 'Gibraltar Strait':(-1.0, 1.0), 'Iceland-Faroe':(4.35,4.85),
                 'Indonesian Throughflow':(-15.,-13.), 'Mozambique Channel':(-25.6,-7.8), 'Pacific Equatorial Undercurrent':(24.5,28.3),
                 'Taiwan-Luzon Strait':(-3.0,-1.8), 'Windward Passage':(-15.,5.)}
# We need some estimated transport for the following:
# Bab_al_mandeb_Strait
# Iceland-Norway
# Hormuz Strait<jupyter_output><empty_output><jupyter_text>Below we define a function for plotting transport time series. Note the following: green = mean transport is within observed values  red    = mean transport is not within observed values  gray  = either there isn't observed values to compare with or just a mean value is available (not a range)<jupyter_code>def plotPanel(section,observedFlows=None,colorCode=True):
    ax = plt.subplot(1,1,1)
    color = '#c3c3c3'; obsLabel = None
    if section.label in observedFlows.keys():
      if isinstance(observedFlows[section.label],tuple):
        if colorCode == True:
          if min(observedFlows[section.label]) <= section.data.mean() <= max(observedFlows[section.label]):
            color = '#90ee90'
          else: color = '#f26161'
        obsLabel = str(min(observedFlows[section.label])) + ' to ' + str(max(observedFlows[section.label]))
      else: obsLabel = str(observedFlows[section.label])
    plt.plot(section.time,section.data,color=color)
    plt.title(section.label,fontsize=14)
    plt.text(0.04,0.11,'Mean = '+'{0:.2f}'.format(section.data.mean()),transform=ax.transAxes,fontsize=14)
    if obsLabel is not None: plt.text(0.04,0.04,'Obs. = '+obsLabel,transform=ax.transAxes,fontsize=14)
    if section.ylim is not None: plt.ylim(section.ylim)
    plt.ylabel('Transport (Sv)',fontsize=14); plt.xlabel('Time since beginning of run (yr)',fontsize=14)
    return<jupyter_output><empty_output><jupyter_text>Plot section transports in alphabetical order  Agulhas Section<jupyter_code>agulhas = Transport(args,'Agulhas_Section','umo',label='Agulhas',ylim=(160,240))
plotPanel(agulhas, observedFlows=observedFlows)<jupyter_output>Processing  Agulhas_Section<jupyter_text>Bab al mandeb Strait (Red Sea)<jupyter_code>bab = Transport(args,'Bab_al_mandeb_Strait','umo',label='Bab al mandeb Strait',ylim=(-0.5, 0.5))
plotPanel(bab, observedFlows=observedFlows)<jupyter_output>Processing  Bab_al_mandeb_Strait<jupyter_text>Bering Strait<jupyter_code>bering = Transport(args,'Bering_Strait','vmo',label='Bering Strait',ylim=(-2,3))
plotPanel(bering, observedFlows=observedFlows)<jupyter_output>Processing  Bering_Strait<jupyter_text>Barents opening<jupyter_code>barents = Transport(args,'Barents_opening','vmo',label='Barents Opening',ylim=(-2,10))
plotPanel(barents, observedFlows=observedFlows)<jupyter_output>Processing  Barents_opening<jupyter_text>Davis Strait<jupyter_code>davis = Transport(args,'Davis_Strait','vmo',label='Davis Strait',ylim=(-4.0,0.5))
plotPanel(davis, observedFlows=observedFlows)<jupyter_output>Processing  Davis_Strait<jupyter_text>Denmark Strait<jupyter_code>denmark = Transport(args,'Denmark_Strait','vmo',label='Denmark Strait',ylim=(-12,2))
plotPanel(denmark, observedFlows=observedFlows)<jupyter_output>Processing  Denmark_Strait<jupyter_text>Drake Passage<jupyter_code>drake = Transport(args,'Drake_Passage','umo',label='Drake Passage',ylim=(160,240))
plotPanel(drake, observedFlows=observedFlows)<jupyter_output>Processing  Drake_Passage<jupyter_text>English Channel<jupyter_code>english = Transport(args,'English_Channel','umo',label='English Channel',ylim=(-0.4,0.4))
plotPanel(english, observedFlows=observedFlows)<jupyter_output>Processing  English_Channel<jupyter_text>Florida Bahamas<jupyter_code>florida = Transport(args,'Florida_Bahamas','vmo',label='Florida-Bahamas',ylim=(5,15))
plotPanel(florida, observedFlows=observedFlows)<jupyter_output>Processing  Florida_Bahamas<jupyter_text>Fram Strait<jupyter_code>fram = Transport(args,'Fram_Strait','vmo',label='Fram Strait',ylim=(-10,8))
plotPanel(fram, observedFlows=observedFlows)<jupyter_output>Processing  Fram_Strait<jupyter_text>Gibraltar Strait<jupyter_code>gibraltar = Transport(args,'Gibraltar_Strait','umo',label='Gibraltar Strait',ylim=(-1.0,1.0))
plotPanel(gibraltar, observedFlows=observedFlows)<jupyter_output>Processing  Gibraltar_Strait<jupyter_text>Hormuz Strait (Persian Gulf or Arabic Sea)<jupyter_code>hormuz = Transport(args,'Hormuz_Strait','umo',label='Hormuz Strait',ylim=(-0.5,0.5))
plotPanel(hormuz, observedFlows=observedFlows)<jupyter_output>Processing  Hormuz_Strait<jupyter_text>Iceland Norway<jupyter_code>iceland = Transport(args,'Iceland_Norway','vmo',label='Iceland-Norway',ylim=(-5,17))
plotPanel(iceland, observedFlows=observedFlows)<jupyter_output>Processing  Iceland_Norway<jupyter_text>Indonesian Throughflow<jupyter_code>indo = Transport(args,'Indonesian_Throughflow','vmo',label='Indonesian Throughflow',ylim=(-20,0))
plotPanel(indo, observedFlows=observedFlows)<jupyter_output>Processing  Indonesian_Throughflow<jupyter_text>Mozambique Channel<jupyter_code>mozambique = Transport(args,'Mozambique_Channel','vmo',label='Mozambique Channel',ylim=(-50,10))
plotPanel(mozambique, observedFlows=observedFlows)<jupyter_output>Processing  Mozambique_Channel<jupyter_text>Pacific undercurrent<jupyter_code>euc = Transport(args,'Pacific_undercurrent','umo',label='Pacific Equatorial Undercurrent',ylim=None, zlim=(0,350))
plotPanel(euc, observedFlows=observedFlows)<jupyter_output>Processing  Pacific_undercurrent<jupyter_text>Taiwan Luzon<jupyter_code>taiwan = Transport(args,'Taiwan_Luzon','umo',label='Taiwan-Luzon Strait',ylim=(-15,10))
plotPanel(taiwan, observedFlows=observedFlows)<jupyter_output>Processing  Taiwan_Luzon<jupyter_text>Windward Passage<jupyter_code>windward = Transport(args,'Windward_Passage','vmo',label='Windward Passage',ylim=(-10,10))
plotPanel(windward, observedFlows=observedFlows)<jupyter_output>Processing  Windward_Passage
{'fraction_non_alphanumeric': 0.14044466043008139, 'fraction_numerical': 0.032195359008625926, 'mean_word_length': 8.136514983351832, 'pattern_counts': {'":': 0, '<': 75, '<?xml version=': 0, '>': 73, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '22', 'dir': 'jupyter-structured-clean-dedup', 'id': '179604', 'license': 'Apache-2.0', 'n_tokens_mistral': 3076, 'n_tokens_neox': 2855, 'n_words': 472, 'path': 'docs/source/examples/section_transports.ipynb', 'repo_name': 'gustavo-marques/mom6-tools', 'size': '8250'}