%% Import data from text file.
% Script for importing data from the following text file:
%
%    D:\Data\STRATUS_2018\CabodeHornos\SCS\Raw\WXT__SMSAWS__20180405.txt
%
% To extend the code to different selected data or a different text file,
% generate a function instead of a script.

% Auto-generated by MATLAB on 2018/04/10 13:58:04
ename='LOG1_20190413.txt';
%% Initialize variables.
disp(['read vaisala file',ename]);
flist=fopen(['D:\Data\STRATUS_2018\CabodeHornos\SCS\CdeH\LOG1_20190413.txt']);
delimiter = '\t','\\' ;
startRow = 2;
temp=[];vasldata=[];

%% Format string for each line of text:
%   column1: text (%q)
%	column2: double (%f)
%   column3: double (%f)
%	column4: double (%f)
%   column5: double (%f)
%	column6: text (%q)
%   column7: text (%q)
%	column8: text (%q)
%   column9: text (%q)
%	column10: text (%q)
%   column11: text (%q)
%	column12: text (%q)
%   column13: text (%q)
%	column14: text (%q)
%   column15: text (%q)
%	column16: text (%q)
%   column17: text (%q)
%	column18: text (%q)
%   column19: text (%q)
%	column20: text (%q)
%   column21: text (%q)
%	column22: text (%q)
%   column23: text (%q)
%	column24: text (%q)
%   column25: text (%q)
%	column26: text (%q)
%   column27: text (%q)
%	column28: text (%q)
%   column29: text (%q)
%	column30: text (%q)
%   column31: text (%q)
%	column32: text (%q)
%   column33: text (%q)
%	column34: text (%q)
%   column35: text (%q)
%	column36: text (%q)
%   column37: text (%q)
%	column38: text (%q)
%   column39: text (%q)
%	column40: text (%q)
%   column41: text (%q)
%	column42: text (%q)
%   column43: text (%q)
%	column44: text (%q)
%   column45: text (%q)
%	column46: text (%q)
%   column47: text (%q)
%	column48: text (%q)
%   column49: text (%q)
%	column50: text (%q)
%   column51: text (%q)
%	column52: text (%q)
%   column53: text (%q)
%	column54: text (%q)
%   column55: text (%q)
%	column56: text (%q)
%   column57: text (%q)
%	column58: text (%q)
%   column59: text (%q)
%	column60: text (%q)
%   column61: text (%q)
%	column62: text (%q)
%   column63: text (%q)
% For more information, see the TEXTSCAN documentation.
%% Open the text file.
fileID = fopen(flist);

temp=(flist);
vasldata=[vasldata cell2mat(temp)'];

scsval = 'vasldata.';
        %% Read columns of data according to format string.
% This call is based on the structure of the file used to generate this
% code. If an error occurs for a different file, try regenerating the code
% from the Import Tool.
%scsval = textscan(flist, formatSpec, 'Delimiter', delimiter, 'HeaderLines' ,startRow-1, 'ReturnOnError', false);

%% Close the text file.
%fclose(fileID);

%% Post processing for unimportable data.
% No unimportable data rules were applied during the import, so no post
% processing code is included. To generate code which works for
% unimportable data, select unimportable cells in a file and regenerate the
% script.

%% Allocate imported array to column variable names
TIME = scsval{:, 3};
WS = scsval{:, 4};
WD = scsval{:, 5};
WSR = scsval{:,6};
WDR = scsval{:, 5};
SC1TXT = scsval{:, 6};
SC2TXT = scsval{:, 7};
SC3TXT = scsval{:, 8};
SC4TXT = scsval{:, 9};
SC5TXT = scsval{:, 10};

yd_time= datenum(TIME(),1400);
yd_scs=yd_time-datenum(2018,04,05);   %Day-Of-Year
bd = 95+ yd_scs;
bds = num2str(bd);

figure

plot(bd ,SC1TXT{:,1},'b')  %Vaisala-Barometer-
ylabel('Pressure (hPa)');
xlabel('Year Day (UTC)')
title('Stratus 2018 Pressure');
grid
%xlim([ bd ed ]);
%ylim([ 1010 1020]);
legend('SCS','location','best');
 if prtit
 ppath = fullfile(path_images,[cruise,'_SCS_Pressure_',sprintf('%02i_%02i_%04i',scs(1,2),scs(1,3),scs(1,1)),graphformat]);
 print(graphdevice,ppath);
 end
%% Clear temporary variables
clearvars filename delimiter startRow formatSpec fileID scsval ans;