Changeset 274
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/civ.m
r273 r274 23 23 %TODO: search range 24 24 25 % Last Modified by GUIDE v2.5 1 6-Nov-2011 20:12:3425 % Last Modified by GUIDE v2.5 17-Nov-2011 23:05:55 26 26 % Begin initialization code - DO NOT EDIT 27 27 gui_Singleton = 1; … … 250 250 251 251 252 struct=read_panel(handles. Patch2Panel)252 struct=read_panel(handles.panel_Patch2) 253 253 254 254 %------------------------------------------------------------------------ … … 1570 1570 [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc,xx,yy,compare]=... 1571 1571 set_civ_filenames(handles,ref_i,ref_j,box_test); 1572 1572 % ADDED 1573 [Rootbat,Filebat]=fileparts(filecell.nc.civ1{1,1});%output netcdf file (without extention) 1574 %ADDED 1573 1575 set(handles.civ,'UserData',filecell);%store for futur use of status callback 1574 1576 if isempty(filecell)% (error message displayed in fct set_civ_filenames) … … 1636 1638 end 1637 1639 switch CivMode 1638 case {'CivX','CivAll'} 1639 1640 for bin_name={'Civ1Bin','Civ2Bin','PatchBin','FixBin','CivBin'} 1641 if isfield(param.global,bin_name{1}) 1642 param.global.(bin_name{1}) 1643 exist(param.global.(bin_name{1})) 1644 if ~exist(param.global.(bin_name{1})) 1645 param.global.(bin_name{1})=fullfile(path_UVMAT,param.global.(bin_name{1})); 1646 if ~exist(param.global.(bin_name{1})) 1647 msgbox_uvmat('ERROR',['Binary ' param.global.(bin_name{1}) ' defined in PARAM.xm does not exist']) 1648 return 1649 end 1650 end 1651 [path,name,ext]=fileparts(param.global.(bin_name{1})) 1652 currentdir=pwd; 1653 cd(path); 1654 param.global.(bin_name{1})=which([name ext]); 1655 display(param.global.(bin_name{1})); 1656 cd(currentdir); 1657 end 1658 end 1640 case {'CivX','CivAll'} 1641 for bin_name={'Civ1Bin','Civ2Bin','PatchBin','FixBin','CivBin'} 1642 if isfield(param.global,bin_name{1}) 1643 if ~exist(param.global.(bin_name{1}),'file')%look for the full path if the file name has been defined with a relative path in PARAM.xml 1644 fullname=fullfile(path_UVMAT,param.global.(bin_name{1})); 1645 if exist(fullname,'file') 1646 param.global.(bin_name{1})=fullname; 1647 else 1648 msgbox_uvmat('ERROR',['Binary ' param.global.(bin_name{1}) ' defined in PARAM.xm does not exist']) 1649 return 1650 end 1651 else 1652 [path,name,ext]=fileparts(param.global.(bin_name{1})); 1653 currentdir=pwd; 1654 cd(path); 1655 binpath=pwd;%path of the binary 1656 param.global.(bin_name{1})=fullfile(binpath,[name ext]); 1657 % display(param.global.(bin_name{1})); 1658 cd(currentdir); 1659 end 1660 1661 end 1662 end 1659 1663 case 'Matlab' 1660 1664 if batch … … 1676 1680 end 1677 1681 1678 %% get patch1 parameters TODO read_param_patch11682 %% get patch1 parameters 1679 1683 if box_test(3) 1680 param.patch1=read_param_patch1(handles) 1684 param.Patch1=read_panel(handles.panel_Patch1); 1685 %param.patch1=read_param_patch1(handles) 1681 1686 end 1682 1687 … … 1704 1709 %% get patch2 parameters 1705 1710 if box_test(6)==1 1706 rho_patch2=str2double(get(handles.SmoothParam,'String')); 1707 if isnan(rho_patch2) 1708 rho_patch2='1000'; 1709 set(handles.SmoothParam,'String','1') 1710 else 1711 rho_patch2=num2str(1000*rho_patch2); 1712 end 1713 nx_patch2=get(handles.Nx,'String'); 1714 ny_patch2=get(handles.Ny,'String'); 1715 if isnan(str2double(nx_patch2)) 1716 nx_patch2='50' ;%default 1717 set(handles.Nx,'String','50'); 1718 end 1719 if isnan(str2double(ny_patch2)) 1720 ny_patch2='50' ;%default 1721 set(handles.Ny,'String','50'); 1722 end 1723 subdomain_patch2=get(handles.SubdomainSize,'String'); 1724 thresh_patch2=get(handles.MaxDiff,'String'); 1711 param.Patch2=read_panel(handles.panel_Patch1); 1712 % rho_patch2=str2double(get(handles.num_SmoothParam,'String')); 1713 % if isnan(rho_patch2) 1714 % rho_patch2='1000'; 1715 % set(handles.num_SmoothParam,'String','1') 1716 % else 1717 % rho_patch2=num2str(1000*rho_patch2); 1718 % end 1719 % nx_patch2=get(handles.num_Nx,'String'); 1720 % ny_patch2=get(handles.num_Ny,'String'); 1721 % if isnan(str2double(nx_patch2)) 1722 % nx_patch2='50' ;%default 1723 % set(handles.num_Nx,'String','50'); 1724 % end 1725 % if isnan(str2double(ny_patch2)) 1726 % ny_patch2='50' ;%default 1727 % set(handles.num_Ny,'String','50'); 1728 % end 1729 % subdomain_patch2=get(handles.num_SubdomainSize,'String'); 1730 % thresh_patch2=get(handles.num_MaxDiff,'String'); 1725 1731 end 1726 1732 … … 1878 1884 switch CivMode 1879 1885 case 'CivX' 1880 cmd_PATCH=cmd_patch(filecell.nc.civ1{ifile,j},param );1886 cmd_PATCH=cmd_patch(filecell.nc.civ1{ifile,j},param.Patch1,param.global.PatchBin); 1881 1887 cmd=[cmd cmd_PATCH '\n']; 1882 1888 case 'CivAll' … … 2041 2047 switch CivMode 2042 2048 case 'CivX' 2043 cmd_PATCH= PATCH_CMD(filecell.nc.civ2{ifile,j},nx_patch2,ny_patch2,rho_patch2,subdomain_patch2,thresh_patch2,test_interp,param.global.PatchBin);2049 cmd_PATCH=cmd_path(filecell.nc.civ2{ifile,j},param); 2044 2050 cmd=[cmd cmd_PATCH '\n']; 2045 2051 case 'CivAll' … … 2984 2990 end 2985 2991 end 2986 if box_test(6)==1 && isequal(get(handles. StereoCheck,'Value'),1)2992 if box_test(6)==1 && isequal(get(handles.check_Stereo,'Value'),1) 2987 2993 for ifile=1:nbfield 2988 2994 for j=1:nbslice … … 3207 3213 %------------------------------------------------------------------------ 3208 3214 % --- PATCH 3209 function cmd=cmd_patch(filename_nc, param)3215 function cmd=cmd_patch(filename_nc,Param,PatchBin) 3210 3216 %------------------------------------------------------------------------ 3211 3217 namelog=[filename_nc(1:end-3) '_patch.log']; 3218 3212 3219 % if test_interp==0 3213 3220 if isunix 3214 cmd=[ param.global.PatchBin...3215 ' -f ' filename_nc ' -m ' param.patch1.nx_patch...3216 ' -n ' param.patch1.ny_patch ' -ro ' param.patch1.rho_patch...3217 ' -nopt ' param.patch1.subdomain_patch...3218 ' > ' namelog ' 2>&1'] ;% redirect standard output to the log file3221 cmd=[PatchBin... 3222 ' -f ' filename_nc ' -m ' num2str(Param.Nx)... 3223 ' -n ' num2str(Param.Ny) ' -ro ' num2str(Param.SmoothingParam)... 3224 ' -nopt ' num2str(Param.SubdomainSize) ... 3225 ' > ' namelog ' 2>&1'] % redirect standard output to the log file 3219 3226 else 3220 3227 cmd=['"' param.global.PatchBin... 3221 '" -f "' filename_nc '" -m ' param. patch1.nx_patch...3222 ' -n ' param. patch1.ny_patch ' -ro ' param.patch1.rho_patch...3223 ' -nopt ' param.patch1.subdomain_patch...3228 '" -f "' filename_nc '" -m ' param.Patch1.Nx... 3229 ' -n ' param.Patch1.Ny ' -ro ' param.Patch1.SmoothParam... 3230 ' -nopt ' Param.Patch1.SubdomainSize ... 3224 3231 ' > "' namelog '" 2>&1']; % redirect standard output to the log file 3225 3232 end … … 3229 3236 % end 3230 3237 cmd=regexprep(cmd,'\\','\\\\'); 3238 3231 3239 %------------------------------------------------------------------------ 3232 3240 % --- STEREO Interp … … 3864 3872 return 3865 3873 end 3866 set(handles. Civ1Panel,'Visible','on')3867 set(handles. PairPanel,'Visible','on')3874 set(handles.panel_Civ1,'Visible','on') 3875 set(handles.panel_PairIndices,'Visible','on') 3868 3876 % set(handles.frame_civ1,'BackgroundColor',[1 1 0]) 3869 3877 % set(handles.frame_para_civ1,'BackgroundColor',[1 1 0]) 3870 3878 % set(handles.frame_grid_civ1,'BackgroundColor',[1 1 0]) 3871 3879 else 3872 set(handles. Civ1Panel,'Visible','off')3880 set(handles.panel_Civ1,'Visible','off') 3873 3881 % set(handles.frame_civ1,'BackgroundColor',[0.831 0.816 0.784]) 3874 3882 % set(handles.frame_para_civ1,'BackgroundColor',[0.831 0.816 0.784]) … … 3934 3942 end 3935 3943 if isequal(state,'on') 3936 set(handles. Fix1Panel,'Visible','on')3944 set(handles.panel_Fix1,'Visible','on') 3937 3945 % set(handles.frame_fix1,'BackgroundColor',[1 1 0]) 3938 3946 else 3939 set(handles. Fix1Panel,'Visible','off')3947 set(handles.panel_Fix1,'Visible','off') 3940 3948 %set(handles.frame_fix1,'BackgroundColor',[0.7 0.7 0.7]) 3941 3949 end … … 3964 3972 return 3965 3973 end 3966 set(handles. Patch1Panel,'Visible','on')3967 else 3968 set(handles. Patch1Panel,'Visible','off')3974 set(handles.panel_Patch1,'Visible','on') 3975 else 3976 set(handles.panel_Patch1,'Visible','off') 3969 3977 end 3970 3978 return … … 3979 3987 set(handles.subdomain_text1,'Visible','on') 3980 3988 set(handles.nx_patch1,'Visible','on') 3981 set(handles. Ny,'Visible','on')3989 set(handles.num_Ny,'Visible','on') 3982 3990 set(handles.nx_patch1_title,'Visible','on') 3983 3991 set(handles.ny_patch1_title,'Visible','on') … … 4005 4013 % set(handles.subdomain_text1,'Visible','off') 4006 4014 % set(handles.nx_patch1,'Visible','off') 4007 % set(handles. Ny,'Visible','off')4015 % set(handles.num_Ny,'Visible','off') 4008 4016 % set(handles.nx_patch1_title,'Visible','off') 4009 4017 % set(handles.ny_patch1_title,'Visible','off') … … 4022 4030 return 4023 4031 end 4024 set(handles. Civ2Panel,'Visible','on')4025 else 4026 set(handles. Civ2Panel,'Visible','off')4032 set(handles.panel_Civ2,'Visible','on') 4033 else 4034 set(handles.panel_Civ2,'Visible','off') 4027 4035 end 4028 4036 return … … 4079 4087 %------------------------------------------------------------------------ 4080 4088 % if isequal(state,'on') 4081 % set(handles. Fix2Panel,'Visible','on')4089 % set(handles.panel_Fix2,'Visible','on') 4082 4090 % 4083 4091 % % set(handles.frame_civ2,'BackgroundColor',[1 1 0]) … … 4092 4100 return 4093 4101 end 4094 set(handles. Fix2Panel,'Visible','on')4095 else 4096 set(handles. Fix2Panel,'Visible','off')4102 set(handles.panel_Fix2,'Visible','on') 4103 else 4104 set(handles.panel_Fix2,'Visible','off') 4097 4105 end 4098 4106 return … … 4149 4157 return 4150 4158 end 4151 set(handles. Patch2Panel,'Visible','on')4152 else 4153 set(handles. Patch2Panel,'Visible','off')4159 set(handles.panel_Patch2,'Visible','on') 4160 else 4161 set(handles.panel_Patch2,'Visible','off') 4154 4162 end 4155 4163 % set(handles.frame_patch2,'BackgroundColor',[1 1 0]) 4156 % set(handles. SmoothParam,'Visible','on')4157 % set(handles. SmoothingParam,'Visible','on')4158 % set(handles. MaxDiff,'Visible','on')4164 % set(handles.num_SmoothParam,'Visible','on') 4165 % set(handles.num_SmoothingParam,'Visible','on') 4166 % set(handles.num_MaxDiff,'Visible','on') 4159 4167 % set(handles.thresh_text2,'Visible','on') 4160 % set(handles. SubdomainSize,'Visible','on')4168 % set(handles.num_SubdomainSize,'Visible','on') 4161 4169 % set(handles.subdomain_text2,'Visible','on') 4162 % set(handles. Nx,'Visible','on')4163 % set(handles. Ny,'Visible','on')4170 % set(handles.num_Nx,'Visible','on') 4171 % set(handles.num_Ny,'Visible','on') 4164 4172 % set(handles.nx_patch2_title,'Visible','on') 4165 4173 % set(handles.ny_patch2_title,'Visible','on') … … 4171 4179 % stereo_test=get(handles.compare,'Value'); 4172 4180 % if stereo_test==3 4173 % set(handles. StereoCheck,'Visible','on')4181 % set(handles.check_Stereo,'Visible','on') 4174 4182 % end 4175 4183 … … 4177 4185 % function desable_patch2(handles) 4178 4186 % %------------------------------------------------------------------------ 4179 % %set(handles. Patch2Panel,'Visible','off')4187 % %set(handles.panel_Patch2,'Visible','off') 4180 4188 % return 4181 4189 % set(handles.frame_patch2,'BackgroundColor',[0.831 0.816 0.784]) 4182 % set(handles. SmoothParam,'Visible','off')4183 % set(handles. SmoothingParam,'Visible','off')4184 % set(handles. MaxDiff,'Visible','off')4190 % set(handles.num_SmoothParam,'Visible','off') 4191 % set(handles.num_SmoothingParam,'Visible','off') 4192 % set(handles.num_MaxDiff,'Visible','off') 4185 4193 % set(handles.thresh_text2,'Visible','off') 4186 % set(handles. SubdomainSize,'Visible','off')4194 % set(handles.num_SubdomainSize,'Visible','off') 4187 4195 % set(handles.subdomain_text2,'Visible','off') 4188 % set(handles. Nx,'Visible','off')4189 % set(handles. Ny,'Visible','off')4196 % set(handles.num_Nx,'Visible','off') 4197 % set(handles.num_Ny,'Visible','off') 4190 4198 % set(handles.nx_patch2_title,'Visible','off') 4191 4199 % set(handles.ny_patch2_title,'Visible','off') … … 4197 4205 % set(handles.subdir_civ2_text,'Visible','off') 4198 4206 % end 4199 % set(handles. StereoCheck,'Visible','off')4207 % set(handles.check_Stereo,'Visible','off') 4200 4208 %------------------------------------------------------------------------ 4201 4209 function enable_pair1(handles,state) … … 4758 4766 set(handles.CivMode,'String',mode_store) 4759 4767 set(handles.test_stereo1,'Value',0) 4760 set(handles. StereoCheck,'Value',0)4768 set(handles.check_Stereo,'Value',0) 4761 4769 set(handles.CivMode,'Value',1) % mode 'civX' selected by default 4762 4770 end … … 4767 4775 end 4768 4776 if test==3 && get(handles.PATCH2,'Value') 4769 set(handles. StereoCheck,'Visible','on')4770 else 4771 set(handles. StereoCheck,'Visible','off')4777 set(handles.check_Stereo,'Visible','on') 4778 else 4779 set(handles.check_Stereo,'Visible','off') 4772 4780 end 4773 4781 mode_Callback(hObject, eventdata, handles) … … 4900 4908 4901 4909 %------------------------------------------------------------------------ 4902 % --- Executes on button press in StereoCheck.4910 % --- Executes on button press in check_Stereo. 4903 4911 function StereoCheck_Callback(hObject, eventdata, handles) 4904 4912 %------------------------------------------------------------------------ 4905 if isequal(get(handles. StereoCheck,'Value'),0)4906 set(handles. SubdomainSize,'Visible','on')4907 set(handles. SmoothParam,'Visible','on')4908 else 4909 set(handles. SubdomainSize,'Visible','off')4910 set(handles. SmoothParam,'Visible','off')4913 if isequal(get(handles.check_Stereo,'Value'),0) 4914 set(handles.num_SubdomainSize,'Visible','on') 4915 set(handles.num_SmoothParam,'Visible','on') 4916 else 4917 set(handles.num_SubdomainSize,'Visible','off') 4918 set(handles.num_SmoothParam,'Visible','off') 4911 4919 end 4912 4920 … … 5184 5192 % set(handles.thresh_patch1,'Visible','off') 5185 5193 % set(handles.thresh_text1,'Visible','off') 5186 % set(handles. MaxDiff,'Visible','off')5194 % set(handles.num_MaxDiff,'Visible','off') 5187 5195 % set(handles.thresh_text2,'Visible','off') 5188 5196 % set(handles.rho,'Style','edit') … … 5202 5210 5203 5211 5204 % --- Executes on button press in check box42.5205 function check box42_Callback(hObject, eventdata, handles)5206 % hObject handle to check box42(see GCBO)5212 % --- Executes on button press in check_Stereo. 5213 function check_Stereo_Callback(hObject, eventdata, handles) 5214 % hObject handle to check_Stereo (see GCBO) 5207 5215 % eventdata reserved - to be defined in a future version of MATLAB 5208 5216 % handles structure with handles and user data (see GUIDATA) 5209 5217 5210 % Hint: get(hObject,'Value') returns toggle state of check box425211 5212 5213 5214 function SubdomainSize_Callback(hObject, eventdata, handles)5215 % hObject handle to SubdomainSize (see GCBO)5218 % Hint: get(hObject,'Value') returns toggle state of check_Stereo 5219 5220 5221 5222 function num_SubdomainSize_Callback(hObject, eventdata, handles) 5223 % hObject handle to num_SubdomainSize (see GCBO) 5216 5224 % eventdata reserved - to be defined in a future version of MATLAB 5217 5225 % handles structure with handles and user data (see GUIDATA) 5218 5226 5219 % Hints: get(hObject,'String') returns contents of SubdomainSize as text5220 % str2double(get(hObject,'String')) returns contents of SubdomainSize as a double5221 5222 5223 5224 function SmoothingParam_Callback(hObject, eventdata, handles)5225 % hObject handle to SmoothingParam (see GCBO)5227 % Hints: get(hObject,'String') returns contents of num_SubdomainSize as text 5228 % str2double(get(hObject,'String')) returns contents of num_SubdomainSize as a double 5229 5230 5231 5232 function num_SmoothingParam_Callback(hObject, eventdata, handles) 5233 % hObject handle to num_SmoothingParam (see GCBO) 5226 5234 % eventdata reserved - to be defined in a future version of MATLAB 5227 5235 % handles structure with handles and user data (see GUIDATA) 5228 5236 5229 % Hints: get(hObject,'String') returns contents of SmoothingParam as text5230 % str2double(get(hObject,'String')) returns contents of SmoothingParam as a double5231 5232 5233 5234 function MaxDiff_Callback(hObject, eventdata, handles)5235 % hObject handle to MaxDiff (see GCBO)5237 % Hints: get(hObject,'String') returns contents of num_SmoothingParam as text 5238 % str2double(get(hObject,'String')) returns contents of num_SmoothingParam as a double 5239 5240 5241 5242 function num_MaxDiff_Callback(hObject, eventdata, handles) 5243 % hObject handle to num_MaxDiff (see GCBO) 5236 5244 % eventdata reserved - to be defined in a future version of MATLAB 5237 5245 % handles structure with handles and user data (see GUIDATA) 5238 5246 5239 % Hints: get(hObject,'String') returns contents of MaxDiff as text5240 % str2double(get(hObject,'String')) returns contents of MaxDiff as a double5241 5242 5243 function Nx_Callback(hObject, eventdata, handles)5244 % hObject handle to Nx (see GCBO)5247 % Hints: get(hObject,'String') returns contents of num_MaxDiff as text 5248 % str2double(get(hObject,'String')) returns contents of num_MaxDiff as a double 5249 5250 5251 function num_Nx_Callback(hObject, eventdata, handles) 5252 % hObject handle to num_Nx (see GCBO) 5245 5253 % eventdata reserved - to be defined in a future version of MATLAB 5246 5254 % handles structure with handles and user data (see GUIDATA) 5247 5255 5248 % Hints: get(hObject,'String') returns contents of Nx as text5249 % str2double(get(hObject,'String')) returns contents of Nx as a double5250 5251 5252 function Ny_Callback(hObject, eventdata, handles)5253 % hObject handle to Ny (see GCBO)5256 % Hints: get(hObject,'String') returns contents of num_Nx as text 5257 % str2double(get(hObject,'String')) returns contents of num_Nx as a double 5258 5259 5260 function num_Ny_Callback(hObject, eventdata, handles) 5261 % hObject handle to num_Ny (see GCBO) 5254 5262 % eventdata reserved - to be defined in a future version of MATLAB 5255 5263 % handles structure with handles and user data (see GUIDATA) 5256 5264 5257 % Hints: get(hObject,'String') returns contents of Ny as text5258 % str2double(get(hObject,'String')) returns contents of Ny as a double5265 % Hints: get(hObject,'String') returns contents of num_Ny as text 5266 % str2double(get(hObject,'String')) returns contents of num_Ny as a double 5259 5267 5260 5268 … … 5274 5282 %set(handles.thresh_patch1,'Visible','off') 5275 5283 set(handles.thresh_text1,'Visible','off') 5276 set(handles. MaxDiff,'Visible','off')5284 set(handles.num_MaxDiff,'Visible','off') 5277 5285 set(handles.thresh_text2,'Visible','off') 5278 5286 set(handles.rho,'Style','edit') … … 5289 5297 end 5290 5298 if get(handles.PATCH2,'Value') 5291 set(handles. MaxDiff,'Visible','on')5299 set(handles.num_MaxDiff,'Visible','on') 5292 5300 set(handles.thresh_text2,'Visible','on') 5293 5301 end … … 5303 5311 for ichild=1:numel(hchild) 5304 5312 object_style=get(hchild(ichild),'Style'); 5313 tag=get(hchild(ichild),'tag'); 5305 5314 check_input=1;%default 5306 5315 switch object_style 5307 5316 case 'edit' 5308 input=str2double(get(hchild(ichild),'String')); 5309 %deal with undefined input: retrieve the default value stored as UserData 5310 if isnan(input) 5311 input=get(hchild(ichild),'UserData'); 5312 set(hchild(ichild),'String',num2str(input)) 5313 end 5317 switch(tag(1:4)) 5318 case 'num_' 5319 input=str2double(get(hchild(ichild),'String')); 5320 %deal with undefined input: retrieve the default value stored as UserData 5321 if isnan(input) 5322 input=get(hchild(ichild),'UserData'); 5323 set(hchild(ichild),'String',num2str(input)) 5324 end 5325 case 'txt_' 5326 input=get(hchild(ichild),'String'); 5327 end 5328 key=tag(5:end); 5314 5329 case 'checkbox' 5315 input=get(hchild(ichild),'Value'); 5330 input=get(hchild(ichild),'Value'); 5331 key=tag(7:end); 5316 5332 otherwise 5317 check_input=0; 5318 5333 check_input=0; 5319 5334 end 5320 5335 if check_input 5321 eval(['struct.' get(hchild(ichild),'tag') '=input;']) 5322 end 5323 end 5336 key 5337 eval(['struct.' key '=input;']) 5338 end 5339 end
Note: See TracChangeset
for help on using the changeset viewer.