clear;
close('all');
fclose('all');

read_parameters_Stratus; %Reading parameter files flux conf from D:/data/lb/flux_eval_rhb_06
plotit=1;
prtit=1;
ddd=input('Input yearday to evaluate.... ');

R=input('Confirm parameters (yes/no) ?......','s');
C=strcmp(R,'yes');
if C==1

    read_pc_day_Stratus_07;    
    read_son_day_Stratus_07;
%     read_motion_Stratus_07;
%     read_gps_day_Stratus_07;
    read_co2_Stratus_07;
    read_scs_day_Stratus_07;

    timatch_5_Stratus_07;    
    timatch_30_Stratus_07;  

    if backup=='1'
        backup_to_harddisk_rhb;
    end;
    
    jjx=min(length(latm),length(qvais));
    rlclr=(.52+.13/60*abs(latm(1:jjx))+(.082-.03/60*abs(latm(1:jjx))).*sqrt(qvais(1:jjx))).*(5.67e-8*(Tvais(1:jjx)'+273.15).^4); 

    clear jdy;
    latd=nanmean(latm);
    lond=nanmean(lonm);
    qa=qvais;
    iv=ones(length(qa),1)*NaN;
    jdys=jd_pc;

    epic01_Rsclear_1;

    
figure;plot(jd_pc,Rhvais,'.b',jd_scs,rhm,'.g');xlim([ddd ddd+1])
title(['Relative Humidity in %. ', cruise, year]);
xlabel(['JD', year]);
legend('PSD', 'Ship');
    print('-djpeg90 ',[way_images_flux '\RH_' num2str(ddd) '.jpg']);xlim([ddd ddd+1])
    
figure;plot(jd_pc,Tsea,'b',jd_scs,tsgm,'.g');xlim([ddd ddd+1])
title(['Sea Temperature (C). ', cruise, year]);   
xlabel(['JD', year]);     
legend('PSD', 'Ship');
    print('-djpeg90 ',[way_images_flux '\SST_' num2str(ddd) '.jpg']);xlim([ddd ddd+1])
    
figure;plot(jd_pc,Tvais,'b',jd_scs,tam,'.g');xlim([ddd ddd+1])
title(['Air Temperature (C). ', cruise, year]);   
xlabel(['JD', year]);   
legend('PSD','Ship');
    print('-djpeg90 ',[way_images_flux '\Tair_' num2str(ddd) '.jpg']);xlim([ddd ddd+1])

ii=find(~isnan(rlclr));
figure;plot(jd_pc,pirm,'b',jd_scs,irm,'g',jd_scs(ii),rlclr(ii),'r');xlim([ddd ddd+1])
title(['IR Flux (W/m^2). ', cruise, year]);    
xlabel(['JD', year]);    
legend('PSD', 'Ship', 'Clearsky');
    print('-djpeg90 ',[way_images_flux '\IRflux_' num2str(ddd) '.jpg']);xlim([ddd ddd+1])

ii=find(~isnan(Rscl));
figure;plot(jd_pc,pspm,'.b',jd_scs,solarm,'.g',jd_pc(ii),Rscl(ii),'r');xlim([ddd ddd+1])
title(['Solar Flux (W/m^2). ', cruise, year]);     
xlabel(['Time of day (', year, ')']);     
legend('PSD', 'Ship','Clearsky');
    print('-djpeg90 ',[way_images_flux '\SOLflux_' num2str(ddd) '.jpg']);xlim([ddd ddd+1])



    ftp_to_NOAA; %send data to our server    

    disp('  ');
    disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');
    disp('<<<<<<<<         END of Flux_eval_program       >>>>>>>>>>>>>>>>>>>>>>>');
    disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%');


else   
    disp(['Go into the file ' fnpar ' to change the parameters']);
end;
