[893] | 1 | %% get the input file |
---|
| 2 | fileinput=uigetfile_uvmat('pick an input file','/fsnet/project/coriolis/2015/15STRATJET/Probes'); |
---|
| 3 | [Path,Name,Ext]=fileparts(fileinput); |
---|
| 4 | |
---|
| 5 | %% read the input file |
---|
| 6 | FileType=''; |
---|
| 7 | if strcmp(Ext,'.lvm') |
---|
| 8 | disp(['reading ' fileinput '...']) |
---|
| 9 | Data=read_lvm(fileinput) |
---|
| 10 | elseif strcmp(Ext,'.nc') |
---|
| 11 | disp(['reading ' fileinput '...']) |
---|
| 12 | Data=nc2struct(fileinput) |
---|
| 13 | else |
---|
| 14 | disp('invalid input file extension') |
---|
| 15 | end |
---|
| 16 | |
---|
| 17 | %% save as netcdf file if it has been opened as .lvm |
---|
| 18 | if strcmp(Ext,'.lvm') |
---|
| 19 | OutputFile=fullfile(Path,[Name '.nc']); |
---|
| 20 | errormsg=struct2nc(OutputFile,Data);% copy the data in a netcdf file |
---|
| 21 | if isempty(errormsg) |
---|
| 22 | disp([OutputFile ' written']) |
---|
| 23 | else |
---|
| 24 | disp(errormsg) |
---|
| 25 | end |
---|
| 26 | [success,msg] = fileattrib(OutputFile,'+w','g')% allow writing access for the group of users |
---|
| 27 | end |
---|
| 28 | |
---|
| 29 | %% use calibration data stored in an xml file |
---|
| 30 | ProbeDoc=[]; |
---|
| 31 | XmlFile=fullfile(Path,[Name '.xml']); |
---|
| 32 | if exist(XmlFile,'file') |
---|
| 33 | ProbeDoc=xml2struct(XmlFile); |
---|
| 34 | end |
---|
| 35 | % if isfield(Data,'Position'), C2,C4,C6 |
---|
| 36 | % Min=1; |
---|
| 37 | % Data.Position=Data.Position+PositionMin; |
---|
| 38 | % end |
---|
| 39 | % a5=-2.134088,b5=1010.1611, |
---|
| 40 | % Data.C2=Data.C2; |
---|
| 41 | % Data.C5=a5*Data.C5+b5; |
---|
| 42 | % Data.C6=Data.C2; |
---|
| 43 | % ylabelstring='density drho (kg/m3)'; |
---|
| 44 | |
---|
| 45 | %% treqnsform conductivity probe signals: calibration + filter at 10 Hz |
---|
| 46 | ylabelstring='conductivity signal (volts)'; |
---|
| 47 | clist=0;% counter of conductivity probes |
---|
| 48 | for ilist=1:numel(Data.ListVarName) |
---|
| 49 | if isequal(Data.ListVarName{ilist}(1),'C');% if the var name begins by 'C' |
---|
| 50 | clist=clist+1; |
---|
| 51 | CName{clist}=Data.ListVarName{ilist}; |
---|
| 52 | if isfield(ProbeDoc,CName{clist})&& ~isempty(ProbeDoc.(CName{clist})) |
---|
| 53 | a=ProbeDoc.(CName{clist}).a; |
---|
| 54 | b=ProbeDoc.(CName{clist}).b; |
---|
| 55 | Data.(CName{clist})=a*Data.(CName{clist})+b;% transform volt signal into density |
---|
| 56 | Data.(CName{clist})=filter(ones(1,20)/20,1,Data.(CName{clist})); % filter the signal to 10 Hz |
---|
| 57 | ylabelstring='density drho (g/cm3)'; |
---|
| 58 | end |
---|
| 59 | end |
---|
| 60 | end |
---|
| 61 | |
---|
| 62 | %% plot conductivity probe signals |
---|
| 63 | figure(1) |
---|
| 64 | set(1,'name','conductivity') |
---|
| 65 | plot_string='plot('; |
---|
| 66 | for clist=1:numel(CName) |
---|
| 67 | plot_string=[plot_string 'Data.Time,Data.' CName{clist} ',']; |
---|
| 68 | end |
---|
| 69 | plot_string(end)=')'; |
---|
| 70 | eval(plot_string) |
---|
| 71 | legend(CName') |
---|
| 72 | htitle=title([Data.Experiment ', ' Data.FileName ', Time=' Data.DateTime ', conductivity probes']); |
---|
| 73 | set(htitle,'Interpreter','none')% desable tex interpreter |
---|
| 74 | xlabel('Time(s)') |
---|
| 75 | ylabel(ylabelstring) |
---|
| 76 | grid on |
---|
| 77 | |
---|
| 78 | if isfield(Data,'Position') |
---|
| 79 | %% plot motor position |
---|
| 80 | figure(2) |
---|
| 81 | set(2,'name','position') |
---|
| 82 | plot(Data.Time,Data.Position) |
---|
| 83 | htitle=title([Data.Experiment ', ' Data.FileName ', Time=' Data.DateTime ', probe position ']); |
---|
| 84 | set(htitle,'Interpreter','none')% desable tex interpreter |
---|
| 85 | xlabel('Time(s)') |
---|
| 86 | ylabel('Z (cm)') |
---|
| 87 | grid on |
---|
| 88 | hold on |
---|
| 89 | plot(Data.Time,Data.Speed) |
---|
| 90 | |
---|
| 91 | %%plot first profile |
---|
| 92 | figure(4) |
---|
| 93 | index1=find(Data.Speed<0,1); %start of descent |
---|
| 94 | Speed=Data.Speed(index1:end); |
---|
| 95 | index2=index1-1+find(Speed>0,1); %end of descent |
---|
| 96 | plot(Data.Position(index1:index2),Data.C1(index1:index2)) |
---|
| 97 | |
---|
| 98 | %% plot conductivity probe profiles (limited to downward motion, Data.Speed<0) |
---|
| 99 | if ~isempty(ProbeDoc) |
---|
| 100 | figure(3) |
---|
| 101 | set(3,'name','profiles') |
---|
| 102 | Zmotor=Data.Position(Data.Speed<0); |
---|
| 103 | Z=Zmotor*ones(1,numel(CName));%motor position transformed in a matrix with a columnfor each probe |
---|
| 104 | Zmax=max(Zmotor); |
---|
| 105 | plot_string='plot('; |
---|
| 106 | for clist=1:numel(CName) |
---|
| 107 | if isfield(ProbeDoc,CName{clist})&& ~isempty(ProbeDoc.(CName{clist})) && size(ProbeDoc.(CName{clist}).Position,2)>=2 % if at least two positions are defined to indicate that the probe moves |
---|
| 108 | Zprobe=Zmotor-Zmax+ProbeDoc.(CName{clist}).Position(2,3);%upper position of the probe |
---|
| 109 | Zprobe(Zprobe<ProbeDoc.(CName{clist}).Position(1,3))=ProbeDoc.(CName{clist}).Position(1,3); |
---|
| 110 | Z(:,clist)=Zprobe;% add to z the first z position of the chosen probe (given in the xml file) |
---|
| 111 | plot_string=[plot_string 'Z(:,' num2str(clist) '),Data.' CName{clist} '(Data.Speed<0),']; |
---|
| 112 | end |
---|
| 113 | end |
---|
| 114 | plot_string(end)=')'; |
---|
| 115 | eval(plot_string) |
---|
| 116 | legend(CName') |
---|
| 117 | htitle=title([Data.Experiment ', ' Data.FileName ', Time=' Data.DateTime ', conductivity probes']); |
---|
| 118 | set(htitle,'Interpreter','none')% desable tex interpreter |
---|
| 119 | xlabel('Z(cm)') |
---|
| 120 | ylabel(ylabelstring) |
---|
| 121 | grid on |
---|
| 122 | end |
---|
| 123 | % plot(Z,Data.C2(Data.Speed<0),Z,Data.C3(Data.Speed<0),Z,Data.C4(Data.Speed<0),Z,Data.C5(Data.Speed<0)) |
---|
| 124 | % legend({'C2';'C3';'C4';'C5'}) |
---|
| 125 | % title([Data.Experiment ', ' Data.FileName ', Time=' Data.DateTime ', profiles conductivity probes']) |
---|
| 126 | % xlabel('Z(cm)') |
---|
| 127 | % %ylabel('signal (Volt)') |
---|
| 128 | % ylabel(ylabelstring) |
---|
| 129 | % grid on |
---|
| 130 | |
---|
| 131 | |
---|
| 132 | % set(3,'name','profiles') |
---|
| 133 | % PositionMin=1; %position of probes at the bottom (Z=1 cm) |
---|
| 134 | % Data.Position=Data.Position-min(Data.Position)+PositionMin; |
---|
| 135 | % Z=Data.Position(Data.Speed<0); |
---|
| 136 | % plot(Z,Data.C2(Data.Speed<0),Z,Data.C5(Data.Speed<0),Z,Data.C6(Data.Speed<0)) |
---|
| 137 | % legend({'C2';'C5';'C6'}) |
---|
| 138 | % title([Data.Experiment ', ' Data.FileName ', Time=' Data.DateTime ', profiles conductivity probes']) |
---|
| 139 | % xlabel('Z(cm)') |
---|
| 140 | % %ylabel('signal (Volt)') |
---|
| 141 | % ylabel(ylabelstring) |
---|
| 142 | % grid on |
---|
| 143 | |
---|
| 144 | end |
---|
| 145 | |
---|
| 146 | |
---|
| 147 | |
---|
| 148 | |
---|
| 149 | %% plot temperature signals |
---|
| 150 | % figure(4) |
---|
| 151 | % set(4,'name','temperature') |
---|
| 152 | % plot(Data.Time,Data.T2,Data.Time,Data.T5,Data.Time,Data.T6) |
---|
| 153 | % legend({'T2';'T5';'T6'}) |
---|
| 154 | % title([Data.Experiment ', ' Data.FileName ', Time=' Data.DateTime ', signal conductivity probes']) |
---|
| 155 | % xlabel('Time(s)') |
---|
| 156 | % ylabel('signal (Volt)') |
---|
| 157 | % grid on |
---|
| 158 | |
---|
| 159 | %% plot velocity (ADV) signals |
---|
| 160 | % figure(5) |
---|
| 161 | % set(5,'name','velocity') |
---|
| 162 | % plot(Data.Time,Data.ADV_X,Data.Time,Data.ADV_Y,Data.Time,Data.ADV_Z1,Data.Time,Data.ADV_Z2) |
---|
| 163 | % legend({'ADV_X';'ADV_Y';'ADV_Z1';'ADV_Z2'}) |
---|
| 164 | % title([Data.Experiment ', ' Data.FileName ', Time=' Data.DateTime ', signal velocity']) |
---|
| 165 | % xlabel('Time(s)') |
---|
| 166 | % ylabel('signal (Volt)') |
---|
| 167 | % grid on |
---|
| 168 | |
---|
| 169 | %% plot velocity interface signals |
---|
| 170 | % figure(6) |
---|
| 171 | % set(6,'name','interface') |
---|
| 172 | % plot(Data.Time,Data.I1,Data.Time,Data.I2,Data.Time,Data.I3,Data.Time,Data.I4) |
---|
| 173 | % legend({'I1';'I2';'I3';'I4'}) |
---|
| 174 | % title([Data.Experiment ', ' Data.FileName ', Time=' Data.DateTime ', signal interface (ultrasound)']) |
---|
| 175 | % xlabel('Time(s)') |
---|
| 176 | % ylabel('signal (Volt)') |
---|
| 177 | % grid on |
---|
| 178 | |
---|
| 179 | |
---|