/[MITgcm]/MITgcm_contrib/gael/profilesMatlabProcessing/profiles_IO_v2/MITprof_read.m
ViewVC logotype

Annotation of /MITgcm_contrib/gael/profilesMatlabProcessing/profiles_IO_v2/MITprof_read.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.4 - (hide annotations) (download)
Fri Nov 5 21:41:00 2010 UTC (14 years, 8 months ago) by gforget
Branch: MAIN
Changes since 1.3: +4 -8 lines
- make this work both with the legacy mexnc stuff (as before)
  and with the modern matlab native netcdf implementation.

1 gforget 1.1 %function: MITprof_read
2     %object: read netcdf data files in the "MIT format"
3     %author: Gael Forget (gforget@mit.edu)
4     %date: june 21th, 2006
5     %
6 gforget 1.3 %usage: [MITprof]=MITprof_read(fileIn);
7 gforget 1.1 % ---> loads full data set
8 gforget 1.3 % [MITprof]=MITprof_read(fileIn,list_vars);
9 gforget 1.1 % ---> loads only the files listed in list_vars cell
10     % array (e.g. list_vars={'prof_T','prof_Tweight'})
11     % plus the one dimensional information (prof_lon etc.)
12     %
13 gforget 1.3 %inputs: fileIn data file name
14     % list_vars variables list (optional)
15 gforget 1.1 %
16     %outputs: MITprof structure containing the various fields/vectors
17    
18 gforget 1.3 function [MITprof]=MITprof_read(fileIn,varargin);
19 gforget 1.1
20 gforget 1.3 if nargin>1; list_vars=varargin{1};
21 gforget 1.2 else; list_vars={'prof_T','prof_Tweight','prof_Tmask','prof_Testim','prof_Tflag',...
22     'prof_S','prof_Sweight','prof_Smask','prof_Sestim','prof_Sflag',...
23 gforget 1.1 'prof_U','prof_Uweight','prof_Umask',...
24     'prof_V','prof_Vweight','prof_Vmask',...
25     'prof_ptr','prof_ptrweight','prof_ptrmask',...
26     'prof_ssh','prof_sshweight','prof_sshmask'};
27     end;
28    
29     list_vars_plus=[{'prof_depth','prof_date','prof_YYYYMMDD','prof_HHMMSS',...
30     'prof_lon','prof_lat','prof_basin','prof_point','prof_descr'}...
31     list_vars];
32    
33 gforget 1.3 %get directory name:
34     tmp1=strfind(fileIn,'/');
35     if ~isempty(tmp1); dirIn=fileIn(1:tmp1(end)); else; dirIn='./'; end;
36     %check that file exists:
37     tmp1=dir(fileIn);
38     if isempty(tmp1); tmp1=dir([fileIn '.nc']); end;
39 gforget 1.1 if isempty(tmp1); error([fileIn ' file not found']); end;
40    
41     for ii=1:length(list_vars_plus);
42 gforget 1.4 ncload([dirIn tmp1.name],list_vars_plus{ii});
43     if ii==1; eval(['MITprof=struct(''prof_depth'',prof_depth);']);
44     elseif ~isempty(tmp1); eval(['MITprof.' list_vars_plus{ii} '=' list_vars_plus{ii} ';']);
45     end; eval(['clear ' list_vars_plus{ii} ']);']);
46 gforget 1.1 end;
47    

  ViewVC Help
Powered by ViewVC 1.1.22