%Read SCS Event file % Each Event is stopped and started to creat daily files (UTC) % DEW LB 7/10/2013 disp('Need to run read_epicz to create 5 min all file'); disp('Read_SCS_WHOTS_2013'); clear close all cruise='WHOTS_2013'; % Cruise name, for example 'STRATUS_2009', 'TOTO_1969', etc... ship='Hiialakai'; % Research vessel data_drive='D:\'; Lacie_drive='G:\'; plotit = 1; ev = input('Input SCS event number to read (011) ','s'); way_proc_data_flux = [data_drive cruise '\' ship '\flux\Processed\']; % Processed data path way_images_flux = [data_drive cruise '\' ship '\flux\Raw_Images\' ]; %Ludo's read clear dir dr=dir(['D:\WHOTS_2013\Hiialakai\SCS\Raw\WHOTS-OBS_' ev '.elg']); e=dr(1).name; disp(['Reading scs file ',e]); flist=fopen(['D:\WHOTS_2013\Hiialakai\SCS\Raw\WHOTS-OBS_' ev '.elg']); temp=[];scsdata=[]; if flist>0, %if the file exists, while ~feof(flist) % temp=textscan(flist,'%f %f %f %*c %f %f %f %*c %f %f %*c %f %f %*c %f %f %*c %f %f %*c %f %f %f %f %f %*[^\n]','delimiter', ' ', 'treatAsEmpty', {'SBE-21','****','FWD','Temp'}, 'headerlines', 1, 'emptyvalue', NaN); temp=textscan(flist,'%2f/%2f/%4f %2f:%2f:%2f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %*4c %f %f %f %*6c %f %*c %f %*c %*4c %f %f %f %*[^\n]','delimiter', ', ', 'headerlines', 1, 'emptyvalue', NaN); scsdata=[scsdata cell2mat(temp)']; end; %end while end; % end if list scs = scsdata; % a=['D:\WHOTS_2013\Hiialakai\SCS\Raw\WHOTS-OBS_' bds '.dat']; % scs = load(a); % 1-3 Date % 4-6 Time UTC % 7 SAMOS-Lat-VALUE % 8 SAMOS-Lon-VALUE % 9 SAMOS-Gyro-VALUE % 10 SAMOS-COG-VALUE % 11 SAMOS-SOG-VALUE % 12 SAMOS-AirTemp-VALUE **** RMYoung deg C % 13 SAMOS-Barometer-VALUE Bad RMYoung % 14 SAMOS-RelHumidity-VALUE **** RMY % % 15 SAMOS-RelWind-Dir-VALUE % 16 SAMOS-RelWind-Spd-VALUE % 17 SAMOS-TrueWind-Dir-VALUE *** Prop-Vane deg T % 18 SAMOS-TrueWind-Spd-VALUE *** Prop-Vane kts % 19 SAMOS-TSG-Temp-VALUE **** SST deg C % 20 SAMOS-TSG-Cond-VALUE % 21 SAMOS-TSG-Sal-VALUE % 22 SAMOS-TSG-SV-VALUE % 23 WINCH-PAYOUT % 24 WINCH-SPD % 25 WINCH-TENSION % 26 WIND-85004-Ultrasonic-Anemometer Rel dir deg % 27 WIND-85004-Ultrasonic-Anemometer Rel spd kts % 28 Depth-Meters % 29 Vaisala-Barometer-- Good Station pressure mb % 30 Baro-Pressure **Bad RMY % Calculate Decimal year day yd_scs=datenum(scsdata(3,:),scsdata(1,:),scsdata(2,:),scsdata(4,:),scsdata(5,:),scsdata(6,:))-datenum(scsdata(3,1),1,0); %Day-Of-Year bd = fix(yd_scs(1)); ed = bd + 1; bds = sprintf('%03d',bd); dds = sprintf('%02d',scsdata(2,1)); mms = sprintf('%02d',scsdata(1,1)) g=['D:\WHOTS_2013\Hiialakai\flux\Processed\WHOTS_2013_proc_met_1min_2013_' mms '_' dds '_' bds '.txt']; met=load(g)'; % 1 jd_pc; %decimal JD % 2 pirm; %s % 3 pspm; %n % 4 Tc1; % % 5 Td1; % % 6 Tsea; % 7 Tvais; % % 8 Rhvais; % % 9 org; % % 10 org_carrier; % % 11 aspir_on; % % 12 press; % s=['D:\WHOTS_2013\Hiialakai\flux\Processed\WHOTS_2013_proc_son_1min_2013_' mms '_' dds '_' bds '.txt']; son=load(s)'; % jd_son; %decimal JD % U; % V; % w; % Tsonic; % dir; % Load 5 min all file b=['D:\WHOTS_2013\Hiialakai\flux\Processed\WHOTS_2013_PSD_flux_5min_all.txt']; met5=load(b)'; % jdy 1 julian day to Matlab format % U 2 true wind,PSD sonic (m/s) % dir 3 true wind direction, PSD sonic (deg) % tsnk 4 sea snake temperature,PSD, 0.05 m depth (C) % ta=x(:,7);%air temperature, PSD (C) (z=15 m) % press 31 PSD atmospheric pressure, mb % RH 32 PSD RHvais, % pp = find(met(12,:) < 1000); met(12,pp) = nan; figure plot(yd_scs,scs(29,:),'r') %Vaisala-Barometer- hold plot(met(1,:),met(12,:),'k.') % plot(met5(1,:),met5(31,:),'b.') ylabel('Pressure (mb)'); xlabel('Year Day (UTC)') title('WHOTS 2013 Pressure'); grid xlim([ bd ed ]); ylim([ 1010 1030]); legend('SCS','PSD','location','best'); if plotit print_buffer = [way_images_flux cruise '_SCS_PSD_P_' bds '.png']; print('-dpng ', print_buffer); end % Calculating Sea Level Pressure using Barometer height % ESRL ht = 14.38m % ship ht = 12.02m % NOAA Tech training %ESRL Pz1 = met(12,:); % Barometer pressure Ra = 287.05; % Constant J/kgK T1 = met(7,:); % Temperature K g = 9.81; % gravity m/s Z1 = 14.38; % height of presure sensor in m %Ps = ssealevel pressure s1 = (9.81*Z1); s2 = (Ra*(T1+274.15)); Ps1 = exp(s1./s2).*Pz1; clear s1 s2 %Ship Pz2 = scs(29,:); % Barometer pressure Ra = 287.05; % Constant J/kgK T2 = scs(12,:); % Temperature K g = 9.81; % gravity m/s Z2 = 12.02; % height of presure sensor in m %Ps = ssealevel pressure s1 = (9.81*Z2); s2 = (Ra*(T2+274.15)); Ps2 = exp(s1./s2).*Pz2; mPs2 = mean(Ps2); minp = fix(min(Ps2)); maxp = fix(max(Ps2)); pp = find(Ps1 > mPs2-3 ) mPs1 = mean(Ps1(pp)); figure plot(yd_scs,scs(29,:),'r') %Vaisala-Barometer- hold plot(met(1,:),met(12,:),'k.') plot(yd_scs,Ps2,'g') %Vaisala-Barometer- plot(met(1,pp),Ps1(pp),'b') ylabel('Pressure (mb)'); xlabel('Year Day (UTC)') title('WHOTS 2013 Sea Level Pressure'); grid xlim([ bd ed ]); ylim([ minp-2 maxp+2]); legend('SCS','PSD','location','best'); if plotit print_buffer = [way_images_flux cruise '_SCS_PSD_Psealvl_' bds '.png']; print('-dpng ', print_buffer); end % Plot RMY and other pressures if 0 figure plot(yd_scs,scs(:,35),'b') %Baro-Pressure hold plot(yd_scs,scs(:,34),'r') %Vaisala-Barometer- plot(yd_scs,scs(:,13),'g') %Samos-Barometer-Value plot(met(1,:),met(12,:),'k.') % PSD ylabel('Pressure (mb)'); xlabel('Year Day (UTC)') title('WHOTS 2013 Pressure'); grid xlim([ bd ed ]); legend('RMY','SCS','RMY','PSD','location','best'); if plotit print_buffer = [way_images_flux cruise '_SCS_PSD_Pall_' bds '.png']; print('-dpng ', print_buffer); end end figure plot(yd_scs,scs(19,:),'b') % Samos-TSG-Temp hold plot(met(1,:),met(6,:),'k') % Seasnake ylabel('SST (C)'); xlabel('Year Day (UTC)') title('WHOTS 2013 SST'); grid xlim([ bd ed ]); legend('SCS','PSD','location','best'); if plotit print_buffer = [way_images_flux cruise '_SCS_PSD_SST_' bds '.png']; print('-dpng ', print_buffer); end figure subplot(2,1,1),plot(yd_scs,scs(12,:),'b') % Samos-AirTemp hold subplot(2,1,1),plot(met(1,:),met(7,:),'r') %PSD Vai Temp subplot(2,1,1),plot(son(1,:),son(5,:),'k') %PSD Son Temp ylabel('Air T (C)'); xlabel('Year Day (UTC)') title('WHOTS 2013 Air Temp'); grid xlim([ bd ed ]); legend('SCS','PSD Vai','PSD Son','location','best','orientation','horizontal'); subplot(2,1,2),plot(yd_scs,scs(14,:),'b') % Samos-RH-Temp hold subplot(2,1,2),plot(met(1,:),met(8,:),'k') % PSD RH ylabel('RH(%)'); xlabel('Year Day (UTC)') title('WHOTS 2013 RH'); ylim([ 0 100]); grid xlim([ bd ed ]); legend('SCS','PSD Vai','location','best'); if plotit print_buffer = [way_images_flux cruise '_SCS_PSD_TRH_' bds '.png']; print('-dpng ', print_buffer); end sonspd = sqrt((son(2,:).^2)+(son(3,:).^2)); figure subplot(2,1,1),plot(yd_scs,scs(17,:),'b.') % Samos-TrueWind-Dir hold subplot(2,1,1),plot(met5(1,:),met5(3,:),'k.') % PSD Son ylabel('Dir (T)'); xlabel('Year Day (UTC)') title('WHOTS 2013 Dir True'); ylim([ 0 360]); grid xlim([ bd ed ]); legend('SCS P-V','PSD Son','location','best'); subplot(2,1,2),plot(yd_scs,scs(18,:)*.55,'b') % Samos TruWind Speed hold subplot(2,1,2),plot(met5(1,:),met5(2,:),'k.') % PSD TrueWind Speed ylabel('Spd (m/s)'); xlabel('Year Day (UTC)') title('WHOTS 2013 Spd True'); ylim([ 0 25]); xlim([ bd ed ]); grid if plotit print_buffer = [way_images_flux cruise '_SCS_PSD_DirSpdT_' bds '.png']; print('-dpng ', print_buffer); end figure subplot(2,1,1),plot(yd_scs,scs(15,:),'b.') % Samos WindDir-Rel hold plot(yd_scs,scs(26,:),'r.') % Ultra Sonic plot(son(1,:),son(6,:),'k.') % PSD Son ylabel('Dir (Rel)'); xlabel('Year Day (UTC)') title('WHOTS 2013 Dir Rel'); ylim([ 0 360]); grid xlim([ bd ed ]); legend('SCS P-V','SCS Son','PSD Son','location','best'); subplot(2,1,2),plot(yd_scs,scs(16,:)*.55,'b') % Samos-WindRel Rel hold plot(yd_scs,scs(27,:)*.55,'r') % Ultra Sonic plot(son(1,:),sonspd,'k') % PSD SOn ylabel('Spd (m/s)'); xlabel('Year Day (UTC)') title('WHOTS 2013 Spd Rel'); ylim([ 0 25]); grid xlim([ bd ed ]); if plotit print_buffer = [way_images_flux cruise '_SCS_PSD_DirSpdR_' bds '.png']; print('-dpng ', print_buffer); end % figure(10) % plot(yd_scs,scs(:,16)*.55,'b') % Samos RelWind Speed % hold % plot(yd_scs,scs(:,18)*.55,'r') % Samos TrueWind Speed % legend('SCS P-V Rel','SCS P-V True','location','best'); % ylabel('Spd (m/s)'); % xlabel('Year Day (UTC)') % title('WHOTS 2013 Spd'); % ylim([ 0 25]); % grid % xlim([ bd ed ]);