
sonic_data=[];

    
fclose('all');

clear st1;clear st2;clear st3;clear jadson;
fclose all;
   
    ddd=[num2str(dd)];
    if dd <10
       ddd=['0' num2str(dd)];
    end;
   
       hr=[num2str(hhh)];
    if hhh <10
       hr=['0' num2str(hhh)];
    end;
    
    mmm=[num2str(mm)];
    if mm<10
    mmm=['0' num2str(mm)];
    end;
    
    yyy=[num2str(yy)];
    if yy<10
    yyy=['0' num2str(yy)];
    end;
   
    minute=num2str(minu);
    if minu<10
    minute=['0' num2str(minu)];
    end;
    
         
        sonic_imp=importdata([path, '\Sonic\sonic_', yyy,'-', mmm, '-' , ddd, '_' , hr , minute ,'.lvm']);
        sonic_data=[sonic_data; sonic_imp];
        disp(['sonic_', yyy,'-', mmm, '-', ddd, '_' ,hr , minute]);
   
time=sonic_data(:,1);
timebase=time-time(1);
u=sonic_data(:,2)/100;
v=sonic_data(:,3)/100;
w=sonic_data(:,4)/100;
speedson=sonic_data(:,5)/50;        %speed of sound


if length(w)>36000
   time_real=0:0.1:3599.9;
   w_real=interp1(timebase,w,time_real','nearest');
   v_real=interp1(timebase,v,time_real','nearest');
   u_real=interp1(timebase,u,time_real','nearest');
   speedson_real=interp1(timebase,speedson,time_real','nearest');
end;

Tsonic=(speedson.*speedson+(u.*u + w.*w)/2. + v.*v)/403-273.15;
U=-u*cos(30/180*pi)-v*sin(30/180*pi);		     	%to North
V=-u*sin(30/180*pi)+v*cos(30/180*pi);  		   %to West
S=sqrt(u.*u+v.*v+w.*w);
dir=atan2(-V,U)*180/pi+180;		%jeff coordinates, +boward, +portward, 180 means wind from
dir=mod(dir+720,360);
%np=jhold;


wmean=tenminmeanTS(w_real,10,10);  




