moc.py 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #!/usr/bin/env python
  2. # B a r a K u d a
  3. #
  4. # Generate lat-depth plot of the Atlantic Meridional Overturning Circulation
  5. #
  6. # L. Brodeau, 2009
  7. import sys
  8. import numpy as nmp
  9. from netCDF4 import Dataset
  10. import barakuda_tool as bt
  11. import barakuda_plot as bp
  12. ldebug = False
  13. venv_needed = {'ORCA','EXP','DIAG_D','MM_FILE','BM_FILE'}
  14. vdic = bt.check_env_var(sys.argv[0], venv_needed)
  15. CONFEXP = vdic['ORCA']+'-'+vdic['EXP']
  16. cv_moc = 'zomsfatl'
  17. path_fig='./'
  18. fig_type='png'
  19. narg = len(sys.argv)
  20. if narg < 3: print 'Usage: '+sys.argv[0]+' <year1> <year2>'; sys.exit(0)
  21. cy1 = sys.argv[1] ; cy2=sys.argv[2]; jy1=int(cy1); jy2=int(cy2)
  22. jy1_clim = jy1 ; jy2_clim = jy2
  23. print ' => mean on the clim : ', jy1_clim, jy2_clim, '\n'
  24. # Getting coordinates:
  25. bt.chck4f(vdic['MM_FILE'])
  26. id_mm = Dataset(vdic['MM_FILE'])
  27. xlat = id_mm.variables['gphit'][0,:,:]
  28. xlon = id_mm.variables['glamt'][0,:,:]
  29. Xmask = id_mm.variables['tmask'][0,:,:,:]
  30. id_mm.close()
  31. [ nk, nj, ni ] = nmp.shape(Xmask)
  32. # Getting basin mask:
  33. bt.chck4f(vdic['BM_FILE'])
  34. id_bm = Dataset(vdic['BM_FILE'])
  35. Xmask_atl = id_bm.variables['tmaskatl'][:,:]
  36. id_bm.close()
  37. for jk in range(nk): Xmask[jk,:,:] = Xmask[jk,:,:] * Xmask_atl[:,:]
  38. # Getting NEMO mean monthly climatology of MLD coverage:
  39. cf_nemo_moc = vdic['DIAG_D']+'/clim/aclim_'+CONFEXP+'_'+cy1+'-'+cy2+'_MOC.nc4'
  40. bt.chck4f(cf_nemo_moc)
  41. id_nemo = Dataset(cf_nemo_moc)
  42. vz = id_nemo.variables['depthw'][:]
  43. amoc = id_nemo.variables[cv_moc][0,:,:]
  44. id_nemo.close()
  45. [ nk, nj ] = amoc.shape ; print ' Shape of AMOC :', nk, nj, '\n'
  46. # Building a latitude vector:
  47. vlat = nmp.zeros(nj)
  48. ji_lat_mid_atlantic = bt.find_index_from_value( -28., xlon[0,:] )
  49. vlat[:] = xlat[:,ji_lat_mid_atlantic]
  50. # Building the vertical mask:
  51. msk_vert = nmp.zeros((nk,nj))
  52. msk_vert[:,:] = nmp.sum(Xmask[:,:,:],axis=2)
  53. idxm = nmp.where(msk_vert[:,:] > 0.);
  54. msk_vert[idxm] = 1.
  55. bp.plot("vert_section")( vlat[:], -vz[:], amoc[:,:], msk_vert[:,:], -4., 20., 1., \
  56. lkcont=True, cpal='ncview_nrl', lzonal=False, xmin=10., xmax=70., dx=5.,
  57. cfignm='AMOC_annual_'+CONFEXP, cbunit='Sv',
  58. zmin=0., zmax=5000., l_zlog=False, cfig_type=fig_type,
  59. czunit='Depth (m)', ctitle='AMOC, '+CONFEXP+' ('+cy1+'-'+cy2+')' )
  60. print '\n Bye!'