Vous êtes ici : Accueil / Alexandre Ganachaud / xbt / cmpxbttsg / read_tsgxbt_tsv.m

read_tsgxbt_tsv.m

Par Webmaster Legos Dernière modification 04/07/2012 16:37

Objective-C source code icon read_tsgxbt_tsv.m — Objective-C source code, 2 kB (2612 bytes)

Contenu du fichier

clear
fclose all
cd /export/home/ganacho/XBT
fid=fopen('Data2/xbt_thermo.tsv')
lhdr=fgetl(fid)

%num line,CODE_TH,NUMVOYAGE,DATE_TH,LAT_TH,LON_TH,SST,CODE_XBT,LAT_XBT,LON_XBT,PROF,TEMP,CODE_TIR
%curline=fgetl(fid)
ii=0;iship=0;
thnoline=fscanf(fid,'%i',1);
while ~isempty(thnoline)
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %READ THERMO
  thshipid=fscanf(fid,'%s',1);
  thcode=fscanf(fid,'%i',1);
  mydate= fscanf(fid,'%s',1);
  mytime= fscanf(fid,'%s',1);
  thdate = datenum(str2num(mydate(1:4)),str2num(mydate(6:7)),...
    str2num(mydate(9:10)),str2num(mytime(1:2)),...
    str2num(mytime(4:5)),str2num(mytime(7:8)));
  thlat= fscanf(fid,'%f',1);
  thlon= fscanf(fid,'%f',1);
  thsst= fscanf(fid,'%f',1);
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %READ XBT
  xshipid=fscanf(fid,'%s',1);
  mydate= fscanf(fid,'%s',1);
  mytime= fscanf(fid,'%s',1);
  xdate = datenum(str2num(mydate(1:4)),str2num(mydate(6:7)),...
    str2num(mydate(9:10)),str2num(mytime(1:2)),...
    str2num(mytime(4:5)),str2num(mytime(7:8)));
  xlat= fscanf(fid,'%f',1);
  xlon= fscanf(fid,'%f',1);
  xdep= fscanf(fid,'%f',1);
  xsst= fscanf(fid,'%f',1);
  xtirid= fscanf(fid,'%i',1);
  if ~strcmp(thshipid,xshipid)
    error('not same ships!')
  end
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  %FILL XBT FIRE ARRAY
  if iship==0 | ~strcmp(thshipid,thxbt(iship).shipid)
    %NEW SHIP
    iship=iship+1;
    ii=0;
    thxbt(iship).shipid=thshipid;
    disp(['New Ship ' thshipid ' line ' num2str(thnoline)]);
    %ppause
  end
  if ii==0 | (xtirid~=thxbt(iship).xbt(ii).xtirid)
    %NEW XBT FIRE
    if 0
      disp(sprintf('%6s %6i %s %6.4g %7.4g %6.4g',...
	thshipid,thcode,datestr(thdate),...
	thlat,thlon,thsst));
      disp(sprintf('%6s %6i %s %6.4g %7.4g %6.4g %6.4g',...
	xshipid,xtirid,datestr(xdate),...
	xlat,xlon,xsst,xdep));
    end
    ii=ii+1;
    thxbt(iship).thg(ii).thcode=thcode;
    thxbt(iship).thg(ii).thdate=thdate;
    thxbt(iship).thg(ii).thlat=thlat;
    thxbt(iship).thg(ii).thlon=thlon;
    thxbt(iship).thg(ii).thsst=thsst;
    thxbt(iship).xbt(ii).xtirid=xtirid;
    thxbt(iship).xbt(ii).xdate=xdate;
    thxbt(iship).xbt(ii).xlat=xlat;
    thxbt(iship).xbt(ii).xlon=xlon;
    thxbt(iship).xbt(ii).xsst=xsst;
    thxbt(iship).xbt(ii).xdep=xdep;
    idep=1;
  else
    %STORE ONLY XBT T/Dep DATA
    idep=idep+1;
    thxbt(iship).xbt(ii).xsst(idep)=xsst;
    thxbt(iship).xbt(ii).xdep(idep)=xdep;
    %disp(sprintf('%i %6.4g %6.4g',thnoline, xsst, xdep))
  end
  thnoline=fscanf(fid,'%i',1);
end
save Data1/thxbt.mat thxbt

Actions sur le document

logo cnes logo IRD Logo université de Toulouse Logo université Paul Sabatier Logo CNRS
Logo bibliothèque OBS Logo Observatoire Midi Pyrénées