[2]  1  %'raw2phys': transform raw signal to physical values using different calibrations laws


 2  %


 3  function FieldPhys=raw2phys(Field)


 4 


 5  % do not transform if Field already in phys coordinates


 6  FieldPhys=Field;%default


 7  if isfield(Field,'CoordType') & isequal(Field.CoordType,'phys')


 8  return %no transform if the data are already physical


 9  else


 10  FieldPhys.CoordType='phys';


 11  end


 12 


 13  %Filtering of the initial data


 14  nbfilter=51;


 15  nbhalf=floor(nbfilter/2);


 16  for ivar=1:length(FieldPhys.ListVarName)


 17  VarName=FieldPhys.ListVarName{ivar};


 18  if ~isequal(VarName,'time')


 19  eval(['FirstVal=FieldPhys.' VarName '(1);'])


 20  eval(['LastVal=FieldPhys.' VarName '(end);'])


 21  FirstVal=ones(nbhalf,1)*FirstVal;


 22  LastVal=ones(nbhalf,1)*LastVal;


 23  eval(['FieldPhys.' VarName '=[FirstVal;FieldPhys.' VarName ';LastVal];'])


 24  eval(['FieldPhys.' VarName '=conv(ones(1,nbfilter)/nbfilter,FieldPhys.' VarName ');']);


 25  eval(['FieldPhys.' VarName '([1:nbfilter1])=[];']);


 26  eval(['FieldPhys.' VarName '([endnbfilter+2:end])=[];']);


 27  end


 28  end


 29 


 30 


 31 


 32  ScanRate=240; %data points per second


 33  VelTranslation=1; % 1 cm/s A VERIFIER


 34  test_Offset=0;


 35  test_Thermistance_B=0;


 36  test_Thermistance_M=0;


 37  if isfield(Field,'ListVarAttribute')


 38  for ilist=1:length(Field.ListVarAttribute)


 39  attr_name=Field.ListVarAttribute{ilist}


 40  if isequal(attr_name,'PhysUnits')


 41  FieldPhys.units =Field.PhysUnits;


 42  end


 43  if isequal(attr_name,'Offset')


 44  test_Offset=1;


 45  end


 46  if isequal(attr_name,'ThermistanceCalib_B')


 47  test_Thermistance_B=1;


 48  end


 49  if isequal(attr_name,'ThermistanceCalib_M')


 50  test_Thermistance_M=1;


 51  end


 52  end


 53  end


 54 


 55 


 56 


 57  % substract offset


 58  if test_Offset


 59  for ivar=1:length(Field.ListVarName)


 60  Val_Offset=Field.Offset{ivar};


 61  if isnumeric(Val_Offset)&~isempty(Val_Offset)


 62  VarName=Field.ListVarName{ivar};


 63  eval(['FieldPhys.' VarName '=FieldPhys.' VarName 'Val_Offset;'])


 64  end


 65  end


 66  end


 67 


 68  %thermistance calibration


 69  if test_Thermistance_M & test_Thermistance_B


 70  for ivar=1:length(Field.ListVarName)


 71  Val_B=Field.ThermistanceCalib_B{ivar};


 72  Val_M=Field.ThermistanceCalib_M{ivar};


 73  if isnumeric(Val_B) & ~isempty(Val_B) & isnumeric(Val_M) & ~isempty(Val_M)


 74  VarName=Field.ListVarName{ivar};


 75  eval(['FieldPhys.' VarName '=(Val_M ./ (log( FieldPhys.' VarName ')Val_B)) 273.15;'])


 76  end


 77  end


 78  end


 79  return


 80 


 81  %NON USED


 82  %density profile


 83  Density=(ConductivityB)/A;%calibration


 84  Density=Density(find(Motor>1));%restrict the record to the time motor on


 85  Density=flipdim(Density,2)';


 86  %detect free surface


 87  [dmax,imax]=max(diff(Density));


 88  nbpoints=length(Density);


 89  Pos=linspace(0,nbpoints*VelTranslation/ScanRate,nbpoints);


 90  Pos=Posimax*VelTranslation/ScanRate;


 91 


 92  %[dmax,jmax]=max(diff(Conductivity))


 93  napoints=length(Conductivity);


 94  Pos1=linspace(0,napoints*VelTranslation/ScanRate,napoints);


 95  %Pos1=Pos1jmax*VelTranslation/ScanRate;


 96 


 97  figure(2);


 98  clf


 99  plot(Pos1,Conductivity)


 100  grid on


 101  figure(3);


 102  size(Pos)


 103  size(Density)


 104  plot(Pos,Density)


 105  hold on


 106  grid on


 107  %determination of N


 108  PosCentr=Pos([floor(nbpoints/4):floor(3*nbpoints/4)]);


 109  DensityCentr=Density([floor(nbpoints/4):floor(3*nbpoints/4)]);


 110  p=polyfit(PosCentr,DensityCentr,1);


 111  LinDens=polyval(p,PosCentr);


 112  plot(PosCentr,LinDens,'r')


 113  grad=p(1)


 114  %find(Motor>1)


 115 


 116  % data.conductivity=flipdim(Conductivity(find(Motor>5)),1)';


 117  % data.deplacement=[100/size(data.conductivity,2):100/size(data.conductivity,2):100];


 118  %


 119  % figure;plot(data.deplacement,data.conductivity);hold on;


 120 


 121  %data.density=flipdim(Conductivity(find(Motor>1)),1)'*3.4764+15.1367;


 122  %data.density=flipdim(Conductivity(find(Motor>1)),2)'*5+14.6090;


 123  %data.density=flipdim(Conductivity(find(Motor>1)),2)'*4.1525+19.50;


 124  % data.density=flipdim(Conductivity(find(Motor>1)),2)'


 125  % data.deplacement=[92/size(data.density,2):92/size(data.density,2):92];


 126  % figure(101)


 127  % plot(data.deplacement,data.density);hold on;


 128 


 129  % t=data.deplacement(find(data.deplacement>20&data.deplacement<80));


 130  %t=data.deplacement(find(data.deplacement>0&data.deplacement<90));


 131  % X=[ones(size(t,2),1)';t];


 132  % Y=data.density(find(data.deplacement>20&data.deplacement<80));


 133  % %Y=data.density(find(data.deplacement>0&data.deplacement<90));


 134  % coeff=Y/X;


 135 


 136  % plot(data.deplacement,data.deplacement*coeff(2)+coeff(1),'r');


 137 


 138  % grad=abs(coeff(2)*100)


 139  Tbv=2*pi/sqrt(981*0.001*grad)


 140  N=2*pi/Tbv


 141  title(strcat('',name,''))


 142  xpos=get(gca,'XLim')


 143  ypos=get(gca,'YLim')


 144  %xtext=xpos(1)+(xpos(2)xpos(1))*3/4


 145  xtext=xpos(1)+(xpos(2)xpos(1))/2


 146  ytext=ypos(1)+(ypos(2)ypos(1))/4


 147  TabText={strcat('Tbv : ',num2str(Tbv),'s'); strcat('Stratification : ',num2str(grad)); strcat('N : ',num2str(2*pi/Tbv),'rad.s1')}


 148  text(xtext,ytext,TabText)


 149  % text(xtext,13,strcat('Tbv : ',num2str(Tbv),'s'));


 150  % text(55,10,strcat('Stratification : ',num2str(grad)));


 151  % text(55,16,strcat('N : ',num2str(2*pi/Tbv),'rad.s1'));

