%function: netcdf_ecco_create %object: create netcdf data files in the "MIT format" %author: Gael Forget (gforget@mit.edu) %date: Apr 17th, 2006 % %main inputs: (structure arrays) % mystruct1D=struct('prof_YYYYMMDD',prof_YYYYMMDD,'prof_HHMMSS',... % prof_HHMMSS, 'prof_lon',prof_lon,'prof_lat',prof_lat); % mystruct=struct('prof_T',prof_T,'prof_Tweight',prof_Tweight, etc ); % OR mystruct=struct('prof_T',prof_T,'prof_Tmask',prof_Tmask, etc ); % %other inputs: file_name, file_characteristics, depth (1D vector), prof_descr (texte) % file_characteristics(1)=total number of profiles % file_characteristics(2)=last profile written % if file_characteristics(2)==0 we create the file % file_characteristics(3)=length of the character description % file_characteristics(4)=missing_value % %asumptions about the inputs: % T is potential temperature, we do not use the missing value % but 0 for weight/mask (facilitate "cost" computation), % units are the standard ones (see the netcdf attributes) % %usage: see netcdf_postprocess_argoctd.m, netcdf_ecco_recompose.m % %Gael, June 7th 1007: I add the option to write interpolation information % assumption: varargin is mystructInterp (i,j,weights), while % XC11 etc. have been added to mystruct1D %Left for later: genericity (read/compute dim4mygrid), additional info about interp stuff function []=netcdf_ecco_create(file_name, file_characteristics, depth, prof_descr, mystruct, mystruct1D,varargin); %a couple of checks: tmp1=length(mystruct1D.prof_lon); if (file_characteristics(2)+tmp1>file_characteristics(1)); fprintf('problem: total number of profiles exceeded \n'); fprintf('writing aborted'); return; end; if (file_characteristics(3)0); prof_descr=[prof_descr char(double(' ')*ones(length(tmp1'),tmp2)) ]; end; fcdf{'prof_descr'}(tmp1',:)=prof_descr(:,:); if incl4mygrid; fcdf{'prof_interp_XC11'}(tmp1')=mystruct1D.prof_interp_XC11; fcdf{'prof_interp_YC11'}(tmp1')=mystruct1D.prof_interp_YC11; fcdf{'prof_interp_XCNINJ'}(tmp1')=mystruct1D.prof_interp_XCNINJ; fcdf{'prof_interp_YCNINJ'}(tmp1')=mystruct1D.prof_interp_YCNINJ; fcdf{'prof_interp_i'}(tmp1',:)=varargin{1}.prof_interp_i; fcdf{'prof_interp_j'}(tmp1',:)=varargin{1}.prof_interp_j; fcdf{'prof_interp_lon'}(tmp1',:)=varargin{1}.prof_interp_lon; fcdf{'prof_interp_lat'}(tmp1',:)=varargin{1}.prof_interp_lat; fcdf{'prof_interp_weights'}(tmp1',:)=varargin{1}.prof_interp_weights; end %fill the data matrices : if isfield(mystruct,'prof_T'); fcdf{'prof_T'}(tmp1',:)=mystruct.prof_T; end; if isfield(mystruct,'prof_Tweight'); fcdf{'prof_Tweight'}(tmp1',:)=mystruct.prof_Tweight; end; if isfield(mystruct,'prof_Tmask'); fcdf{'prof_Tmask'}(tmp1',:)=mystruct.prof_Tmask; end; if isfield(mystruct,'prof_S'); fcdf{'prof_S'}(tmp1',:)=mystruct.prof_S; end; if isfield(mystruct,'prof_Sweight'); fcdf{'prof_Sweight'}(tmp1',:)=mystruct.prof_Sweight; end; if isfield(mystruct,'prof_Smask'); fcdf{'prof_Smask'}(tmp1',:)=mystruct.prof_Smask; end; if isfield(mystruct,'prof_U'); fcdf{'prof_U'}(tmp1',:)=mystruct.prof_U; end; if isfield(mystruct,'prof_Uweight'); fcdf{'prof_Uweight'}(tmp1',:)=mystruct.prof_Uweight; end; if isfield(mystruct,'prof_Umask'); fcdf{'prof_Umask'}(tmp1',:)=mystruct.prof_Umask; end; if isfield(mystruct,'prof_V'); fcdf{'prof_V'}(tmp1',:)=mystruct.prof_V; end; if isfield(mystruct,'prof_Vweight'); fcdf{'prof_Vweight'}(tmp1',:)=mystruct.prof_Vweight; end; if isfield(mystruct,'prof_Vmask'); fcdf{'prof_Vmask'}(tmp1',:)=mystruct.prof_Vmask; end; if isfield(mystruct,'prof_ptr'); fcdf{'prof_ptr'}(tmp1',:)=mystruct.prof_ptr; end; if isfield(mystruct,'prof_ptrweight'); fcdf{'prof_ptrweight'}(tmp1',:)=mystruct.prof_ptrweight; end; if isfield(mystruct,'prof_ptrmask'); fcdf{'prof_ptrmask'}(tmp1',:)=mystruct.prof_ptrmask; end; if isfield(mystruct,'prof_ssh'); fcdf{'prof_ssh'}(tmp1',:)=mystruct.prof_ssh; end; if isfield(mystruct,'prof_sshweight'); fcdf{'prof_sshweight'}(tmp1',:)=mystruct.prof_sshweight; end; if isfield(mystruct,'prof_sshmask'); fcdf{'prof_sshmask'}(tmp1',:)=mystruct.prof_sshmask; end; %close the file fcdf=close(fcdf);