%function: netcdf_ecco_GenericgridMat2Nc %object: complete an "ECCO format" data set with interpolation information %author: Gael Forget (gforget@mit.edu) %date: June 12th, 2007 % %inputs: an "ECCO format" data set and associated mat files generated by netcdf_ecco_GenericgridMatFirstStep %output: an "ECCO format" data set specific to a chosen grid function []=netcdf_ecco_GenericgridMat2Nc(file_data,rep_data,rep_mat,rep_out); [depth,myvars,prof_descr,mystruct,mystruct1D]=netcdf_ecco_read(rep_data,file_data); tmp_name=findstr(file_data,'.nc'); tmp_name=file_data(1:tmp_name(end)-1); eval(['files_list=ls('' -1 ' rep_mat tmp_name '_4mygrid.*.mat '');']); tmp1=files_list; tmp2=strfind(files_list,rep_mat)+length(rep_mat); tmp3=strfind(files_list,'.mat')+3; files_list=''; for tmp4=1:length(tmp2); files_list=strvcat(files_list, tmp1(tmp2(tmp4):tmp3(tmp4)) ); end for icur=1:size(files_list,1) eval(['load ' rep_mat deblank(files_list(icur,:)) ';']); if icur==1; prof_interp_XC11_all=prof_interp_XC11; prof_interp_YC11_all=prof_interp_YC11; prof_interp_XCNINJ_all=prof_interp_XCNINJ; prof_interp_YCNINJ_all=prof_interp_YCNINJ; prof_interp_i_all=prof_interp_i; prof_interp_j_all=prof_interp_j; prof_interp_lon_all=prof_interp_lon; prof_interp_lat_all=prof_interp_lat; prof_interp_weights_all=prof_interp_weights; else tmp1=find(~isnan(prof_interp_XC11)); prof_interp_XC11_all(tmp1)=prof_interp_XC11(tmp1); prof_interp_YC11_all(tmp1)=prof_interp_YC11(tmp1); prof_interp_XCNINJ_all(tmp1)=prof_interp_XCNINJ(tmp1); prof_interp_YCNINJ_all(tmp1)=prof_interp_YCNINJ(tmp1); prof_interp_i_all(tmp1,:)=prof_interp_i(tmp1,:); prof_interp_j_all(tmp1,:)=prof_interp_j(tmp1,:); prof_interp_lon_all(tmp1,:)=prof_interp_lon(tmp1,:); prof_interp_lat_all(tmp1,:)=prof_interp_lat(tmp1,:); prof_interp_weights_all(tmp1,:)=prof_interp_weights(tmp1,:); end end tmp1=length(find(~isnan(prof_interp_XC11_all))); tmp2=length(prof_interp_XC11_all); fprintf([' \n\n => coeffs defined for ' num2str(tmp1) ' profiles out of ' num2str(tmp2) ' \n']); tmp3=find(isnan(prof_interp_XC11_all)); prof_interp_XC11_all(tmp3)=-9999; prof_interp_YC11_all(tmp3)=-9999; prof_interp_XCNINJ_all(tmp3)=-9999; prof_interp_YCNINJ_all(tmp3)=-9999; prof_interp_i_all(tmp3,:)=-9999; prof_interp_j_all(tmp3,:)=-9999; prof_interp_lon_all(tmp3,:)=-9999; prof_interp_lat_all(tmp3,:)=-9999; prof_interp_weights_all(tmp3,:)=-9999; mystruct1D=struct('prof_YYYYMMDD',mystruct1D.prof_YYYYMMDD,'prof_HHMMSS',mystruct1D.prof_HHMMSS,... 'prof_lon',mystruct1D.prof_lon,'prof_lat',mystruct1D.prof_lat,... 'prof_interp_XC11',prof_interp_XC11_all,'prof_interp_YC11',prof_interp_YC11_all,... 'prof_interp_XCNINJ',prof_interp_XCNINJ_all,'prof_interp_YCNINJ',prof_interp_YCNINJ_all... ); mystruct4mygrid=struct('prof_interp_i',prof_interp_i_all,... 'prof_interp_j',prof_interp_j_all,... 'prof_interp_lon',prof_interp_lon_all,... 'prof_interp_lat',prof_interp_lat_all,... 'prof_interp_weights',prof_interp_weights_all); file_characteristics=[length(mystruct1D.prof_lon) 0 size(prof_descr,2) -9999]; netcdf_ecco_create([rep_out tmp_name '_4mygrid.nc'], file_characteristics, depth, ... prof_descr, mystruct, mystruct1D,mystruct4mygrid); fprintf([rep_out tmp_name '_4mygrid.nc written \n']);