- Timestamp:
- May 19, 2013, 11:37:49 PM (12 years ago)
- Location:
- trunk/src
- Files:
-
- 1 deleted
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/find_file_series.m
r610 r635 250 250 else 251 251 i1_series=i1_series(:,2)*ones(1,FileInfo.NumberOfFrames); 252 i1_series=[i1_series(:,1) i1_series]; 253 j1_series=ones(size(i1_series,1),1)*(0:FileInfo.NumberOfFrames); 252 i1_series=[zeros(size(i1_series,1),1) i1_series]; 253 j1_series=ones(size(i1_series,1),1)*(1:FileInfo.NumberOfFrames); 254 j1_series=[zeros(size(i1_series,1),1) j1_series]; 254 255 % include the first index in the root name 255 256 r=regexp(NomType,'^(?<tiretnum>_?\d+)','names');%look for a number or _1 at the beginning of NomType -
trunk/src/get_file_series.m
r599 r635 20 20 incr_i=Param.IndexRange.incr_i; 21 21 last_i=Param.IndexRange.last_i; 22 ref_i=first_i:incr_i:last_i; 23 ref_j=[]; 22 % ref_i=first_i:incr_i:last_i; 23 %ref_j=[]; 24 first_j=[];last_j=[];incr_j=1;%default 24 25 if isfield(Param.IndexRange,'first_j') 25 26 first_j=Param.IndexRange.first_j; 26 27 incr_j=Param.IndexRange.incr_j; 27 28 last_j=Param.IndexRange.last_j; 28 ref_j=first_j:incr_j:last_j;29 29 end 30 30 31 31 %% determine the list of input file names 32 32 nbmissing=0; 33 34 for iview=1:size(InputTable,1) 33 NbView=size(InputTable,1); 34 i1_series=cell(NbView,1);% initiate index series with empty cells 35 i2_series=cell(NbView,1); 36 j1_series=cell(NbView,1); 37 j2_series=cell(NbView,1); 38 for iview=1:NbView 35 39 r.mode=''; 36 40 if isfield (Param.IndexRange,'PairString') … … 38 42 Param.IndexRange.PairString={Param.IndexRange.PairString}; 39 43 end 40 r=regexp(Param.IndexRange.PairString{iview,1},'(?<mode>(Di=)|(Dj=)) -*(?<num1>\d+)\|(?<num2>\d+)','names'); 44 r=regexp(Param.IndexRange.PairString{iview,1},'(?<mode>(Di=)|(Dj=)) -*(?<num1>\d+)\|(?<num2>\d+)','names');%look for mode=Dj or Di 41 45 if isempty(r) 42 r=regexp(Param.IndexRange.PairString{iview,1},'(?<num1>\d+)(?<mode>-)(?<num2>\d+)','names'); 46 r=regexp(Param.IndexRange.PairString{iview,1},'(?<num1>\d+)(?<mode>-)(?<num2>\d+)','names');%look for burst pairs 43 47 end 44 48 % TODO case of free pairs: … … 51 55 r(1).mode='*-*'; 52 56 else 53 r(1).mode='';57 r(1).mode=''; 54 58 end 55 59 end 56 if isequal(r(1).mode,'*-*')% free pairs 60 61 if isempty(incr_i) || isempty(incr_j) || isequal(r(1).mode,'*-*')% free pairs 57 62 FilePath=fullfile(InputTable{iview,1},InputTable{iview,2}); 58 63 fileinput=[InputTable{iview,3} InputTable{iview,4} InputTable{iview,5}]; 59 [tild,tild,tild,i1_series{iview},i2_series{iview},j1_series{iview},j2_series{iview},NomType,FileType,FileInfo,MovieObject,i1_input,i2_input,j1_input,j2_input]=find_file_series(FilePath,fileinput); 60 i1_series{iview}=squeeze(i1_series{iview}(1,:,:)); %first pair index 61 check_select=i1_series{iview}>=first_i & i1_series{iview}<=last_i; 62 i1_series{iview}=i1_series{iview}(check_select); 63 i2_series{iview}=[]; %first pair index 64 [tild,tild,tild,i1_series{iview},i2_series{iview},j1_series{iview},j2_series{iview},NomType,FileType,FileInfo,MovieObject,... 65 i1_input,i2_input,j1_input,j2_input]=find_file_series(FilePath,fileinput); 66 i1_series{iview}=squeeze(i1_series{iview}(1,:,:)); %select first pair index as ordered by find_file_series 64 67 j1_series{iview}=squeeze(j1_series{iview}(1,:,:)); %first pair index 65 j2_series{iview}=squeeze(j2_series{iview}(1,:,:)); %first pair index 66 j1_series{iview}=j1_series{iview}(check_select); 67 j2_series{iview}=j2_series{iview}(check_select); 68 j2_series{iview}=squeeze(j2_series{iview}(1,:,:)); %second pair index 69 %check_select=i1_series{iview}>=first_i & i1_series{iview}<=last_i; 70 if isempty(incr_i) 71 if isempty(incr_j) 72 [ref_j,ref_i]=find(i1_series{iview}); 73 ref_i=ref_i-1; 74 ref_j=ref_j-1; 75 ref_i=ref_i(ref_i>=first_i & ref_i<=last_i); 76 ref_j=ref_j(ref_j>=first_j & ref_j<=last_j); 77 else 78 ref_j=first_j:incr_j:last_j; 79 [tild,ref_i]=find(i1_series{iview}(:,ref_j)); 80 ref_i=ref_i-1; 81 ref_i=ref_i(ref_i>=first_i & ref_i<=last_i); 82 end 83 else 84 ref_i=first_i:incr_i:last_i;%default 85 if isempty(incr_j) 86 [ref_j,tild]=find(i1_series{iview}); 87 ref_j=ref_j-1; 88 ref_j=ref_j(ref_j>=first_j & ref_j<=last_j); 89 else 90 ref_j=first_j:incr_j:last_j; 91 end 92 end 93 i1_series{iview}=i1_series{iview}(ref_j,ref_i); 94 j1_series{iview}=j1_series{iview}(ref_j,ref_i); 95 if ~isempty(j2_series{iview}) 96 j2_series{iview}=j2_series{iview}(ref_j,ref_i); 97 end 68 98 else 99 ref_i=first_i:incr_i:last_i;%default 100 ref_j=first_j:incr_j:last_j;%default 101 end 102 if ~isequal(r(1).mode,'*-*')% imposed pairs or single i and/or j index 69 103 [i1_series{iview},i2_series{iview},j1_series{iview},j2_series{iview}]=find_file_indices(ref_i,ref_j,str2num(r.num1),str2num(r.num2),r.mode); 70 104 end 71 105 72 106 %case of pairs (.nc files) 73 107 i2=[];j1=[];j2=[]; … … 83 117 j2=j2_series{iview}(ifile); 84 118 end 85 119 filecell{iview,ifile}=fullfile_uvmat(InputTable{iview,1},InputTable{iview,2},InputTable{iview,3},InputTable{iview,5},InputTable{iview,4},i1,i2,j1,j2); 86 120 end 87 121 end -
trunk/src/read_field.m
r595 r635 34 34 ParamOut=ParamIn;%default 35 35 errormsg=''; 36 if ~exist(FileName,'file') 37 erromsg=['input file ' FileName ' does not exist']; 38 return 39 end 36 40 A=[]; 37 41 InputField={}; -
trunk/src/series.m
r630 r635 524 524 InputTable(iview,:)=[{RootPath},{SubDir},{RootFile},{NomType},{FileExt}]; 525 525 set(handles.TimeTable,'Data',[{[]},{[]},{[]},{[]}]) 526 set(handles.MinIndex_i,'Data',[ {[]}])527 set(handles.MaxIndex_i,'Data',[ {[]}])528 set(handles.MinIndex_j,'Data',[ {[]}])529 set(handles.MaxIndex_j,'Data',[ {[]}])526 set(handles.MinIndex_i,'Data',[]) 527 set(handles.MaxIndex_i,'Data',[]) 528 set(handles.MinIndex_j,'Data',[]) 529 set(handles.MaxIndex_j,'Data',[]) 530 530 set(handles.ListView,'Value',1) 531 531 set(handles.ListView,'String',{'1'}) … … 606 606 MinIndex_j=1;% index j set to 1 by default 607 607 MaxIndex_j=1; 608 MinIndex_i=find(i1_series( :,2,:), 1 )-1;% min ref index i detected in the series (corresponding to the first non-zero value of i1_series, except for zero index)609 MaxIndex_i=find(i1_series( :,2,:), 1,'last' )-1;%max ref index i detected in the series (corresponding to the last non-zero value of i1_series)608 MinIndex_i=find(i1_series(1,2,:), 1 )-1;% min ref index i detected in the series (corresponding to the first non-zero value of i1_series, except for zero index) 609 MaxIndex_i=find(i1_series(1,2,:),1,'last' )-1;%max ref index i detected in the series (corresponding to the last non-zero value of i1_series) 610 610 else 611 pair_max=squeeze(max(i1_series,[],1)); %max on pair index 612 j_max=max(pair_max,[],1); 613 MinIndex_i=find(j_max, 1 )-1;% min ref index i detected in the series (corresponding to the first non-zero value of i1_series, except for zero index) 614 MaxIndex_i=find(j_max, 1, 'last' )-1;% max ref index i detected in the series (corresponding to the first non-zero value of i1_series, except for zero index) 615 diff_i_max=diff(j_max); 611 ref_i=squeeze(max(i1_series(1,:,:),[],2));% select ref_j index for each ref_i 612 ref_j=squeeze(max(j1_series(1,:,:),[],3));% select ref_i index for each ref_j 613 % [ref_j,ref_i]=find(squeeze(i1_series(1,:,:))); 614 % [ref_j,ref_i]=find(squeeze(i1_series(1,:,:))) 615 MinIndex_i=min(find(ref_i))-1; 616 MaxIndex_i=max(find(ref_i))-1; 617 % MinIndex_j=min(ref_j)-1; 618 MaxIndex_j=max(find(ref_j))-1; 619 % MinIndex_j=min(find(j1_series_j))-1; 620 % MaxIndex_j=max(find(j1_series_j))-1; 621 % MaxIndex_i=max(i1_series_i)-1; 622 % MinIndex_j=min(i1_series_j)-1; 623 % MaxIndex_j=max(i1_series_j)-1; 624 % MaxIndex_i=max(ref_i)-1; 625 MinIndex_j=min(find(ref_j))-1; 626 % MaxIndex_j=max(ref_j)-1; 627 diff_j_max=diff(ref_j); 628 diff_i_max=diff(ref_i); 629 630 % pair_max=squeeze(max(i1_series,[],1)); %max on pair index 631 % j_max=max(pair_max,[],1); 632 % MinIndex_i=find(j_max, 1 )-1;% min ref index i detected in the series (corresponding to the first non-zero value of i1_series, except for zero index) 633 % MaxIndex_i=find(j_max, 1, 'last' )-1;% max ref index i detected in the series (corresponding to the first non-zero value of i1_series, except for zero index) 634 % diff_i_max=diff(j_max); 616 635 if ~isempty(diff_i_max) && isequal (diff_i_max,diff_i_max(1)*ones(size(diff_i_max))) 617 636 set(handles.num_incr_i,'String',num2str(diff_i_max(1)))% detect an increment to dispaly by default 618 637 end 619 i_max=max(pair_max,[],2);620 MinIndex_j=min(find(i_max))-1;% min ref index j621 MaxIndex_j=max(find(i_max))-1;% max ref index j622 diff_j_max=diff(i_max);638 % i_max=max(pair_max,[],2); 639 % MinIndex_j=min(find(i_max))-1;% min ref index j 640 % MaxIndex_j=max(find(i_max))-1;% max ref index j 641 % diff_j_max=diff(i_max); 623 642 if isequal (diff_j_max,diff_j_max(1)*ones(size(diff_j_max))) 624 643 set(handles.num_incr_j,'String',num2str(diff_j_max(1))) … … 635 654 MaxIndex_i_cell=get(handles.MaxIndex_i,'Data');%retrieve the min indices in the table MinIndex 636 655 MaxIndex_j_cell=get(handles.MaxIndex_j,'Data');%retrieve the min indices in the table MinIndex 637 MinIndex_i_cell {iview,1}=MinIndex_i;638 MinIndex_j_cell {iview,1}=MinIndex_j;639 MaxIndex_i_cell {iview,1}=MaxIndex_i;640 MaxIndex_j_cell {iview,1}=MaxIndex_j;656 MinIndex_i_cell(iview,1)=MinIndex_i; 657 MinIndex_j_cell(iview,1)=MinIndex_j; 658 MaxIndex_i_cell(iview,1)=MaxIndex_i; 659 MaxIndex_j_cell(iview,1)=MaxIndex_j; 641 660 set(handles.MinIndex_i,'Data',MinIndex_i_cell)%display the min indices in the table MinIndex 642 661 set(handles.MinIndex_j,'Data',MinIndex_j_cell)%display the max indices in the table MaxIndex … … 1321 1340 %------------------------------------------------------------------------ 1322 1341 % --- Executes on button press in RUN. 1342 %------------------------------------------------------------------------ 1323 1343 function RUN_Callback(hObject, eventdata, handles) 1324 %------------------------------------------------------------------------ 1325 1326 set(handles.RUN,'BusyAction','queue'); 1327 set(0,'CurrentFigure',handles.series) 1328 set(handles.RUN, 'Enable','Off') 1329 set(handles.RUN,'BackgroundColor',[ 0.831 0.816 0.784])1344 1345 %% settings of the button RUN 1346 set(handles.RUN,'BusyAction','queue');% activation of STOP button will set BusyAction to 'cancel' 1347 %set(0,'CurrentFigure',handles.series); % display the GUI series 1348 set(handles.RUN, 'Enable','Off')% avoid further RUN action until the current one is finished 1349 set(handles.RUN,'BackgroundColor',[1 1 0])%show activation of RUN by yellow color 1330 1350 drawnow 1331 1351 1332 %% read the input parameters and set the output dir and nomenclature 1333 [Series,OutputDir,errormsg]=prepare_jobs(handles);% get parameters form the GUI series 1334 if ~isempty(errormsg) 1335 if ~strcmp(errormsg,'Cancel') 1336 msgbox_uvmat('ERROR',errormsg) 1337 end 1338 STOP_Callback([],[], handles) 1339 return 1340 end 1341 OutputNomType=nomtype2pair(Series.InputTable{1,4});% nomenclature for output files 1342 DirXml=fullfile(OutputDir,'0_XML'); 1343 if ~exist(DirXml,'dir') 1344 [tild,msg1]=mkdir(DirXml); 1345 if ~strcmp(msg1,'') 1346 msgbox_uvmat('ERROR',['cannot create ' DirXml ': ' msg1]);%error message for directory creation 1347 return 1348 end 1349 end 1350 1351 %% select the Action modes 1352 RunMode='local';%default 1353 if isfield(Series.Action,'RunMode') 1354 RunMode=Series.Action.RunMode; 1352 %% read the data on the GUI series 1353 Param=read_GUI_series(handles);%displayed parameters 1354 SeriesData=get(handles.series,'UserData');%hidden parameters 1355 1356 %% create the output data directory if needed 1357 if isfield(Param,'OutputSubDir') 1358 SubDirOut=[get(handles.OutputSubDir,'String') Param.OutputDirExt]; 1359 SubDirOutNew=SubDirOut; 1360 detect=exist(fullfile(Param.InputTable{1,1},SubDirOutNew),'dir');% test if the dir already exist 1361 check_create=1; %need to create the result directory by default 1362 while detect 1363 answer=msgbox_uvmat('INPUT_Y-N',['use existing ouput directory: ' fullfile(Param.InputTable{1,1},SubDirOutNew) ', possibly delete previous data']); 1364 if strcmp(answer,'Cancel') 1365 errormsg='Cancel'; 1366 return 1367 elseif strcmp(answer,'Yes') 1368 detect=0; 1369 check_create=0; 1370 else 1371 r=regexp(SubDirOutNew,'(?<root>.*\D)(?<num1>\d+)$','names');%detect whether name ends by a number 1372 if isempty(r) 1373 r(1).root=[SubDirOutNew '_']; 1374 r(1).num1='0'; 1375 end 1376 SubDirOutNew=[r(1).root num2str(str2num(r(1).num1)+1)];%increment the index by 1 or put 1 1377 detect=exist(fullfile(Param.InputTable{1,1},SubDirOutNew),'dir');% test if the dir already exists 1378 check_create=1; 1379 end 1380 end 1381 Param.OutputDirExt=regexprep(SubDirOutNew,Param.OutputSubDir,''); 1382 Param.OutputRootFile=Param.InputTable{1,3};% the first sorted RootFile taken for output 1383 set(handles.OutputDirExt,'String',Param.OutputDirExt) 1384 OutputDir=fullfile(Param.InputTable{1,1},[Param.OutputSubDir Param.OutputDirExt]);% full name (with path) of output directory 1385 if check_create % create output directory if it does not exist 1386 [tild,msg1]=mkdir(OutputDir); 1387 if ~strcmp(msg1,'') 1388 errormsg=['cannot create ' OutputDir ': ' msg1];%error message for directory creation 1389 return 1390 end 1391 end 1392 OutputNomType=nomtype2pair(Param.InputTable{1,4});% nomenclature for output files 1393 DirXml=fullfile(OutputDir,'0_XML'); 1394 if ~exist(DirXml,'dir') 1395 [tild,msg1]=mkdir(DirXml); 1396 if ~strcmp(msg1,'') 1397 msgbox_uvmat('ERROR',['cannot create ' DirXml ': ' msg1]);%error message for directory creation 1398 return 1399 end 1400 end 1401 end 1402 1403 %% select the Action mode, 'local', 'background' or 'cluster' (if available) 1404 RunMode='local';%default (needed for first opening of the GUI series) 1405 if isfield(Param.Action,'RunMode') 1406 RunMode=Param.Action.RunMode; 1355 1407 end 1356 1408 ActionExt='.m';%default 1357 if isfield( Series.Action,'ActionExt')1358 ActionExt= Series.Action.ActionExt;% '.m' or '.sh' (compiled)1359 end 1360 ActionName= Series.Action.ActionName;1361 ActionPath= Series.Action.ActionPath;1409 if isfield(Param.Action,'ActionExt') 1410 ActionExt=Param.Action.ActionExt;% '.m' or '.sh' (compiled) 1411 end 1412 ActionName=Param.Action.ActionName; 1413 ActionPath=Param.Action.ActionPath; 1362 1414 path_series=fileparts(which('series')); 1363 1415 … … 1411 1463 return 1412 1464 end 1413 % Series.RunTime=RunTime;1414 1465 end 1415 1466 … … 1419 1470 NbCore=1;% no need to split the calculation 1420 1471 case 'cluster_oar' 1421 if strcmp( Series.Action.ActionExt,'.m')% case of Matlab function (uncompiled)1472 if strcmp(Param.Action.ActionExt,'.m')% case of Matlab function (uncompiled) 1422 1473 NbCore=1;% one core used only (limitation of Matlab licences) 1423 1474 msgbox_uvmat('WARNING','Number of cores =1: select the compiled version civ_matlab.sh for multi-core processing'); … … 1429 1480 end 1430 1481 end 1431 if ~isfield( Series.IndexRange,'NbSlice')1432 Series.IndexRange.NbSlice=[];1433 end 1434 if isempty( Series.IndexRange.NbSlice)1482 if ~isfield(Param.IndexRange,'NbSlice') 1483 Param.IndexRange.NbSlice=[]; 1484 end 1485 if isempty(Param.IndexRange.NbSlice) 1435 1486 NbProcess=NbCore;% choose one process per core 1436 1487 else 1437 NbProcess= Series.IndexRange.NbSlice;% the nbre of run processes is equal to the number of slices1488 NbProcess=Param.IndexRange.NbSlice;% the nbre of run processes is equal to the number of slices 1438 1489 NbCore=min(NbCore,NbProcess);% at least one process per core 1439 1490 end 1440 1491 1441 1442 %% read index ranges 1443 [first_i,incr_i,last_i,first_j,incr_j,last_j,errormsg]=get_index_range(Series.IndexRange); 1444 if ~isempty(errormsg) 1445 msgbox_uvmat('ERROR',['series/Run_Callback/get_index_range' errormsg]) 1492 %% get the set of reference field indices 1493 first_i=1; 1494 last_i=1; 1495 incr_i=1; 1496 first_j=1; 1497 last_j=1; 1498 incr_j=1; 1499 if isfield(Param.IndexRange,'first_i') 1500 first_i=Param.IndexRange.first_i; 1501 incr_i=Param.IndexRange.incr_i; 1502 last_i=Param.IndexRange.last_i; 1503 end 1504 if isfield(Param.IndexRange,'first_j') 1505 first_j=Param.IndexRange.first_j; 1506 last_j=Param.IndexRange.last_j; 1507 incr_j=Param.IndexRange.incr_j; 1508 end 1509 if last_i < first_i || last_j < first_j 1510 msgbox_uvmat('ERROR', 'series/Run_Callback:last field index must be larger or equal to the first one') 1446 1511 set(handles.RUN, 'Enable','On'), 1447 1512 set(handles.RUN,'BackgroundColor',[1 0 0]) 1448 1513 return 1514 end 1515 %incr_i must be defined, =1 by default, if NbSlice is active 1516 if isempty(incr_i)&& ~isempty(Param.IndexRange.NbSlice) 1517 incr_i=1; 1518 set(handles.num_incr_i,'String','1') 1519 end 1520 if isempty(incr_i) 1521 if isempty(incr_j) 1522 [ref_j,ref_i]=find(squeeze(SeriesData.i1_series{1}(1,:,:))); 1523 ref_j=ref_j(ref_j>=first_j & ref_j<=last_j); 1524 ref_i=ref_i(ref_i>=first_i & ref_i<=last_i); 1525 ref_j=ref_j-1; 1526 ref_i=ref_i-1; 1527 else 1528 ref_j=first_j:incr_j:last_j; 1529 [tild,ref_i]=find(squeeze(SeriesData.i1_series{1}(1,:,:))); 1530 ref_i=ref_i-1; 1531 ref_i=ref_i(ref_i>=first_i & ref_i<=last_i); 1532 end 1449 1533 else 1450 BlockLength=ceil(numel(first_i:incr_i:last_i)/NbProcess); 1451 end 1452 nbfield_j=numel(first_j:incr_j:last_j); 1534 ref_i=first_i:incr_i:last_i; 1535 if isempty(incr_j) 1536 [ref_j,tild]=find(squeeze(SeriesData.i1_series{1}(1,:,:))); 1537 ref_j=ref_j-1; 1538 ref_j=ref_j(ref_j>=first_j & ref_j<=last_j); 1539 else 1540 ref_j=first_j:incr_j:last_j; 1541 end 1542 end 1543 BlockLength=ceil(numel(ref_i)/NbProcess); 1544 nbfield_j=numel(ref_j); 1453 1545 1454 1546 %% record nbre of output files and starting time for computation for status … … 1457 1549 switch StatusData.OutputFileMode 1458 1550 case 'NbInput' 1459 StatusData.NbOutputFile=numel( first_i:incr_i:last_i)*numel(first_j:incr_j:last_j);1551 StatusData.NbOutputFile=numel(ref_i)*nbfield_j; 1460 1552 case 'NbInput_i' 1461 StatusData.NbOutputFile=numel( first_i:incr_i:last_i);1553 StatusData.NbOutputFile=numel(ref_i); 1462 1554 case 'NbSlice' 1463 1555 StatusData.NbOutputFile=str2num(get(handles.num_NbSlice,'String')); … … 1469 1561 %% direct processing on the current Matlab session 1470 1562 if strcmp (RunMode,'local') 1471 % Series.RUNHandle=handles.RUN;1472 % Series.WaitbarHandle=handles.Waitbar;1473 1563 for iprocess=1:NbProcess 1474 if isempty(Series.IndexRange.NbSlice) 1475 Series.IndexRange.first_i=first_i+(iprocess-1)*BlockLength*incr_i; 1476 if Series.IndexRange.first_i>last_i 1564 if isempty(Param.IndexRange.NbSlice) 1565 %Param.IndexRange.first_i=first_i+(iprocess-1)*BlockLength*incr_i; 1566 Param.IndexRange.first_i=ref_i(1+(iprocess-1)*BlockLength); 1567 if Param.IndexRange.first_i>last_i 1477 1568 break 1478 1569 end 1479 Series.IndexRange.last_i=min(first_i+(iprocess)*BlockLength*incr_i-1,last_i); 1480 else 1481 Series.IndexRange.first_i= first_i+incr_i*(iprocess-1); 1482 Series.IndexRange.incr_i=incr_i*Series.IndexRange.NbSlice; 1483 end 1484 t=struct2xml(Series); 1570 Param.IndexRange.last_i=min(ref_i(iprocess*BlockLength),last_i); 1571 %Param.IndexRange.last_i=min(first_i+(iprocess)*BlockLength*incr_i-1,last_i); 1572 else %multislices (then incr_i is not empty) 1573 Param.IndexRange.first_i= first_i+incr_i*(iprocess-1); 1574 Param.IndexRange.incr_i=incr_i*Param.IndexRange.NbSlice; 1575 end 1576 if isfield(Param,'OutputSubDir') 1577 t=struct2xml(Param); 1485 1578 t=set(t,1,'name','Series'); 1486 filexml=fullfile_uvmat(DirXml,'', Series.InputTable{1,3},'.xml',OutputNomType,...1487 Series.IndexRange.first_i,Series.IndexRange.last_i,first_j,last_j);1579 filexml=fullfile_uvmat(DirXml,'',Param.InputTable{1,3},'.xml',OutputNomType,... 1580 Param.IndexRange.first_i,Param.IndexRange.last_i,first_j,last_j); 1488 1581 save(t,filexml); 1582 end 1489 1583 switch ActionExt 1490 1584 case '.m' 1491 h_fun( Series);1585 h_fun(Param); 1492 1586 case '.sh' 1493 1587 switch computer … … 1506 1600 %% processing on a different session of the same computer (background) or cluster, create executable files 1507 1601 batch_file_list=cell(NbProcess,1);% initiate the list of executable files 1508 DirBat=fullfile(OutputDir,'0_BAT'); 1602 DirBat=fullfile(OutputDir,'0_EXE'); 1603 switch computer 1604 case {'PCWIN','PCWIN64'} %Windows system 1605 ExeExt='.bat'; 1606 case {'GLNX86','GLNXA64','MACI64'}%Linux system 1607 ExeExt='.sh'; 1608 end 1509 1609 %create subdirectory for executable files 1510 1610 if ~exist(DirBat,'dir') … … 1525 1625 end 1526 1626 for iprocess=1:NbProcess 1527 if isempty( Series.IndexRange.NbSlice)% process by blocks of i index1528 Series.IndexRange.first_i=first_i+(iprocess-1)*BlockLength*incr_i;1529 if Series.IndexRange.first_i>last_i1627 if isempty(Param.IndexRange.NbSlice)% process by blocks of i index 1628 Param.IndexRange.first_i=first_i+(iprocess-1)*BlockLength*incr_i; 1629 if Param.IndexRange.first_i>last_i 1530 1630 NbProcess=iprocess-1; 1531 1631 break% leave the loop, we are at the end of the calculation 1532 1632 end 1533 Series.IndexRange.last_i=min(last_i,first_i+(iprocess)*BlockLength*incr_i-1);1633 Param.IndexRange.last_i=min(last_i,first_i+(iprocess)*BlockLength*incr_i-1); 1534 1634 else% process by slices of i index if NbSlice is defined, computation in a single process if NbSlice =1 1535 Series.IndexRange.first_i= first_i+iprocess-1;1536 Series.IndexRange.incr_i=incr_i*Series.IndexRange.NbSlice;1635 Param.IndexRange.first_i= first_i+iprocess-1; 1636 Param.IndexRange.incr_i=incr_i*Param.IndexRange.NbSlice; 1537 1637 end 1538 1638 1539 1639 % create, fill and save the xml parameter file 1540 t=struct2xml( Series);1640 t=struct2xml(Param); 1541 1641 t=set(t,1,'name','Series'); 1542 filexml=fullfile_uvmat(DirXml,'', Series.InputTable{1,3},'.xml',OutputNomType,...1543 Series.IndexRange.first_i,Series.IndexRange.last_i,first_j,last_j);1642 filexml=fullfile_uvmat(DirXml,'',Param.InputTable{1,3},'.xml',OutputNomType,... 1643 Param.IndexRange.first_i,Param.IndexRange.last_i,first_j,last_j); 1544 1644 save(t,filexml);% save the parameter file 1545 1645 1546 1646 %create the executable file 1547 % filebat=fullfile_uvmat(DirBat,'',Series.InputTable{1,3},'.bat',OutputNomType,... 1548 % Series.IndexRange.first_i,Series.IndexRange.last_i,first_j,last_j); 1549 filebat=fullfile_uvmat(DirBat,'',Series.InputTable{1,3},'.sh',OutputNomType,... 1550 Series.IndexRange.first_i,Series.IndexRange.last_i,first_j,last_j); 1647 filebat=fullfile_uvmat(DirBat,'',Param.InputTable{1,3},ExeExt,OutputNomType,... 1648 Param.IndexRange.first_i,Param.IndexRange.last_i,first_j,last_j); 1551 1649 batch_file_list{iprocess}=filebat; 1552 1650 [fid,message]=fopen(filebat,'w');% create the executable file … … 1557 1655 1558 1656 % set the log file name 1559 filelog=fullfile_uvmat(DirLog,'', Series.InputTable{1,3},'.log',OutputNomType,...1560 Series.IndexRange.first_i,Series.IndexRange.last_i,first_j,last_j);1657 filelog=fullfile_uvmat(DirLog,'',Param.InputTable{1,3},'.log',OutputNomType,... 1658 Param.IndexRange.first_i,Param.IndexRange.last_i,first_j,last_j); 1561 1659 1562 1660 % fill and save the executable file … … 1570 1668 'matlab -nodisplay -nosplash -nojvm -logfile ''' filelog ''' <<END_MATLAB \n'... 1571 1669 'addpath(''' path_series '''); \n'... 1572 'addpath(''' Series.Action.ActionPath '''); \n'...1573 '' Series.Action.ActionName '( ''' filexml '''); \n'...1670 'addpath(''' Param.Action.ActionPath '''); \n'... 1671 '' Param.Action.ActionName '( ''' filexml '''); \n'... 1574 1672 'exit \n'... 1575 1673 'END_MATLAB \n']; … … 1580 1678 text_matlabscript=['matlab -automation -logfile ' regexprep(filelog,'\\','\\\\')... 1581 1679 ' -r "addpath(''' regexprep(path_series,'\\','\\\\') ''');'... 1582 'addpath(''' regexprep( Series.Action.ActionPath,'\\','\\\\') ''');'...1583 '' Series.Action.ActionName '( ''' regexprep(filexml,'\\','\\\\') ''');exit"'];1680 'addpath(''' regexprep(Param.Action.ActionPath,'\\','\\\\') ''');'... 1681 '' Param.Action.ActionName '( ''' regexprep(filexml,'\\','\\\\') ''');exit"']; 1584 1682 fprintf(fid,text_matlabscript);%fill the executable file with the char string cmd 1585 1683 fclose(fid);% close the executable file … … 1600 1698 % cmd=['matlab -automation -logfile ' regexprep(filelog,'\\','\\\\')... 1601 1699 % ' -r "addpath(''' regexprep(path_series,'\\','\\\\') ''');'... 1602 % 'addpath(''' regexprep( Series.Action.ActionPath,'\\','\\\\') ''');'...1603 % '' Series.Action.ActionName '( ''' regexprep(filexml,'\\','\\\\') ''');exit"'];1700 % 'addpath(''' regexprep(Param.Action.ActionPath,'\\','\\\\') ''');'... 1701 % '' Param.Action.ActionName '( ''' regexprep(filexml,'\\','\\\\') ''');exit"']; 1604 1702 fprintf(fid,cmd); 1605 1703 fclose(fid); … … 1680 1778 % --- Main launch command, called by RUN and BATCH 1681 1779 1682 function [Series,OutputDir,errormsg]=prepare_jobs(handles) 1683 %INPUT: 1684 % handles: handles of graphic objects on the GUI series 1685 1686 %------------------------------------------------------------------------ 1687 OutputDir=''; 1688 errormsg=''; 1689 1690 %% Read parameters from series 1691 Series=read_GUI(handles.series); 1692 1693 %% get_field GUI 1694 % if isfield(Series,'InputFields')&&isfield(Series.InputFields,'Field') 1695 % if strcmp(Series.InputFields.Field,'get_field...') 1696 % hget_field=findobj(allchild(0),'name','get_field'); 1697 % Series.GetField=read_GUI(hget_field); 1698 % end 1699 % end 1700 1701 %% create the output data directory 1702 %determine the root file corresponding to the first sub dir 1703 if get(handles.RUN,'value') && isfield(Series,'OutputSubDir') 1704 SubDirOut=[get(handles.OutputSubDir,'String') Series.OutputDirExt]; 1705 SubDirOutNew=SubDirOut; 1706 SeriesData=get(handles.series,'UserData'); 1707 % if size(Series.InputTable,1)>1 && isfield(SeriesData,'AllowInputSort') && SeriesData.AllowInputSort 1708 % [tild,iview]=sort(Series.InputTable(:,2)); %subdirectories sorted in alphabetical order 1709 % Series.InputTable=Series.InputTable(iview,:); 1710 % end 1711 detect=exist(fullfile(Series.InputTable{1,1},SubDirOutNew),'dir');% test if the dir already exist 1712 check_create=1; %need to create the result directory by default 1713 while detect 1714 answer=msgbox_uvmat('INPUT_Y-N',['use existing ouput directory: ' fullfile(Series.InputTable{1,1},SubDirOutNew) ', possibly delete previous data']); 1715 if strcmp(answer,'Cancel') 1716 errormsg='Cancel'; 1717 return 1718 elseif strcmp(answer,'Yes') 1719 detect=0; 1720 check_create=0; 1721 else 1722 r=regexp(SubDirOutNew,'(?<root>.*\D)(?<num1>\d+)$','names');%detect whether name ends by a number 1723 if isempty(r) 1724 r(1).root=[SubDirOutNew '_']; 1725 r(1).num1='0'; 1726 end 1727 SubDirOutNew=[r(1).root num2str(str2num(r(1).num1)+1)];%increment the index by 1 or put 1 1728 detect=exist(fullfile(Series.InputTable{1,1},SubDirOutNew),'dir');% test if the dir already exists 1729 check_create=1; 1730 end 1731 end 1732 Series.OutputDirExt=regexprep(SubDirOutNew,Series.OutputSubDir,''); 1733 Series.OutputRootFile=Series.InputTable{1,3};% the first sorted RootFile taken for output 1734 set(handles.OutputDirExt,'String',Series.OutputDirExt) 1735 OutputDir=fullfile(Series.InputTable{1,1},[Series.OutputSubDir Series.OutputDirExt]);% full name (with path) of output directory 1736 if check_create % create output directory if it does not exist 1737 [tild,msg1]=mkdir(OutputDir); 1738 if ~strcmp(msg1,'') 1739 errormsg=['cannot create ' OutputDir ': ' msg1];%error message for directory creation 1740 return 1741 end 1742 end 1743 % RootOut=fullfile(OutputDir,Series.InputTable{1,3});% name of the parameter xml file set in this directory 1744 end 1745 1746 %% removes unused information on Series 1747 if isfield(Series,'Pairs') 1748 Series=rmfield(Series,'Pairs'); %info Pairs not needed for output 1749 end 1750 Series.IndexRange=rmfield(Series.IndexRange,'TimeTable'); 1751 % Series.IndexRange=rmfield(Series.IndexRange,'MinIndex_j'); 1752 % Series.IndexRange=rmfield(Series.IndexRange,'MaxIndex_i'); 1753 empty_line=false(size(Series.InputTable,1),1); 1754 for iline=1:size(Series.InputTable,1) 1755 empty_line(iline)=isequal(Series.InputTable(iline,1:3),{'','',''}); 1756 end 1757 Series.InputTable(empty_line,:)=[]; 1780 %------------------------------------------------------------------------ 1781 % --- read parameters from the GUI series 1782 %------------------------------------------------------------------------ 1783 function Param=read_GUI_series(handles) 1784 1785 %% read raw parameters from the GUI series 1786 Param=read_GUI(handles.series); 1787 1788 %% clean the output structure by removing unused information 1789 if isfield(Param,'Pairs') 1790 Param=rmfield(Param,'Pairs'); %info Pairs not needed for output 1791 end 1792 Param.IndexRange=rmfield(Param.IndexRange,'TimeTable'); 1793 empty_line=false(size(Param.InputTable,1),1); 1794 for iline=1:size(Param.InputTable,1) 1795 empty_line(iline)=isequal(Param.InputTable(iline,1:3),{'','',''}); 1796 end 1797 Param.InputTable(empty_line,:)=[]; 1758 1798 1759 1799 %------------------------------------------------------------------------ … … 1882 1922 1883 1923 %% Activate the Action fct 1884 [Series,tild,errormsg]=prepare_jobs(handles);% read the parameters from the GUI series 1885 if ~isempty(errormsg) 1886 if ~strcmp(errormsg,'Cancel') 1887 msgbox_uvmat('ERROR',errormsg) 1888 end 1889 return 1890 end 1891 ParamOut=h_fun(Series); 1924 Param=read_GUI_series(handles);% read the parameters from the GUI series 1925 ParamOut=h_fun(Param); 1892 1926 1893 1927 %% Put the first line of the selected Action fct as tooltip help … … 1918 1952 1919 1953 %% Check whether alphabetical sorting of input Subdir is alowed by the Action fct (for multiples series entries) 1920 if isfield(ParamOut,'AllowInputSort')&&isequal(ParamOut.AllowInputSort,'on')&& size( Series.InputTable,1)>11954 if isfield(ParamOut,'AllowInputSort')&&isequal(ParamOut.AllowInputSort,'on')&& size(Param.InputTable,1)>1 1921 1955 [tild,iview]=sort(InputTable(:,2)); %subdirectories sorted in alphabetical order 1922 1956 set(handles.InputTable,'Data',InputTable(iview,:)); … … 1941 1975 MaxIndex_i=get(handles.MaxIndex_i,'Data'); 1942 1976 MaxIndex_j=get(handles.MaxIndex_j,'Data'); 1943 set(handles.num_first_i,'String',num2str(MinIndex_i {1}))% set first as the min index (for the first line)1944 set(handles.num_last_i,'String',num2str(MaxIndex_i {1}))% set last as the max index (for the first line)1977 set(handles.num_first_i,'String',num2str(MinIndex_i(1)))% set first as the min index (for the first line) 1978 set(handles.num_last_i,'String',num2str(MaxIndex_i(1)))% set last as the max index (for the first line) 1945 1979 set(handles.num_incr_i,'String','1') 1946 set(handles.num_first_j,'String',num2str(MinIndex_j {1}))% set first as the min index (for the first line)1947 set(handles.num_last_j,'String',num2str(MaxIndex_j {1}))% set last as the max index (for the first line)1980 set(handles.num_first_j,'String',num2str(MinIndex_j(1)))% set first as the min index (for the first line) 1981 set(handles.num_last_j,'String',num2str(MaxIndex_j(1)))% set last as the max index (for the first line) 1948 1982 set(handles.num_incr_j,'String','1') 1949 1983 else % check index ranges 1950 1984 first_i=1;last_i=1;first_j=1;last_j=1; 1951 if isfield( Series.IndexRange,'first_i')1952 first_i= Series.IndexRange.first_i;1953 % incr_i= Series.IndexRange.incr_i;1954 last_i= Series.IndexRange.last_i;1955 end 1956 if isfield( Series.IndexRange,'first_j')1957 first_j= Series.IndexRange.first_j;1958 % incr_j= Series.IndexRange.incr_j;1959 last_j= Series.IndexRange.last_j;1985 if isfield(Param.IndexRange,'first_i') 1986 first_i=Param.IndexRange.first_i; 1987 % incr_i=Param.IndexRange.incr_i; 1988 last_i=Param.IndexRange.last_i; 1989 end 1990 if isfield(Param.IndexRange,'first_j') 1991 first_j=Param.IndexRange.first_j; 1992 % incr_j=Param.IndexRange.incr_j; 1993 last_j=Param.IndexRange.last_j; 1960 1994 end 1961 1995 if last_i < first_i || last_j < first_j , msgbox_uvmat('ERROR','last field number must be larger than the first one'),... … … 2120 2154 delete(hget_field)%delete opened versions of get_field 2121 2155 end 2122 Series=read_GUI(handles.series);2123 Series.InputTable=Series.InputTable(1,:);2124 filecell=get_file_series( Series);2156 Param=read_GUI(handles.series); 2157 Param.InputTable=Param.InputTable(1,:); 2158 filecell=get_file_series(Param); 2125 2159 if exist(filecell{1,1},'file') 2126 2160 GetFieldData=get_field(filecell{1,1}); … … 2431 2465 if isempty(TransformIndex)%the input string does not exist in the menu 2432 2466 TransformIndex= length(TransformList); 2433 TransformList=[TransformList(1:end-1);{Transform nName};TransformList(end)];% the selected function is appended in the menu, before the last item 'more...'2467 TransformList=[TransformList(1:end-1);{TransformName};TransformList(end)];% the selected function is appended in the menu, before the last item 'more...' 2434 2468 set(handles.TransformName,'String',TransformList) 2435 2469 TransformPathList=[TransformPathList;{TransformPath}]; … … 2451 2485 set(handles.TransformName,'UserData',TransformPathList); 2452 2486 2453 2454 % -------------------------------------------------------------------- 2487 %------------------------------------------------------------------------ 2488 % --- fct activated by the upper bar menu ExportConfig 2489 %------------------------------------------------------------------------ 2455 2490 function MenuExportConfig_Callback(hObject, eventdata, handles) 2456 global Series 2457 [Series,errormsg]=prepare_jobs(handles); 2458 2459 evalin('base','global Series')%make CurData global in the workspace2491 2492 global Param 2493 Param=read_GUI_series(handles); 2494 evalin('base','global Param')%make CurData global in the workspace 2460 2495 display('current series config :') 2461 evalin('base',' Series') %display CurData in the workspace2496 evalin('base','Param') %display CurData in the workspace 2462 2497 commandwindow; %brings the Matlab command window to the front 2463 2498 2464 % -------------------------------------------------------------------- 2499 %------------------------------------------------------------------------ 2500 % --- fct activated by the upper bar menu InportConfig 2501 %------------------------------------------------------------------------ 2465 2502 function MenuImportConfig_Callback(hObject, eventdata, handles) 2466 % -------------------------------------------------------------------- 2503 2467 2504 InputTable=get(handles.InputTable,'Data'); 2468 2505 [FileName, PathName] = uigetfile( ... … … 2476 2513 fill_GUI(Param,handles.series) 2477 2514 2478 % --- Executes on selection change in RunMode. 2479 function RunMode_Callback(hObject, eventdata, handles) 2480 2481 % --- Executes on selection change in Coord_x. 2482 function Coord_x_Callback(hObject, eventdata, handles) 2483 2484 % --- Executes on selection change in Coord_y. 2485 function Coord_y_Callback(hObject, eventdata, handles) 2486 2487 % -------------------------------------------------------------------- 2488 % --- Executes when series is resized. 2515 %------------------------------------------------------------------------ 2516 % --- Executes when the GUI series is resized. 2517 %------------------------------------------------------------------------ 2489 2518 function series_ResizeFcn(hObject, eventdata, handles) 2490 % -------------------------------------------------------------------- 2519 2491 2520 %% input table 2492 2521 set(handles.InputTable,'Unit','pixel') … … 2670 2699 set(hwaitbar,'Position',BarPosition) 2671 2700 end 2672 %TODO: adjust waitbar 2673 2674 % civ_files=get(hfig,'UserData'); 2675 2676 % [filepath,filename,ext]=fileparts(civ_files{1}); 2677 % [tild,SubDir,extdir]=fileparts(filepath); 2678 % SubDir=[SubDir extdir]; 2679 % option_civ=StatusData.option_civ; 2680 % nbfiles=numel(civ_files); 2681 % testrecent=0; 2682 % count=0; 2683 % datnum=zeros(1,nbfiles); 2684 % filefound=cell(1,nbfiles); 2685 % for ifile=1:nbfiles 2686 % detect=exist(civ_files{ifile},'file'); % check the existence of the file 2687 % option=0; 2688 % if detect==0 2689 % option_str='not created'; 2690 % else 2691 % datfile=dir(civ_files{ifile}); 2692 % if isfield(datfile,'datenum') 2693 % datnum(ifile)=datfile.datenum;%only available in recent matlab versions 2694 % testrecent=1; 2695 % end 2696 % filefound(ifile)={datfile.name}; 2697 % 2698 % % check the content netcdf file 2699 % Data=nc2struct(civ_files{ifile},'ListGlobalAttribute','CivStage','patch2','fix2','civ2','patch','fix'); 2700 % option_list={'civ1','fix1','patch1','civ2','fix2','patch2'}; 2701 % if ~isempty(Data.CivStage) 2702 % option=Data.CivStage;%case of Matlab civ 2703 % else 2704 % if ~isempty(Data.patch2) && isequal(Data.patch2,1) 2705 % option=6; 2706 % elseif ~isempty(Data.fix2) && isequal(Data.fix2,1) 2707 % option=5; 2708 % elseif ~isempty(Data.civ2) && isequal(Data.civ2,1); 2709 % option=4; 2710 % elseif ~isempty(Data.patch) && isequal(Data.patch,1); 2711 % option=3; 2712 % elseif ~isempty(Data.fix) && isequal(Data.fix,1); 2713 % option=2; 2714 % else 2715 % option=1; 2716 % end 2717 % end 2718 % option_str=option_list{option}; 2719 % if datnum(ifile)<StatusData.time_ref 2720 % option_str=[option_str ' --OLD--']; 2721 % end 2722 % end 2723 % if option >= option_civ 2724 % count=count+1; 2725 % end 2726 % [filepath,filename,ext]=fileparts(civ_files{ifile}); 2727 % Tabchar{ifile,1}=[fullfile(SubDir,filename) ext '...' option_str]; 2728 % end 2729 % datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files 2730 % if isempty(datnum) 2731 % if testrecent 2732 % message='no civ result created yet'; 2733 % else 2734 % message=''; 2735 % end 2736 % else 2737 % datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files 2738 % [first,ind]=min(datnum); 2739 % [last,indlast]=max(datnum); 2740 % message={[num2str(count) ' file(s) done over ' num2str(nbfiles)] ;['oldest modification: ' cell2mat(filefound(ind)) ' : ' datestr(first)];... 2741 % ['latest modification: ' cell2mat(filefound(indlast)) ' : ' datestr(last)]}; 2742 % end 2743 % hlist=findobj(hfig,'tag','list'); 2744 % htitlebox=findobj(hfig,'tag','titlebox'); 2745 % hwaitbar=findobj(hfig,'tag','waitbar'); 2746 % set(hlist,'String',Tabchar) 2747 % set(htitlebox,'String', message) 2748 % 2749 %------------------------------------------------------------------------ 2750 % launched by deleting the status figure 2751 function stop_status(hObject, eventdata) 2752 %------------------------------------------------------------------------ 2753 hciv=findobj(allchild(0),'tag','series'); 2754 hhciv=guidata(hciv); 2755 set(hhciv.status,'value',0) %reset the status uicontrol in the GUI civ 2756 set(hhciv.status,'BackgroundColor',[0 1 0]) 2757 delete(gcbf) 2758 2701 2702 %------------------------------------------------------------------------ 2759 2703 % --- Executes on selection change in ActionExt. 2704 %------------------------------------------------------------------------ 2760 2705 function ActionExt_Callback(hObject, eventdata, handles) 2706 2761 2707 ActionExtList=get(handles.ActionExt,'String'); 2762 2708 ActionExt=ActionExtList{get(handles.ActionExt,'Value')}; … … 2782 2728 compile(ActionName,TransformPath) 2783 2729 cd(currentdir) 2784 end 2785 2730 end 2786 2731 else 2787 2732 sh_file_info=dir(fullfile(get(handles.ActionPath,'String'),[ActionName '.sh'])); … … 2852 2797 end 2853 2798 menu=menu(1:imax); 2854 -
trunk/src/series/aver_stat.m
r633 r635 94 94 nbfield_i=size(i1_series{1},2); %nb of fields for the i index 95 95 nbfield=nbfield_j*nbfield_i; %total number of fields 96 [first_i,tild,last_i,first_j,tild,last_j,errormsg]=get_index_range(Param.IndexRange);97 if ~isempty(errormsg),display(errormsg),return,end98 96 99 97 %% determine the file type on each line from the first input file … … 140 138 elseif CheckNc{1} 141 139 FileExtOut='.nc';% write result as .nc files for netcdf inputs 142 else 140 else 143 141 msgbox_uvmat('ERROR',['invalid file type input ' FileType{1}]) 144 142 return 145 143 end 146 144 if nbview==2 && ~isequal(CheckImage{1},CheckImage{2}) 147 145 msgbox_uvmat('ERROR','input must be two image series or two netcdf file series') 148 146 return 149 147 end 150 %NomTypeOut='_1-2_1';% output file index will indicate the first and last ref index in the series 148 149 %% settings for the output file 151 150 NomTypeOut=nomtype2pair(NomType{1});% determine the index nomenclature type for the output file 151 first_i=i1_series{1}(1); 152 last_i=i1_series{1}(end); 153 if isempty(j1_series{1})% if there is no second index j 154 first_j=1;last_j=1; 155 else 156 first_j=j1_series{1}(1); 157 last_j=j1_series{1}(end); 158 end 152 159 153 160 %% Set field names and velocity types … … 177 184 for index=1:nbfield 178 185 update_waitbar(WaitbarHandle,index/nbfield) 179 if ~isempty(RUNHandle)&& ishandle(RUNHandle) &&~strcmp(get(RUNHandle,'BusyAction'),'queue')186 if ~isempty(RUNHandle)&& ~strcmp(get(RUNHandle,'BusyAction'),'queue') 180 187 disp('program stopped by user') 181 188 break … … 238 245 239 246 %%%%%%%%%%%% MAIN RUNNING OPERATIONS %%%%%%%%%%%% 240 %update sum241 247 if nbfiles==1 %first field 242 248 time_1=[]; … … 255 261 siz=size(Field.(VarName)); 256 262 if ~isequal(DataOut.(VarName),0)&& ~isequal(siz,sizmean) 257 msgbox_uvmat('ERROR',['unequal size of input field ' VarName ', need to project on a grid'])263 displ_uvmat('ERROR',['unequal size of input field ' VarName ', need to project on a grid'],checkrun) 258 264 return 259 265 else … … 285 291 end 286 292 else % time from ImaDoc prevails if it exists 287 % j1=1;%default288 % if ~isempty(j1_series{1})289 % j1=j1_series{1};290 % end291 %DataOut.Time=time(1,i1_series{1}(1),j1);292 %DataOut.Time_end=time(end,i1_series{end}(end),j1_series{end}(end));293 293 DataOut.Time=time(1); 294 294 DataOut.Time_end=time(end); -
trunk/src/series/check_data_files.m
r626 r635 104 104 Tabchar{2}=''; 105 105 Tabchar{3}=[num2str(FileInfo.FrameRate) ' frames/s ']; 106 message=''; 106 107 % Tabchar{4}=''; 107 108 % Tabchar{5}=[' compression' FileInfo.VideoCompression]; -
trunk/src/series/civ_input.m
r633 r635 195 195 %check_letter=~isempty(regexp(NomTypeIma,'[ab|AB]$'));%detect pair label by letter 196 196 %if isequal(NomTypeNc,'_1-2')||isempty(MaxIndex_j)|| (MaxIndex_j==1) 197 MaxIndex_i=Param.IndexRange.MaxIndex_i{1}; 198 MaxIndex_j=Param.IndexRange.MaxIndex_j{1}; 199 MinIndex_i=Param.IndexRange.MinIndex_i{1}; 200 MinIndex_j=Param.IndexRange.MinIndex_j{1}; 197 MaxIndex_i=Param.IndexRange.MaxIndex_i(1); 198 MinIndex_i=Param.IndexRange.MinIndex_i(1); 199 MaxIndex_j=1;%default 200 MinIndex_j=1; 201 if isfield(Param.IndexRange,'MaxIndex_j')&&isfield(Param.IndexRange,'MinIndex_j') 202 MaxIndex_j=Param.IndexRange.MaxIndex_j(1); 203 MinIndex_j=Param.IndexRange.MinIndex_j(1); 204 end 201 205 CivInputData.MaxIndex_i=MaxIndex_i; 202 206 CivInputData.MaxIndex_j=MaxIndex_j; … … 211 215 set(handles.ListPairMode,'Value',1)% advice 'pair j1-j2' except in MaxIndex_j is large 212 216 end 213 elseif ~(strcmp(FileType,'video') || strcmp(FileType,'mmreader')) 217 %elseif ~(strcmp(FileType,'video') || strcmp(FileType,'mmreader')) 218 else 214 219 set(handles.ListPairMode,'String',{'pair j1-j2';'series(Dj)';'series(Di)'})%multiple choice 215 220 if strcmp(NomTypeNc,'_1-2_1') … … 1131 1136 Time=CivInputData.Time; 1132 1137 checkframe=strcmp(TimeUnit,'frame'); 1133 %displ_num=get(handles.ListPairCiv1,'UserData');1134 1135 %% eliminate the first pairs inconsistent with the position1136 % if isempty(displ_num)1137 % nbpair=0;1138 % else1139 % nbpair=length(displ_num(1,:));%nbre of displayed pairs1140 % if isequal(mode,'series(Di)') %| isequal(mode,'st_series(Di)')1141 % nbpair=min(2*ref_i-1,nbpair);%limit the number of pairs with positive first index1142 % elseif isequal(mode,'series(Dj)')% | isequal(mode,'st_series(Dj)')1143 % nbpair=min(2*ref_j-1,nbpair);%limit the number of pairs with positive first index1144 % end1145 % end1146 % nbpair=min(200,nbpair);%limit the number of displayed pairs to 2001147 1138 1148 1139 %% case with no Civ1 operation, netcdf files need to exist for reading … … 1224 1215 1225 1216 %% determine the menu display in .ListPairCiv1 1226 % the menu depends on the mode defined in ListPairMode_callback through the array displ_num:1227 % displ_num(1,:)=indices j11228 % displ_num(2,:)=indices j21229 % displ_num(3,:)=indices i11230 % displ_num(4,:)=indices i21231 % in mode 'pair j1-j2', j1 and j2 are the file indices, else the indices1232 % are relative to the reference indices ref_i and ref_j respectively.1233 1217 testpair=0; %TODO: check 1234 1218 if isequal(mode,'series(Di)') … … 1239 1223 if select(ipair) 1240 1224 displ_pair{ipair}=['Di= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2))]; 1241 %if ~checkframe && size(Time,1)>=ref_i+1+displ_num(4,ipair) && size(Time,2)>=ref_j+1+displ_num(2,ipair)&&displ_num(2,ipair)>=1 &&displ_num(1,ipair)>=1 1242 % dt=Time(ref_i+1+displ_num(4,ipair),ref_j+1+displ_num(2,ipair))-Time(ref_i+1+displ_num(3,ipair),ref_j+1+displ_num(1,ipair));%Time interval dt 1243 if ~checkframe && size(Time,1)>=ref_i+1+ceil(ipair/2) && size(Time,2)>=ref_j+1&& ref_i-floor(ipair/2)>=0 && ref_j>=0 1225 if ~checkframe 1226 if size(Time,1)>=ref_i+1+ceil(ipair/2) && size(Time,2)>=ref_j+1&& ref_i-floor(ipair/2)>=0 && ref_j>=0 1244 1227 dt=Time(ref_i+1+ceil(ipair/2),ref_j+1)-Time(ref_i+1-floor(ipair/2),ref_j+1);%Time interval dtref_j+1 1228 displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)]; 1229 end 1245 1230 else 1246 dt= 1;1247 end1248 displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)];1231 dt=ipair/1000; 1232 displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(ipair)]; 1233 end 1249 1234 else 1250 1235 displ_pair{ipair}='...'; %pair not displayed in the menu … … 1259 1244 if select(ipair) 1260 1245 displ_pair{ipair}=['Dj= ' num2str(-floor(ipair/2)) '|' num2str(ceil(ipair/2))]; 1261 if ~checkframe && size(Time,1)>=ref_i+1+displ_num(4,ipair) && size(Time,2)>=ref_j+1+displ_num(2,ipair) 1262 dt=Time(ref_i+1+displ_num(4,ipair),ref_j+1+displ_num(2,ipair))-Time(ref_i+1+displ_num(3,ipair),ref_j+1+displ_num(1,ipair));%Time interval dt 1246 if ~checkframe 1247 if size(Time,2)>=ref_j+1+ceil(ipair/2) && size(Time,1)>=ref_i+1 && ref_j-floor(ipair/2)>=0 && ref_i>=0 1248 dt=Time(ref_i+1,ref_j+1+ceil(ipair/2))-Time(ref_i+1,ref_j+1-floor(ipair/2));%Time interval dtref_j+1 1249 displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)]; 1250 end 1251 else 1252 dt=ipair/1000; 1263 1253 displ_pair{ipair}=[displ_pair{ipair} ' :dt= ' num2str(dt*1000)]; 1264 end1254 end 1265 1255 else 1266 1256 displ_pair{ipair}='...'; %pair not displayed in the menu -
trunk/src/series/civ_series.m
r633 r635 79 79 %% input files and indexing 80 80 NbField=1; 81 MaxIndex=cell2mat(Param.IndexRange.MaxIndex); 82 MinIndex=cell2mat(Param.IndexRange.MinIndex); 81 MaxIndex_i=Param.IndexRange.MaxIndex_i; 82 MinIndex_i=Param.IndexRange.MinIndex_i; 83 MaxIndex_j=1;MinIndex_j=1; 84 if isfield(Param.IndexRange,'MaxIndex_j')&& isfield(Param.IndexRange,'MinIndex_j') 85 MaxIndex_j=Param.IndexRange.MaxIndex_j; 86 MinIndex_j=Param.IndexRange.MinIndex_j; 87 end 83 88 if isfield(Param,'InputTable') 84 89 [filecell,i_series,tild,j_series]=get_file_series(Param); … … 120 125 if iview_B==0 121 126 FileType_B=FileType_A; 122 VideoObject_B=VideoObject_A;127 VideoObject_B=VideoObject_A; 123 128 PairCiv1=Param.ActionInput.PairIndices.ListPairCiv1; 124 129 PairCiv2=''; … … 127 132 end 128 133 [i1_series_Civ1,i2_series_Civ1,j1_series_Civ1,j2_series_Civ1,check_bounds,NomTypeNc]=... 129 find_pair_indices(PairCiv1,i_series{1},j_series{1},MinIndex ,MaxIndex);134 find_pair_indices(PairCiv1,i_series{1},j_series{1},MinIndex_i,MaxIndex_i,MinIndex_j,MaxIndex_j); 130 135 if ~isempty(PairCiv2) 131 136 [i1_series_Civ2,i2_series_Civ2,j1_series_Civ2,j2_series_Civ2,check_bounds_Civ2]=... 132 find_pair_indices(PairCiv2,i_series{1},j_series{1},MinIndex ,MaxIndex);137 find_pair_indices(PairCiv2,i_series{1},j_series{1},MinIndex_i,MaxIndex_i,MinIndex_j,MaxIndex_j); 133 138 check_bounds=check_bounds | check_bounds_Civ2; 134 139 end … … 158 163 end 159 164 else 160 165 [FileType_B,FileInfo,VideoObject_B]=get_file_type(filecell{2,1}); 161 166 if isempty(find(strcmp(FileType_B,{'multimage','mmreader','video'}))) 162 167 displ(['ERROR: the file line ' num2str(iview_B) ' must be an image']) 163 end 168 end 164 169 %TODO : introduce the second file series if relevant: case %displacement 165 170 end … … 217 222 %%%%% MAIN LOOP %%%%%% 218 223 for ifield=1:NbField 219 update_waitbar(WaitbarHandle,i ndex/nbfield)220 if ~isempty(RUNHandle) && ishandle(RUNHandle) &&~strcmp(get(RUNHandle,'BusyAction'),'queue')224 update_waitbar(WaitbarHandle,ifield/NbField) 225 if ~isempty(RUNHandle) && ~strcmp(get(RUNHandle,'BusyAction'),'queue') 221 226 disp('program stopped by user') 222 227 break … … 264 269 j2=j2_series_Civ1(ifield); 265 270 end 266 Data.Civ1_Time=(time( i2+1,j2+1)+time(i1+1,j1+1))/2;267 Data.Civ1_Dt=time( i2+1,j2+1)-time(i1+1,j1+1);271 Data.Civ1_Time=(time(j2+1,i2+1)+time(j1+1,i1+1))/2; 272 Data.Civ1_Dt=time(j2+1,i2+1)-time(j1+1,i1+1); 268 273 for ilist=1:length(list_param) 269 274 Data.(Civ1_param{4+ilist})=Param.ActionInput.Civ1.(list_param{ilist}); … … 400 405 ImageName_A_Civ2=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,i1_series_Civ2(ifield),[],j1_series_Civ2(ifield)); 401 406 402 if strcmp(ImageName_A_Civ2,ImageName_A) && isequal(FrameIndex_A_Civ1(ifield),FrameIndex_A_Civ2 )407 if strcmp(ImageName_A_Civ2,ImageName_A) && isequal(FrameIndex_A_Civ1(ifield),FrameIndex_A_Civ2(ifield)) 403 408 par_civ2.ImageA=par_civ1.ImageA; 404 409 else 405 [par_civ2.ImageA,VideoObject_A] = read_image(ImageName_A,FileType_A,VideoObject_A,FrameIndex_A_Civ2 );410 [par_civ2.ImageA,VideoObject_A] = read_image(ImageName_A,FileType_A,VideoObject_A,FrameIndex_A_Civ2(ifield)); 406 411 end 407 412 ImageName_B_Civ2=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,i2_series_Civ2(ifield),[],j2_series_Civ2(ifield)); … … 409 414 par_civ2.ImageB=par_civ1.ImageB; 410 415 else 411 [par_civ2.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ2 );416 [par_civ2.ImageB,VideoObject_B] = read_image(ImageName_B,FileType_B,VideoObject_B,FrameIndex_B_Civ2(ifield)); 412 417 end 413 418 414 419 ncfile=fullfile_uvmat(RootPath,OutputDir,RootFile,'.nc',NomTypeNc,i1_series_Civ2(ifield),i2_series_Civ2(ifield),... 415 420 j1_series_Civ2(ifield),j2_series_Civ2(ifield)); 416 par_civ2.ImageWidth=FileInfo .Width;417 par_civ2.ImageHeight=FileInfo .Height;421 par_civ2.ImageWidth=FileInfo_A.Width; 422 par_civ2.ImageHeight=FileInfo_A.Height; 418 423 419 424 if isfield(par_civ2,'Grid')% grid points set as input file … … 935 940 % --- determine the list of index pairs of processing file 936 941 function [i1_series,i2_series,j1_series,j2_series,check_bounds,NomTypeNc]=... 937 find_pair_indices(str_civ,i_series,j_series,MinIndex ,MaxIndex)942 find_pair_indices(str_civ,i_series,j_series,MinIndex_i,MaxIndex_i,MinIndex_j,MaxIndex_j) 938 943 %------------------------------------------------------------------------ 939 944 i1_series=i_series;% set of first image indexes … … 973 978 i1_series=i_series-ind1;% set of first image numbers 974 979 i2_series=i_series+ind2; 975 check_bounds=i1_series<MinIndex(1,1) | i2_series>MaxIndex(1,1);980 check_bounds=i1_series<MinIndex_i | i2_series>MaxIndex_i; 976 981 if isempty(j_series) 977 982 NomTypeNc='_1-2'; … … 984 989 j1_series=j_series-ind1; 985 990 j2_series=j_series+ind2; 986 check_bounds=j1_series<MinIndex (1,2) | j2_series>MaxIndex(1,2);991 check_bounds=j1_series<MinIndex_j | j2_series>MaxIndex_j; 987 992 NomTypeNc='_1_1-2'; 988 993 else %bursts -
trunk/src/series/float_tracking.m
r619 r635 115 115 nbfield_i=size(i1_series{1},2); %nb of fields for the i index 116 116 nbfield=nbfield_j*nbfield_i; %total number of fields 117 [first_i,tild,last_i,first_j,tild,last_j,errormsg]=get_index_range(Param.IndexRange);118 if ~isempty(errormsg),display(errormsg),return,end119 117 120 118 %% frame index for movie or multimage file input -
trunk/src/series/ima_levels.m
r633 r635 151 151 for ifile=1:nbfield 152 152 update_waitbar(WaitbarHandle,ifile/nbfield) 153 if ~isempty(RUNHandle) &&ishandle(RUNHandle)&& ~strcmp(get(RUNHandle,'BusyAction'),'queue')153 if ~isempty(RUNHandle)&& ~strcmp(get(RUNHandle,'BusyAction'),'queue') 154 154 disp('program stopped by user') 155 155 return -
trunk/src/series/merge_proj.m
r633 r635 51 51 ParamOut.TransformPath=fullfile(fileparts(which('uvmat')),'transform_field');% path to transform functions (needed for compilation only) 52 52 ParamOut.ProjObject='on';%can use projection object(option 'off'/'on', 53 ParamOut.Mask='o ff';%can use mask option (option 'off'/'on', 'off' by default)53 ParamOut.Mask='on';%can use mask option (option 'off'/'on', 'off' by default) 54 54 ParamOut.OutputDirExt='.mproj';%set the output dir extension 55 55 ParamOut.OutputFileMode='NbInput';% '=NbInput': 1 output file per input file index, '=NbInput_i': 1 file per input file index i, '=NbSlice': 1 file per slice … … 58 58 msgbox_uvmat('WARNING','the first input file does not exist') 59 59 elseif isequal(size(Param.InputTable,1),1) && ~isfield(Param,'ProjObject') 60 msgbox_uvmat('WARNING',' a projection object of type plane needs to be introducedfor merge_proj')60 msgbox_uvmat('WARNING','You may need a projection object of type plane for merge_proj') 61 61 end 62 62 return -
trunk/src/series/particle_tracking.m
r619 r635 115 115 nbfield_i=size(i1_series{1},2); %nb of fields for the i index 116 116 nbfield=nbfield_j*nbfield_i; %total number of fields 117 [first_i,tild,last_i,first_j,tild,last_j,errormsg]=get_index_range(Param.IndexRange);118 if ~isempty(errormsg),display(errormsg),return,end119 117 120 118 %% frame index for movie or multimage file input -
trunk/src/series/relabel_i_j.m
r624 r635 226 226 for ifile=1:nbfield 227 227 update_waitbar(WaitbarHandle,ifile/nbfield) 228 if ishandle(RUNHandle) && ~strcmp(get(RUNHandle,'BusyAction'),'queue')228 if ~isempty(RUNHandle) && ~strcmp(get(RUNHandle,'BusyAction'),'queue') 229 229 disp('program stopped by user') 230 230 break -
trunk/src/series/time_series.m
r633 r635 98 98 nbfield_i=size(i1_series{1},2); %nb of fields for the i index 99 99 nbfield=nbfield_j*nbfield_i; %total number of fields 100 [first_i,tild,last_i,first_j,tild,last_j,errormsg]=get_index_range(Param.IndexRange);101 if ~isempty(errormsg),display(errormsg),return,end100 % [first_i,tild,last_i,first_j,tild,last_j,errormsg]=get_index_range(Param.IndexRange); 101 % if ~isempty(errormsg),display(errormsg),return,end 102 102 103 103 %% determine the file type on each line from the first input file … … 153 153 return 154 154 end 155 156 %% settings for the output file 155 157 NomTypeOut=nomtype2pair(NomType{1});% determine the index nomenclature type for the output file 158 first_i=i1_series{1}(1); 159 last_i=i1_series{1}(end); 160 if isempty(j1_series{1})% if there is no second index j 161 first_j=1;last_j=1; 162 else 163 first_j=j1_series{1}(1); 164 last_j=j1_series{1}(end); 165 end 156 166 157 167 %% Set field names and velocity types … … 210 220 for index=1:nbfield 211 221 update_waitbar(WaitbarHandle,index/nbfield) 212 if ~isempty(RUNHandle) && ishandle(RUNHandle) &&~strcmp(get(RUNHandle,'BusyAction'),'queue')222 if ~isempty(RUNHandle) && ~strcmp(get(RUNHandle,'BusyAction'),'queue') 213 223 disp('program stopped by user') 214 224 break % leave the loop if stop is ordered -
trunk/src/uigetfile_uvmat.m
r620 r635 67 67 %set(hrefresh,'UserData',StatusData) 68 68 if strcmp(option,'status_display') %put a run advancement display 69 set(hfig,'DeleteFcn',@stop_status) 70 uicontrol('Style','frame','Units','normalized', 'Position',[0.05 0.81 0.01 0.05],'BackgroundColor',[1 0 0],'tag','waitbar'); 71 uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.81 0.9 0.05]); 69 set(hfig,'DeleteFcn',@(src,event)close(option,src,event)) 70 uicontrol('Style','frame','Units','normalized', 'Position', [0.05 0.85 0.9 0.04]); 71 uicontrol('Style','frame','Units','normalized', 'Position',[0.05 0.85 0.01 0.04],'BackgroundColor',[1 0 0],'tag','waitbar'); 72 72 73 else %put a title and additional pushbuttons 73 74 uicontrol('Style','text','Units','normalized', 'Position', [0.15 0.75 0.6 0.03],'BackgroundColor',BackgroundColor,... … … 109 110 DirName=get(htitlebox,'String'); 110 111 hsort_option=findobj(hfig,'tag','sort_option'); 111 sort_option='name'; 112 if strcmp(get(hsort_option,'Visible'),'on')&& isequal(get(hsort_option,'Value'),2) 113 sort_option='date'; 114 end 115 hcheck_date=findobj(hfig,'tag','check_date'); 116 ListFiles=list_files(DirName,get(hcheck_date,'Value'),sort_option);% list the directory content 117 118 set(hlist,'String',ListFiles) 119 Value=[]; 120 if ~isempty(InputFileName) 121 Value=find(strcmp(InputFileName,ListFiles)); 122 end 123 if isempty(Value) 124 Value=1; 125 end 126 set(hlist,'Value',Value) 127 set(hlist,'BackgroundColor',[0.7 0.7 0.7]) 128 if strcmp(get(hfig,'Tag'),'status_display') 112 if strcmp(get(hfig,'Tag'),'status_display') 129 113 hseries=findobj(allchild(0),'tag','series'); 130 hstatus=findobj(hseries,'tag','status _display');114 hstatus=findobj(hseries,'tag','status'); 131 115 StatusData=get(hstatus,'UserData'); 132 116 TimeStart=0; 133 117 if isfield(StatusData,'TimeStart') 134 118 TimeStart=StatusData.TimeStart; 135 end 119 end 136 120 hlist=findobj(hfig,'tag','list'); 137 testrecent=0; 138 datnum=zeros(numel(ListDisplay),1); 139 for ilist=1:numel(ListDisplay) 140 ListDisplay{ilist}=ListFiles(ilist).name; 141 if ListFiles(ilist).isdir 142 ListDisplay{ilist}=['/' ListDisplay{ilist}]; 143 elseif isfield(ListFiles(ilist),'datenum') 144 datnum(ilist)=ListFiles(ilist).datenum;%only available in recent matlab versions 145 testrecent=1; 146 if datnum(ilist)<TimeStart 147 ListDisplay{ilist}=[ListDisplay{ilist} ' --OLD--']; 148 end 149 end 150 end 151 152 %% Look at date of creation 153 ListDisplay=ListDisplay(datnum~=0); 154 datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files 155 121 testrecent=0; 156 122 NbOutputFile=[]; 157 if isempty(datnum) 158 if testrecent 159 message='no result created yet'; 160 else 161 message=''; 162 end 163 else 164 [first,indfirst]=min(datnum); 165 [last,indlast]=max(datnum); 166 NbOutputFile_str='?'; 167 if isfield(StatusData,'NbOutputFile') 168 NbOutputFile=StatusData.NbOutputFile; 169 NbOutputFile_str=num2str(NbOutputFile); 170 end 171 message={[num2str(numel(datnum)) ' file(s) done over ' NbOutputFile_str] ;['oldest modification: ' ListDisplay{indfirst} ' : ' datestr(first)];... 172 ['latest modification: ' ListDisplay{indlast} ' : ' datestr(last)]}; 173 end 174 set(htitlebox,'String', [DirName{1};message]) 123 if isfield(StatusData,'NbOutputFile') 124 NbOutputFile=StatusData.NbOutputFile; 125 NbOutputFile_str=num2str(NbOutputFile); 126 end 127 [ListFiles,NumFiles]=list_files(DirName,1,TimeStart);% list the directory content 175 128 176 129 %% update the waitbar … … 178 131 if ~isempty(NbOutputFile) 179 132 BarPosition=get(hwaitbar,'Position'); 180 BarPosition(3)=0.9* numel(datnum)/NbOutputFile;133 BarPosition(3)=0.9*max(0.01,NumFiles/NbOutputFile);% the bar width cannot be set to 0, set to 0.01 instead 181 134 set(hwaitbar,'Position',BarPosition) 182 135 end 183 end 184 136 else 137 sort_option='name'; 138 if strcmp(get(hsort_option,'Visible'),'on')&& isequal(get(hsort_option,'Value'),2) 139 sort_option='date'; 140 end 141 hcheck_date=findobj(hfig,'tag','check_date'); 142 [ListFiles,NumFiles]=list_files(DirName,get(hcheck_date,'Value'),sort_option);% list the directory content 143 end 144 145 set(hlist,'String',ListFiles) 146 Value=[]; 147 if ~isempty(InputFileName) 148 Value=find(strcmp(InputFileName,ListFiles)); 149 end 150 if isempty(Value) 151 Value=1; 152 end 153 set(hlist,'Value',Value) 154 set(hlist,'BackgroundColor',[0.7 0.7 0.7]) 185 155 %------------------------------------------------------------------------ 186 156 % --- launched by selecting an item on the file list … … 272 242 %------------------------------------------------------------------------- 273 243 % list the content of a directory 274 function ListFiles=list_files(DirName,check_date,sort_option)244 function [ListFiles,NumFiles]=list_files(DirName,check_date,sort_option) 275 245 %------------------------------------------------------------------------- 276 246 ListStruct=dir(DirName);% get structure of the current directory 247 NumFiles=0; %default 277 248 if numel(ListStruct)<1 % case of empty dir 278 249 ListFiles={}; … … 283 254 check_dir=cell2mat(ListCells(4,:));% =1 for directories, =0 for files 284 255 ListFiles(check_dir)=regexprep(ListFiles(check_dir),'^.+','+/$0');% put '+/' in front of dir name display 285 if strcmp(sort_option,'date') 286 ListDates=cell2mat(ListCells(5,:));%list of numerical dates 287 ListDates(check_dir)=max(ListDates(~check_dir))+1000; % we set the dir in front 256 ListDates=cell2mat(ListCells(5,:));%list of numerical dates 257 if isnumeric(sort_option) 258 check_old=ListDates<sort_option-1;% -1 is put to account for a 1 s delay in the record of starting time 259 NumFiles=numel(find(~check_old&~check_dir)); 260 end 261 if ~isempty(find(~check_dir)) 262 ListDates(check_dir)=max(ListDates(~check_dir))+1000; % we set the dir in front 263 end 264 if isnumeric(sort_option)|| strcmp(sort_option,'date') 288 265 [tild,index_sort]=sort(ListDates,2,'descend');% sort files by chronological order, recent first, put the dir first in the list 289 266 else … … 295 272 ListFiles=[{'+/..'} ListFiles(check_keep)]; 296 273 if check_date 297 ListDateString=ListCells(2,:);%list of file dates 298 ListDateString(check_dir)={''}; 299 ListDateString=ListDateString(index_sort);% sort the corresponding dates 300 ListDateString=[{''} ListDateString(check_keep)]; 301 ListFiles=[ListFiles; ListDateString]; 302 ListFiles=cell2tab(ListFiles','...'); 274 ListDateString=ListCells(2,:);%list of file dates 275 if isnumeric(sort_option) 276 ListDateString(check_old)={'--OLD--'}; 277 end 278 ListDateString(check_dir)={''}; 279 ListDateString=ListDateString(index_sort);% sort the corresponding dates 280 ListDateString=[{''} ListDateString(check_keep)]; 281 ListFiles=[ListFiles; ListDateString]; 282 ListFiles=cell2tab(ListFiles','...'); 303 283 end 304 284 … … 343 323 %------------------------------------------------------------------------- 344 324 if strcmp(option,'status_display') 345 hseries=findobj(allchild(0),' tag','series');346 hstatus=findobj(h fig,'Tag','status_display');347 set(h hciv.status,'value',0) %reset the status uicontrol in the GUI civ348 set(h hciv.status,'BackgroundColor',[0 1 0])325 hseries=findobj(allchild(0),'Tag','series'); 326 hstatus=findobj(hseries,'Tag','status'); 327 set(hstatus,'value',0) %reset the status uicontrol in the GUI series 328 set(hstatus,'BackgroundColor',[0 1 0]) 349 329 end 350 330 delete(gcbf) -
trunk/src/uvmat.m
r627 r635 1465 1465 function runplus_Callback(hObject, eventdata, handles) 1466 1466 %------------------------------------------------------------------------ 1467 1467 1468 set(handles.runplus,'BackgroundColor',[1 1 0])%paint the command button in yellow 1468 1469 drawnow 1469 %TODO: introduce the option: increment ='*' to move to the next available view 1470 increment=str2num(get(handles.num_IndexIncrement,'String')); %get the field increment d 1471 % if isnan(increment) 1472 % set(handles.num_IndexIncrement,'String','1')%default value 1473 % increment=1; 1474 % end 1470 increment=str2double(get(handles.num_IndexIncrement,'String')); %get the field increment d 1471 if isnan(increment)% case of free increment: move to next available field index 1472 increment='+'; 1473 end 1475 1474 errormsg=runpm(hObject,eventdata,handles,increment); 1476 1475 if ~isempty(errormsg) … … 1485 1484 function runmin_Callback(hObject, eventdata, handles) 1486 1485 %------------------------------------------------------------------------ 1486 1487 1487 set(handles.runmin,'BackgroundColor',[1 1 0])%paint the command button in yellow 1488 1488 drawnow 1489 increment=-str2num(get(handles.num_IndexIncrement,'String')); %get the field increment d 1490 % if isnan(increment) 1491 % set(handles.num_IndexIncrement,'String','1')%default value 1492 % increment=1; 1493 % end 1489 increment=-str2double(get(handles.num_IndexIncrement,'String')); %get the field increment d 1490 if isnan(increment)% case of free increment: move to previous available field index 1491 increment='-'; 1492 end 1494 1493 errormsg=runpm(hObject,eventdata,handles,increment); 1495 1494 if ~isempty(errormsg) … … 1502 1501 function Movie_Callback(hObject, eventdata, handles) 1503 1502 %------------------------------------------------------------------------ 1503 1504 1504 set(handles.Movie,'BackgroundColor',[1 1 0])%paint the command button in yellow 1505 1505 drawnow 1506 increment=str2num(get(handles.num_IndexIncrement,'String')); %get the field increment d 1507 % if isnan(increment) 1508 % set(handles.num_IndexIncrement,'String','1')%default value 1509 % increment=1; 1510 % end 1506 increment=str2double(get(handles.num_IndexIncrement,'String')); %get the field increment d 1507 if isnan(increment)% case of free increment: move to next available field index 1508 increment='+'; 1509 end 1511 1510 set(handles.STOP,'Visible','on') 1512 1511 set(handles.speed,'Visible','on') … … 1535 1534 set(handles.MovieBackward,'BackgroundColor',[1 1 0])%paint the command button in yellow 1536 1535 drawnow 1537 increment=-str2num(get(handles.num_IndexIncrement,'String')); %get the field increment d 1536 increment=-str2double(get(handles.num_IndexIncrement,'String')); %get the field increment d 1537 if isnan(increment)% case of free increment: move to next available field index 1538 increment='-'; 1539 end 1538 1540 set(handles.STOP,'Visible','on') 1539 1541 set(handles.speed,'Visible','on') … … 1607 1609 1608 1610 %% increment (or decrement) the field indices and update the input filename(s) 1609 if isempty(increment)1611 if ~isnumeric(increment)% undefined increment value 1610 1612 set(handles.CheckFixPair,'Value',0) 1611 1613 end … … 1617 1619 j1_1=j1; 1618 1620 j2_1=j2; 1619 if CheckFixPair 1621 if CheckFixPair && isnumeric(increment) 1620 1622 if get(handles.scan_i,'Value')==1% case of scanning along index i 1621 1623 i1=i1+increment; … … 1624 1626 i1_1=i1_1+increment; 1625 1627 i2_1=i2_1+increment; 1626 end 1627 1628 end 1628 1629 else % case of scanning along index j (burst numbers) 1629 1630 j1=j1+increment; … … 1649 1650 end 1650 1651 end 1651 if ~isempty(increment)1652 if isnumeric(increment) 1652 1653 if get(handles.scan_i,'Value')==1% case of scanning along index i 1653 1654 ref_i=ref_i+increment;% increment the current reference index i … … 1657 1658 else % free increment 1658 1659 runaction=get(gcbo,'tag'); 1659 if strcmp( runaction,'runplus')||strcmp(runaction,'Movie')% if runplus or movie is activated1660 if strcmp(increment,'+')% if runplus or movie is activated 1660 1661 step=1; 1661 1662 else … … 1719 1720 end 1720 1721 end 1721 if ~isempty(increment)1722 if isnumeric(increment) 1722 1723 if get(handles.scan_i,'Value')==1% case of scanning along index i 1723 1724 ref_i_1=ref_i_1+increment;% increment the current reference index i
Note: See TracChangeset
for help on using the changeset viewer.