disp('plt_means_07')
clear
close all
fclose('all');
% modified on 30-mar-01 by D.E.Lane for Kai 2001 cruise
% modified 10 nov 03 by cfairall for the weller 2003 cruise
% modified 09 jul 04 by hare
% modified April 06 by lbariteau for the AMMA 2006 cruise (changement of
% the variables in the Mean Campbell datalogger)

% modified 5.25.2007 DEW to read in daly mean files with pressure and plot
% entire period.

pathdata = 'S:\GOMECC_2007\RHB\flux\Processed\';
outpath  = 'S:\GOMECC_2007\RHB\flux\Processed_Images\';
eval(['cd ', pathdata]);

cruise_name ='AMMA 2007 ';

e ='S:\GOMECC_2007\RHB\flux\Processed\proc_means*';
m=dir('S:\GOMECC_2007\RHB\flux\Processed\proc_means*');
lm = length(m)

bpt = 1;

for ii = 1:lm

    disp(['Reading ',m(ii).name]);
    flist=fopen(m(ii).name,'r');

    %jad;  %decimal JD
    %pirm; %s
    %pspm; %n
    %Tc1;  %
    %Td1;  %
    %Tsea;
    %Tvais;    %
    %Rhvais;   %
    %org;  %
    %org_carrier; %
    %aspir_on;  %
    %press;  %

    if flist>0,					    %if the file exists,

        psdm = load(m(ii).name);    %load 1 day of PSD mean logger data
        ld = length(psdm);
        ept = bpt + ld - 1;
        tpsdm(bpt:ept,:) = psdm; % copy data into one long array
        bpt = ept + 1;

    end;                            %end of flist

end;

jad = tpsdm(:,1);  %decimal JD
pir1 = tpsdm(:,2); ; %s
psp1 = tpsdm(:,3); ; %n
Tc1 = tpsdm(:,4); ;  %
Td1 = tpsdm(:,5); ;  %
Tsea = tpsdm(:,6); ;
Tvais = tpsdm(:,7); ;    %
Rhvais = tpsdm(:,8); ;   %
org = tpsdm(:,9); ;  %
org_carrier = tpsdm(:,10); ; %
aspir_on = tpsdm(:,11); ;  %
press = tpsdm(:,12); ;  %


bd = min(jad);
ed = max(jad);
year = '2007';

if 1

    figure;plot(jad,press,'r');
    title('Vaisala Pressure');
    xlabel(['DOY', year]);
    ylabel('Pressure (mb)');
    axis([bd,ed,1005,1025])
    %axis([bd,ed,min(press)-5,max(press)+5])
    print_buffer = [outpath, cruise_name,'Press_AC.jpg'];
print('-djpeg90 ', print_buffer);



    %figure;plot(jad,Tc1,'r',jad,Tc2,'m',jad,Td1,'k',jad,Td2,'c',jad,Tsea,'b',jad,Tvais,'g');title('PSD Temperatures (case 1 (red),2(magenta); dome 1(black),2(cyan); snake(blue), Tair(green))');xlabel(['DOY', year]);ylabel('Temperature (C)');

    figure;plot(jad,psp1);
    title('PSD psp');
    xlabel(['DOY', year]);
    ylabel('Solar FLux (W/m^2)');
    axis([bd,ed,0,1200])
    print_buffer = [outpath, cruise_name,'SW_AC.jpg'];
print('-djpeg90 ', print_buffer);

    
    figure;plot(jad,pir1);
    title('PSD pir');
    xlabel(['DOY', year]);
    ylabel('IR Flux (W/m^2)'); 
    axis([bd,ed,300,500])
        print_buffer = [outpath, cruise_name,'IR_AC.jpg'];
print('-djpeg90 ', print_buffer);



    figure;plot(jad,Rhvais);
    title('PSD RH');
    xlabel(['DOY', year]);
    ylabel('Relative Humidity (%)');
    axis([bd,ed,0,105])
        print_buffer = [outpath, cruise_name,'RH_AC.jpg'];
print('-djpeg90 ', print_buffer);



    %figure;plot(jad,org);title('PSD org rain rate');xlabel(['DOY', year]);ylabel('Rain Rate (mm/hr)');
    %figure;plot(jad,aspir_on);title('PSD aspirator');xlabel(['DOY', year]);ylabel('Backflow Indicator (Volt). If 0V, there is backflow');%axis([max(jad)-1 max(jad) -0.2 5.2])
    %figure;plot(jad,org_carrier);title('PSD org carrier');xlabel(['DOY', year]);ylabel('Rain Gauge Function (V)');

    figure;plot(jad,Tsea,jad,Tvais);
    title('PSD');
    xlabel(['DOY', year]);
    ylabel('Temperature (degC)');
    axis([bd,ed,15,35])
    legend('SST','Tair')
        print_buffer = [outpath, cruise_name,'SSTTa_AC.jpg'];
print('-djpeg90 ', print_buffer);

   figure;plot(jad,aspir_on);
    title('PSD');
    xlabel(['DOY', year]);
    ylabel('Aspirator Flow 0 = bad 5 = good');
    axis([bd,ed,0,6])
        print_buffer = [outpath, cruise_name,'ASPIR_AC.jpg'];
print('-djpeg90 ', print_buffer);

 figure;plot(jad,Tc1,jad,Td1);
    title('PSD');
    xlabel(['DOY', year]);
    ylabel('Temp  (degC)');
    axis([bd,ed,15,35])
    legend('Case 1','Dome 1')
        print_buffer = [outpath, cruise_name,'TcTd_AC.jpg'];
print('-djpeg90 ', print_buffer);

end


