/[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.5 - (hide annotations) (download)
Wed Jan 5 20:01:31 2011 UTC (14 years, 6 months ago) by gforget
Branch: MAIN
Changes since 1.4: +8 -0 lines
to accomodate old files:
	fix old 'depth' name convention
	fix lon>180

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 gforget 1.5 %fix old name convention:
44     if ii==1&isempty(prof_depth); ncload([dirIn tmp1.name],'depth'); prof_depth=depth; clear depth; end;
45    
46 gforget 1.4 if ii==1; eval(['MITprof=struct(''prof_depth'',prof_depth);']);
47     elseif ~isempty(tmp1); eval(['MITprof.' list_vars_plus{ii} '=' list_vars_plus{ii} ';']);
48     end; eval(['clear ' list_vars_plus{ii} ']);']);
49 gforget 1.1 end;
50    
51 gforget 1.5 %make sure that lon is -180+180:
52     tmp_lon=MITprof.prof_lon;
53     tmp_lon(find(tmp_lon>180))=tmp_lon(find(tmp_lon>180))-360;
54     MITprof.prof_lon=tmp_lon;
55    

  ViewVC Help
Powered by ViewVC 1.1.22