Changeset 313
- Timestamp:
- Dec 1, 2011, 12:44:42 PM (13 years ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/civ.m
r312 r313 342 342 set(handles.RootName,'String',RootName) 343 343 set(handles.RootName,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding 344 num_i1=str2double(i1_str);345 num_i2=str2double(i2_str);346 num_j1=str2double(j1_str);347 num_j2=str2double(j2_str);348 num_ref_i= num_i1;%efaulmt ref index349 num_ref_j= num_j1;344 i1=str2double(i1_str); 345 i2=str2double(i2_str); 346 j1=str2double(j1_str); 347 j2=str2double(j2_str); 348 num_ref_i=i1;%efaulmt ref index 349 num_ref_j=j1; 350 350 browse.incr_pair=[0 0];%default 351 351 … … 356 356 else %case of netcdf input file, look for corresponding images 357 357 nom_type_nc=nom_type_input; 358 if ~is empty(num_i2)359 num_ref_i=floor((num_ref_i+ num_i2)/2);% reference image number corresponding to the file360 browse.incr_pair(1)= num_i2-num_i1;358 if ~isnan(i2) 359 num_ref_i=floor((num_ref_i+i2)/2);% reference image number corresponding to the file 360 browse.incr_pair(1)=i2-i1; 361 361 browse.incr_pair(2)=0; 362 362 end … … 378 378 end 379 379 for ilist=1:numel(dirima) 380 [pp,ff,i1 ,i2,j1,j2,ext_list,nom_type_list]=name2display(dirima(ilist).name);380 [pp,ff,i1_str,i2_str,j1_str,j2_str,ext_list,nom_type_list]=name2display(dirima(ilist).name); 381 381 form=imformats(ext_list(2:end)); 382 382 if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab 383 383 ext_ima=ext_list; 384 384 nom_type_ima=nom_type_list; 385 num_i1=str2double(i1); 386 num_j1=str2double(j1); 387 num_i2=str2double(i2); 388 num_j2=str2double(j2); 389 385 i1=str2double(i1_str); 386 j1=str2double(j1_str); 387 i2=str2double(i2_str); 388 j2=str2double(j2_str); 390 389 % set the range of fields (1:1 by default) and selected pair 391 if isequal( num_i2,num_i1)||isnan(num_i2)392 num_ref_i= num_i1;390 if isequal(i2,i1)||isnan(i2) 391 num_ref_i=i1; 393 392 else 394 num_ref_i=floor(( num_i1+num_i2)/2);395 browse.incr_pair(1)= num_i2-num_i1;393 num_ref_i=floor((i1+i2)/2); 394 browse.incr_pair(1)=i2-i1; 396 395 browse.incr_pair(2)=0; 397 396 end 398 if isequal( num_j1,num_j2)||isnan(num_j2)399 if isnan( num_j1)397 if isequal(j1,j2)||isnan(j2) 398 if isnan(j1) 400 399 num_ref_j=1; 401 400 else 402 num_ref_j= num_j1;401 num_ref_j=j1; 403 402 end 404 403 else 405 num_ref_j=floor(( num_j1+num_j2)/2);406 browse.incr_pair(2)= num_j2-num_j1;404 num_ref_j=floor((j1+j2)/2); 405 browse.incr_pair(2)=j2-j1; 407 406 end 408 407 break … … 937 936 %----------------------------------------------------------------------- 938 937 errormsg='';%default 939 %% read the civ GUI 938 939 %% read the input parameters from the GUI civ 940 940 Param=read_GUI(handles.civ); 941 941 … … 943 943 operations={'Civ1','Fix1','Patch1','Civ2','Fix2','Patch2'}; 944 944 box_test=[Param.CheckCiv1 Param.CheckFix1 Param.CheckPatch1 Param.CheckCiv2 Param.CheckFix2 Param.CheckPatch2]; 945 946 945 index_first=find(box_test==1,1); 947 946 if isempty(index_first) … … 989 988 status_Callback(hObject, eventdata, handles) 990 989 end 991 992 %% set the list of files and check them993 display('checking the files...')994 [ref_i,ref_j,errormsg]=find_ref_indices(handles);995 if ~isempty(errormsg)996 return997 end998 [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]=...999 set_civ_filenames(handles,ref_i,ref_j,box_test);1000 % ADDED1001 [Rootbat,Filebat]=fileparts(filecell.nc.civ1{1,1});%output netcdf file (without extention)1002 %ADDED1003 set(handles.civ,'UserData',filecell);%store for futur use of status callback1004 if isempty(filecell)% (error message displayed in fct set_civ_filenames)1005 return1006 end1007 nbfield=numel(num1_civ1);1008 nbslice=numel(num_a_civ1);1009 990 1010 991 %% read the PARAM.xml file to get the binaries (and batch_mode if batch) … … 1098 1079 display('files OK, processing...') 1099 1080 1081 %% set the list of files and check them 1082 display('checking the files...') 1083 [ref_i,ref_j,errormsg]=find_ref_indices(handles); 1084 if ~isempty(errormsg) 1085 return 1086 end 1087 [filecell,i1_civ1,i2_civ1,j1_civ1,j2_civ1,i1_civ2,i2_civ2,j1_civ2,j2_civ2,nom_type_nc,xx,yy,compare]=... 1088 set_civ_filenames(handles,ref_i,ref_j,box_test); 1089 Rootbat=fileparts(filecell.nc.civ1{1,1});%output netcdf file (without extention) 1090 set(handles.civ,'UserData',filecell);%store for futur use of status callback 1091 if isempty(filecell)% (error message displayed in fct set_civ_filenames) 1092 return 1093 end 1094 nbfield=numel(i1_civ1); 1095 nbslice=numel(j1_civ1); 1100 1096 1101 1097 %% MAIN LOOP … … 1118 1114 end 1119 1115 case 'CivAll' 1120 % if CivAll1121 1116 CivAllxml=xmltree;% xml contents, all parameters 1122 1117 CivAllCmd=''; 1123 1118 CivAllxml=set(CivAllxml,1,'name','CivDoc'); 1124 1119 end 1125 1126 1120 1127 1121 % define output file name 1128 1122 if Param.CheckCiv2==1 || Param.CheckFix2==1 || Param.CheckPatch2==1 … … 1137 1131 Param.Civ1.filename_ima_a=filecell.ima1.civ1{ifile,j}; 1138 1132 Param.Civ1.filename_ima_b=filecell.ima2.civ1{ifile,j}; 1139 if size(time,1)>= num2_civ1(ifile) && size(time,2)>=num_b_civ1(ifile)1140 Param.Civ1.Dt=(time( num2_civ1(ifile),num_b_civ1(j))-time(num1_civ1(ifile),num_a_civ1(j)));1141 Param.Civ1.T0=((time( num2_civ1(ifile),num_b_civ1(j))+time(num1_civ1(ifile),num_a_civ1(j)))/2);1133 if size(time,1)>=i2_civ1(ifile) && size(time,2)>=j2_civ1(j) 1134 Param.Civ1.Dt=(time(i2_civ1(ifile),j2_civ1(j))-time(i1_civ1(ifile),j1_civ1(j))); 1135 Param.Civ1.T0=((time(i2_civ1(ifile),j2_civ1(j))+time(i1_civ1(ifile),j1_civ1(j)))/2); 1142 1136 else 1143 1137 Param.Civ1.Dt=1; 1144 1138 Param.Civ1.T0=0; 1145 1139 end 1146 Param.Civ1.term_a=num2stra( num_a_civ1(j),nom_type_nc);%UTILITE?1147 Param.Civ1.term_b=num2stra( num_b_civ1(j),nom_type_nc);%1140 Param.Civ1.term_a=num2stra(j1_civ1(j),nom_type_nc);%UTILITE? 1141 Param.Civ1.term_b=num2stra(j2_civ1(j),nom_type_nc);% 1148 1142 Param.Civ1.pxcmx=1; %velocities are expressed in pixel dispalcement 1149 1143 Param.Civ1.pxcmy=1; … … 1160 1154 maskbase=[filecell.filebase '_' Param.Civ1.MaskName]; % 1161 1155 nbslice_mask=str2double(maskdispl(1:end-4)); % 1162 num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1;1163 Param.Civ1.MaskName=name_generator(maskbase, num1_mask,1,'.png','_i');1156 i1_mask=mod(i1_civ1(ifile)-1,nbslice_mask)+1; 1157 Param.Civ1.MaskName=name_generator(maskbase,i1_mask,1,'.png','_i'); 1164 1158 if exist(Param.Civ1.MaskName,'file') 1165 1159 Param.Civ1.maskflag='y'; … … 1174 1168 end 1175 1169 1176 % read grid parameters =1170 % read grid parameters 1177 1171 if Param.Civ1.CheckGrid 1178 Param.Civ1.GridFlag='y';1172 % Param.Civ1.GridFlag='y'; 1179 1173 if isequal(Param.Civ1.GridName(end-3:end),'grid') 1180 1174 nbslice_grid=str2double(Param.Civ1.GridName(1:end-4)); % 1181 1175 if ~isnan(nbslice_grid) 1182 num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1;1183 Param.Civ1.GridName=[filecell.filebase '_' name_generator( gridname,num1_grid,1,'.grid','_i')];1176 i1_grid=mod(i1_civ1(ifile)-1,nbslice_grid)+1; 1177 Param.Civ1.GridName=[filecell.filebase '_' name_generator(Param.Civ1.GridName,i1_grid,1,'.grid','_i')]; 1184 1178 if ~exist(Param.Civ1.GridName,'file') 1185 1179 msgbox_uvmat('ERROR','grid file absent for civ1') … … 1189 1183 end 1190 1184 end 1191 else1192 Param.Civ1.GridName='noFile use default';1193 Param.Civ1.GridFlag='n';1185 % else 1186 % Param.Civ1.GridName='noFile use default'; 1187 % Param.Civ1.GridFlag='n'; 1194 1188 end 1195 1189 … … 1219 1213 cmd=[cmd... 1220 1214 cmd_fix(filecell.nc.civ1{ifile,j},Param,'Fix1') '\n']; 1221 case 'CivAll' 1215 case 'CivAll'%to abandon 1222 1216 fix1.inputFileName=filecell.nc.civ1{ifile,j} ; 1223 1217 fix1.fi1=num2str(param.fix1.flagindex1(1)); … … 1257 1251 nbslice_grid=str2double(gridname(1:end-4)); % 1258 1252 if ~isnan(nbslice_grid) 1259 num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1;1260 patch1.gridPatch=[filecell.filebase '_' name_generator(gridname, num1_grid,1,'.grid','_i')];1253 i1_grid=mod(i1_civ1(ifile)-1,nbslice_grid)+1; 1254 patch1.gridPatch=[filecell.filebase '_' name_generator(gridname,i1_grid,1,'.grid','_i')]; 1261 1255 if ~exist(patch1.gridPatch,'file') 1262 1256 msgbox_uvmat('ERROR','grid file absent for patch1') … … 1290 1284 Param.Civ2.filename_ima_a=filecell.ima1.civ2{ifile,j}; 1291 1285 Param.Civ2.filename_ima_b=filecell.ima2.civ2{ifile,j}; 1292 if size(time,1)>= num2_civ2(ifile) && size(time,2)>=num_b_civ2(ifile)1293 Param.Civ2.Dt=num2str(time( num2_civ2(ifile),num_b_civ2(j))-time(num1_civ2(ifile),num_a_civ2(j)));1294 Param.Civ2.T0=num2str((time( num2_civ2(ifile),num_b_civ2(j))+time(num1_civ2(ifile),num_a_civ2(j)))/2);1286 if size(time,1)>=i2_civ2(ifile) && size(time,2)>=j2_civ2(j) 1287 Param.Civ2.Dt=num2str(time(i2_civ2(ifile),j2_civ2(j))-time(i1_civ2(ifile),j1_civ2(j))); 1288 Param.Civ2.T0=num2str((time(i2_civ2(ifile),j2_civ2(j))+time(i1_civ2(ifile),j1_civ2(j)))/2); 1295 1289 else 1296 1290 Param.Civ2.Dt=1; 1297 1291 Param.Civ2.T0=0; 1298 1292 end 1299 Param.Civ2.term_a=num2stra( num_a_civ2(j),nom_type_nc);1300 Param.Civ2.term_b=num2stra( num_b_civ2(j),nom_type_nc);1293 Param.Civ2.term_a=num2stra(j1_civ2(j),nom_type_nc); 1294 Param.Civ2.term_b=num2stra(j2_civ2(j),nom_type_nc); 1301 1295 Param.Civ2.filename_nc1=filecell.nc.civ1{ifile,j}; 1302 1296 Param.Civ2.filename_nc1(end-2:end)=[]; % remove '.nc' … … 1311 1305 maskbase=[filecell.filebase '_' maskdispl]; % 1312 1306 nbslice_mask=str2double(maskdispl(1:end-4)); % 1313 num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1;1314 Param.Civ2.MaskName=name_generator(maskbase, num1_mask,1,'.png','_i');1307 i1_mask=mod(i1_civ2(ifile)-1,nbslice_mask)+1; 1308 Param.Civ2.MaskName=name_generator(maskbase,i1_mask,1,'.png','_i'); 1315 1309 if exist(Param.Civ2.MaskName,'file') 1316 1310 Param.Civ2.MaskFlag='y'; … … 1329 1323 if ~isnan(nbslice_grid) 1330 1324 Param.Civ2.GridFlag='y'; 1331 num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1;1332 Param.Civ2.GridName=[filecell.filebase '_' name_generator(gridname, num1_grid,1,'.grid','_i')];1333 if exist(Param.Civ2.GridName,'file')1334 Param.Civ2.GridFlag='y';1335 else1336 Param.Civ2.GridName='noFile use default';1337 Param.Civ2.GridFlag='n';1338 end1325 i1_grid=mod(i1_civ2(ifile)-1,nbslice_grid)+1; 1326 Param.Civ2.GridName=[filecell.filebase '_' name_generator(gridname,i1_grid,1,'.grid','_i')]; 1327 % if exist(Param.Civ2.GridName,'file') 1328 % Param.Civ2.GridFlag='y'; 1329 % else 1330 % Param.Civ2.GridName='noFile use default'; 1331 % Param.Civ2.GridFlag='n'; 1332 % end 1339 1333 elseif exist(gridname,'file') 1340 Param.Civ2.GridFlag='y';1341 else1342 Param.Civ2.GridName='noFile use default';1343 Param.Civ2.GridFlag='n';1334 % Param.Civ2.GridFlag='y'; 1335 % else 1336 % Param.Civ2.GridName='noFile use default'; 1337 % Param.Civ2.GridFlag='n'; 1344 1338 end 1345 else1346 Param.Civ2.GridName='noFile use default';1347 Param.Civ2.GridFlag='n';1339 % else 1340 % Param.Civ2.GridName='noFile use default'; 1341 % Param.Civ2.GridFlag='n'; 1348 1342 end 1349 1343 % A=imread(filecell.ima1.civ2{1,1});%read the first image to get the size 1350 1344 % sizim=size(A); 1351 Param.Civ2.ImageInfo=imfinfo(filecell.ima1.civ1{1,1});%read the first image to get the size 1345 Param.Civ2.ImageInfo=imfinfo(filecell.ima1.civ2{1,1});%read the first image to get the size 1346 % TODO: case of movie 1352 1347 % Param.Civ2.npx=(sizim(2)); 1353 1348 % Param.Civ2.npy=(sizim(1)); … … 1399 1394 %CheckPatch2 1400 1395 if Param.CheckPatch2==1 1396 1401 1397 switch CivMode 1398 1402 1399 case 'CivX' 1403 1400 cmd=[cmd... 1404 1401 cmd_patch(filecell.nc.civ1{ifile,j},Param,'Patch2') '\n']; 1402 1405 1403 case 'CivAll' 1406 1404 patch2.inputFileName=filecell.nc.civ1{ifile,j} ; … … 1415 1413 nbslice_grid=str2double(gridname(1:end-4)); % 1416 1414 if ~isnan(nbslice_grid) 1417 num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1;1418 patch2.gridPatch=[filecell.filebase '_' name_generator(gridname, num1_grid,1,'.grid','_i')];1415 i1_grid=mod(i1_civ2(ifile)-1,nbslice_grid)+1; 1416 patch2.gridPatch=[filecell.filebase '_' name_generator(gridname,i1_grid,1,'.grid','_i')]; 1419 1417 if ~exist(patch2.gridPatch,'file') 1420 1418 msgbox_uvmat('ERROR','grid file absent for patch2') … … 1447 1445 1448 1446 switch CivMode 1447 1449 1448 case {'CivX','CivAll'} 1450 1449 if isequal(CivMode,'CivAll') 1451 1450 save(CivAllxml,[OutputFile '.xml']); 1452 1451 cmd=[cmd sparam.CivBin ' -f ' OutputFile '.xml ' CivAllCmd ' >' OutputFile '.log' '\n']; 1453 end 1454 1452 end 1455 1453 % create the .bat file used in run or batch 1456 1454 filename_bat=[OutputFile '.bat']; … … 1461 1459 end 1462 1460 fprintf(fid,cmd); 1463 fclose(fid); 1464 1461 fclose(fid); 1465 1462 if isunix 1466 1463 system(['chmod +x ' filename_bat]); 1467 end 1468 1464 end 1469 1465 batch_file_list{length(batch_file_list)+1}=filename_bat; 1470 1466 … … 1483 1479 end 1484 1480 1485 if batch 1486 switch batch_mode 1481 if batch 1482 switch batch_mode 1483 1487 1484 case 'sge' 1488 1485 for p=1:length(batch_file_list) … … 1490 1487 display(cmd);eval(cmd); 1491 1488 end 1489 1492 1490 case 'oar_old' 1493 1491 for p=1:length(batch_file_list) … … 1496 1494 '-l "/core=1+{type = ''smalljob''}/licence=1,walltime=00:60:00" ' batch_file_list{p}]; 1497 1495 display(oar_command);eval(oar_command); 1498 end 1496 end 1499 1497 case 'oar' %oar-dispatch.pl 1498 1499 filename_joblist=fullfile(Rootbat,'job_list.txt'); 1500 fid=fopen(filename_joblist,'w'); 1501 walltime_onejob=600;%seconds 1502 for p=1:length(batch_file_list) 1503 oar_command=['oarsub -n CIVX '... 1504 '-E ' regexprep(batch_file_list{p},'\.bat\>','.errors') ' -O ' regexprep(batch_file_list{p},'\.bat\>','.log ')... 1505 '-l "/core=1,walltime=' datestr(walltime_onejob/86400,13) '" ' batch_file_list{p}]; 1506 fprintf(fid,[oar_command '\n']); 1507 end 1508 fclose(fid); 1509 ncores=36; 1510 oar_command=['oarsub -t container -n civx-container '... 1511 '-l /core=' num2str(ncores)... 1512 ',walltime=' datestr(1.05*walltime_onejob/86400*max(length(batch_file_list),ncores)/ncores,13)... 1513 ' "oar-dispatch -f ' filename_joblist '"']; 1514 filename_oarcommand=fullfile(Rootbat,'oar_command'); 1515 fid=fopen(filename_oarcommand,'w'); 1516 fprintf(fid,[oar_command '\n']); 1517 fclose(fid); 1518 display(oar_command); 1519 eval(['! . ' filename_oarcommand]) 1520 1521 case 'oar_mpi' 1522 filename_joblist=fullfile(Rootbat,'job_list.txt'); 1523 fid=fopen(filename_joblist,'w'); 1524 1525 for p=1:length(batch_file_list) 1526 fprintf(fid,[batch_file_list{p} '\n']); 1527 end 1528 fclose(fid) 1529 text_oarscript=[... 1530 '#!/bin/bash \n'... 1531 '#OAR -n Mylauncher \n'... 1532 '#OAR -l node=4/core=5,walltime=0:15:00 \n'... 1533 '#OAR -E stderrfile.log \n'... 1534 '#OAR -O stdoutfile.log \n'... 1535 '# ========================================================= \n'... 1536 '# This simple program launch a multinode parallel OpenMPI mpilauncher \n'... 1537 '# application for coriolis PIV post-processing. \n'... 1538 '# OAR uses oarshmost wrapper to propagate the user environement. \n'... 1539 '# This wrapper assert that the user has the same environment on all the \n'... 1540 '# allocated nodes (basic behavior needed by most MPI applications). \n'... 1541 '# \n'... 1542 '# REQUIREMENT: \n'... 1543 '# the oarshmost wrapper should be installed in $HOME/bin directory. \n'... 1544 '# If a different location is used, change the line following the comment "Bidouille" \n'... 1545 '# ========================================================= \n'... 1546 '# USER should only modify these 2 lines \n'... 1547 'WORKDIR=/home/users/gostiaux/tmp/begou \n'... 1548 'COMMANDE="/home/users/gostiaux/tmp/begou/mpilauncher -f ' filename_joblist '" \n'... 1549 '# ========================================================= \n'... 1550 '# DO NOT MODIFY the FOLOWING LINES. (or be carefull) \n'... 1551 'echo "job starting on: "`hostname` \n'... 1552 'MPINODES="-host `tr [\\\\\\n] [,] <$OAR_NODEFILE |sed -e "s/,$/ /"`" \n'... 1553 'NCPUS=`cat $OAR_NODEFILE |wc -l` \n'... 1554 '#========== Bidouille ============== \n'... 1555 'export OMPI_MCA_plm_rsh_agent=$HOME/tmp/begou/oarshmost \n'... 1556 'cd $WORKDIR \n'... 1557 'CMD="mpirun -np $NCPUS -wdir $WORKDIR $MPINODES $COMMANDE" \n'... 1558 'echo "I run: $CMD" \n'... 1559 '$CMD \n'... 1560 'echo "job ending" \n'... 1561 ]; 1562 % oarsub -S ./oar.sub 1563 filename_oarscript=fullfile(Rootbat,'oar_command'); 1564 fid=fopen(filename_oarscript,'w'); 1565 fprintf(fid,[text_oarscript]); 1566 fclose(fid); 1567 eval(['!chmod +x ' filename_oarscript]); 1568 eval(['!oarsub -S ' filename_oarscript]); 1569 1570 case 'oar_new' % to be develloped with Patrick Begou 1571 filename_joblist=fullfile(Rootbat,'job_list.txt'); 1572 fid=fopen(filename_superbat,'w'); 1573 if fid==-1 1574 msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat]) 1575 return 1576 end 1577 for p=1:length(batch_file_list) 1578 fprintf(fid,[batch_file_list{p} '\n']); 1579 end 1580 fclose(fid); 1581 walltime=datestr(length(super_cmd)*10/24/60,13); 1582 eval( ['!oarsub -n CIVX -q nicejob -l "/core=1+{type = ''smalljob''}/licence=1,walltime=' walltime '" ' filename_superbat]); 1500 1583 oar_modes={'oar-dispatch','mpilauncher'}; 1501 1584 text={'Batch processing on servcalcul3 LEGI';... … … 1600 1683 end 1601 1684 system([filename_superbat ' &']);% execute main commmand 1602 end 1603 1685 end 1604 1686 end 1605 1687 … … 4068 4150 fprintf(fid, ['SearchBoxeSize ' num2str(Param.Civ1.Searchx) ' ' num2str(Param.Civ1.Searchy) '\n' ]); 4069 4151 fprintf(fid, ['RO ' num2str(Param.Civ1.Rho) '\n' ]); 4070 fprintf(fid, ['GridSpacing ' num2str(Param.Civ1.Dx) ' ' num2str(Param.Civ1.Dy) '\n' ]); 4152 if isfield(Param.Civ1,'GridName') 4153 fprintf(fid, ['GridSpacing ' '25' ' ' '25' '\n' ]); 4154 else 4155 fprintf(fid, ['GridSpacing ' num2str(Param.Civ1.Dx) ' ' num2str(Param.Civ1.Dy) '\n' ]); 4156 end 4071 4157 fprintf(fid, ['XX 1.0' '\n' ]); 4072 4158 fprintf(fid, ['Dt_TO ' num2str(Param.Civ1.Dt) ' ' num2str(Param.Civ1.T0) '\n' ]); … … 4074 4160 fprintf(fid, ['XX 1' '\n' ]); 4075 4161 fprintf(fid, ['ShiftXY ' num2str(Param.Civ1.Shiftx) ' ' num2str(Param.Civ1.Shifty) '\n' ]); 4076 fprintf(fid, ['Grid ' Param.Civ1.GridFlag '\n' ]); 4077 fprintf(fid, ['GridName ' regexprep(Param.Civ1.GridName,'\\','\\\\') '\n' ]); 4162 if isfield(Param.Civ1,'GridName') 4163 fprintf(fid, ['Grid ' 'y' '\n' ]); 4164 fprintf(fid, ['GridName ' regexprep(Param.Civ1.GridName,'\\','\\\\') '\n' ]); 4165 else 4166 fprintf(fid, ['Grid ' 'n' '\n' ]); 4167 fprintf(fid, ['GridName ' 'noFile use default' '\n' ]); 4168 end 4078 4169 fprintf(fid, ['XX 85' '\n' ]); 4079 4170 fprintf(fid, ['XX 1.0' '\n' ]); … … 4189 4280 fprintf(fid, ['SearchBoxeSize ' num2str(Param.Civ2.Bx) ' ' num2str(Param.Civ2.By) '\n']); 4190 4281 fprintf(fid, ['RO ' num2str(Param.Civ2.Rho) '\n']); 4191 fprintf(fid, ['GridSpacing ' num2str(Param.Civ2.Dx) ' ' num2str(Param.Civ2.Dy) '\n']); 4282 if isfield(Param.Civ2,'GridName') 4283 fprintf(fid, ['GridSpacing ' '25' ' ' '25' '\n' ]); 4284 else 4285 fprintf(fid, ['GridSpacing ' num2str(Param.Civ2.Dx) ' ' num2str(Param.Civ2.Dy) '\n' ]); 4286 end 4287 % fprintf(fid, ['GridSpacing ' num2str(Param.Civ2.Dx) ' ' num2str(Param.Civ2.Dy) '\n']); 4192 4288 fprintf(fid, ['XX 1.0' '\n' ]); 4193 4289 fprintf(fid, ['Dt_TO ' num2str(Param.Civ2.Dt) ' ' num2str(Param.Civ2.T0) '\n' ]); … … 4195 4291 fprintf(fid, ['XX 1' '\n' ]); 4196 4292 fprintf(fid, 'ShiftXY 0 0\n'); 4197 fprintf(fid, ['Grid ' Param.Civ2.GridFlag '\n' ]); 4198 fprintf(fid, ['GridName ' regexprep(Param.Civ2.GridName,'\\','\\\\') '\n']); 4293 if isfield(Param.Civ2,'GridName') 4294 fprintf(fid, ['Grid ' 'y' '\n' ]); 4295 fprintf(fid, ['GridName ' regexprep(Param.Civ2.GridName,'\\','\\\\') '\n' ]); 4296 else 4297 fprintf(fid, ['Grid ' 'n' '\n' ]); 4298 fprintf(fid, ['GridName ' 'noFile use default' '\n' ]); 4299 end 4300 % fprintf(fid, ['Grid ' Param.Civ2.GridFlag '\n' ]); 4301 % fprintf(fid, ['GridName ' regexprep(Param.Civ2.GridName,'\\','\\\\') '\n']); 4199 4302 fprintf(fid, ['XX 85' '\n' ]); 4200 4303 fprintf(fid, ['XX 1.0' '\n' ]); -
trunk/src/plot_field.m
r294 r313 524 524 else 525 525 test_vec=1; 526 eval(['vec_U=Data.' Data.ListVarName{ivar_U} ';'])527 eval(['vec_V=Data.' Data.ListVarName{ivar_V} ';'])526 vec_U=Data.(Data.ListVarName{ivar_U}); 527 vec_V=Data.(Data.ListVarName{ivar_V}); 528 528 if ~isempty(ivar_X) && ~isempty(ivar_Y)% 2D field (with unstructured coordinates or structured ones (then ivar_X and ivar_Y empty) 529 529 XName=Data.ListVarName{ivar_X}; … … 552 552 if ~isempty(ivar_F)%~(isfield(PlotParam.Vectors,'HideWarning')&& isequal(PlotParam.Vectors.HideWarning,1)) 553 553 if test_vec 554 eval(['vec_F=Data.' Data.ListVarName{ivar_F} ';'])% warning flags for dubious vectors554 vec_F=Data.(Data.ListVarName{ivar_F}); % warning flags for dubious vectors 555 555 if ~(isfield(PlotParam.Vectors,'CheckHideWarning') && isequal(PlotParam.Vectors.CheckHideWarning,1)) 556 556 test_black=1; … … 560 560 if ~isempty(ivar_FF) %&& ~test_false 561 561 if test_vec% TODO: deal with FF for structured coordinates 562 eval(['vec_FF=Data.' Data.ListVarName{ivar_FF} ';'])% flags for false vectors562 vec_FF=Data.(Data.ListVarName{ivar_FF}); % flags for false vectors 563 563 end 564 564 end -
trunk/src/set_col_vec.m
r102 r313 1 1 %'set_col_vec': sets the color code for vectors depending on a scalar vec_C and parameters given by the struct colcode 2 %function [colorlist,col_vec,minC, colcode1,colcode2,maxC]=colvec(colcode,vec_C)2 %function [colorlist,col_vec,minC,ColCode1,ColCode2,maxC]=colvec(colcode,vec_C) 3 3 %OUTPUT 4 4 %colorlist(nb,3); %list of nb colors 5 5 %col_vec, size=[length(vec_C),3)];%list of color indices corresponding to vec_C 6 6 %minC, maxC: min and max of vec_C 7 % colcode1, colcode2: absolute threshold in vec_C corresponding to colcode.colcode1 and colcode.colcode27 %ColCode1, ColCode2: absolute threshold in vec_C corresponding to colcode.ColCode1 and colcode.ColCode2 8 8 %INPUT 9 9 % colcode: struture setting the colorcode for vectors 10 10 % colcode.CName: 'ima_cor','black','white',... 11 % colcode. ColorCode ='black', 'white', 'rgb','brg', '64 colors'11 % colcode.ListColorCode ='black', 'white', 'rgb','brg', '64 colors' 12 12 % colcode.FixedCbounds =0; thresholds scaling relative to min and max, =1 fixed thresholds 13 13 % colcode.MinC; min 14 14 % colcode.MaxC; max 15 % colcode. colcode1: first threshold for rgb, relative to min (0) and max (1)16 % colcode. colcode2: second threshold for rgb, relative to min (0) and max (1),17 % rmq: we need min <= colcode1 <= colcode2 <= max, otherwise18 % colcode1 and colcode2 are adjusted to the bounds15 % colcode.ColCode1: first threshold for rgb, relative to min (0) and max (1) 16 % colcode.ColCode2: second threshold for rgb, relative to min (0) and max (1), 17 % rmq: we need min <= ColCode1 <= ColCode2 <= max, otherwise 18 % ColCode1 and ColCode2 are adjusted to the bounds 19 19 % vec_C: matlab vector representing the scalar setting the color 20 20 function [colorlist,col_vec,colcode_out]=set_col_vec(colcode,vec_C) … … 27 27 return 28 28 end 29 if (isfield(colcode,' FixedCbounds') && isequal(colcode.FixedCbounds,1))30 minC=colcode.Min C;31 maxC=colcode.Max C;29 if (isfield(colcode,'CheckFixVecColor') && isequal(colcode.CheckFixVecColor,1)) 30 minC=colcode.MinVec; 31 maxC=colcode.MaxVec; 32 32 else 33 33 minC=min(vec_C); … … 37 37 %default input parameters 38 38 if ~isstruct(colcode),colcode=[];end; 39 if ~isfield(colcode,' ColorCode') || isempty(colcode.ColorCode)39 if ~isfield(colcode,'ListColorCode') || isempty(colcode.ListColorCode) 40 40 colorlist=[0 0 1]; %blue 41 41 col_vec=ones(size(vec_C)); 42 42 return 43 43 end 44 if isfield(colcode,' colcode1')45 colcode1=minC+colcode.colcode1*(maxC-minC);44 if isfield(colcode,'ColCode1') 45 ColCode1=minC+colcode.ColCode1*(maxC-minC); 46 46 else 47 colcode1=minC+(maxC-minC)/3;%default47 ColCode1=minC+(maxC-minC)/3;%default 48 48 end 49 if isfield(colcode,' colcode2')50 colcode2=minC+colcode.colcode2*(maxC-minC);49 if isfield(colcode,'ColCode2') 50 ColCode2=minC+colcode.ColCode2*(maxC-minC); 51 51 else 52 colcode2=minC+2*(maxC-minC)/3;%default52 ColCode2=minC+2*(maxC-minC)/3;%default 53 53 end 54 54 colcode_out.MinC=minC; 55 55 colcode_out.MaxC=maxC; 56 if strcmp(colcode. ColorCode,'black')56 if strcmp(colcode.ListColorCode,'black') 57 57 colorlist(1,:)=[0 0 0];%black 58 58 col_vec=ones(size(vec_C));%all vectors at color#1 59 elseif strcmp(colcode. ColorCode,'white')59 elseif strcmp(colcode.ListColorCode,'white') 60 60 colorlist(1,:)=[1 1 1];%white 61 61 col_vec=ones(size(vec_C));%all vectors at color#1 62 elseif strcmp(colcode. ColorCode,'rgb')|| strcmp(colcode.ColorCode,'bgr')% 3 color representation63 ind1=find(vec_C < colcode1); % =1 for red vectors64 ind_green=find((vec_C >= colcode1) & (vec_C < colcode2));% =1 for green vectors65 ind3=find(vec_C >= colcode2);% =1 for blue vectors62 elseif strcmp(colcode.ListColorCode,'rgb')|| strcmp(colcode.ListColorCode,'bgr')% 3 color representation 63 ind1=find(vec_C < ColCode1); % =1 for red vectors 64 ind_green=find((vec_C >= ColCode1) & (vec_C < ColCode2));% =1 for green vectors 65 ind3=find(vec_C >= ColCode2);% =1 for blue vectors 66 66 colorlist(2,:)=[0 1 0];%green 67 67 col_vec(ind1)=1; 68 68 col_vec(ind_green)=2; 69 69 col_vec(ind3)=3; 70 if strcmp(colcode. ColorCode,'rgb')70 if strcmp(colcode.ListColorCode,'rgb') 71 71 colorlist(1,:)=[1 0 0];%red 72 72 colorlist(3,:)=[0 0 1];%blue -
trunk/src/write_plot_param.m
r295 r313 52 52 MinC=PlotParam.Vectors.MinC; 53 53 MaxC=PlotParam.Vectors.MaxC; 54 set(handles. min_vec,'String', num2str(MinC,3));55 set(handles. max_vec,'String',num2str(MaxC,3));56 list=get(handles. color_code,'String');57 ichoice=get(handles. color_code,'Value');54 set(handles.num_MinVec,'String', num2str(MinC,3)); 55 set(handles.num_MaxVec,'String',num2str(MaxC,3)); 56 list=get(handles.ListColorCode,'String'); 57 ichoice=get(handles.ListColorCode,'Value'); 58 58 color_option=list{ichoice}; 59 59 test3color=strcmp(color_option,'rgb')||strcmp(color_option,'bgr'); 60 60 if test3color% need to update color thresholds 61 set(handles. colcode1,'Visible','on')62 set(handles. colcode2,'Visible','on')63 set(handles. slider1,'Visible','on')64 set(handles. slider2,'Visible','on')65 colcode1=MinC+(MaxC-MinC)*PlotParam.Vectors.colcode1;66 colcode2=MinC+(MaxC-MinC)*PlotParam.Vectors.colcode2;67 set(handles. colcode1,'String',num2str(colcode1,3))68 set(handles. colcode2,'String',num2str(colcode2,3))69 set(handles. slider1,'Value',PlotParam.Vectors.colcode1)70 set(handles. slider2,'Value',PlotParam.Vectors.colcode2)61 set(handles.num_ColCode1,'Visible','on') 62 set(handles.num_ColCode2,'Visible','on') 63 set(handles.Slider1,'Visible','on') 64 set(handles.Slider2,'Visible','on') 65 ColCode1=MinC+(MaxC-MinC)*PlotParam.Vectors.ColCode1; 66 ColCode2=MinC+(MaxC-MinC)*PlotParam.Vectors.ColCode2; 67 set(handles.num_ColCode1,'String',num2str(ColCode1,3)) 68 set(handles.num_ColCode2,'String',num2str(ColCode2,3)) 69 set(handles.Slider1,'Value',PlotParam.Vectors.ColCode1) 70 set(handles.Slider2,'Value',PlotParam.Vectors.ColCode2) 71 71 else 72 set(handles. colcode1,'Visible','off')73 set(handles. colcode2,'Visible','off')74 set(handles. slider1,'Visible','off')75 set(handles. slider2,'Visible','off')72 set(handles.num_ColCode1,'Visible','off') 73 set(handles.num_ColCode2,'Visible','off') 74 set(handles.Slider1,'Visible','off') 75 set(handles.Slider2,'Visible','off') 76 76 end 77 77 end
Note: See TracChangeset
for help on using the changeset viewer.