function [uvw]=sonic_f(sonics,omegam,euler,uvwplat,R)
%
% CORRECT SONIC ANEMOMETER COMPONENTS FOR PLATFORM MOTION AND ORIENTATION.
%
% INPUTS:
%
%    Sonics     - row of integers corre to sonic numbers which are to be 
%	  	  corrected
%    omegam     - (3XN) measured angular rate 'vector' in platform frame
%    euler      - (3XN) array of euler angles (phi, theta, psi)
%    uvwplat    - (3XN) array of platform velocities (output from accels_.m)
% 
% OUTPUTS:
%
%    uvw        - (MXN) array of corrected sonic anemometer components, in the 
% 		            fixed earth reference frame  (North-West-up)
%
% CALCULATE WINDS IN EARTH BASED FRAME. THE ANGULAR VELOCITY IS CALCULATED AS
% THE CROSS PRODUCT BETWEEN THE ANGULAR RATE VECTOR AND POSITION VECTOR.THE 
% MEASURED AND ANGULAR VELOCITIES ARE IN THE PLATFORM FRAME AND MUST BE
% ROTATED INTO THE EARTH FRAME. THE PLATFORM VELOCITY IS ALREADY IN THE EARTH
% FRAME (FROM ACCELS.M), SO HERE THEY CAN JUST BE ADDED.
%
%  UVW =  MEASURED VELOCITY + ANGULAR RATE INDUCED VELOCITIES + 
%	  INTEGRATED ACCELEROMETERS  

R = [R(1); R(2); R(3)] * ones(1,length(sonics));

uvw = neaqs_trans( sonics + cross(omegam,R) ,euler,0);

%uvw(1,:)=uvw(1,:) + uvwplat(1,:) ;
%uvw(2,:)=uvw(2,:) + uvwplat(2,:) ;
%uvw(3,:)=uvw(3,:) + uvwplat(3,:) ;

%uvw(3,1:length(uvw(3,:))-5)=uvw(3,1:length(uvw(3,:))-5)+uvwplat(3,6:length(uvw(3,:)));
%uvw(3,length(uvw(1,:))-4:length(uvw(1,:)))=uvw(3,length(uvw(1,:))-4:length(uvw(1,:)))+uvwplat(3,length(uvw(1,:))-4:length(uvw(1,:)));