plot_time_series.py 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830
  1. #!/usr/bin/env python
  2. # B a r a K u d a
  3. #
  4. # Generate misc. time-series out of NEMO output files...
  5. #
  6. # L. Brodeau, 2013
  7. #
  8. import sys
  9. import os
  10. import numpy as nmp
  11. from netCDF4 import Dataset
  12. import barakuda_tool as bt
  13. import barakuda_ncio as bn
  14. import barakuda_orca as bo
  15. import barakuda_plot as bp
  16. Socean = 363. ; # Surface of the ocean in 10^6 km^2
  17. Lt_1y = 365.*24.*3600.*1E-6 ; # Length of 1 year in 10^6 seconds (=31.536)
  18. csn = sys.argv[0]
  19. cv_evb = 'evap_ao_cea' ; # debug evap in ec-earth...
  20. DEFAULT_LEGEND_LOC = 'lower left'
  21. venv_needed = {'ORCA','EXP','NN_SST','NN_SSS','NN_SSH','NN_T','NN_S','NN_MLD','LMOCLAT',
  22. 'TRANSPORT_SECTION_FILE','FIG_FORM','BM_FILE'}
  23. vdic = bt.check_env_var(csn, venv_needed)
  24. CONFEXP = vdic['ORCA']+'-'+vdic['EXP']
  25. ff = vdic['FIG_FORM'] ; # format for figures (usually "png" or "svg")
  26. narg = len(sys.argv)
  27. if narg != 2:
  28. print 'Usage: {} <diag>'.format(csn)
  29. sys.exit(0)
  30. cdiag = sys.argv[1]
  31. print '\n '+csn+': diag => "'+cdiag+'"'
  32. if cdiag == 'mean_tos':
  33. cvar = vdic['NN_SST']
  34. idfig = 'simple'
  35. clnm = 'Globally-averaged sea surface temperature'
  36. cyu = r'$^{\circ}$C'
  37. ym = yp = 0.
  38. elif cdiag == 'mean_sos':
  39. cvar = vdic['NN_SSS']
  40. idfig = 'simple'
  41. clnm = 'Globally-averaged sea surface salinity'
  42. cyu = r'PSU'
  43. ym = yp = 0.
  44. elif cdiag == 'mean_fwf':
  45. venv_ndd = {'NN_FWF','NN_EMP','NN_RNF','NN_P','NN_CLV','NN_E'}
  46. vdic_fwf = bt.check_env_var(csn, venv_ndd)
  47. idfig = 'fwf'
  48. cvar = 'EmPmR'
  49. clnm = 'Globally-averaged upward net freshwater flux (E-P-R = '+vdic_fwf['NN_FWF']+')'
  50. cvr2 = 'R'
  51. cln2 = 'Globally-averaged continental runoffs (R = '+vdic_fwf['NN_RNF']+')'
  52. cvr3 = 'EmP'
  53. cln3 = 'Globally-averaged Evaporation - Precipitation (E-P = '+vdic_fwf['NN_EMP']+')'
  54. cvr4 = 'P'
  55. cln4 = 'Globally-averaged Precipitation (P = '+vdic_fwf['NN_P']+')'
  56. cvr5 = 'ICalv'
  57. cln5 = 'Globally-averaged ice calving from icebergs (ICalv = '+vdic_fwf['NN_CLV']+')'
  58. cvr6 = 'E'
  59. cln6 = 'Globally-averaged evaporation (E = '+vdic_fwf['NN_E']+')'
  60. cvr7 = 'Eb'
  61. cln7 = 'Globally-averaged evap. t.i.a sea-ice (E = '+cv_evb+')'
  62. cyu = r'Sv'
  63. ym = yp = 0.
  64. elif cdiag == 'mean_htf':
  65. venv_ndd = {'NN_QNET','NN_QSOL'}
  66. vdic_htf = bt.check_env_var(csn, venv_ndd)
  67. idfig = 'htf'
  68. cvar = 'Qnet'
  69. clnm = 'Globally-averaged net total heat flux to the ocean ('+vdic_htf['NN_QNET']+')'
  70. cvr2 = 'Qsol'
  71. cln2 = 'Globally-averaged net solar heat flux to the ocean ('+vdic_htf['NN_QSOL']+')'
  72. cyu = r'PW'
  73. ym = yp = 0.
  74. elif cdiag == 'mean_zos':
  75. cvar = vdic['NN_SSH']
  76. idfig = 'simple'
  77. clnm = 'Globally-averaged sea surface height'
  78. cyu = r'm'
  79. ym = yp = 0.
  80. elif cdiag == '3d_thetao':
  81. cvar = vdic['NN_T']
  82. idfig = 'ts3d'
  83. clnm = 'Globally-averaged temperature'
  84. cyu = r'$^{\circ}$C'
  85. #ym = 3.6 ; yp = 4.
  86. ym = 0. ; yp = 0.
  87. #ym0 = 1.5 ; yp0 = 20.
  88. ym0 = yp0 = 0.
  89. elif cdiag == '3d_so':
  90. cvar = vdic['NN_S']
  91. idfig = 'ts3d'
  92. clnm = 'Globally-averaged salinity'
  93. cyu = r'PSU'
  94. #ym = 34.6 ; yp = 35.
  95. #ym0 = 34.6 ; yp0 = 35.
  96. ym = yp = 0.
  97. ym0 = yp0 = 0.
  98. elif cdiag == 'amoc':
  99. idfig = 'amoc'
  100. cyu = r'Sv'
  101. ym = 4.5
  102. yp = 25.5
  103. elif cdiag == 'mean_mld':
  104. cvar = vdic['NN_MLD']
  105. idfig = 'mld'
  106. clnm = 'Mean mixed-layer depth, '
  107. cyu = r'm'
  108. ym = yp = 0.
  109. elif cdiag == 'transport_sections':
  110. idfig = 'transport'
  111. print ' Using TRANSPORT_SECTION_FILE = '+vdic['TRANSPORT_SECTION_FILE']
  112. list_sections = bt.get_sections_from_file(vdic['TRANSPORT_SECTION_FILE'])
  113. print 'List of sections to treat: ', list_sections
  114. elif cdiag == 'seaice':
  115. idfig = 'ice'
  116. cyu = r'10$^6$km$^2$'
  117. else:
  118. print 'ERROR: '+csn+' => diagnostic '+cdiag+' unknown!'; sys.exit(0)
  119. #############################################################
  120. # Time series of 2D-averaged 2D fields such as SST, SSS, SSH
  121. #############################################################
  122. if idfig == 'simple':
  123. cf_in = 'mean_'+cvar+'_'+CONFEXP+'_GLO.nc' ; bt.chck4f(cf_in, script_name=csn)
  124. id_in = Dataset(cf_in)
  125. vtime = id_in.variables['time'][:]
  126. vvar = id_in.variables[cvar][:]
  127. id_in.close()
  128. (nby, nbm, nbr, ittic) = bt.test_nb_years(vtime, cdiag)
  129. # Annual data
  130. VY, FY = bt.monthly_2_annual(vtime[:], vvar[:])
  131. # Time to plot
  132. bp.plot("1d_mon_ann")(vtime, VY, vvar, FY, cfignm=cdiag+'_'+CONFEXP, dt=ittic,
  133. cyunit=cyu, ctitle = CONFEXP+': '+clnm, ymin=ym, ymax=yp, cfig_type=ff)
  134. if cvar == vdic['NN_SSH']:
  135. clnm = 'Global freshwater imbalance based on annual SSH drift'
  136. Fimb = nmp.zeros(nby)
  137. for jy in range(1,nby):
  138. Fimb[jy] = (FY[jy] - FY[jy-1])*Socean/Lt_1y
  139. Fimb[0] = nmp.nan
  140. bp.plot("1d_mon_ann")(VY, VY, Fimb, Fimb, cfignm=cdiag+'-imb_'+CONFEXP, dt=ittic,
  141. cyunit='Sv', ctitle = CONFEXP+': '+clnm,
  142. ymin=-0.8, ymax=0.8, dy=0.1, cfig_type=ff, y_cst_to_add=0.)
  143. ############################################################
  144. # Time series of 3D-averaged 3D fields such as SST, SSS, SSH
  145. ############################################################
  146. if idfig == 'ts3d':
  147. vzrange = [ '0-bottom', '0-100' , '100-1000', '1000-bottom' ] ; nbzrange = len(vzrange)
  148. vlab = [ 'AllDepth', '0m-100m', '100m-1000m', '1000m-bottom' ]
  149. list_basin_names, list_basin_lgnms = bo.get_basin_info(vdic['BM_FILE'])
  150. nb_oce = len(list_basin_names)
  151. joce = 0
  152. for coce in list_basin_names[:]:
  153. cf_in = '3d_'+cvar+'_'+CONFEXP+'_'+coce+'.nc' ; bt.chck4f(cf_in, script_name=csn)
  154. id_in = Dataset(cf_in)
  155. vtime = id_in.variables['time'][:]
  156. if joce == 0: (nby, nbm, nbr, ittic) = bt.test_nb_years(vtime, cdiag)
  157. jz = 0
  158. for czr in vzrange:
  159. if not joce and not jz:
  160. FM = nmp.zeros((nb_oce, nbzrange, nbr))
  161. print ' * reading '+cvar+'_'+czr+' in '+cf_in
  162. FM[joce,jz,:] = id_in.variables[cvar+'_'+czr][:]
  163. jz = jz + 1
  164. id_in.close()
  165. # Annual data (if makes sence):
  166. if joce == 0:
  167. VY = nmp.zeros(nby)
  168. FY = nmp.zeros((nb_oce, 4, nby))
  169. if nbm >= 12:
  170. # the file contains monthly data (nbm=-1 otherwize)
  171. VY[:], FY[joce,:,:] = bt.monthly_2_annual(vtime[:], FM[joce,:,:])
  172. else:
  173. # the file contains annual data
  174. VY[:] = vtime[:]
  175. FY[joce,:,:] = FM[joce,:,:]
  176. print ' *** '+list_basin_lgnms[joce]+' done...\n'
  177. joce = joce + 1
  178. # One plot only for global:
  179. bp.plot("1d_mon_ann")(vtime, VY, FM[0,0,:], FY[0,0,:], cfignm=cdiag+'_'+CONFEXP, dt=ittic,
  180. cyunit=cyu, ctitle = CONFEXP+': '+clnm, ymin=ym, ymax=yp, cfig_type=ff)
  181. # Global for different depth:
  182. bp.plot("1d_multi")(vtime, FM[0,:,:], vlab[:], cfignm=cdiag+'_lev_'+CONFEXP, dt=ittic,
  183. loc_legend='out', cyunit=cyu, ctitle = CONFEXP+': '+clnm, ymin=ym0, ymax=yp0, cfig_type=ff)
  184. # Show each ocean (All depth):
  185. bp.plot("1d_multi")(vtime, FM[:,0,:], list_basin_lgnms, cfignm=cdiag+'_basins_'+CONFEXP, dt=ittic,
  186. loc_legend='out', cyunit=cyu, ctitle = CONFEXP+': '+clnm, ymin=ym0, ymax=yp0, cfig_type=ff)
  187. #############################################################
  188. # Time series of 2D-average of surface heat flux components
  189. # - might include IFS (atmosphere) fields when EC-Earth
  190. #############################################################
  191. if idfig == 'htf':
  192. l_qsr = False
  193. cf_in = cdiag+'_'+CONFEXP+'_GLO.nc' ; bt.chck4f(cf_in, script_name=csn)
  194. id_in = Dataset(cf_in)
  195. list_var = id_in.variables.keys()
  196. vtime = id_in.variables['time'][:]
  197. vqnt = id_in.variables[cvar][:]
  198. if cvr2 in list_var[:]:
  199. l_qsr = True
  200. vqsr = id_in.variables[cvr2][:]
  201. id_in.close()
  202. (nby, nbm, nbr, ittic) = bt.test_nb_years(vtime, cdiag)
  203. # Checking if there a potential file for IFS:
  204. l_htf_ifs = False
  205. cf_IFS_in = cdiag+'_IFS_'+vdic['EXP']+'_GLO.nc'
  206. print ' *** Checking for the existence of '+cf_IFS_in
  207. if os.path.exists(cf_IFS_in):
  208. print " *** IFS HTF files found!"
  209. id_IFS_in = Dataset(cf_IFS_in)
  210. vqnt_ifs = id_IFS_in.variables['flx_qnet_pw'][:]
  211. vqsr_ifs = id_IFS_in.variables['flx_ssr_pw'][:]
  212. id_IFS_in.close()
  213. if len(vqnt_ifs) != nbm:
  214. print 'ERROR: '+csn+' => length of E-P of IFS in '+cf_IFS_in+' does not agree with its NEMO counterpart!'
  215. print ' =>', len(vqnt_ifs), nbm
  216. sys.exit(0)
  217. l_htf_ifs = True
  218. else:
  219. print ' => Nope!\n'
  220. # Annual data
  221. VY, FY = bt.monthly_2_annual(vtime, vqnt)
  222. # Time to plot
  223. bp.plot("1d_mon_ann")(vtime, VY, vqnt, FY, cfignm=cdiag+'_qnt_'+CONFEXP, dt=ittic,
  224. cyunit=cyu, ctitle = CONFEXP+': '+clnm, ymin=ym, ymax=yp, cfig_type=ff)
  225. if l_qsr:
  226. VY, FY = bt.monthly_2_annual(vtime, vqsr)
  227. bp.plot("1d_mon_ann")(vtime, VY, vqsr, FY, cfignm=cdiag+'_qsr_'+CONFEXP, dt=ittic,
  228. cyunit=cyu, ctitle = CONFEXP+': '+cln2, ymin=ym, ymax=yp, cfig_type=ff)
  229. # Only Qnet (NEMO and IFS)
  230. if l_htf_ifs:
  231. vlab = [] ; nbd = 2
  232. Xplt = nmp.zeros((nbd,nbm))
  233. Xplt[0,:] = vqnt[:] ; vlab.append('Qnet NEMO ('+vdic_htf['NN_QNET']+')')
  234. Xplt[1,:] = vqnt_ifs[:] ; vlab.append('Qnet IFS (SSR+STR+SLHF+SSHF')
  235. bp.plot("1d_multi")(vtime, Xplt, vlab, cfignm=cdiag+'_qnt_NEMO_IFS_'+CONFEXP, dt=ittic,
  236. cyunit=cyu, ctitle = 'NEMO & IFS, '+CONFEXP+': Surface net heat flux (monthly)',
  237. ymin=ym, ymax=yp, cfig_type=ff, loc_legend='out')
  238. # Same but annual:
  239. Xplt = nmp.zeros((nbd,nby))
  240. VY, Xplt[0,:] = bt.monthly_2_annual(vtime[:], vqnt[:])
  241. VY, Xplt[1,:] = bt.monthly_2_annual(vtime[:], vqnt_ifs[:])
  242. bp.plot("1d_multi")(VY, Xplt, vlab, cfignm=cdiag+'_qnt_NEMO_IFS_annual_'+CONFEXP, dt=ittic,
  243. cyunit=cyu, ctitle = 'NEMO & IFS, '+CONFEXP+': Surface net heat flux (annual)',
  244. ymin=ym, ymax=yp, cfig_type=ff, loc_legend='out',
  245. cinfo='Mean diff = '+str(round(nmp.mean(vqnt[:]-vqnt_ifs[:]),3))+' '+cyu )
  246. # Only Qnon-solar (NEMO and IFS)
  247. if l_htf_ifs and l_qsr:
  248. vlab = [] ; nbd = 2
  249. Xplt = nmp.zeros((nbd,nbm))
  250. Xplt[0,:] = vqnt[:] - vqsr[:] ; vlab.append('Qnsol NEMO ('+vdic_htf['NN_QNET']+'-'+vdic_htf['NN_QSOL']+')')
  251. Xplt[1,:] = vqnt_ifs[:] - vqsr_ifs[:] ; vlab.append('Qnsol IFS (STR+SLHF+SSHF)')
  252. bp.plot("1d_multi")(vtime, Xplt, vlab, cfignm=cdiag+'_qns_NEMO_IFS_'+CONFEXP, dt=ittic,
  253. cyunit=cyu, ctitle = 'NEMO & IFS, '+CONFEXP+': Surface net NON-solar flux (monthly)',
  254. ymin=ym, ymax=yp, cfig_type=ff, loc_legend='out')
  255. # Same but annual:
  256. Xplt = nmp.zeros((nbd,nby))
  257. VY, Xplt[0,:] = bt.monthly_2_annual(vtime[:], vqnt[:] - vqsr[:])
  258. VY, Xplt[1,:] = bt.monthly_2_annual(vtime[:], vqnt_ifs[:] - vqsr_ifs[:])
  259. bp.plot("1d_multi")(VY, Xplt, vlab, cfignm=cdiag+'_qns_NEMO_IFS_annual_'+CONFEXP, dt=ittic,
  260. cyunit=cyu, ctitle = 'NEMO & IFS, '+CONFEXP+': Surface net NON-solar flux (annual)',
  261. ymin=ym, ymax=yp, cfig_type=ff, loc_legend='out',
  262. cinfo='Mean diff = '+str(round(nmp.mean(vqnt[:]-vqsr[:] - (vqnt_ifs[:]-vqsr_ifs[:])),3))+' '+cyu )
  263. # Only Qsol (NEMO and IFS)
  264. if l_htf_ifs and l_qsr:
  265. vlab = [] ; nbd = 2
  266. Xplt = nmp.zeros((nbd,nbm))
  267. Xplt[0,:] = vqsr[:] ; vlab.append('Qsol NEMO ('+vdic_htf['NN_QSOL']+')')
  268. Xplt[1,:] = vqsr_ifs[:] ; vlab.append('Qsol IFS (SSR)')
  269. bp.plot("1d_multi")(vtime, Xplt, vlab, cfignm=cdiag+'_qsr_NEMO_IFS_'+CONFEXP, dt=ittic,
  270. cyunit=cyu, ctitle = 'NEMO & IFS, '+CONFEXP+': Surface net solar flux (monthly)',
  271. ymin=ym, ymax=yp, cfig_type=ff, loc_legend='out')
  272. # Same but annual:
  273. Xplt = nmp.zeros((nbd,nby))
  274. VY, Xplt[0,:] = bt.monthly_2_annual(vtime[:], vqsr[:])
  275. VY, Xplt[1,:] = bt.monthly_2_annual(vtime[:], vqsr_ifs[:])
  276. bp.plot("1d_multi")(VY, Xplt, vlab, cfignm=cdiag+'_qsr_NEMO_IFS_annual_'+CONFEXP, dt=ittic,
  277. cyunit=cyu, ctitle = 'NEMO & IFS, '+CONFEXP+': Surface net solar flux (annual)',
  278. ymin=ym, ymax=yp, cfig_type=ff, loc_legend='out',
  279. cinfo='Mean diff = '+str(round(nmp.mean(vqsr[:]-vqsr_ifs[:]),3))+' '+cyu )
  280. ###################################################################
  281. # Time series of 2D-average of surface freshwater flux components
  282. # - might include IFS (atmosphere) fields when EC-Earth
  283. ###################################################################
  284. if idfig == 'fwf':
  285. l_rnf = False ; l_emp = False ; l_prc = False ; l_clv = False ; l_evp = False ; l_evb = False
  286. cf_in = cdiag+'_'+CONFEXP+'_GLO.nc' ; bt.chck4f(cf_in, script_name=csn)
  287. id_in = Dataset(cf_in)
  288. list_var = id_in.variables.keys()
  289. vtime = id_in.variables['time'][:]
  290. vfwf = id_in.variables[cvar][:]
  291. if cvr2 in list_var[:]:
  292. l_rnf = True
  293. vrnf = id_in.variables[cvr2][:]
  294. if cvr3 in list_var[:]:
  295. l_emp = True
  296. vemp = id_in.variables[cvr3][:]
  297. if cvr4 in list_var[:]:
  298. # There is sometimes Precip in NEMO output which only has NaN! lolo
  299. l_prc = True ; l_prc_nemo_valid = True
  300. vprc = id_in.variables[cvr4][:]
  301. if nmp.isnan(vprc[0]): l_prc_nemo_valid = False
  302. if cvr5 in list_var[:]:
  303. l_clv = True
  304. vclv = id_in.variables[cvr5][:]
  305. if cvr6 in list_var[:]:
  306. l_evp = True
  307. vevp = id_in.variables[cvr6][:]
  308. if cvr7 in list_var[:]:
  309. l_evb = True
  310. vevb = id_in.variables[cvr7][:]
  311. id_in.close()
  312. (nby, nbm, nbr, ittic) = bt.test_nb_years(vtime, cdiag)
  313. # Checking if there a potential file for IFS:
  314. l_fwf_ifs = False
  315. cf_IFS_in = cdiag+'_IFS_'+vdic['EXP']+'_GLO.nc'
  316. print ' *** Checking for the existence of '+cf_IFS_in
  317. if os.path.exists(cf_IFS_in):
  318. print " *** IFS FWF files found!"
  319. id_IFS_in = Dataset(cf_IFS_in)
  320. vemp_ifs = id_IFS_in.variables['flx_emp_sv'][:]
  321. ve_ifs = id_IFS_in.variables['flx_e_sv'][:]
  322. vp_ifs = id_IFS_in.variables['flx_p_sv'][:]
  323. vemp_glb_ifs = id_IFS_in.variables['flx_emp_glb_sv'][:]
  324. #ve_glb_ifs = id_IFS_in.variables['flx_e_glb_sv'][:]
  325. #vp_glb_ifs = id_IFS_in.variables['flx_p_glb_sv'][:]
  326. vemp_land_ifs = id_IFS_in.variables['flx_emp_land_sv'][:]
  327. ve_land_ifs = id_IFS_in.variables['flx_e_land_sv'][:]
  328. vp_land_ifs = id_IFS_in.variables['flx_p_land_sv'][:]
  329. id_IFS_in.close()
  330. if len(vemp_ifs) != nbm:
  331. print 'ERROR: '+csn+' => length of E-P of IFS in '+cf_IFS_in+' does not agree with its NEMO counterpart!'
  332. print ' =>', len(vemp_ifs), nbm
  333. sys.exit(0)
  334. l_fwf_ifs = True
  335. else:
  336. print ' => Nope!\n'
  337. # Annual data
  338. VY, FY = bt.monthly_2_annual(vtime, vfwf)
  339. # Time to plot
  340. bp.plot("1d_mon_ann")(vtime, VY, vfwf, FY, cfignm=cdiag+'_fwf_'+CONFEXP, dt=ittic,
  341. cyunit=cyu, ctitle = CONFEXP+': '+clnm, ymin=ym, ymax=yp, cfig_type=ff)
  342. if l_rnf:
  343. VY, FY = bt.monthly_2_annual(vtime, vrnf)
  344. bp.plot("1d_mon_ann")(vtime, VY, vrnf, FY, cfignm=cdiag+'_rnf_'+CONFEXP, dt=ittic,
  345. cyunit=cyu, ctitle = CONFEXP+': '+cln2, ymin=ym, ymax=yp, cfig_type=ff)
  346. if l_emp:
  347. VY, FY = bt.monthly_2_annual(vtime, vemp)
  348. bp.plot("1d_mon_ann")(vtime, VY, vemp, FY, cfignm=cdiag+'_emp_'+CONFEXP, dt=ittic,
  349. cyunit=cyu, ctitle = CONFEXP+': '+cln3, ymin=ym, ymax=yp, cfig_type=ff)
  350. if l_evp:
  351. VY, FY = bt.monthly_2_annual(vtime, vevp)
  352. bp.plot("1d_mon_ann")(vtime, VY, vevp, FY, cfignm=cdiag+'_evp_'+CONFEXP, dt=ittic,
  353. cyunit=cyu, ctitle = CONFEXP+': '+cln6, ymin=ym, ymax=yp, cfig_type=ff)
  354. if l_prc and l_prc_nemo_valid:
  355. VY, FY = bt.monthly_2_annual(vtime, vprc)
  356. bp.plot("1d_mon_ann")(vtime, VY, vprc, FY, cfignm=cdiag+'_prc_'+CONFEXP, dt=ittic,
  357. cyunit=cyu, ctitle = CONFEXP+': '+cln4, ymin=ym, ymax=yp, cfig_type=ff)
  358. if l_evp and l_prc and l_prc_nemo_valid:
  359. VY, FY = bt.monthly_2_annual(vtime, vevp-vprc)
  360. bp.plot("1d_mon_ann")(vtime, VY, vevp-vprc, FY, cfignm=cdiag+'_prc_'+CONFEXP, dt=ittic,
  361. cyunit=cyu, ctitle = CONFEXP+': E-P as E-P !', ymin=ym, ymax=yp, cfig_type=ff)
  362. if l_clv:
  363. VY, FY = bt.monthly_2_annual(vtime, vclv)
  364. bp.plot("1d_mon_ann")(vtime, VY, vclv, FY, cfignm=cdiag+'_clv_'+CONFEXP, dt=ittic,
  365. cyunit=cyu, ctitle = CONFEXP+': '+cln5, ymin=ym, ymax=yp, cfig_type=ff)
  366. # Only runoffs (-(E-P) over land for IFS):
  367. if l_fwf_ifs and l_rnf:
  368. vlab = [] ; nbd = 2
  369. if l_clv: nbd = 3
  370. Xplt = nmp.zeros((nbd,nbm))
  371. Xplt[0,:] = vrnf[:] ; vlab.append('R NEMO')
  372. Xplt[1,:] = -vemp_land_ifs[:] ; vlab.append('-(E-P) over land IFS')
  373. if l_clv: Xplt[2,:] = vrnf[:] + vclv[:] ; vlab.append('R + Ice Calving NEMO')
  374. bp.plot("1d_multi")(vtime, Xplt, vlab, cfignm=cdiag+'_rnf_NEMO_IFS_'+CONFEXP, dt=ittic,
  375. cyunit=cyu, ctitle = 'NEMO & IFS, '+CONFEXP+': Continental runoffs (monthly)',
  376. ymin=ym, ymax=yp, cfig_type=ff, loc_legend='out')
  377. # Same but annual:
  378. Xplt = nmp.zeros((nbd,nby))
  379. VY, Xplt[0,:] = bt.monthly_2_annual(vtime[:], vrnf[:])
  380. VY, Xplt[1,:] = bt.monthly_2_annual(vtime[:], -vemp_land_ifs[:])
  381. if l_clv: VY, Xplt[2,:] = bt.monthly_2_annual(vtime[:], vrnf[:] + vclv[:])
  382. bp.plot("1d_multi")(VY, Xplt, vlab, cfignm=cdiag+'_rnf_NEMO_IFS_annual_'+CONFEXP, dt=ittic,
  383. cyunit=cyu, ctitle = 'NEMO & IFS, '+CONFEXP+': Continental runoffs (annual)',
  384. ymin=ym, ymax=yp, cfig_type=ff, loc_legend='out',
  385. cinfo='Mean diff = '+str(round(nmp.mean(vrnf[:]+vemp_land_ifs[:]),3))+' '+cyu )
  386. # Only runoff and calving in NEMO:
  387. if l_clv and l_rnf:
  388. vlab = [] ; nbd = 2
  389. Xplt = nmp.zeros((nbd,nbm))
  390. cttl = 'NEMO: '+CONFEXP+': Continental Runoffs and Ice Calving'
  391. cfig = cdiag+'_rnf_clv_NEMO_'
  392. Xplt[0,:] = vrnf[:] ; vlab.append('R NEMO ('+vdic_fwf['NN_RNF']+')')
  393. Xplt[1,:] = vclv[:] ; vlab.append('Ice Calving NEMO ('+vdic_fwf['NN_CLV']+')')
  394. bp.plot("1d_multi")(vtime, Xplt, vlab, cfignm=cfig+CONFEXP, dt=ittic,
  395. cyunit=cyu, ctitle = cttl+' (monthly)',
  396. ymin=ym, ymax=yp, cfig_type=ff, loc_legend='out')
  397. # Same but annual:
  398. Xplt = nmp.zeros((nbd,nby))
  399. VY, Xplt[0,:] = bt.monthly_2_annual(vtime[:], vrnf[:])
  400. VY, Xplt[1,:] = bt.monthly_2_annual(vtime[:], vclv[:])
  401. bp.plot("1d_multi")(VY, Xplt, vlab, cfignm=cfig+'annual_'+CONFEXP, dt=ittic,
  402. cyunit=cyu, ctitle = cttl+' (annual)',
  403. ymin=ym, ymax=yp, cfig_type=ff, loc_legend='out')
  404. # Only Precip (NEMO and IFS)
  405. if l_fwf_ifs and l_prc and l_prc_nemo_valid:
  406. vlab = [] ; nbd = 2
  407. Xplt = nmp.zeros((nbd,nbm))
  408. Xplt[0,:] = vprc[:] ; vlab.append('P NEMO')
  409. Xplt[1,:] = vp_ifs[:] ; vlab.append('P IFS')
  410. bp.plot("1d_multi")(vtime, Xplt, vlab, cfignm=cdiag+'_prc_NEMO_IFS_'+CONFEXP, dt=ittic,
  411. cyunit=cyu, ctitle = 'NEMO & IFS, '+CONFEXP+': Precip (monthly)',
  412. ymin=ym, ymax=yp, cfig_type=ff, loc_legend='out')
  413. # Same but annual:
  414. Xplt = nmp.zeros((nbd,nby))
  415. VY, Xplt[0,:] = bt.monthly_2_annual(vtime[:], vprc[:])
  416. VY, Xplt[1,:] = bt.monthly_2_annual(vtime[:], vp_ifs[:])
  417. bp.plot("1d_multi")(VY, Xplt, vlab, cfignm=cdiag+'_prc_NEMO_IFS_annual_'+CONFEXP, dt=ittic,
  418. cyunit=cyu, ctitle = 'NEMO & IFS, '+CONFEXP+': Precip (annual)',
  419. ymin=ym, ymax=yp, cfig_type=ff, loc_legend='out',
  420. cinfo='Mean diff = '+str(round(nmp.mean(vprc[:]-vp_ifs[:]),3))+' '+cyu )
  421. # Only Evaporation (NEMO and IFS)
  422. if l_fwf_ifs and l_evp:
  423. vlab = [] ; nbd = 2
  424. if l_evb : nbd = 3
  425. Xplt = nmp.zeros((nbd,nbm))
  426. Xplt[0,:] = vevp[:] ; vlab.append('E NEMO ('+vdic_fwf['NN_E']+')')
  427. Xplt[1,:] = ve_ifs[:] ; vlab.append('E IFS')
  428. if l_evb: Xplt[2,:] = vevb[:] ; vlab.append('E NEMO ('+cv_evb+')')
  429. bp.plot("1d_multi")(vtime, Xplt, vlab, cfignm=cdiag+'_evp_NEMO_IFS_'+CONFEXP, dt=ittic,
  430. cyunit=cyu, ctitle = 'NEMO & IFS, '+CONFEXP+': Evaporation (monthly)',
  431. ymin=ym, ymax=yp, cfig_type=ff, loc_legend='out')
  432. # Same but annual:
  433. Xplt = nmp.zeros((nbd,nby))
  434. VY, Xplt[0,:] = bt.monthly_2_annual(vtime[:], vevp[:])
  435. VY, Xplt[1,:] = bt.monthly_2_annual(vtime[:], ve_ifs[:])
  436. if l_evb: Xplt[2,:] = bt.monthly_2_annual(vtime[:], vevb[:])
  437. bp.plot("1d_multi")(VY, Xplt, vlab, cfignm=cdiag+'_evp_NEMO_IFS_annual_'+CONFEXP, dt=ittic,
  438. cyunit=cyu, ctitle = 'NEMO & IFS, '+CONFEXP+': Evaporation (annual)',
  439. ymin=ym, ymax=yp, cfig_type=ff, loc_legend='out',
  440. cinfo='Mean diff = '+str(round(nmp.mean(vevp[:]-ve_ifs[:]),3))+' '+cyu )
  441. # Only [ Evaporation - Precipitation ] (NEMO and IFS)
  442. if l_fwf_ifs and l_evp and l_prc and l_prc_nemo_valid:
  443. vlab = [] ; nbd = 2
  444. Xplt = nmp.zeros((nbd,nbm))
  445. Xplt[0,:] = vevp[:] - vprc[:] ; vlab.append('E-P NEMO')
  446. Xplt[1,:] = ve_ifs[:] - vp_ifs[:] ; vlab.append('E-P IFS')
  447. bp.plot("1d_multi")(vtime, Xplt, vlab, cfignm=cdiag+'_EmP_NEMO_IFS_'+CONFEXP, dt=ittic,
  448. cyunit=cyu, ctitle = 'NEMO & IFS, '+CONFEXP+': E-P (monthly)',
  449. ymin=ym, ymax=yp, cfig_type=ff, loc_legend='out')
  450. # Same but annual:
  451. Xplt = nmp.zeros((nbd,nby))
  452. VY, Xplt[0,:] = bt.monthly_2_annual(vtime[:], vevp[:] - vprc[:])
  453. VY, Xplt[1,:] = bt.monthly_2_annual(vtime[:], ve_ifs[:] - vp_ifs[:])
  454. bp.plot("1d_multi")(VY, Xplt, vlab, cfignm=cdiag+'_EmP_NEMO_IFS_annual_'+CONFEXP, dt=ittic,
  455. cyunit=cyu, ctitle = 'NEMO & IFS, '+CONFEXP+': E-P (annual)',
  456. ymin=ym, ymax=yp, cfig_type=ff, loc_legend='out',
  457. cinfo='Mean diff = '+str(round(nmp.mean((vevp[:]-vprc[:])-(ve_ifs[:]-vp_ifs[:])),3))+' '+cyu )
  458. # Only [ Evaporation - Precipitation - Runoffs ] (NEMO and IFS)
  459. if l_fwf_ifs and l_evp and l_prc and l_prc_nemo_valid and l_rnf:
  460. vlab = [] ; nbd = 3
  461. if l_clv: nbd = 4
  462. Xplt = nmp.zeros((nbd,nbm))
  463. Xplt[0,:] = vevp[:] - vprc[:] - vrnf[:] ; vlab.append('E-P-R NEMO (as E-P-R)')
  464. Xplt[1,:] = ve_ifs[:] - vp_ifs[:] + vemp_land_ifs[:] ; vlab.append('E-P-R IFS')
  465. Xplt[2,:] = vfwf[:] ; vlab.append('NEMO: '+vdic_fwf['NN_FWF'])
  466. if l_clv: Xplt[3,:] = vfwf[:] + vclv[:] ; vlab.append('NEMO: '+vdic_fwf['NN_FWF']+'+'+vdic_fwf['NN_CLV'])
  467. bp.plot("1d_multi")(vtime, Xplt, vlab, cfignm=cdiag+'_EmPmR_NEMO_IFS_'+CONFEXP, dt=ittic,
  468. cyunit=cyu, ctitle = 'NEMO & IFS, '+CONFEXP+': E-P-R (monthly)',
  469. ymin=ym, ymax=yp, cfig_type=ff, loc_legend='out')
  470. # Same but annual:
  471. Xplt = nmp.zeros((nbd,nby))
  472. VY, Xplt[0,:] = bt.monthly_2_annual(vtime[:], vevp[:] - vprc[:] - vrnf[:])
  473. VY, Xplt[1,:] = bt.monthly_2_annual(vtime[:], ve_ifs[:] - vp_ifs[:] + vemp_land_ifs[:])
  474. VY, Xplt[2,:] = bt.monthly_2_annual(vtime[:], vfwf[:])
  475. if l_clv: Vy, Xplt[3,:] = bt.monthly_2_annual(vtime[:], vfwf[:] + vclv[:])
  476. bp.plot("1d_multi")(VY, Xplt, vlab, cfignm=cdiag+'_EmPmR_NEMO_IFS_annual_'+CONFEXP, dt=ittic,
  477. cyunit=cyu, ctitle = 'NEMO & IFS, '+CONFEXP+': E-P-R (annual)',
  478. ymin=ym, ymax=yp, cfig_type=ff, loc_legend='out',
  479. cinfo='Mean diff = '+str(round(nmp.mean((vevp[:]-vprc[:]-vrnf[:])-(ve_ifs[:]-vp_ifs[:]+vemp_land_ifs[:])),3))+' '+cyu )
  480. # Only P for NEMO and IFS, and RNF NEMO:
  481. if l_fwf_ifs and l_prc:
  482. vlab = [] ; nbd = 3
  483. if l_rnf: nbd = 4
  484. if l_rnf and l_clv: nbd = 5
  485. Xplt = nmp.zeros((nbd,nbm))
  486. if not l_prc_nemo_valid:
  487. print 'WARNING: NEMO precip is NOTHING!!! Filling with 0! ('+csn+')'
  488. Xplt[0,:] = 0.0 ; vlab.append('P NEMO: MISSING in NEMO output file!')
  489. else:
  490. Xplt[0,:] = vprc[:] ; vlab.append('P NEMO')
  491. Xplt[1,:] = vp_ifs[:] ; vlab.append('P IFS (oceans)')
  492. Xplt[2,:] = vp_land_ifs[:] ; vlab.append('P IFS (land)')
  493. if l_rnf:
  494. Xplt[3,:] = vrnf[:] ; vlab.append('R NEMO')
  495. if l_rnf and l_clv:
  496. Xplt[4,:] = vclv[:] ; vlab.append('Calving NEMO')
  497. bp.plot("1d_multi")(vtime, Xplt, vlab, cfignm=cdiag+'_prc_IFS_'+CONFEXP, dt=ittic,
  498. cyunit=cyu, ctitle = CONFEXP+': Precip and NEMO runoffs (monthly)', ymin=ym, ymax=yp, cfig_type=ff,
  499. loc_legend='out')
  500. ##########################################
  501. # AMOC
  502. ##########################################
  503. if idfig == 'amoc':
  504. clmoc = vdic['LMOCLAT']
  505. list_lat = clmoc.split() ; nblat = len(list_lat)
  506. print '\n AMOC: '+str(nblat)+' latitude bands!'
  507. i40 = 2 ; # position of AMOC at 40!
  508. jl = 0
  509. for clr in list_lat:
  510. [ c1, c2 ] = clr.split('-') ; clat_info = '+'+c1+'N+'+c2+'N'
  511. cf_in = 'max_moc_atl_'+clat_info+'.nc' ; bt.chck4f(cf_in, script_name=csn)
  512. id_in = Dataset(cf_in)
  513. if jl==0:
  514. vtime = id_in.variables['time'][:]
  515. (nby, nbm, nbr, ittic) = bt.test_nb_years(vtime, cdiag)
  516. vlabels = nmp.zeros(nblat, dtype = nmp.dtype('a8'))
  517. Xamoc = nmp.zeros((nblat , nbr))
  518. vlabels[jl] = clat_info
  519. Xamoc[jl,:] = id_in.variables['moc_atl'][:]
  520. id_in.close()
  521. jl = jl + 1
  522. # Plot annual+montly for AMOC at 40
  523. VY = nmp.zeros(nby)
  524. FY = nmp.zeros(nby)
  525. if nbm >= 12:
  526. VY[:], FY[:] = bt.monthly_2_annual(vtime, Xamoc[i40,:])
  527. else:
  528. # the file contains annual data
  529. VY[:] = vtime[:]
  530. FY[:] = Xamoc[i40,:]
  531. # Time to plot
  532. bp.plot("1d_mon_ann")(vtime, VY, Xamoc[i40,:], FY, cfignm=cdiag+'_'+CONFEXP, dt=ittic,
  533. cyunit=cyu, ctitle = CONFEXP+': '+r'Max. of AMOC between '+vlabels[i40],
  534. ymin=ym, ymax=yp, dy=1., i_y_jump=2, cfig_type=ff, y_cst_to_add=10.)
  535. # Plot annual for AMOC at specified latitudes:
  536. FY = nmp.zeros((nblat , nby))
  537. if nbm >= 12:
  538. # the file contains monthly data (nbm=-1 otherwize)
  539. VY[:], FY[:,:] = bt.monthly_2_annual(vtime, Xamoc[:,:])
  540. else:
  541. # the file contains annual data
  542. FY[:,:] = Xamoc[:,:]
  543. bp.plot("1d_multi")(VY, FY, vlabels, cfignm=cdiag+'_'+CONFEXP+'_comp', dt=ittic,
  544. cyunit=cyu, ctitle = CONFEXP+': '+r'Max. of AMOC', ymin=0, ymax=0,
  545. loc_legend='out', cfig_type=ff)
  546. if idfig == 'ice':
  547. vlab_sum = [ 'Arctic (Sept.)' , 'Antarctic (March)' ]
  548. vlab_win = [ 'Arctic (March)' , 'Antarctic (Sept.)' ]
  549. # montly sea-ice volume and area, Arctic and Antarctic...
  550. cf_in = 'seaice_diags.nc' ; bt.chck4f(cf_in, script_name=csn)
  551. id_in = Dataset(cf_in)
  552. vtime = id_in.variables['time'][:]
  553. vvolu_n = id_in.variables['volu_ne'][:]
  554. varea_n = id_in.variables['area_ne'][:]
  555. vvolu_s = id_in.variables['volu_se'][:]
  556. varea_s = id_in.variables['area_se'][:]
  557. id_in.close()
  558. (nby, nbm, nbr, ittic) = bt.test_nb_years(vtime, cdiag)
  559. cyua = r'10$^6$km$^2$'
  560. cyuv = r'10$^3$km$^3$'
  561. vtime_y = nmp.zeros(nby)
  562. Xplt = nmp.zeros((2 , nby))
  563. vtime_y, FY = bt.monthly_2_annual(vtime[:], vvolu_n[:])
  564. # End local summer
  565. Xplt[0,:] = varea_n[8::12] ; # area Arctic september
  566. Xplt[1,:] = varea_s[2::12] ; # area Antarctic march
  567. bp.plot("1d_multi")(vtime_y, Xplt, vlab_sum, cfignm='seaice_area_summer_'+CONFEXP, dt=ittic,
  568. cyunit=cyua, ctitle = CONFEXP+': '+r'Sea-ice area, end of local summer',
  569. loc_legend='out', ymin=0., ymax=0., cfig_type=ff)
  570. Xplt[0,:] = vvolu_n[8::12] ; # volume Arctic september
  571. Xplt[1,:] = vvolu_s[2::12] ; # volume Antarctic march
  572. bp.plot("1d_multi")(vtime_y, Xplt, vlab_sum, cfignm='seaice_volume_summer_'+CONFEXP, dt=ittic,
  573. cyunit=cyuv, ctitle = CONFEXP+': '+r'Sea-ice volume, end of local summer',
  574. loc_legend='out', ymin=0., ymax=0., cfig_type=ff)
  575. # End of local winter
  576. Xplt[0,:] = varea_n[2::12] ; # area Arctic march
  577. Xplt[1,:] = varea_s[8::12] ; # area Antarctic september
  578. bp.plot("1d_multi")(vtime_y, Xplt, vlab_win, cfignm='seaice_area_winter_'+CONFEXP, dt=ittic,
  579. cyunit=cyua, ctitle = CONFEXP+': '+r'Sea-ice area, end of local winter',
  580. loc_legend='out', ymin=0., ymax=0., cfig_type=ff)
  581. Xplt[0,:] = vvolu_n[2::12] ; # volume Arctic march
  582. Xplt[1,:] = vvolu_s[8::12] ; # volume Antarctic september
  583. bp.plot("1d_multi")(vtime_y, Xplt, vlab_win, cfignm='seaice_volume_winter_'+CONFEXP, dt=ittic,
  584. cyunit=cyuv, ctitle = CONFEXP+': '+r'Sea-ice volume, end of local winter',
  585. loc_legend='out', ymin=0., ymax=0., cfig_type=ff)
  586. if idfig == 'transport':
  587. js = 0
  588. for csec in list_sections:
  589. print '\n * treating section '+csec
  590. cf_in = 'transport_sect_'+csec+'.nc' ; bt.chck4f(cf_in, script_name=csn)
  591. nbtrsp = 4
  592. # Checking if the same section was done for sea-ice transport:
  593. cf_ice = 'transport_ice_sect_'+csec+'.nc'
  594. l_add_ice = os.path.exists(cf_ice)
  595. if l_add_ice: nbtrsp = nbtrsp+1
  596. # Reading ocean transports:
  597. id_in = Dataset(cf_in)
  598. if js == 0:
  599. vtime = id_in.variables['time'][:]
  600. (nby, nbm, nbr, ittic) = bt.test_nb_years(vtime, cdiag)
  601. Xtrsp = nmp.zeros((nbtrsp , nbr)) ; # time + nbtrsp types of transport
  602. Xtrsp[0,:] = id_in.variables['trsp_volu'][:]
  603. Xtrsp[1,:] = id_in.variables['trsp_heat'][:]
  604. Xtrsp[2,:] = id_in.variables['trsp_salt'][:]
  605. Xtrsp[3,:] = id_in.variables['trsp_frwt'][:]
  606. cref_temp = id_in.variables['trsp_heat'].Tref
  607. cref_sali = id_in.variables['trsp_salt'].Sref
  608. id_in.close()
  609. # Reading ice transport:
  610. if l_add_ice:
  611. id_ice = Dataset(cf_ice)
  612. vtmp = id_ice.variables['trsp_frwt'][:]
  613. if len(vtmp) != nbr:
  614. print 'ERROR: '+csn+' => length of trsp_frwt in '+cf_ice+' doesnot match with that in '+cf_in+'!'
  615. sys.exit(0)
  616. Xtrsp[4,:] = vtmp[:]
  617. id_ice.close()
  618. del vtmp
  619. VY = nmp.zeros(nby)
  620. FY = nmp.zeros((nbtrsp , nby))
  621. if nbm >= 12:
  622. VY[:], FY[:,:] = bt.monthly_2_annual(vtime, Xtrsp[:,:])
  623. else:
  624. # the file contains annual data
  625. VY[:] = vtime[:]
  626. FY[:,:] = Xtrsp[:,:]
  627. # Transport of volume:
  628. bp.plot("1d_mon_ann")(vtime, VY, Xtrsp[0,:], FY[0,:], cfignm='transport_vol_'+csec+'_'+CONFEXP,
  629. dt=ittic, cyunit='Sv', ctitle = CONFEXP+': transport of volume, '+csec,
  630. ymin=0, ymax=0, cfig_type=ff, y_cst_to_add=0.)
  631. # Transport of heat:
  632. bp.plot("1d_mon_ann")(vtime, VY, Xtrsp[1,:], FY[1,:], cfignm='transport_heat_'+csec+'_'+CONFEXP,
  633. dt=ittic, cyunit='PW', ctitle = CONFEXP+': transport of heat (Tref='+cref_temp+'C), '+csec,
  634. ymin=0, ymax=0, mnth_col='g', cfig_type=ff, y_cst_to_add=0.)
  635. # Transport of freshwater:
  636. if l_add_ice:
  637. # Transport of liquid + solid freshwater:
  638. bp.plot("1d_multi")(VY, nmp.array([FY[3,:],FY[3,:]+FY[4,:]]), ['liquid', 'liquid+solid'], cfignm='transport_lsfw_'+csec+'_'+CONFEXP,
  639. dt=ittic, loc_legend='out', cyunit='Sv', ctitle = CONFEXP+': transport of freshwater (Sref='+cref_sali+'), '+csec,
  640. ymin=0, ymax=0, cfig_type=ff, y_cst_to_add=0.)
  641. bp.plot("1d_mon_ann")(vtime, VY, Xtrsp[3,:]+Xtrsp[4,:], FY[3,:]+FY[4,:], cfignm='transport_fw_'+csec+'_'+CONFEXP,
  642. dt=ittic, cyunit='Sv', ctitle = CONFEXP+': transport of (liquid+solid) freshwater (Sref='+cref_sali+'), '+csec,
  643. ymin=0, ymax=0, mnth_col='#738FBF', cfig_type=ff, y_cst_to_add=0.)
  644. else:
  645. # Transport of liquid freshwater only:
  646. bp.plot("1d_mon_ann")(vtime, VY, Xtrsp[3,:], FY[3,:], cfignm='transport_fw_'+csec+'_'+CONFEXP,
  647. dt=ittic, cyunit='Sv', ctitle = CONFEXP+': transport of (liquid) freshwater (Sref='+cref_sali+'), '+csec,
  648. ymin=0, ymax=0, mnth_col='#738FBF', cfig_type=ff, y_cst_to_add=0.)
  649. js = js + 1
  650. #################################################
  651. # MLD in regions defined in the basin_mask file!
  652. #################################################
  653. if idfig == 'mld':
  654. list_basin_names, list_basin_lgnms = bo.get_basin_info(vdic['BM_FILE'])
  655. nb_oce = len(list_basin_names)
  656. joce = 0
  657. for coce in list_basin_names[:]:
  658. cf_in_m = 'mean_'+cvar+'_'+CONFEXP+'_'+coce+'.nc'
  659. if os.path.exists(cf_in_m):
  660. print ' Opening '+cf_in_m
  661. vt0, vd0 = bn.read_1d_series(cf_in_m, cvar, cv_t='time', l_return_time=True)
  662. if joce==0: (nby, nbm, nbr, ittic) = bt.test_nb_years(vt0, cdiag)
  663. VY, FY = bt.monthly_2_annual(vt0, vd0)
  664. bp.plot("1d_mon_ann")(vt0, VY, vd0, FY, cfignm=cdiag+'_'+CONFEXP+'_'+coce, dt=ittic,
  665. cyunit=cyu, ctitle = CONFEXP+': '+clnm+list_basin_lgnms[joce],
  666. ymin=ym, ymax=yp,
  667. plt_m03=True, plt_m09=True, cfig_type=ff)
  668. else:
  669. print 'WARNING: '+csn+' => MLD diag => '+cf_in_m+' not found!'
  670. joce = joce+1
  671. print ''+csn+' done...\n'