function [x_3dgrid,y_3dgrid,z_3dgrid, u_inst,v_inst,  w_inst, u_mean, v_mean, w_mean, tke] = tke_model2(input_data)
% enter cell array input_data with number_of_file to include in the mean
% enter cell array with the file number of the file2process the tke, path and file_number to read')

number_of_file=input_data.number_of_file
file2process=input_data.file2process
path0=(['C:\Documents and Settings\sylvie.lorsolo\My Documents\research\HRD research\',input_data.path1]); 
filename=dir([path0,'\*.nc']);
u_mean=zeros(297,297,34);
v_mean=zeros(297,297,34);
w_mean=zeros(297,297,34);
% tempu=[];
% tempv=[];
% tempw=[];
milieu=fix(number_of_file/2);
for fil=(file2process-milieu):(file2process+milieu)
    input_data.file_number=fil;
    [x_3dgrid,y_3dgrid,z_3dgrid,u_grid,v_grid,w_grid, XLAT,XLONG]=wrf_windfield(input_data);
    
    if fil==file2process
        u_inst=u_grid;
        v_inst=v_grid;
        w_inst=w_grid;
        xlat=XLAT;
        xlong=XLONG;
    end
    
    u_mean=u_grid + u_mean;
    v_mean=v_grid + v_mean;
    w_mean=w_grid + w_mean;

end

u_mean=u_mean/number_of_file;
v_mean=v_mean/number_of_file;
w_mean=w_mean/number_of_file;

u_prime = u_inst - u_mean;
v_prime = v_inst - v_mean;
w_prime = w_inst - w_mean;

tke=0.5*(u_prime.^2 + v_prime.^2 + w_prime.^2);%((std(tempu))^2 + (std(tempv))^2 +(std(tempw))^2 );


