vqnt[jt] = nmp.sum( QNT_m[jt, :-2, :-2] * Xarea_t[:-2, :-2]) * 1.E-9 # to PW if l_qsr: vqsr[jt] = nmp.sum( QSR_m[jt, :-2, :-2] * Xarea_t[:-2, :-2]) * 1.E-9 # to PW cf_out = vdic['DIAG_D'] + '/mean_htf_' + CONFEXP + '_GLO.nc' bnc.wrt_appnd_1d_series( vtime, vqnt, cf_out, 'Qnet', cu_t='year', cu_d='PW', cln_d='Globally averaged net heat flux (nemo:' + vdic['NN_QNET'] + ')', vd2=vqsr, cvar2='Qsol', cln_d2='Globally averaged net solar heat flux (nemo:' + vdic['NN_QSOL'] + ')') print ' +++ ' + cnexec + ' => Done with heat flux diags!\n' # Freshwater fluxes if l_fwf: print '\n\n +++ ' + cnexec + ' => Starting freshwater flux diags!' #cv_fwf = vdic['NN_FWF'] #cv_emp = vdic['NN_EMP']
########################################## # Writing/Appending in output netcdf file ########################################## # Appending only 1 record for 1 year into the netcdf file! cf_out = vdic['DIAG_D']+'/DMV_'+czcrit+'_box_'+cbox+'_'+CONFRUN+'.nc' cv_dmv_m = 'DMV_'+czcrit+'_'+ccold cv_dmv_jfm = 'DMV_'+czcrit+'_'+cvinter long_name1 = 'Deep Mixed Volume (crit = '+czcrit+'m) for '+ccold_ln+' on box '+cbox long_name2 = 'Deep Mixed Volume (crit = '+czcrit+'m) for '+cvinter+' on box '+cbox long_name3 = 'Deepest ML point in '+ccold_ln+' on box '+cbox long_name4 = 'Mean MLD in '+ccold_ln+' where MLD > '+czcrit+'m on box '+cbox bnc.wrt_appnd_1d_series([float(jyear)], [VDMV[2]], cf_out, cv_dmv_m, cu_t='year', cu_d='10^3 km^3', cln_d=long_name1, vd2=[rc_WINT], cvar2=cv_dmv_jfm, cln_d2=long_name2, vd3=[rML_max], cvar3='ML_max', cln_d3=long_name3, vd4=[rML_deep_mean], cvar4='ML_deep_mean', cln_d4=long_name4) print '\n Z_crit '+str(int(czcrit))+'m done!\n\n' print '\nBye!\n'
jb = jb + 1 ; # next basin! print '\n +++ '+cnexec+' => Done with 2D-summing of variable '+cvar+'!\n' del Xd_m jv = jv + 1 ; # next variable! # Time to write netcdf file: vtime = nmp.zeros(12) for jt in range(12): vtime[jt] = float(jyear) + (float(jt)+0.5)*1./float(12) #print ' * Calendar: ', vtime[:] c1 = '2D-integral of ' jb = 0 for cbasin in list_basin_names[:]: c2 = ') on region '+list_basin_lgnms[jb] cf_out = cdir_out+'/fwf_int_'+CONFEXP+'_'+cbasin+'.nc' bnc.wrt_appnd_1d_series(vtime, v_fwf_m[:,jb,0], cf_out, vnnm[0], cu_t='year', cu_d=cunit, cln_d =c1+vnnm[0]+' ('+vvar[0]+c2, vd2=v_fwf_m[:,jb,1], cvar2=vnnm[1], cln_d2=c1+vnnm[1]+' ('+vvar[1]+c2, vd3=v_fwf_m[:,jb,2], cvar3=vnnm[2], cln_d3=c1+vnnm[2]+' ('+vvar[2]+c2, vd4=v_fwf_m[:,jb,3], cvar4=vnnm[3], cln_d4=c1+vnnm[3]+' ('+vvar[3]+c2, vd5=v_fwf_m[:,jb,4], cvar5=vnnm[4], cln_d5=c1+vnnm[4]+' ('+vvar[4]+c2) jb = jb + 1 print '\n *** EXITING '+cnexec+' for year '+cyear+' and variable '+cvar+'!\n'
########################################## # Writing/Appending in output netcdf file ########################################## # Appending only 1 record for 1 year into the netcdf file! cf_out = vdic['DIAG_D']+'/DMV_'+czcrit+'_box_'+cbox+'_'+CONFEXP+'.nc' cv_dmv_m = 'DMV_'+czcrit+'_'+ccold cv_dmv_jfm = 'DMV_'+czcrit+'_'+cvinter long_name1 = 'Deep Mixed Volume (crit = '+czcrit+'m) for '+ccold_ln+' on box '+cbox long_name2 = 'Deep Mixed Volume (crit = '+czcrit+'m) for '+cvinter+' on box '+cbox long_name3 = 'Deepest ML point in '+ccold_ln+' on box '+cbox long_name4 = 'Mean MLD in '+ccold_ln+' where MLD > '+czcrit+'m on box '+cbox bnc.wrt_appnd_1d_series([float(jyear)], [VDMV[2]], cf_out, cv_dmv_m, cu_t='year', cu_d='10^3 km^3', cln_d=long_name1, vd2=[rc_WINT], cvar2=cv_dmv_jfm, cln_d2=long_name2, vd3=[rML_max], cvar3='ML_max', cln_d3=long_name3, cun3='m', vd4=[rML_deep_mean], cvar4='ML_deep_mean', cln_d4=long_name4, cun4='m') print '\n Z_crit '+str(int(czcrit))+'m done!\n\n' print '\nBye!\n'
# ======================================== Vts_tot = bo.mean_3d(Xd_m[:,:,j1:j2,i1:i2], mask[joce,:,j1:j2,i1:i2], Xv[:,j1:j2,i1:i2]) ; # Top to bottom Vts_0_100 = bo.mean_3d(Xd_m[:,:j100m,j1:j2,i1:i2], mask[joce,:j100m,j1:j2,i1:i2], Xv[:j100m,j1:j2,i1:i2]) Vts_100_1000 = bo.mean_3d(Xd_m[:,j100m:j1000m,j1:j2,i1:i2], mask[joce,j100m:j1000m,j1:j2,i1:i2], Xv[j100m:j1000m,j1:j2,i1:i2]) Vts_1000_bot = bo.mean_3d(Xd_m[:,j1000m:,j1:j2,i1:i2], mask[joce,j1000m:,j1:j2,i1:i2], Xv[j1000m:,j1:j2,i1:i2]) cf_out = vdic['DIAG_D']+'/3d_'+cvar+'_'+CONFEXP+'_'+cocean+'.nc' cv1 = cvar+'_0-bottom' cv2 = cvar+'_0-100' cv3 = cvar+'_100-1000' cv4 = cvar+'_1000-bottom' bnc.wrt_appnd_1d_series(vtime, Vts_tot, cf_out, cv1, cu_t='year', cu_d='Unknown', cln_d ='3D-average of '+cvar+': surface to bottom, '+colnm, vd2=Vts_0_100, cvar2=cv2, cln_d2='3D-average of '+cvar+': surface to 100m, '+colnm, vd3=Vts_100_1000, cvar3=cv3, cln_d3='3D-average of '+cvar+': 100m to 1000m, '+colnm, vd4=Vts_1000_bot, cvar4=cv4, cln_d4='3D-average of '+cvar+': 1000m to bottom, '+colnm) # II) Annual mean vertical profile # ================================ Vf = nmp.zeros(nk) for jk in range(nk): [ rf ] = bo.mean_2d(Xd_y[:,jk,j1:j2,i1:i2], mask[joce,jk,j1:j2,i1:i2], Xa[j1:j2,i1:i2]) Vf[jk] = rf
l_htf = l_qnt ; # Forgeting heat flux if both Qnet is missing... if l_htf: [ nt, nj0, ni0 ] = QNT_m.shape vtime = nmp.zeros(nt) for jt in range(nt): vtime[jt] = float(jyear) + (float(jt)+0.5)*1./12. vqnt = [] ; vqsr = [] if l_qnt: vqnt = nmp.zeros(nt) if l_qsr: vqsr = nmp.zeros(nt) for jt in range(nt): if l_qnt: vqnt[jt] = nmp.sum( QNT_m[jt,:,:]*Xarea_t ) * 1.E-9 ; # to PW if l_qsr: vqsr[jt] = nmp.sum( QSR_m[jt,:,:]*Xarea_t ) * 1.E-9 ; # to PW cf_out = vdic['DIAG_D']+'/mean_htf_'+CONFRUN+'_global.nc' bnc.wrt_appnd_1d_series(vtime, vqnt, cf_out, 'Qnet', cu_t='year', cu_d='PW', cln_d ='Globally averaged net heat flux (nemo:'+cv_qnt+')', vd2=vqsr, cvar2='Qsol', cln_d2='Globally averaged net solar heat flux (nemo:'+cv_qsr+')', ) # Freshwater fluxes if l_fwf: cv_fwf = vdic['NN_FWF'] cv_emp = vdic['NN_EMP'] cv_prc = vdic['NN_P'] cv_rnf = vdic['NN_RNF'] cv_clv = vdic['NN_CLV'] cv_evp = vdic['NN_E'] # cv_evb (top of file...)
bnc.wrt_appnd_1d_series(Vtime, ssh_m, cf_out, 'ssh', cu_t='year', cu_d='m', cln_d=cc + 'sea surface height', vd2=sst_m, cvar2='sst', cln_d2=cc + 'sea surface temperature', cun2='deg.C', vd3=sss_m, cvar3='sss', cln_d3=cc + 'sea surface salinity', cun3='PSU', vd4=surf_T_m, cvar4='surf_T', cln_d4=cc + 'Temperature (first ' + czs + 'm)', cun4='deg.C', vd5=T_m, cvar5='theta', cln_d5=cc + 'potential temperature', cun5='deg.C', vd6=H_m, cvar6='HC', cln_d6=cc + 'heat content', cun6='PJ', vd7=surf_S_m, cvar7='surf_S', cln_d7=cc + 'salinity (first ' + czs + 'm)', cun7='PSU', vd8=S_m, cvar8='S', cln_d8=cc + 'salinity', cun8='PSU', vd9=ss0_m, cvar9='SSs0', cln_d9=cc + 'sea surface sigma0 (sst&sss)', cun9='', vd10=surf_s0_m, cvar10='surf_s0', cln_d10=cc + 'surface sigma0 (first ' + czs + 'm)', cun10='')
print 'Volume associated with SSH (km^3) = ', Vol_m[jm], '\n' Vtime = nmp.zeros(Nt) for jm in range(Nt): Vtime[jm] = float(jy) + (float(jm)+0.5)/12. cc = 'Box-averaged ' cf_out = vdic['DIAG_D']+'/budget_'+CONFRUN+'_box_'+cbox+'.nc' bnc.wrt_appnd_1d_series(Vtime, ssh_m, cf_out, 'ssh', cu_t='year', cu_d='m', cln_d=cc+'sea surface height', vd2=sst_m, cvar2='sst', cln_d2=cc+'sea surface temperature', cun2='deg.C', vd3=sss_m, cvar3='sss', cln_d3=cc+'sea surface salinity', cun3='PSU', vd4=surf_T_m, cvar4='surf_T', cln_d4=cc+'Temperature (first '+czs+'m)', cun4='deg.C', vd5=T_m, cvar5='theta', cln_d5=cc+'potential temperature', cun5='deg.C', vd6=H_m, cvar6='HC', cln_d6=cc+'heat content', cun6='PJ', vd7=surf_S_m, cvar7='surf_S', cln_d7=cc+'salinity (first '+czs+'m)', cun7='PSU', vd8=S_m, cvar8='S', cln_d8=cc+'salinity', cun8='PSU', vd9=ss0_m, cvar9='SSs0', cln_d9=cc+'sea surface sigma0 (sst&sss)', cun9='', vd10=surf_s0_m,cvar10='surf_s0', cln_d10=cc+'surface sigma0 (first '+czs+'m)', cun10='' ) cf_out = vdic['DIAG_D']+'/budget_srf_flx_'+CONFRUN+'_box_'+cbox+'.nc' bnc.wrt_appnd_1d_series(Vtime, Qnet_m, cf_out, 'Qnet', cu_t='year', cu_d='W/m^2', cln_d=cc+'net heat flux', vd2=Qnet_x_S_m, cvar2='Qnet_x_S', cln_d2=cc+'net heat flux x Surface', cun2='PW', vd3=Qsw_m, cvar3='Qsw', cln_d3=cc+'solar radiation', cun3='W/m^2', vd4=Qsw_x_S_m, cvar4='Qsw_x_S', cln_d4=cc+'solar radiation x Surface', cun4='PW', vd5=PmE_m, cvar5='PmE', cln_d5=cc+'net freshwater flux', cun5='Sv', vd6=Tau_m, cvar6='Tau', cln_d6=cc+'wind stress module', cun6='N/m^2'
if l_qsr: vqsr = nmp.zeros(nt) for jt in range(nt): if l_qnt: vqnt[jt] = nmp.sum(QNT_m[jt, :, :] * Xarea_t) * 1.E-9 # to PW if l_qsr: vqsr[jt] = nmp.sum(QSR_m[jt, :, :] * Xarea_t) * 1.E-9 # to PW cf_out = vdic['DIAG_D'] + '/mean_htf_' + CONFRUN + '_global.nc' bnc.wrt_appnd_1d_series( vtime, vqnt, cf_out, 'Qnet', cu_t='year', cu_d='PW', cln_d='Globally averaged net heat flux (nemo:' + cv_qnt + ')', vd2=vqsr, cvar2='Qsol', cln_d2='Globally averaged net solar heat flux (nemo:' + cv_qsr + ')', ) # Freshwater fluxes if l_fwf: cv_fwf = vdic['NN_FWF'] cv_emp = vdic['NN_EMP'] cv_prc = vdic['NN_P'] cv_rnf = vdic['NN_RNF'] cv_clv = vdic['NN_CLV'] cv_evp = vdic['NN_E']