Changeset 1153 for trunk


Ignore:
Timestamp:
Jul 5, 2024, 9:00:14 AM (6 months ago)
Author:
sommeria
Message:

civ3 improved

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/read_civdata.m

    r1135 r1153  
    191191if iscell(vel_type),vel_type=vel_type{1}; end%transform cell to string if needed
    192192errormsg='';
     193if CivStage>=6
     194    CivStage=6;
     195end
    193196
    194197%% select the priority order for automatic vel_type selection
    195 if strcmp(vel_type,'civ2') && strcmp(ProjModeRequest,'derivatives')
    196     vel_type='filter2';
    197 elseif strcmp(vel_type,'civ1') && strcmp(ProjModeRequest,'derivatives')
    198     vel_type='filter1';
     198if strcmp(ProjModeRequest,'derivatives')&& numel(vel_type)>=3 && strcmp(vel_type(1:3),'civ')
     199    vel_type=['filter' vel_type(4:end)];
    199200end
    200201if isempty(vel_type)||strcmp(vel_type,'*')
    201202    vel_type='filter2';% case CivStage >=6
    202203    switch CivStage
     204        case {1,2}% civ1 available but not filter1
     205            vel_type='civ1';
     206        case 3
     207            vel_type='filter1';
     208
    203209        case {4,5}% civ2 available but not filter2
    204210            if strcmp(ProjModeRequest,'derivatives')% derivatives needed
     
    207213                vel_type='civ2';
    208214            end
    209         case 3
    210             vel_type='filter1';
    211         case {1,2}% civ1 available but not filter1
    212             vel_type='civ1';
    213215    end
    214216end
  • trunk/src/series/civ_input.m

    r1152 r1153  
    140140
    141141        iview_image=2;%line # for the input images
    142     case 'civxdata'% case of  civx data,
    143         msgbox_uvmat('ERROR','old civX convention, use the GUI civ')
    144         return
    145142    otherwise
    146143        if ~strcmp(FieldType,'image')
     
    216213%show the reference image edit box if relevant (not needed for movies or in the absence of time information
    217214if numel(time)>=2 % if there are at least two time values to define dt
    218     if size(time,1)<MaxIndex_i;
     215    if size(time,1)<MaxIndex_i
    219216        msgbox_uvmat('WARNING','maximum i index restricted by the timing of the xml file');
    220217    elseif size(time,2)<MaxIndex_j
     
    252249    end
    253250else  %case of netcdf file opening, start with the stage read in the file if the input file is being refreshed
    254 %     if isequal(get(hhseries.REFRESH,'BackgroundColor'),[1 1 0]) &&...
    255 %             ~(isfield(Param,'ActionInput') && isfield(Param.ActionInput,'ConfigSource'))
    256             for index = 1:min(ind_opening,5)
    257                 set(handles.(ListOptions{index}),'value',0)
    258                 fill_civ_input(Data,handles); %fill civ_input with the parameters retrieved from an input Civ file
    259             end
    260             if isempty(FileInfo)
    261             FileInfo.FileName='';
    262 end
    263             set(handles.ConfigSource,'String',FileInfo.FileName);
    264             set(handles.(ListOptions{min(ind_opening+1,6)}),'value',1)
    265             for index = ind_opening+2:6
    266                 set(handles.(ListOptions{index}),'value',0)
    267             end
    268             checkrefresh=1;
    269 %     end
    270     if ind_opening>=3
     251    %     if isequal(get(hhseries.REFRESH,'BackgroundColor'),[1 1 0]) &&...
     252    %             ~(isfield(Param,'ActionInput') && isfield(Param.ActionInput,'ConfigSource'))
     253    for index = 1:min(ind_opening,5)
     254        set(handles.(ListOptions{index}),'value',0)
     255        fill_civ_input(Data,handles); %fill civ_input with the parameters retrieved from an input Civ file
     256    end
     257    if isempty(FileInfo)
     258        FileInfo.FileName='';
     259    end
     260    set(handles.ConfigSource,'String',FileInfo.FileName);
     261    if ind_opening<6
     262        for index = 1:ind_opening
     263            set(handles.(ListOptions{index}),'value',0)
     264        end
     265        for index = ind_opening+1:6
     266            set(handles.(ListOptions{index}),'value',1)
     267        end
     268        set(handles.CheckCiv3,'Visible','off')% make visible the switch 'iterate/repet' for Civ2.
     269        set(handles.CheckCiv3,'Value',0)% select'iterate/repet' by default
     270    else
     271        for index = 1:3
     272            set(handles.(ListOptions{index}),'value',0)
     273        end
     274        for index = 4:6
     275            set(handles.(ListOptions{index}),'value',1)
     276        end
    271277        set(handles.CheckCiv3,'Visible','on')% make visible the switch 'iterate/repet' for Civ2.
    272     else
    273         set(handles.CheckCiv3,'Visible','off')
    274     end
     278        set(handles.CheckCiv3,'Value',1)% select'iterate/repet' by default
     279    end
     280    checkrefresh=1;
     281    %     end
     282    % if ind_opening==6
     283    %     set(handles.CheckCiv3,'Visible','on')% make visible the switch 'iterate/repet' for Civ2.
     284    % else
     285    %     set(handles.CheckCiv3,'Visible','off')
     286    % end
    275287end
    276288
     
    10781090end
    10791091
    1080 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1081 % Callbacks in the uipanel Fix1
    1082 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1083 %------------------------------------------------------------------------
    1084 % % --- Executes on button press in CheckMask.
    1085 % function get_mask_fix1_Callback(hObject, eventdata, handles)
    1086 % %------------------------------------------------------------------------
    1087 % maskval=get(handles.CheckMask,'Value');
    1088 % if isequal(maskval,0)
    1089 %     set(handles.Mask,'String','')
    1090 % else
    1091 %     mask_displ='no mask'; %default
    1092 %     filebase=get(handles.RootPath,'String');
    1093 %     [nbslice, flag_mask]=get_mask(filebase,handles);
    1094 %     if isequal(flag_mask,1)
    1095 %         mask_displ=[num2str(nbslice) 'mask'];
    1096 %     elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series
    1097 %         filebase_a=get(handles.RootFile_1,'String');
    1098 %         [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles);
    1099 %         if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice)
    1100 %             mask_displ='no mask';
    1101 %         end
    1102 %     end
    1103 %     if isequal(mask_displ,'no mask')
    1104 %         [FileName, PathName, filterindex] = uigetfile( ...
    1105 %             {'*.png', ' (*.png)';
    1106 %             '*.png',  '.png files '; ...
    1107 %             '*.*', 'All Files (*.*)'}, ...
    1108 %             'Pick a mask file *.png',filebase);
    1109 %         mask_displ=fullfile(PathName,FileName);
    1110 %         if ~exist(mask_displ,'file')
    1111 %             mask_displ='no mask';
    1112 %         end
    1113 %     end
    1114 %     if isequal(mask_displ,'no mask')
    1115 %         set(handles.CheckMask,'Value',0)
    1116 %         set(handles.CheckMask,'Value',0)
    1117 %         set(handles.CheckMask,'Value',0)
    1118 %     else
    1119 %         %set(handles.CheckMask,'Value',1)
    1120 %         set(handles.CheckMask,'Value',1)
    1121 %     end
    1122 %     set(handles.Mask,'String',mask_displ)
    1123 %     set(handles.Mask,'String',mask_displ)
    1124 %     set(handles.Mask,'String',mask_displ)
    1125 % end
    1126 
    1127 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1128 % Callbacks in the uipanel Civ2
    1129 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    1130 %------------------------------------------------------------------------
    1131 % --- Executes on button press in CheckMask: select box for mask option
    1132 function get_mask_civ2_Callback(hObject, eventdata, handles)
    1133 %------------------------------------------------------------------------
    1134 maskval=get(handles.CheckMask,'Value');
    1135 if isequal(maskval,0)
    1136     set(handles.Mask,'String','')
    1137 else
    1138     mask_displ='no mask'; %default
    1139     filebase=get(handles.RootPath,'String');
    1140     [nbslice, flag_mask]=get_mask(filebase,handles);
    1141     if isequal(flag_mask,1)
    1142         mask_displ=[num2str(nbslice) 'mask'];
    1143     elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series
    1144         filebase_a=get(handles.RootFile_1,'String');
    1145         [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles);
    1146         if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice)
    1147             mask_displ='no mask';
    1148         end
    1149     end
    1150     if isequal(mask_displ,'no mask')
    1151         [FileName, PathName, filterindex] = uigetfile( ...
    1152             {'*.png', ' (*.png)';
    1153             '*.png',  '.png files '; ...
    1154             '*.*', 'All Files (*.*)'}, ...
    1155             'Pick a mask file *.png',filebase);
    1156         mask_displ=fullfile(PathName,FileName);
    1157         if ~exist(mask_displ,'file')
    1158             mask_displ='no mask';
    1159         end
    1160     end
    1161     if isequal(mask_displ,'no mask')
    1162         set(handles.CheckMask,'Value',0)
    1163         set(handles.CheckMask,'Value',0)
    1164     else
    1165         set(handles.CheckMask,'Value',1)
    1166     end
    1167     set(handles.Mask,'String',mask_displ)
    1168 end
    1169 
    1170 % %------------------------------------------------------------------------
    1171 % % --- Executes on button press in CheckMask.
    1172 % function get_mask_fix2_Callback(hObject, eventdata, handles)
    1173 % %------------------------------------------------------------------------
    1174 % maskval=get(handles.CheckMask,'Value');
    1175 % if isequal(maskval,0)
    1176 %     set(handles.Mask,'String','')
    1177 % else
    1178 %     mask_displ='no mask'; %default
    1179 %     filebase=get(handles.RootPath,'String');
    1180 %     [nbslice, flag_mask]=get_mask(filebase,handles);
    1181 %     if isequal(flag_mask,1)
    1182 %         mask_displ=[num2str(nbslice) 'mask'];
    1183 %     elseif get(handles.ListCompareMode,'Value')>1 & ~isequal(mask_displ,'no mask')% look for the second mask series
    1184 %         filebase_a=get(handles.RootFile_1,'String');
    1185 %         [nbslice_a, flag_mask_a]=get_mask(filebase_a,handles);
    1186 %         if isequal(flag_mask_a,0) || ~isequal(nbslice_a,nbslice)
    1187 %             mask_displ='no mask';
    1188 %         end
    1189 %     end
    1190 %     if isequal(mask_displ,'no mask')
    1191 %         [FileName, PathName, filterindex] = uigetfile( ...
    1192 %             {'*.png', ' (*.png)';
    1193 %             '*.png',  '.png files '; ...
    1194 %             '*.*', 'All Files (*.*)'}, ...
    1195 %             'Pick a mask file *.png',filebase);
    1196 %         mask_displ=fullfile(PathName,FileName);
    1197 %         if ~exist(mask_displ,'file')
    1198 %             mask_displ='no mask';
    1199 %         end
    1200 %     end
    1201 %     if isequal(mask_displ,'no mask')
    1202 %         set(handles.CheckMask,'Value',0)
    1203 %     end
    1204 %     set(handles.Mask,'String',mask_displ)
    1205 % end
    1206 
    1207 %------------------------------------------------------------------------
    1208 % --- function called to look for mask files
    1209 function [nbslice, flag_mask]=get_mask(filebase,handles)
    1210 %------------------------------------------------------------------------
    1211 %detect mask files, images with appropriate file base
    1212 %[filebase '_' xx 'mask'], xx=nbslice
    1213 %flag_mask=1 indicates detection
    1214 
    1215 flag_mask=0;%default
    1216 nbslice=1;
    1217 
    1218 % subdir=get(handles.Civ1_ImageB,'String');
    1219 [Path,Name]=fileparts(filebase);
    1220 if ~isdir(Path)
    1221     msgbox_uvmat('ERROR','no path for input files')
    1222     return
    1223 end
    1224 % currentdir=pwd;
    1225 % cd(Path);%move in the dir of the root name filebase
    1226 maskfiles=dir(fullfile(Path,[Name '_*mask_*.png']));%look for mask files
    1227 % cd(currentdir);%come back to the current working directory
    1228 if ~isempty(maskfiles)
    1229     %     msgbox_uvmat('ERROR','no mask available, to create it use Tools/Make mask in the upper menu bar of uvmat')
    1230     % else
    1231     flag_mask=1;
    1232     maskname=maskfiles(1).name;% take the first mask file in the list
    1233     [Path2,Name,ext]=fileparts(maskname);
    1234     Namedouble=double(Name);
    1235     val=(48>Namedouble)|(Namedouble>57);% select the non-numerical characters
    1236     ind_mask=findstr('mask',Name);
    1237     i=ind_mask-1;
    1238     while val(i)==0 && i>0
    1239         i=i-1;
    1240     end
    1241     nbslice=str2double(Name(i+1:ind_mask-1));
    1242     if ~isnan(nbslice) && Name(i)=='_'
    1243         flag_mask=1;
    1244     else
    1245         msgbox_uvmat('ERROR',['bad mask file ' Name ext ' found in ' Path2])
    1246         return
    1247         nbslice=1;
    1248     end
    1249 end
    1250 
    12511092%------------------------------------------------------------------------
    12521093% --- function called to look for grid files
     
    14191260function CheckMask_Callback(hObject, eventdata, handles)
    14201261%------------------------------------------------------------------------
    1421 value=get(hObject,'Value');
    14221262hparent=get(hObject,'parent');
    1423 parent_tag=get(hparent,'Tag');
    14241263hchildren=get(hparent,'children');
    14251264handle_txtbox=findobj(hchildren,'tag','Mask');% look for the mask name box in the same panel
    1426 handle_NbSlice=findobj(hchildren,'tag','num_NbSlice');% look for the mask name box in the same panel
     1265% handle_NbSlice=findobj(hchildren,'tag','num_NbSlice');% look for the mask name box in the same panel
    14271266testmask=0;
    1428 if value
     1267if get(hObject,'Value')% if the checkbox is activated
    14291268    hseries=findobj(allchild(0),'Tag','series');
    14301269    hhseries=guidata(hseries);
    14311270    InputTable=get(hhseries.InputTable,'Data');
    1432     ind_A=1;% line index of the (first) image series
    1433     if strcmp(InputTable{1,5},'.nc');
    1434         ind_A=2;
    1435     end
    1436  % browse for a mask
    1437         filemask= uigetfile_uvmat('pick a mask image file:',InputTable{ind_A,1},'image');
    1438         [FilePath,FileName,Ext]=fileparts(filemask);   
    1439         [RootPath,SubDir,RootFile,i1_series,i2,j1,j2,NomType]=find_file_series(FilePath,[FileName,Ext]);
     1271    if strcmp(InputTable{1,5},'.nc')
     1272        ind_A=2;%case of nc file as input (for civ3), image in second line
     1273    else
     1274        ind_A=1;% line index of the (first) image series
     1275    end
     1276    % browse for a mask
     1277    filemask= uigetfile_uvmat('pick a mask image file:',InputTable{ind_A,1},'image');
     1278    if ~isempty(filemask)
     1279        [FilePath,FileName,FileExt]=fileparts(filemask);
     1280        [RootPath,SubDir,RootFile,i1_series,i2,j1,j2,NomType]=find_file_series(FilePath,[FileName FileExt]);
    14401281        if strcmp(NomType,'_1')
    1441            NbSlice=i1_series(1,2,end);
    1442            set(handles.num_NbSlice,'String',num2str(NbSlice))
     1282            NbSlice=i1_series(1,2,end);
     1283            set(handles.num_NbSlice,'String',num2str(NbSlice))
     1284        elseif ~strcmp(NomType,'*')
     1285            msgbox_uvmat('ERROR','multilevel masks must be labeled with a single index as _1,_2,...');
     1286            return
    14431287        end
    14441288        set(hObject,'UserData',filemask);%store for future use
    1445         if ~isempty(filemask)
    1446             testmask=1;
    1447         end
     1289        testmask=1;
     1290    end
    14481291end
    14491292if testmask
  • trunk/src/series/civ_series.m

    r1152 r1153  
    903903        time_total=toc(tstart);
    904904        disp(['ellapsed time ' num2str(time_total/60,2) ' minutes'])
    905         disp(['time image reading ' num2str(time_input,2) ' s'])
     905        if exist('time_input','var')
     906            disp(['time image reading ' num2str(time_input,2) ' s'])
     907        end
    906908        disp(['time civ1 ' num2str(time_civ1,2) ' s'])
    907909        disp(['time patch1 ' num2str(time_patch1,2) ' s'])
  • trunk/src/uvmat.m

    r1152 r1153  
    28782878            set(handles.CheckMask,'Value',0)
    28792879        end
     2880
    28802881        [MaskPath,MaskName,MaskExt]=fileparts(MaskFullName);
    2881         [tild,tild,MaskFile,i1_series,i2_series,j1_series,j2_series,MaskNomType]=find_file_series(MaskPath,[MaskName MaskExt],0);
    2882         if ~(isempty(i2_series) && isempty(j2_series))
    2883             MaskNomType='*';
    2884         end
    2885     end
    2886     Mask.Path=MaskPath;
    2887     if isempty(MaskFile)
    2888         Mask.File='';
    2889     elseif ischar(MaskFile)
    2890         Mask.File=MaskFile;
    2891     else
    2892         Mask.File=MaskFile{1};
    2893     end
    2894     Mask.NbSlice_i=1;
    2895     Mask.NbSlice_j=1;
    2896     if isempty(j1_series)
    2897         if isempty(i1_series)
    2898             MaskNomType='*';
    2899         else
    2900         Mask.NbSlice_i=i1_series(1,2,end);
    2901         end
    2902     else
    2903         Mask.NbSlice_j=j1_series(1,end,2);
    2904     end
    2905     Mask.Ext=MaskExt;
    2906     Mask.NomType=MaskNomType;
     2882        [tild,tild,MaskFile,i1_series,i2,j1,j2,MaskNomType]=find_file_series(MaskPath,[MaskName MaskExt],0);
     2883        if strcmp(NomType,'_1')
     2884            NbSlice=i1_series(1,2,end);
     2885           set(handles.num_NbSlice,'String',num2str(NbSlice))
     2886        end
     2887    end
     2888    % Mask.Path=MaskPath;
     2889    % if isempty(MaskFile)
     2890    %     Mask.File='';
     2891    % elseif ischar(MaskFile)
     2892    %     Mask.File=MaskFile;
     2893    % else
     2894    %     Mask.File=MaskFile{1};
     2895    % end
     2896    % Mask.NbSlice_i=1;
     2897    % Mask.NbSlice_j=1;
     2898    % if isempty(j1_series)
     2899    %     if isempty(i1_series)
     2900    %         MaskNomType='*';
     2901    %     else
     2902    %     Mask.NbSlice_i=i1_series(1,2,end);
     2903    %     end
     2904    % else
     2905    %     Mask.NbSlice_j=j1_series(1,end,2);
     2906    % end
     2907    % Mask.Ext=MaskExt;
     2908    % Mask.NomType=MaskNomType;
    29072909    set(handles.CheckMask,'UserData',Mask);
    29082910    errormsg=update_mask(handles);
     
    49464948%------------------------------------------------------------------------
    49474949% --- set the visibility of relevant velocity type menus:
    4948 function menu=set_veltype_display(Civ,FileType)
     4950function menu=set_veltype_display(CivStage,FileType)
    49494951%------------------------------------------------------------------------
    49504952if ~exist('FileType','var')
     
    49524954end
    49534955imin=1;
     4956if CivStage>=6
     4957    CivStage=6;
     4958end
    49544959switch FileType
    49554960    case 'civx'
    49564961        menu={'civ1';'interp1';'filter1';'civ2';'interp2';'filter2'};
    4957         if isequal(Civ,0)
     4962        if isequal(CivStage,0)
    49584963            imax=0;
    4959         elseif isequal(Civ,1) || isequal(Civ,2)
     4964        elseif isequal(CivStage,1) || isequal(CivStage,2)
    49604965            imax=1;
    4961         elseif isequal(Civ,3)
     4966        elseif isequal(CivStage,3)
    49624967            imax=3;
    4963         elseif isequal(Civ,4) || isequal(Civ,5)
     4968        elseif isequal(CivStage,4) || isequal(CivStage,5)
    49644969            imax=4;
    4965         elseif isequal(Civ,6) %patch2
     4970        elseif isequal(CivStage,6) %patch2
    49664971            imax=6;
    49674972        end
    49684973    case {'civdata','pivdata_fluidimage'}
    4969         menu={'civ1';'filter1';'civ2';'filter2';'civ3';'filter3'};
     4974        menu={'civ1';'filter1';'civ2';'filter2'};
    49704975        imax=[0 1 1 2 3 3 4 5 5 6];
    4971         imax=imax(min(Civ+1,10));
    4972 %         if isequal(Civ,0)
    4973 %             imax=0;
    4974 %         elseif isequal(Civ,1) || isequal(Civ,2)
    4975 %             imax=1;
    4976 %         elseif isequal(Civ,3)
    4977 %             imax=2;
    4978 %         elseif isequal(Civ,4) || isequal(Civ,5)
    4979 %             imax=3;
    4980 %         elseif Civ==6 %patch2
    4981 %             imax=4;
    4982 %         else
    4983 %             imax=4;imin=3;
    4984 %         end
     4976        imax=imax(min(CivStage+1,10));
    49854977end
    49864978menu=menu(imin:imax);
Note: See TracChangeset for help on using the changeset viewer.