/[MITgcm]/MITgcm/verification/flt_example/input/read_flt_traj.m
ViewVC logotype

Annotation of /MITgcm/verification/flt_example/input/read_flt_traj.m

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


Revision 1.5 - (hide annotations) (download)
Wed Feb 25 01:41:00 2009 UTC (15 years, 4 months ago) by dfer
Branch: MAIN
CVS Tags: checkpoint62c, checkpoint62a, checkpoint62g, checkpoint62f, checkpoint62e, checkpoint62d, checkpoint62k, checkpoint62j, checkpoint62i, checkpoint62h, checkpoint62o, checkpoint62n, checkpoint62m, checkpoint62l, checkpoint62s, checkpoint62r, checkpoint62q, checkpoint62p, checkpoint62w, checkpoint62v, checkpoint62u, checkpoint62t, checkpoint62z, checkpoint62y, checkpoint62x, checkpoint62, checkpoint63, checkpoint63h, checkpoint63i, checkpoint63d, checkpoint63e, checkpoint63f, checkpoint63g, checkpoint63a, checkpoint63b, checkpoint63c, checkpoint62b, checkpoint61n, checkpoint61q, checkpoint61z, checkpoint61o, checkpoint61l, checkpoint61m, checkpoint61j, checkpoint61k, checkpoint61v, checkpoint61w, checkpoint61t, checkpoint61u, checkpoint61r, checkpoint61s, checkpoint61p, checkpoint61x, checkpoint61y
Changes since 1.4: +5 -5 lines
Remove tabs

1 adcroft 1.1 function [flt,data,header] = read_flt_traj(fName)
2     % Reads the float_trajectories files.
3     %
4     % returns a structured array with fields 'time','x','y','k','u','v','t','s','p'
5     %
6     % eg.
7     % >> flts=read_flt_traj('float_trajectories');
8     % >> plot( flts(3).time, flts(3).x/1e3 )
9     % >> for k=1:126;plot(flts(k).x/1e3,flts(k).y/1e3);hold on;end;hold off
10    
11 dfer 1.5 % $Header: /u/gcmpack/MITgcm/verification/flt_example/input/read_flt_traj.m,v 1.4 2009/02/05 01:03:33 jmc Exp $
12 jmc 1.3 % $Name: $
13    
14 dfer 1.5 imax=13; % record size
15     ieee='b'; % IEEE big-endian format
16     bytesPerRec=imax*8; % 8 bytes per real*8
17 adcroft 1.1
18 jmc 1.3 [I]=strfind(fName,'/');
19     if length(I) == 0,
20     bDr='';
21     else
22     fprintf(' found Dir Sep in file name (');
23 dfer 1.5 fprintf(' %i',I);
24 jmc 1.3 bDr=fName(1:I(end));
25     fprintf(' ) ; load files from Dir "%s"\n',bDr);
26     end
27    
28     fls=dir([fName,'.*data']);
29 adcroft 1.1
30     data=zeros(imax,0);
31     header=zeros(imax,0);
32    
33     % Read everything
34     for k=1:size(fls,1)
35 jmc 1.3 fid=fopen([bDr,fls(k).name],'r',ieee);
36     %fprintf('fid= %i\n',fid);
37 adcroft 1.1 nrecs=fls(k).bytes/bytesPerRec;
38     ldata=fread(fid,[imax nrecs],'real*8');
39     fclose(fid);
40     header=[header ldata(:,1)];
41     data=[data ldata(:,2:end)];
42     end
43    
44 jmc 1.4 flt=struct('numsteps',[],'time',[],'x',[],'y',[],'z',[]);
45 adcroft 1.1
46     % Sort it all out
47     for k=1:max(max(data(1,:)));
48     j=find( data(1,:)==k );
49     [t,jj]=sort( data(2,j) ); j=j(jj);
50     flt(k).time=data(2,j);
51 jmc 1.4 flt(k).x=data( 3,j);
52     flt(k).y=data( 4,j);
53     flt(k).z=data( 5,j);
54     flt(k).i=data( 6,j);
55     flt(k).j=data( 7,j);
56     flt(k).k=data( 8,j);
57     flt(k).p=data( 9,j);
58     flt(k).u=data(10,j);
59     flt(k).v=data(11,j);
60     flt(k).t=data(12,j);
61     flt(k).s=data(13,j);
62 adcroft 1.1 end

  ViewVC Help
Powered by ViewVC 1.1.22