%This program is made daily sensitive to the data from the Vaissala ceilometer CL31

%enter path of the raw data:
% raw_data_path=way_raw_data_ceilo;%'S:\GOMECC_2007\RHB\Ceilometer\Raw\';

%enter path of where to put the processed data:
% processed_data_path='C:\Data\CRUISES\RHB_Setup_Charleston-11-16_March_2007\ceilometer\test\OnRHB\';
% processed_data_path=way_proc_data_ceilo;%'S:\GOMECC_2007\RHB\Ceilometer\Processed\';

%enter path of where to put the processed images:
% process_images_path='C:\Data\CRUISES\RHB_Setup_Charleston-11-16_March_2007\ceilometer\test\OnRHB\';
% process_images_path=way_images_ceilo;%'S:\GOMECC_2007\RHB\Ceilometer\Raw_Images\';

%modified 10/15/2009 DEW
clear;
close('all');
fclose('all');


%try

Fluxroot='D:\STRATUS_2009\RHB\AUTOFlux_programs_v2\';  % name of the path where the 'flux' folder + read_parameters file are installed.
cd([Fluxroot, 'flux'])         %Changes current directory to fluxroot
addpath(genpath(Fluxroot))     %adds flux folder and all of its subdirectories to the top of the MATLAB search path.
%%%%%%%%%%%  Read parameters %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
read_parameters_RHB_2009;     %reads the parameters for the cruise.

%%%%%%%%%%%%%%%%%%%Modifies current directory and search path%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Ceiloroot='D:\STRATUS_2009\RHB\AUTOFlux_programs_v2\';  % name of the path where the 'flux' folder + read_parameters file are installed.
cd([Ceiloroot, 'ceilo'])         %Changes current directory to fluxroot
addpath(genpath(Ceiloroot))     %adds flux folder and all of its subdirectories to the top of the MATLAB search path.

%%%%%%%%%%%  Defines some options %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
plotit=true; % for making plots.
prtit=true;  % for printing plots--ineffective unless plotit is also true
graphformat='.png';  %select graphics format files
graphdevice='-dpng'; %select graphic device
saveit=true; % for saving data files
clearit=true;% for clearing data sometimes to save memory
emailconf=false; %for sending email confirmation to NOAA email recipient list (Send_email_to_PSD3group.m)
%set to false as it does not seem to work from DAS computers :(
report=[];
data_ftp=false;     %to activate ftp to Boulder server
data_backup=false;    %true;  %to activate backup to Lacie hardrive (if present)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

cruise_name=[cruise yyyy];%'WGC';

dd = clock;  % date vector
edn=datenum(dd(1),dd(2),dd(3),dd(4),dd(5),dd(6)); %MATLAB day
bdn=edn-1;    % this is to get the prevuous days data.
ddv = datevec(bdn);
year = num2str(ddv(1));
hr = 00;   % assumes ceilometer program hasn't restarted
fname=sprintf('A%c%02d%02d%02d.dat', year(4), ddv(2), ddv(3), hr)  %Aymmddhh.DAT
copyfile(['Y:\' fname],[way_raw_data_ceilo]); % copy yesterdays file from ceilometer PC (Y:) to D:
ls([way_raw_data_ceilo '*.DAT'])

%
eval([ 'read_daily_rawceilo_CL31_', cruise, '_', yyyy])
eval([ 'ceilo_daily_plot_program_', cruise, '_', yyyy])

%compress ceilometer files into a zip file so it can be ftp'd
mn = sprintf('%02d',ddv(2));
dy = sprintf('%02d',ddv(3));
jds = sprintf('%03d',jd);
if exist([way_images_ceilo, cruise, '_', yyyy, '_', ship, '_ceilobackscatter_', mon, dy, '_' jds, '.png'],'file') && exist([way_images_ceilo, cruise, '_', yyyy, '_', ship, '_ceilobase_', mon, dy, '_' jds, '.png'],'file')
    entrynames=zip([way_proc_data_flux, cruise, '_', yyyy, '_', ship, '_ceilo_', mon, dy, '_' jds, '.zip'],{[way_images_ceilo,  cruise, '_', yyyy, '_', ship, '_ceilobackscatter_', mon, dy, '_' jds graphformat],[way_images_ceilo,  cruise, '_', yyyy, '_', ship, '_ceilobase_', mon, dy, '_' jdn(1:3) graphformat]}); 
end

exit
