% epic01_Rscldar_5  computes clear sky solar for ETL data
%jdy is julian day (decimal) at the start of average interval
%lat and lon are decimal latitude and longitude
%iv is column water vapor in cm
%   if no data is available for iv, put in NaN and select a ratio of iv to
%   near-surface water vapor mixing ratio, qrat.  Typical tropical value is
%   4.5
%calls SolarRadiance
	%
qrat=4.0   ; 
p=1010;%pressure
k1=.07;%aerosol optical depth, band 1
k2=.07;%aerosol optical depth, band 2
oz=0.2;%column ozone
watvap=iv;
ii=find(isnan(iv));watvap(ii)=qa(ii)/qrat;%total column water vapor
jdx=floor(jdy+5/60/24);%julian day in bin centers for 10-min aves

tutc=(jdy+5/60/24-jdx)*24;%0:1:23;%hour of the day
[n m]=size(tutc);
clear sw sz saz dirs sky;
[sw,sz,saz,dirs,sky] = SolarRadiancex(lat,lon,jdx,tutc,watvap,p,k1,k2,oz);
Rscl=sw;
figure;plot(jdy,Rscl,jdy,rs,'o');xlabel('Julian Day (2008)');ylabel('Downward Solar Flux (W/m^2)');
ss=stdt;axis([ss endt 0 1200]);

%sw = downward shortwave (W/m^2)
%sz=zenith angle
%saz = azimuth angle
%dirs is direct solar
%sky is diffuse solar
