% Tidal Model Driver (TMD)
% Output harmonic constants and predict tides
%
close all; clear all;
w=what('TMD');funcdir=[w.path '/FUNCTIONS'];
path(path,funcdir);
fprintf('Welcome to TMD: Tidal Model Driver!\n');
fprintf('\n');
fprintf('TMD FILE NAME/FORMAT CONVENTION (MUST follow!):\n');
fprintf('1. TMD supports format of models downloaded from: ,\n');
fprintf(' http://volkov.oce.orst.edu/tides \n');
fprintf(' http://www.esr.org/polar_tides_models \n');
fprintf('2. Elevation file name should start from ''h''.\n');
fprintf('3. Transport file name should start from ''UV''.\n');
fprintf('4. Bathymetry grid file name should start from ''g''.\n');
fprintf('5. If grid is uniform in km string ''km'' should be found\n');
fprintf(' either in model file names or in grid file name.\n')';
fprintf('6. For any tidal model a control file starting from \n');
fprintf(' ''Model_*'' ib subdirectory TMD/DATA should be given. \n');
fprintf(' The file MUST contain 3 lines:\n');
fprintf(' <Elevaltion file name>\n');
fprintf(' <Transport file name>\n');
fprintf(' <Bathymetry grid file name>\n');
fprintf(' If the model files are NOT in TMD/DATA, exact path should be included.\n');
fprintf(' If the model files are in TMD/DATA, no path in file names is needed.\n');
fprintf(' If grid is uniform in km the NAME of function converting\n');
fprintf(' lat,lon to x,y and back should be provided in 4-th line, \n');
fprintf(' for example:''xy_ll'' for Arctic or ''xy_ll_S'' for Antarctic\n');
fprintf('\n');
%
curdir=pwd;
dir_check=exist('DATA','dir');
if(dir_check==0);
disp('Subdirectory DATA not found. You must navigate to');
disp('location of Model files from current directory.');
break
else
eval('cd DATA');
end
cfile=0;
[cfile,pname]=uigetfile('Model*','Open MODEL files listed in ');
if cfile==0,eval(['cd ' curdir]);break;end
CFname=[pname cfile];
fid=fopen(CFname,'r');
hfile=fgetl(fid);ufile=fgetl(fid);Gname=fgetl(fid);Fxy_ll=fgetl(fid);
fclose(fid);
eval(['cd ' curdir]);
%
if strcmp(hfile(1:4),'DATA')>0,
hfile=[curdir '/' hfile];
ufile=[curdir '/' ufile];
Gname=[curdir '/' Gname];
elseif isempty(findstr(hfile,'/'))>0 & isempty(findstr(hfile,'\'))>0,
% files are assumed to be in TMD/DATA
hfile=[curdir '/DATA/' hfile];
ufile=[curdir '/DATA/' ufile];
Gname=[curdir '/DATA/' Gname];
end
k=0;
% Check if the files exist
if exist(hfile,'file')==0,
fprintf ('File %s does NOT exist\n',hfile);k=1;
end
if exist(ufile,'file')==0,
fprintf ('File %s does NOT exist\n',ufile);k=1;
end
if exist(Gname,'file')==0,
fprintf ('File %s does NOT exist\n',Gname);k=1;
end
if k==1,
fprintf('Check control file: %s\n',CFname);
break
end
%
km=0;
ikm=findstr(hfile,'km');
if isempty(ikm)>0,ikm=findstr(ufile,'km');end
if isempty(ikm)>0,ikm=findstr(Gname,'km');end
if isempty(ikm)==0,km=1;end
if km==0, % new grid convention, dt<0->km
[sy_lims,H,mz,iob,dt]=grd_in(Gname);
if dt<0,km=1;end
end
if km==1,fprintf('The model is on uniform grid in km\n');
else fprintf('The model is on uniform grid in lat,lon\n');end
if km==1 & Fxy_ll==-1,
fprintf(' If grid is uniform in km the NAME of function converting\n');
fprintf(' lat,lon to x,y and back MUST be given in 4-th line of\n');
fprintf('%s\n',CFname);
fprintf('TMD exiting...\n');
break;close all
end
if km==0, Fxy_ll='Fdum';end
% define model name by comparing strings hfile and ufile
Mname=TMD_findMname(hfile,ufile);
k=findstr(CFname,'/');
if isempty(k)>0,k=findstr(CFname,'\');end % PC path names
if isempty(k)==0,
Mname=CFname(k(end)+7:end);
end
if exist('junk','dir')==0, mkdir junk;end
tmpFileName=['junk/tmp' Mname '.mat'];
%
nFig=0;nFig2=0;mode=1;
InFname='LAT_LON/lat_lon';
OutFname='OUT/data.out';
if exist(tmpFileName,'file')>0,
eval(['load ' tmpFileName]);
lat=lat0;lon=lon0;yy=yy0;mm=mm0;dd=dd0;hh=hh0;mi=mi0;nh=nh0;
if km==1,eval(['[x0,y0]=' Fxy_ll '(lon,lat,''F'');']);
else x0=lon;y0=lat;end
end
[conList]=rd_con(hfile);
[nc,dum]=size(conList);
np=6;
nb=nc+np;
nt=6;
bgCol=[.4,.4,.6];
icon=zeros(1,nc);icon(1)=1;
ipar=[1 0 0 0 0 0];ipar1=ipar;
XL=[];YL=[];XLP=[];YLP=[];
icz1=0;icu1=0;ice1=0;icp1=0;ik1=0;ipp1=0;
ic1=1;ik=1;arw='r';
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
figure(1);
fprintf('Loading TMD (Tidal Model Driver)...');
icpl=1;
TMD_fig1;
%
set(gcf,'numbertitle','off','menubar','none','name',...
['Tidal Model Driver Model:',Mname,...
' Programmed by: Lana Erofeeva, 2003-2010']);
fprintf('done\n');
fprintf('\n');
fprintf('See button tips for HELP.\n');
fprintf('Type ''help tmd_extract_HC'',''help tmd_tide_pred'', ''help tmd_ellipse'',\n');
fprintf('Type ''help tmd_get_coeff'',''help tmd_get_ellipse'',\n');
fprintf('if you wish to use the scripts instead of GUI.\n');
fprintf('Model and files are in %s\n and %s.\n',hfile,ufile);
fprintf('Bathymetry grid file is in %s.\n',Gname);
fprintf('Input file examples are in LAT_LON\n');
fprintf('\n');
fprintf('Programmed by: Lana Erofeeva: ');TMD_release;
fprintf('\n');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ax=p3(3);ay=p3(4);bh=0.8*ay/nb;
dh=0.2*ay/(nb-1);
bw=(0.98-0.04-(p3(1)+ax))/2;
ch=nc*bh+(nc-1)*dh+0.02;
% CONSTITUENT FRAME POSITION
pos0=[p3(1)+ax+0.02+bw, p3(2)+p3(4)-ch+0.015, bw+0.02,ch ];
%%%%%
% Buttons (right)
% CONSTITUENTS
vc=0;
Cfc=['vc=1-vc;if vc==1,icon=ones(nc,1);else ',...
'icon=zeros(nc,1);end;',...
'for k=1:nc,set(uc(k),''value'',icon(k));end;'];
fc=uicontrol('Style','pushbutton','units','normalized','position',pos0,...
'BackgroundColor',bgCol,'Callback',Cfc,...
'ToolTipString','Click on FRAME to Select/Unselect ALL');
pos=pos0;
pos(1)=pos0(1)+0.01;pos(2)=pos(2)+0.01;pos(3)=bw;pos(4)=bh;
Cbk1=['for k=1:nc,icon(nc-k+1)=get(uc(k),''value'');end;'];
%
if exist('poscf','var')==0,
poscf=pos;poscf(2)=poscf(2)+(nc-1)*(bh+dh);
poscf(1)=poscf(1)-5e-3;poscf(3)=poscf(3)+0.01;
poscf(2)=poscf(2)-5e-3;poscf(4)=poscf(4)+0.01;
poscf2=pos(2)-5e-3;bhdh=bh+dh;
icpl=1;
end
BDFcn=['icpl=icpl+1;if icpl>nc,icpl=icpl-nc;end;',...
'poscf(2)=poscf2+(nc-icpl)*bhdh;',...
'set(ucpf,''position'',poscf);if ik>1,TMD_fig1;end'];
ucpf=uicontrol('Style','Frame','units','normalized','position',poscf,...
'BackgroundColor','g','ToolTipString',...
'Constituent to plot: Right click to change');
%
for ic=1:nc
con=upper(conList(nc-ic+1,:));
BDFcn=['icpl=nc-',int2str(ic),'+1;',...
'poscf(2)=poscf2+(nc-icpl)*bhdh;',...
'set(ucpf,''position'',poscf);if ik>1,TMD_fig1;end'];
bdf1=int2str(ic);
uc(ic)=uicontrol('Style','radiobutton','units','normalized','position',pos,...
'string',con,'value',icon(nc-ic+1),'FontWeight','bold',...
'CallBack',Cbk1,'ToolTipString',...
'Left click to Select/Unselect, Right click to plot',...
'ButtonDownFcn',BDFcn);
pos(2)=pos(2)+(bh+dh);
end
% PARAMETERS
Cbk2=['for k=1:np,ipar(np-k+1)=get(upar(k),''value'');end;',...
'if mode==2 & ipar(6)==1,ipar=ipar1;end;dif=ipar-ipar1;',...
'if sum(dif)>0,ipar=zeros(1,np);ipar(min(find(dif~=0)))=1;ipar1=ipar;end;',...
'for k=1:np,set(upar(k),''value'',ipar(np-k+1));end;',...
'if ipar(6)==0,val1=get(uPl,''value'');',...
'if val1>3,set(uPl,''value'',3);end;set(uPl,''string'',sPl1);',...
'else set(uPl,''string'',sPl2);end;',...
'k=get(uPl,''value'');if k>1,TMD_fig1;end;'];
pname=['Ell';'v ';'u ';'V ';'U ';'z ';];
hints=['Tidal Ellipse ';'North velocity ';'East velocity ';...
'North transport';'East transport ';'Elevation '];
bw=0.98-(p3(1)+ax)-0.02;
bw1=(0.98-(p3(1)+ax)-0.02-0.01)/2;
pos1(2)=p3(2);
pos1(3)=bw+0.02;
pos1(4)=np*bh+(np-1)*dh-0.02;
posf=pos1;posf(2)=posf(2)+posf(4)/2-0.01;posf(4)=posf(4)/2+0.01;
uicontrol('Style','Frame','units','normalized','position',posf,...
'BackgroundColor',bgCol);
dh=0.9*dh;
bh=(pos1(4)-0.02-(np-1)*dh)/np;
pos=[p3(1)+ax+0.02, p3(2)+np/2*bh+(np/2-1)*
TMD2.05.zip_TMD潮汐_tmd模拟潮汐_潮汐模拟_潮汐计算_潮汐预测
版权申诉
5星 · 超过95%的资源 121 浏览量
2022-07-15
07:32:29
上传
评论 2
收藏 379KB ZIP 举报
四散
- 粉丝: 50
- 资源: 1万+
最新资源
- 用C语言为母亲节献上一份特别的祝福.zip
- LCD1602液晶显示屏的深入探索与实用指南.zip
- 基于Matlab人脸肤色定理的教师人数统计+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于Matlab霍夫曼变换的表盘读数识别+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于Matlab火灾烟雾检测源码带GUI界面+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于Matlab的恶劣天气交通标志识别系统+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于MATLAB的霍夫曼变换的表盘示数识别+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于Matlab的车道线识别系统 +源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于MATLAB的教室人数统计系统带Gui界面+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于MATLAB的教室人数统计系统带Gui界面+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论10