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

Added obs values and color coding #80

Merged
merged 2 commits into from
Apr 6, 2016
Merged
Changes from all commits
Commits
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
39 changes: 30 additions & 9 deletions tools/analysis/section_transports.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ def run():
parser.add_argument('-o','--outdir', type=str, default='.', help='''Directory in which to place plots.''')
parser.add_argument('-t','--trange', type=str, default=None, help='''Tuple containing start and end years to plot''')
cmdLineArgs = parser.parse_args()
A = main(cmdLineArgs)
return A
main(cmdLineArgs)

def main(cmdLineArgs,stream=None):

Expand Down Expand Up @@ -50,20 +49,41 @@ def __init__(self, cmdLineArgs, section, var, label=None, ylim=None, mks2Sv=True
if cmdLineArgs.suptitle != '': self.suptitle = cmdLineArgs.suptitle + ' ' + cmdLineArgs.label
else: self.suptitle = rootGroup.title + ' ' + cmdLineArgs.label

def plotPanel(section,n,autolim=True):
def plotPanel(section,n,observedFlows=None,autolim=True,colorCode=True):
ax = plt.subplot(6,3,n)
plt.plot(section.time,section.data,color='#c3c3c3')
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=12)
plt.text(0.04,0.05,'Mean = '+'{0:.2f}'.format(section.data.mean()),transform=ax.transAxes,fontsize=10)
plt.text(0.04,0.11,'Mean = '+'{0:.2f}'.format(section.data.mean()),transform=ax.transAxes,fontsize=10)
if obsLabel != None: plt.text(0.04,0.04,'Obs. = '+obsLabel,transform=ax.transAxes,fontsize=10)
if autolim == False:
if section.ylim != None: plt.ylim(section.ylim)
if n in [1,4,7,10,13,16]: plt.ylabel('Transport (Sv)')

reference = 'Griffies et al., 2016: Experimental and diagnostic protocol for the physical component of the\nCMIP6 Ocean Model Intercomparison Project (OMIP) Geosci. Model Dev., Submitted'
observedFlows = {'reference':reference,'Bering Strait':(0.7,1.1),
'Barents Opening':2.0, 'Canadian Archipelago':(0.5,1.0), 'Denmark Strait':(-4.8,-2.0),
'Drake Passage':(129.8,143.6), 'English Channel':(0.1,0.2), 'Faroe-Scotland':(0.8,1.0), 'Florida-Bahamas':(28.9,34.3),
'Fram Strait':(6.2,7.0), 'Gibraltar Strait':0.11, 'Iceland-Faroe':(4.35,4.85),
'Indonesian Throughflow':-13., 'Mozambique Channel':(-25.6,-7.8), 'Pacific Equatorial Undercurrent':(24.,36.),
'Taiwan-Luzon Strait':(-3.0,-1.8), 'Windward Passage':(-15.,5.)}

plotSections = []

try: res = Transport(cmdLineArgs,'ocean_Agulhas_section','umo',label='Agulhas',ylim=(120,180)); plotSections.append(res)
except: print('WARNING: unable to process ocean_Agulhas_section')

try: res = Transport(cmdLineArgs,'ocean_Bering_Strait','vmo',label='Bering Strait',ylim=(-2,8)); plotSections.append(res)
except: print('WARNING: unable to process ocean_Barents_opening')

try: res = Transport(cmdLineArgs,'ocean_Barents_opening','umo',label='Barents Opening',ylim=(-2,8)); plotSections.append(res)
except: print('WARNING: unable to process ocean_Barents_opening')

Expand Down Expand Up @@ -106,15 +126,16 @@ def plotPanel(section,n,autolim=True):
try: res = Transport(cmdLineArgs,'ocean_Pacific_undercurrent','umo',label='Pacific Equatorial Undercurrent',ylim=(-8,8)); plotSections.append(res)
except: print('WARNING: unable to process ocean_Pacific_undercurrent')

try: res = Transport(cmdLineArgs,'ocean_Taiwan_Luzon','umo',label='Taiwan-Luzon Striat',ylim=(-15,10)); plotSections.append(res)
try: res = Transport(cmdLineArgs,'ocean_Taiwan_Luzon','umo',label='Taiwan-Luzon Strait',ylim=(-15,10)); plotSections.append(res)
except: print('WARNING: unable to process ocean_Taiwan_Luzon')

try: res = Transport(cmdLineArgs,'ocean_Windward_Passage','vmo',label='Windward Passage',ylim=(-15,15)); plotSections.append(res)
except: print('WARNING: unable to process ocean_Windward_Passage')

fig = plt.figure(figsize=(13,17))
for n in range(0,len(plotSections)): plotPanel(plotSections[n],n)
fig.text(0.5,0.94,str(plotSections[n-1].suptitle),horizontalalignment='center',fontsize=14)
for n in range(0,len(plotSections)): plotPanel(plotSections[n],n,observedFlows=observedFlows)
fig.text(0.5,0.955,str(plotSections[n-1].suptitle),horizontalalignment='center',fontsize=14)
fig.text(0.5,0.925,'Observations summarized in '+observedFlows['reference'],horizontalalignment='center',fontsize=11)
plt.subplots_adjust(hspace=0.3)
if stream != None: fig.text(0.5,0.05,str('Generated by dora.gfdl.noaa.gov'),horizontalalignment='center',fontsize=12)
plt.show(block=False)
Expand All @@ -124,5 +145,5 @@ def plotPanel(section,n,autolim=True):
plt.savefig(objOut)

if __name__ == '__main__':
A = run()
run()