diff --git a/tools/analysis/SSS_bias_WOA05.py b/tools/analysis/SSS_bias_WOA05.py index d3b918a580..41db6c31db 100755 --- a/tools/analysis/SSS_bias_WOA05.py +++ b/tools/analysis/SSS_bias_WOA05.py @@ -3,49 +3,56 @@ import netCDF4 import numpy import m6plot - -try: import argparse -except: raise Exception('This version of python is not new enough. python 2.7 or newer is required.') - -parser = argparse.ArgumentParser(description='''Script for plotting annual-average SSS bias.''') -parser.add_argument('annual_file', type=str, help='''Annually-averaged file containing 3D 'salt'.''') -parser.add_argument('-l','--label', type=str, default='', help='''Label to add to the plot.''') -parser.add_argument('-o','--outdir', type=str, default='.', help='''Directory in which to place plots.''') -parser.add_argument('-g','--gridspecdir', type=str, required=True, - help='''Directory containing mosaic/grid-spec files (ocean_hgrid.nc and ocean_mask.nc).''') -parser.add_argument('-w','--woa', type=str, required=True, - help='''File containing WOA (or obs) data to compare against.''') -cmdLineArgs = parser.parse_args() - -numpy.seterr(divide='ignore', invalid='ignore', over='ignore') # To avoid warnings - -x = netCDF4.Dataset(cmdLineArgs.gridspecdir+'/ocean_hgrid.nc').variables['x'][::2,::2] -y = netCDF4.Dataset(cmdLineArgs.gridspecdir+'/ocean_hgrid.nc').variables['y'][::2,::2] -msk = netCDF4.Dataset(cmdLineArgs.gridspecdir+'/ocean_mask.nc').variables['mask'][:] -area = msk*netCDF4.Dataset(cmdLineArgs.gridspecdir+'/ocean_hgrid.nc').variables['area'][:,:].reshape([msk.shape[0], 2, msk.shape[1], 2]).sum(axis=-3).sum(axis=-1) -msk = numpy.ma.array(msk, mask=(msk==0)) - -Sobs = netCDF4.Dataset( cmdLineArgs.woa ).variables['salt'] -if len(Sobs.shape)==3: Sobs = Sobs[0] -else: Sobs = Sobs[:,0].mean(axis=0) - -rootGroup = netCDF4.Dataset( cmdLineArgs.annual_file ) -if 'salt' in rootGroup.variables: varName = 'salt' -elif 'so' in rootGroup.variables: varName = 'so' -else: raise Exception('Could not find "salt" or "so" in file "%s"'%(cmdLineArgs.annual_file)) -if rootGroup.variables[varName].shape[0]>1: salt = rootGroup.variables[varName][:,0].mean(axis=0) -else: Smod = rootGroup.variables[varName][0,0] - -ci=m6plot.pmCI(0.125,2.25,.25) -m6plot.xyplot( Smod - Sobs , x, y, area=area, +import sys + +def run(): + try: import argparse + except: raise Exception('This version of python is not new enough. python 2.7 or newer is required.') + parser = argparse.ArgumentParser(description='''Script for plotting annual-average SSS bias.''') + parser.add_argument('annual_file', type=str, help='''Annually-averaged file containing 3D 'salt'.''') + parser.add_argument('-l','--label', type=str, default='', help='''Label to add to the plot.''') + parser.add_argument('-o','--outdir', type=str, default='.', help='''Directory in which to place plots.''') + parser.add_argument('-g','--gridspecdir', type=str, required=True, + help='''Directory containing mosaic/grid-spec files (ocean_hgrid.nc and ocean_mask.nc).''') + parser.add_argument('-w','--woa', type=str, required=True, + help='''File containing WOA (or obs) data to compare against.''') + cmdLineArgs = parser.parse_args() + main(cmdLineArgs) + +def main(cmdLineArgs,stream=None): + numpy.seterr(divide='ignore', invalid='ignore', over='ignore') # To avoid warnings + + x = netCDF4.Dataset(cmdLineArgs.gridspecdir+'/ocean_hgrid.nc').variables['x'][::2,::2] + y = netCDF4.Dataset(cmdLineArgs.gridspecdir+'/ocean_hgrid.nc').variables['y'][::2,::2] + msk = netCDF4.Dataset(cmdLineArgs.gridspecdir+'/ocean_mask.nc').variables['mask'][:] + area = msk*netCDF4.Dataset(cmdLineArgs.gridspecdir+'/ocean_hgrid.nc').variables['area'][:,:].reshape([msk.shape[0], 2, msk.shape[1], 2]).sum(axis=-3).sum(axis=-1) + msk = numpy.ma.array(msk, mask=(msk==0)) + + Sobs = netCDF4.Dataset( cmdLineArgs.woa ).variables['salt'] + if len(Sobs.shape)==3: Sobs = Sobs[0] + else: Sobs = Sobs[:,0].mean(axis=0) + + rootGroup = netCDF4.MFDataset( cmdLineArgs.annual_file ) + if 'salt' in rootGroup.variables: varName = 'salt' + elif 'so' in rootGroup.variables: varName = 'so' + else: raise Exception('Could not find "salt" or "so" in file "%s"'%(cmdLineArgs.annual_file)) + if rootGroup.variables[varName].shape[0]>1: Smod = rootGroup.variables[varName][:,0].mean(axis=0) + else: Smod = rootGroup.variables[varName][0,0] + + ci=m6plot.pmCI(0.125,2.25,.25) + if stream == None: stream = cmdLineArgs.outdir+'/SSS_bias_WOA05.png' + m6plot.xyplot( Smod - Sobs , x, y, area=area, suptitle=rootGroup.title+' '+cmdLineArgs.label, title='SSS bias (w.r.t. WOA\'05) [ppt]', clim=ci, colormap='dunnePM', centerlabels=True, extend='both', - save=cmdLineArgs.outdir+'/SSS_bias_WOA05.png') - -m6plot.xycompare( Smod, Sobs , x, y, area=area, + save=stream) + + m6plot.xycompare( Smod, Sobs , x, y, area=area, suptitle=rootGroup.title+' '+cmdLineArgs.label, title1='SSS [ppt]', title2='WOA\'05 SSS [ppt]', clim=m6plot.linCI(20,30,10, 31,39,.5), colormap='dunneRainbow', extend='both', dlim=ci, dcolormap='dunnePM', dextend='both', centerdlabels=True, save=cmdLineArgs.outdir+'/SSS_bias_WOA05.3_panel.png') + +if __name__ == '__main__': + run() diff --git a/tools/analysis/SST_bias_WOA05.py b/tools/analysis/SST_bias_WOA05.py index 060b8156dd..3d25b166e2 100755 --- a/tools/analysis/SST_bias_WOA05.py +++ b/tools/analysis/SST_bias_WOA05.py @@ -3,53 +3,60 @@ import netCDF4 import numpy import m6plot - -try: import argparse -except: raise Exception('This version of python is not new enough. python 2.7 or newer is required.') - -parser = argparse.ArgumentParser(description='''Script for plotting annual-average SST bias.''') -parser.add_argument('annual_file', type=str, help='''Annually-averaged file containing 3D 'temp'.''') -parser.add_argument('-l','--label', type=str, default='', help='''Label to add to the plot.''') -parser.add_argument('-o','--outdir', type=str, default='.', help='''Directory in which to place plots.''') -parser.add_argument('-g','--gridspecdir', type=str, required=True, - help='''Directory containing mosaic/grid-spec files (ocean_hgrid.nc and ocean_mask.nc).''') -parser.add_argument('-w','--woa', type=str, required=True, - help='''File containing WOA (or obs) data to compare against.''') -cmdLineArgs = parser.parse_args() - -numpy.seterr(divide='ignore', invalid='ignore', over='ignore') # To avoid warnings - -x = netCDF4.Dataset(cmdLineArgs.gridspecdir+'/ocean_hgrid.nc').variables['x'][::2,::2] -y = netCDF4.Dataset(cmdLineArgs.gridspecdir+'/ocean_hgrid.nc').variables['y'][::2,::2] -msk = netCDF4.Dataset(cmdLineArgs.gridspecdir+'/ocean_mask.nc').variables['mask'][:] -area = msk*netCDF4.Dataset(cmdLineArgs.gridspecdir+'/ocean_hgrid.nc').variables['area'][:,:].reshape([msk.shape[0], 2, msk.shape[1], 2]).sum(axis=-3).sum(axis=-1) -msk = numpy.ma.array(msk, mask=(msk==0)) - -Tobs = netCDF4.Dataset( cmdLineArgs.woa ) -if 'temp' in Tobs.variables: Tobs = Tobs.variables['temp'] -elif 'ptemp' in Tobs.variables: Tobs = Tobs.variables['ptemp'] -else: raise Exception('Could not find "temp" or "ptemp" in file "%s"'%(cmdLineArgs.woa)) -if len(Tobs.shape)==3: Tobs = Tobs[0] -else: Tobs = Tobs[:,0].mean(axis=0) - -rootGroup = netCDF4.Dataset( cmdLineArgs.annual_file ) -if 'temp' in rootGroup.variables: varName = 'temp' -elif 'ptemp' in rootGroup.variables: varName = 'ptemp' -elif 'thetao' in rootGroup.variables: varName = 'thetao' -else: raise Exception('Could not find "temp", "ptemp" or "thetao" in file "%s"'%(cmdLineArgs.annual_file)) -if rootGroup.variables[varName].shape[0]>1: salt = rootGroup.variables[varName][:,0].mean(axis=0) -else: Tmod = rootGroup.variables[varName][0,0] - -ci=m6plot.pmCI(0.25,4.5,.5) -m6plot.xyplot( Tmod - Tobs , x, y, area=area, +import sys + +def run(): + try: import argparse + except: raise Exception('This version of python is not new enough. python 2.7 or newer is required.') + parser = argparse.ArgumentParser(description='''Script for plotting annual-average SST bias.''') + parser.add_argument('annual_file', type=str, help='''Annually-averaged file containing 3D 'temp'.''') + parser.add_argument('-l','--label', type=str, default='', help='''Label to add to the plot.''') + parser.add_argument('-o','--outdir', type=str, default='.', help='''Directory in which to place plots.''') + parser.add_argument('-g','--gridspecdir', type=str, required=True, + help='''Directory containing mosaic/grid-spec files (ocean_hgrid.nc and ocean_mask.nc).''') + parser.add_argument('-w','--woa', type=str, required=True, + help='''File containing WOA (or obs) data to compare against.''') + cmdLineArgs = parser.parse_args() + main(cmdLineArgs) + +def main(cmdLineArgs,stream=None): + numpy.seterr(divide='ignore', invalid='ignore', over='ignore') # To avoid warnings + + x = netCDF4.Dataset(cmdLineArgs.gridspecdir+'/ocean_hgrid.nc').variables['x'][::2,::2] + y = netCDF4.Dataset(cmdLineArgs.gridspecdir+'/ocean_hgrid.nc').variables['y'][::2,::2] + msk = netCDF4.Dataset(cmdLineArgs.gridspecdir+'/ocean_mask.nc').variables['mask'][:] + area = msk*netCDF4.Dataset(cmdLineArgs.gridspecdir+'/ocean_hgrid.nc').variables['area'][:,:].reshape([msk.shape[0], 2, msk.shape[1], 2]).sum(axis=-3).sum(axis=-1) + msk = numpy.ma.array(msk, mask=(msk==0)) + + Tobs = netCDF4.Dataset( cmdLineArgs.woa ) + if 'temp' in Tobs.variables: Tobs = Tobs.variables['temp'] + elif 'ptemp' in Tobs.variables: Tobs = Tobs.variables['ptemp'] + else: raise Exception('Could not find "temp" or "ptemp" in file "%s"'%(cmdLineArgs.woa)) + if len(Tobs.shape)==3: Tobs = Tobs[0] + else: Tobs = Tobs[:,0].mean(axis=0) + + rootGroup = netCDF4.MFDataset( cmdLineArgs.annual_file ) + if 'temp' in rootGroup.variables: varName = 'temp' + elif 'ptemp' in rootGroup.variables: varName = 'ptemp' + elif 'thetao' in rootGroup.variables: varName = 'thetao' + else: raise Exception('Could not find "temp", "ptemp" or "thetao" in file "%s"'%(cmdLineArgs.annual_file)) + if rootGroup.variables[varName].shape[0]>1: Tmod = rootGroup.variables[varName][:,0].mean(axis=0) + else: Tmod = rootGroup.variables[varName][0,0] + + ci=m6plot.pmCI(0.25,4.5,.5) + if stream == None: stream = cmdLineArgs.outdir+'/SST_bias_WOA05.png' + m6plot.xyplot( Tmod - Tobs , x, y, area=area, suptitle=rootGroup.title+' '+cmdLineArgs.label, title='SST bias (w.r.t. WOA\'05) [$\degree$C]', clim=ci, colormap='dunnePM', centerlabels=True, extend='both', - save=cmdLineArgs.outdir+'/SST_bias_WOA05.png') + save=stream) -m6plot.xycompare( Tmod, Tobs , x, y, area=area, + m6plot.xycompare( Tmod, Tobs , x, y, area=area, suptitle=rootGroup.title+' '+cmdLineArgs.label, title1='SST [$\degree$C]', title2='WOA\'05 SST [$\degree$C]', clim=m6plot.linCI(-2,29,.5), colormap='dunneRainbow', extend='max', dlim=ci, dcolormap='dunnePM', dextend='both', centerdlabels=True, save=cmdLineArgs.outdir+'/SST_bias_WOA05.3_panel.png') + +if __name__ == '__main__': + run() diff --git a/tools/analysis/meridional_overturning.py b/tools/analysis/meridional_overturning.py index e3f1999fde..bcf53f012f 100755 --- a/tools/analysis/meridional_overturning.py +++ b/tools/analysis/meridional_overturning.py @@ -4,99 +4,114 @@ import numpy import m6plot import matplotlib.pyplot as plt +import sys -try: import argparse -except: raise Exception('This version of python is not new enough. python 2.7 or newer is required.') +def run(): + try: import argparse + except: raise Exception('This version of python is not new enough. python 2.7 or newer is required.') + parser = argparse.ArgumentParser(description='''Script for plotting meridional overturning.''') + parser.add_argument('annual_file', type=str, help='''Annually-averaged file containing 3D 'vh' and 'e'.''') + parser.add_argument('-l','--label', type=str, default='', help='''Label to add to the plot.''') + parser.add_argument('-o','--outdir', type=str, default='.', help='''Directory in which to place plots.''') + parser.add_argument('-g','--gridspecdir', type=str, required=True, + help='''Directory containing mosaic/grid-spec files (ocean_hgrid.nc and ocean_mask.nc).''') + cmdLineArgs = parser.parse_args() + main(cmdLineArgs) -parser = argparse.ArgumentParser(description='''Script for plotting meridional overturning.''') -parser.add_argument('annual_file', type=str, help='''Annually-averaged file containing 3D 'vh' and 'e'.''') -parser.add_argument('-l','--label', type=str, default='', help='''Label to add to the plot.''') -parser.add_argument('-o','--outdir', type=str, default='.', help='''Directory in which to place plots.''') -parser.add_argument('-g','--gridspecdir', type=str, required=True, - help='''Directory containing mosaic/grid-spec files (ocean_hgrid.nc and ocean_mask.nc).''') -cmdLineArgs = parser.parse_args() - -#x = netCDF4.Dataset(cmdLineArgs.gridspecdir+'/ocean_hgrid.nc').variables['x'][::2,::2] -y = netCDF4.Dataset(cmdLineArgs.gridspecdir+'/ocean_hgrid.nc').variables['y'][::2,::2] -msk = netCDF4.Dataset(cmdLineArgs.gridspecdir+'/ocean_mask.nc').variables['mask'][:] -area = msk*netCDF4.Dataset(cmdLineArgs.gridspecdir+'/ocean_hgrid.nc').variables['area'][:,:].reshape([msk.shape[0], 2, msk.shape[1], 2]).sum(axis=-3).sum(axis=-1) -depth = netCDF4.Dataset(cmdLineArgs.gridspecdir+'/ocean_topog.nc').variables['depth'][:] -basin_code = netCDF4.Dataset(cmdLineArgs.gridspecdir+'/basin_codes.v20140629.nc').variables['basin'][:] - -rootGroup = netCDF4.Dataset( cmdLineArgs.annual_file ) -if 'vh' in rootGroup.variables: - varName = 'vh'; conversion_factor = 1.e-9 -elif 'vmo' in rootGroup.variables: - varName = 'vmo'; conversion_factor = 1.e-9 -else: raise Exception('Could not find "vh" or "vmo" in file "%s"'%(cmdLineArgs.annual_file)) -if len(rootGroup.variables[varName].shape)==4: VHmod = rootGroup.variables[varName][:].mean(axis=0).filled(0.) -else: VHmod = rootGroup.variables[varName][:].filled(0.) -if 'e' in rootGroup.variables: Zmod = rootGroup.variables['e'][0] -elif 'zw' in rootGroup.variables: - zw = rootGroup.variables['zw'][:] - Zmod = numpy.zeros((zw.shape[0], depth.shape[0], depth.shape[1] )) - for k in range(zw.shape[0]): - Zmod[k] = -numpy.minimum( depth, abs(zw[k]) ) -else: raise Exception('Neither a model-space output file or a z-space diagnostic file?') - -def MOCpsi(vh, vmsk=None): - """Sums 'vh' zonally and cumulatively in the vertical to yield an overturning stream function, psi(y,z).""" - shape = list(vh.shape); shape[-3] += 1 - psi = numpy.zeros(shape[:-1]) - if len(shape)==3: - for k in range(shape[-3]-1,0,-1): - if vmsk==None: psi[k-1,:] = psi[k,:] - vh[k-1].sum(axis=-1) - else: psi[k-1,:] = psi[k,:] - (vmsk*vh[k-1]).sum(axis=-1) - else: - for n in range(shape[0]): +def main(cmdLineArgs,stream=None): + #x = netCDF4.Dataset(cmdLineArgs.gridspecdir+'/ocean_hgrid.nc').variables['x'][::2,::2] + y = netCDF4.Dataset(cmdLineArgs.gridspecdir+'/ocean_hgrid.nc').variables['y'][::2,::2] + msk = netCDF4.Dataset(cmdLineArgs.gridspecdir+'/ocean_mask.nc').variables['mask'][:] + area = msk*netCDF4.Dataset(cmdLineArgs.gridspecdir+'/ocean_hgrid.nc').variables['area'][:,:].reshape([msk.shape[0], 2, msk.shape[1], 2]).sum(axis=-3).sum(axis=-1) + depth = netCDF4.Dataset(cmdLineArgs.gridspecdir+'/ocean_topog.nc').variables['depth'][:] + basin_code = netCDF4.Dataset(cmdLineArgs.gridspecdir+'/basin_codes.v20140629.nc').variables['basin'][:] + + if stream != None: + if len(stream) != 2: + raise ValueError('If specifying output streams, exactly two streams are needed for this analysis') + + rootGroup = netCDF4.MFDataset( cmdLineArgs.annual_file ) + if 'vh' in rootGroup.variables: + varName = 'vh'; conversion_factor = 1.e-9 + elif 'vmo' in rootGroup.variables: + varName = 'vmo'; conversion_factor = 1.e-9 + else: raise Exception('Could not find "vh" or "vmo" in file "%s"'%(cmdLineArgs.annual_file)) + if len(rootGroup.variables[varName].shape)==4: VHmod = rootGroup.variables[varName][:].mean(axis=0).filled(0.) + else: VHmod = rootGroup.variables[varName][:].filled(0.) + if 'e' in rootGroup.variables: Zmod = rootGroup.variables['e'][0] + elif 'zw' in rootGroup.variables: + zw = rootGroup.variables['zw'][:] + Zmod = numpy.zeros((zw.shape[0], depth.shape[0], depth.shape[1] )) + for k in range(zw.shape[0]): + Zmod[k] = -numpy.minimum( depth, abs(zw[k]) ) + else: raise Exception('Neither a model-space output file or a z-space diagnostic file?') + + def MOCpsi(vh, vmsk=None): + """Sums 'vh' zonally and cumulatively in the vertical to yield an overturning stream function, psi(y,z).""" + shape = list(vh.shape); shape[-3] += 1 + psi = numpy.zeros(shape[:-1]) + if len(shape)==3: for k in range(shape[-3]-1,0,-1): - if vmsk==None: psi[n,k-1,:] = psi[n,k,:] - vh[n,k-1].sum(axis=-1) - else: psi[n,k-1,:] = psi[n,k,:] - (vmsk*vh[n,k-1]).sum(axis=-1) - return psi + if vmsk==None: psi[k-1,:] = psi[k,:] - vh[k-1].sum(axis=-1) + else: psi[k-1,:] = psi[k,:] - (vmsk*vh[k-1]).sum(axis=-1) + else: + for n in range(shape[0]): + for k in range(shape[-3]-1,0,-1): + if vmsk==None: psi[n,k-1,:] = psi[n,k,:] - vh[n,k-1].sum(axis=-1) + else: psi[n,k-1,:] = psi[n,k,:] - (vmsk*vh[n,k-1]).sum(axis=-1) + return psi + + def plotPsi(y, z, psi, ci, title): + cmap = plt.get_cmap('dunnePM') + plt.contourf(y, z, psi, levels=ci, cmap=cmap, extend='both') + cbar = plt.colorbar() + plt.contour(y, z, psi, levels=ci, colors='k', hold='on') + plt.gca().set_yscale('splitscale',zval=[0,-2000,-6500]) + plt.title(title) + cbar.set_label('[Sv]'); plt.ylabel('Elevation [m]') -def plotPsi(y, z, psi, ci, title): + def findExtrema(y, z, psi, min_lat=-90., max_lat=90., min_depth=0., mult=1.): + psiMax = mult*numpy.amax( mult * numpy.ma.array(psi)[(y>=min_lat) & (y<=max_lat) & (z<-min_depth)] ) + idx = numpy.argmin(numpy.abs(psi-psiMax)) + (j,i) = numpy.unravel_index(idx, psi.shape) + plt.plot(y[j,i],z[j,i],'kx',hold=True) + plt.text(y[j,i],z[j,i],'%.1f'%(psi[j,i])) + + m6plot.setFigureSize(npanels=1) cmap = plt.get_cmap('dunnePM') - plt.contourf(y, z, psi, levels=ci, cmap=cmap, extend='both') - cbar = plt.colorbar() - plt.contour(y, z, psi, levels=ci, colors='k', hold='on') - plt.gca().set_yscale('splitscale',zval=[0,-2000,-6500]) - plt.title(title) - cbar.set_label('[Sv]'); plt.ylabel('Elevation [m]') - -def findExtrema(y, z, psi, min_lat=-90., max_lat=90., min_depth=0., mult=1.): - psiMax = mult*numpy.amax( mult * numpy.ma.array(psi)[(y>=min_lat) & (y<=max_lat) & (z<-min_depth)] ) - idx = numpy.argmin(numpy.abs(psi-psiMax)) - (j,i) = numpy.unravel_index(idx, psi.shape) - plt.plot(y[j,i],z[j,i],'kx',hold=True) - plt.text(y[j,i],z[j,i],'%.1f'%(psi[j,i])) + # Global MOC + z = Zmod.min(axis=-1); psiPlot = MOCpsi(VHmod)*conversion_factor + yy = y[1:,:].max(axis=-1)+0*z + ci=m6plot.pmCI(0.,40.,5.) + plotPsi(yy, z, psiPlot, ci, 'Global MOC [Sv]') + plt.xlabel(r'Latitude [$\degree$N]') + plt.suptitle(rootGroup.title+' '+cmdLineArgs.label) + findExtrema(yy, z, psiPlot, max_lat=-30.) + findExtrema(yy, z, psiPlot, min_lat=25.) + findExtrema(yy, z, psiPlot, min_depth=2000., mult=-1.) + if stream != None: + plt.savefig(stream[0]) + else: + plt.savefig(cmdLineArgs.outdir+'/MOC_global.png') + + # Atlantic MOC + plt.clf() + m = 0*basin_code; m[(basin_code==2) | (basin_code==4) | (basin_code==6) | (basin_code==7) | (basin_code==8)]=1 + ci=m6plot.pmCI(0.,22.,2.) + z = (m*Zmod).min(axis=-1); psiPlot = MOCpsi(VHmod, vmsk=m*numpy.roll(m,1,axis=1))*conversion_factor + yy = y[1:,:].max(axis=-1)+0*z + plotPsi(yy, z, psiPlot, ci, 'Atlantic MOC [Sv]') + plt.xlabel(r'Latitude [$\degree$N]') + plt.suptitle(rootGroup.title+' '+cmdLineArgs.label) + findExtrema(yy, z, psiPlot, min_lat=26.5, max_lat=27.) # RAPID + findExtrema(yy, z, psiPlot, max_lat=-33.) + findExtrema(yy, z, psiPlot) + findExtrema(yy, z, psiPlot, min_lat=5.) + if stream != None: + plt.savefig(stream[1]) + else: + plt.savefig(cmdLineArgs.outdir+'/MOC_Atlantic.png') -m6plot.setFigureSize(npanels=1) -cmap = plt.get_cmap('dunnePM') - -# Global MOC -z = Zmod.min(axis=-1); psiPlot = MOCpsi(VHmod)*conversion_factor -yy = y[1:,:].max(axis=-1)+0*z -ci=m6plot.pmCI(0.,40.,5.) -plotPsi(yy, z, psiPlot, ci, 'Global MOC [Sv]') -plt.xlabel(r'Latitude [$\degree$N]') -plt.suptitle(rootGroup.title+' '+cmdLineArgs.label) -findExtrema(yy, z, psiPlot, max_lat=-30.) -findExtrema(yy, z, psiPlot, min_lat=25.) -findExtrema(yy, z, psiPlot, min_depth=2000., mult=-1.) -plt.savefig(cmdLineArgs.outdir+'/MOC_global.png') - -# Atlantic MOC -plt.clf() -m = 0*basin_code; m[(basin_code==2) | (basin_code==4) | (basin_code==6) | (basin_code==7) | (basin_code==8)]=1 -ci=m6plot.pmCI(0.,22.,2.) -z = (m*Zmod).min(axis=-1); psiPlot = MOCpsi(VHmod, vmsk=m*numpy.roll(m,1,axis=1))*conversion_factor -yy = y[1:,:].max(axis=-1)+0*z -plotPsi(yy, z, psiPlot, ci, 'Atlantic MOC [Sv]') -plt.xlabel(r'Latitude [$\degree$N]') -plt.suptitle(rootGroup.title+' '+cmdLineArgs.label) -findExtrema(yy, z, psiPlot, min_lat=26.5, max_lat=27.) # RAPID -findExtrema(yy, z, psiPlot, max_lat=-33.) -findExtrema(yy, z, psiPlot) -findExtrema(yy, z, psiPlot, min_lat=5.) -plt.savefig(cmdLineArgs.outdir+'/MOC_Atlantic.png') +if __name__ == '__main__': + run()