X=read_netcdfFile2('C:\Data\cwf\Dropbox\division\Review_2015\NOAA_PSD_init\elnino\EUREC4A\field_ops\all_rad_profiles.nc');
swdn=X.sw_dn;
swup=X.sw_up;
lwdn=X.lw_dn;
lwup=X.lw_up;
plev=X.plev;
play=double(X.play);
ta=X.tlay;%tair in K
Q=X.h2o;%water vapor density in Kg/m^3
Rg=287.1;%gas constant dry air
figure; plot(nanmeanx(Q'),play); set(gca,'ydir','reverse');ylim([800 1015]*100)
tam=nanmeanx(ta');qam=nanmeanx(Q');%mean ta and Q profiles

rho=play/Rg./tam'-.61*qam';%mean air density
swnet=swdn-swup;
lwnet=lwdn-lwup;
netradgs=diff(nanmeanx(swnet'));%mean net radiation
netradgl=diff(nanmeanx(lwnet'));%mean net radiation
netradg=netradgs+netradgl;

tdots=9.83/1001*netradgs/100*3600*24;%g/cp dp=100 Pa, convert to deg/day
tdotl=9.83/1001*netradgl/100*3600*24;%g/cp dp=100 Pa, convert to deg/day
tdot=9.83/1001*netradg/100*3600*24;%g/cp dp=100 Pa, convert to deg/day

figure;plot(tdot,play,'.',tdots,play,'x',tdotl,play,'o'); set(gca,'ydir','reverse');xlim([-4 4]);grid;xlabel('Heating rad (deg/day)');ylabel('Pressure (pa)');title('Mean ATOMIC profiles');
legend('Total','Solar','IR');

%figure;plot(tdots,play,'.'); set(gca,'ydir','reverse');xlim([-4 2]);grid;xlabel('Heating rad (deg/day)');ylabel('Pressure (pa)');title('Mean ATOMIC profiles');