Home > utilities > readzetUBVB.m

readzetUBVB

PURPOSE ^

program to read POLCOMS output bin files dailymean

SYNOPSIS ^

function [data]=readzetUBVB(opts,daysf)

DESCRIPTION ^

 program to read POLCOMS output bin files dailymean
 create file used next in many matlab file
 output matrix  only
 periode 1 for 'janjun' 2 for 'juldec'
 function [u,v,tmp,sal]=readUVT()
 opts = opts.outputfolder;opts.inputfolder;opt.RUN etc
 chose if we had outputed the Vertical velocity, the TKE and the WA of
 polcoms
 variables=1 if they are outputed
 variables=0 otherwise
 outputfolder='/users/modellers/rito/research/Projects/ECOOP/WEC_V0.2/yr2/'
 inputfolder='/users/modellers/rito/research/Projects/ECOOP/WEC_V0.2/yr2/'

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % program to read POLCOMS output bin files dailymean
0002 % create file used next in many matlab file
0003 % output matrix  only
0004 % periode 1 for 'janjun' 2 for 'juldec'
0005 % function [u,v,tmp,sal]=readUVT()
0006 % opts = opts.outputfolder;opts.inputfolder;opt.RUN etc
0007 function [data]=readzetUBVB(opts,daysf)
0008 % chose if we had outputed the Vertical velocity, the TKE and the WA of
0009 % polcoms
0010 % variables=1 if they are outputed
0011 % variables=0 otherwise
0012 % outputfolder='/users/modellers/rito/research/Projects/ECOOP/WEC_V0.2/yr2/'
0013 % inputfolder='/users/modellers/rito/research/Projects/ECOOP/WEC_V0.2/yr2/'
0014 readf=opts.zetUVfile;
0015 LEV=opts.PolcomsLevs;
0016 zet=[];u=[];v=[];
0017 %fid is for the input file
0018 readf
0019 fid=fopen(readf,'r','n');
0020 dump= fread(fid,1,'int32');
0021 l= fread(fid,1,'int32')
0022 m= fread(fid,1,'int32')
0023 n= fread(fid,1,'int32')
0024 npsea= fread(fid,1,'int32');
0025 dump = fread(fid,2,'int32');
0026 isea= fread(fid,npsea,'int32');
0027 dump = fread(fid,2,'int32');
0028 jsea= fread(fid,npsea,'int32');
0029 dump = fread(fid,2,'int32');
0030 
0031 l= fread(fid,1,'int32');
0032 m= fread(fid,1,'int32');
0033 n= fread(fid,1,'int32');
0034 npusea= fread(fid,1,'int32');
0035 dump = fread(fid,2,'int32');
0036 iusea= fread(fid,npusea,'int32');
0037 dump = fread(fid,2,'int32');
0038 jusea= fread(fid,npusea,'int32');
0039 dump = fread(fid,2,'int32');
0040 hfb = ftell(fid)
0041 for jk=1:daysf
0042     %         read from  the binary file
0043     %          hfb_old = ftell(fid)
0044     u=nan*ones(l,m);
0045     v=nan*ones(l,m);
0046     zet=nan*ones(l,m);
0047     
0048     itimt4 =fread(fid,1,'int32');disp(['Day :',num2str(jk)]);
0049     dump = fread(fid,2,'int32');
0050     dumpzet = fread(fid,[npsea],'float32')';
0051     dump = fread(fid,2,'int32');
0052     dumpu = fread(fid,[npusea],'float32')';
0053     dump = fread(fid,2,'int32');
0054     dumpv = fread(fid,[npusea],'float32')';
0055     dump = fread(fid,2,'int32');
0056     for i=1:npusea
0057         u(iusea(i),jusea(i))=dumpu(i);
0058         v(iusea(i),jusea(i))=dumpv(i);
0059     end
0060     for i=1:npsea
0061         zet(isea(i),jsea(i))=dumpzet(i);
0062     end
0063     %         print in the matlab file
0064     if isfield(opts,'PolcomsPoints') && ~isempty(opts.PolcomsPoints)
0065         
0066         data.zet(jk,:) = zet(sub2ind(size(v),opts.PolcomsPoints(:,1),opts.PolcomsPoints(:,2)));
0067         data.ub(jk,:) = u(sub2ind(size(v),opts.PolcomsPoints(:,1),opts.PolcomsPoints(:,2)));
0068         data.vb(jk,:) = v(sub2ind(size(v),opts.PolcomsPoints(:,1),opts.PolcomsPoints(:,2)));
0069         
0070     else
0071         data.zet(jk,:,:) = zet;
0072         data.ub(jk,:,:) = u;
0073         data.vb(jk,:,:) = v;
0074     end
0075     %      disp([ftell(fid),ftell(fid)-hfb_old])
0076 end
0077 fclose(fid);
0078 return

Generated on Wed 20-Feb-2019 16:06:01 by m2html © 2005