Changeset 1095 for trunk/src/uvmat.m


Ignore:
Timestamp:
Mar 31, 2021, 3:32:03 PM (4 years ago)
Author:
sommeria
Message:

reading mat files added, +-fixed,OpenDAP improved

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/uvmat.m

    r1094 r1095  
    21982198        editxml(fileinput);
    21992199        return
    2200     case 'mat'% matlab data file
    2201         global Data_uvmat
    2202 Data_uvmat.Field=load(fileinput);
    2203 evalin('base','global Data_uvmat')%make CurData global in the workspace
    2204 disp('Data_uvmat.Field=')
    2205 evalin('base','Data_uvmat.Field') %display CurData in the workspace
    2206 commandwindow; %brings the Matlab command window to the front
    2207 return
     2200%     case 'mat'% matlab data file
     2201% %         global Data_uvmat
     2202% Data_uvmat.Field=load(fileinput);
     2203% evalin('base','global Data_uvmat')%make CurData global in the workspace
     2204% disp('Data_uvmat.Field=')
     2205% evalin('base','Data_uvmat.Field') %display CurData in the workspace
     2206% commandwindow; %brings the Matlab command window to the front
     2207% return
    22082208    otherwise
    22092209        set(handles_RootPath,'String',RootPath);
     
    22782278       
    22792279        %enable other menus
    2280 %         set(handles.MenuOpenCampaign,'Enable','on')
    22812280        set(handles.MenuExport,'Enable','on')
    22822281        set(handles.MenuExportFigure,'Enable','on')
     
    23552354if isfield(FileInfo,'FrameRate')% frame rate given in the file (case of video data)
    23562355    TimeUnit='s';
    2357     if isempty(j1_series); %frame index along i
     2356    if isempty(j1_series) %frame index along i
    23582357        XmlData.Time=zeros(FileInfo.NumberOfFrames+1,2);
    23592358        XmlData.Time(:,2)=(0:1/FileInfo.FrameRate:(FileInfo.NumberOfFrames)/FileInfo.FrameRate)';
     
    25522551        set(handles.Coord_x,'String','X');
    25532552        set(handles.Coord_y,'String','Y');
    2554     case 'netcdf'
     2553    case {'netcdf','mat'}
    25552554        set(handles_Fields,'Value',1)
    25562555        set(handles_Fields,'String',{'get_field...'})
     
    30193018        pause(1.02-get(handles.speed,'Value'))% wait for next image
    30203019end
    3021 if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj),
     3020if isfield(UvData,'aviobj') && ~isempty( UvData.aviobj)
    30223021    UvData.aviobj=close(UvData.aviobj);
    30233022   set(handles.uvmat,'UserData',UvData);
     
    30633062set(handles.MovieBackward,'BusyAction','Cancel')
    30643063set(handles.MenuExportMovie,'BusyAction','Cancel')
    3065 %set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command buttonback to red
    30663064set(handles.Movie,'BackgroundColor',[1 0 0])%paint the command buttonback to red
    30673065set(handles.MovieBackward,'BackgroundColor',[1 0 0])%paint the command buttonback to red
     
    30733071errormsg='';%default
    30743072%% check for movie pair status
    3075 movie_status=get(handles.movie_pair,'Value');
    3076 if movie_status
    3077     STOP_Callback(hObject, eventdata, handles)%interrupt movie pair if active
    3078 end
     3073% movie_status=get(handles.movie_pair,'Value');
     3074% if movie_status
     3075%     STOP_Callback(hObject, eventdata, handles)%interrupt movie pair if active
     3076% end
    30793077
    30803078%% read the current input file name(s) and field indices
     
    30903088    j1=str2num(get(handles.j1,'String'));%case of indexed movie
    30913089end
    3092 if movie_status% we read the second index from the edit box
    3093     i2=str2num(get(handles.i2,'String'));%read the field indices (for movie, it is not given by the file name)
    3094     if strcmp(get(handles.j2,'Visible'),'on')
    3095     j2=str2num(get(handles.j2,'String'));%
    3096     end
    3097 end
     3090% if movie_status% we read the second index from the edit box
     3091%     i2=str2num(get(handles.i2,'String'));%read the field indices (for movie, it is not given by the file name)
     3092%     if strcmp(get(handles.j2,'Visible'),'on')
     3093%     j2=str2num(get(handles.j2,'String'));%
     3094%     end
     3095% end
    30983096sub_value= get(handles.SubField,'Value');
    30993097if sub_value % a second input file has been entered
     
    31133111    set(handles.CheckFixPair,'Value',0)
    31143112end
    3115 CheckFixPair=get(handles.CheckFixPair,'Value')||(isempty(i2)&&isempty(j2));
     3113CheckFixPair=get(handles.CheckFixPair,'Value')||(isempty(i2)&& isempty(j2));
    31163114
    31173115% the pair i1-i2 or j1-j2 is imposed (check box CheckFixPair selected)
     
    31323130        end
    31333131    end
    3134 
    3135 % the pair i1-i2 or j1-j2 is free (check box CheckFixPair not selected): the list of existing indices recorded in UvData is used
     3132   
     3133    % the pair i1-i2 or j1-j2 is free (check box CheckFixPair not selected): the list of existing indices recorded in UvData is used
    31363134else
    31373135    UvData=get(handles.uvmat,'UserData');
     
    31543152        end
    31553153    else % free increment
    3156        % runaction=get(gcbo,'tag');
    31573154        if strcmp(increment,'+')% if runplus or movie is activated
    31583155            step=1;
     
    32033200        j2=UvData.j2_series{1}(ref_indices(end));
    32043201    end
    3205 
     3202   
    32063203    % case of a second file series
    32073204    if sub_value
     
    33003297    end
    33013298    if strcmp(NomType,'level')
    3302        indices=num2str(i1);
     3299        indices=num2str(i1);
    33033300    else
    3304     indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2);
     3301        indices=fullfile_uvmat('','','','',NomType,i1,i2,j1,j2);
    33053302    end
    33063303    set(handles.FileIndex,'String',indices);
     
    33093306        set(handles.FileIndex_1,'String',indices_1);
    33103307    end
    3311     if isequal(movie_status,1)
    3312         set(handles.movie_pair,'Value',1)
    3313         movie_pair_Callback(hObject, eventdata, handles); %reactivate moviepair if it was activated
    3314     else
    3315         if isempty(i2), set(handles.i2,'String',''); end % suppress the second index display if not used
    3316         if isempty(j2), set(handles.j2,'String',''); end
    3317     end
     3308    if isempty(i2), set(handles.i2,'String',''); end % suppress the second index display if not used
     3309    if isempty(j2), set(handles.j2,'String',''); end
    33183310end
    33193311
     
    33523344        msgbox_uvmat('ERROR',errormsg);
    33533345    end
    3354    
    3355     %     set(hima,'CData',Field_b.A); %TODO: generalise to other kinds of fields
    33563346    pause(1.02-get(handles.speed,'Value'));% wait for next image
    33573347    errormsg=runpm(hObject,eventdata,handles,-increment);
    3358    
    3359     %     set(hima,'CData',Field_a.A);
     3348    if ~isempty(errormsg)
     3349        msgbox_uvmat('ERROR',errormsg);
     3350    end
    33603351    pause(1.02-get(handles.speed,'Value'));% wait for next image
     3352    get(handles.speed,'Value')~=0 && isequal(get(handles.movie_pair,'BusyAction'),'queue')
    33613353end
    33623354set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
     
    33643356set(handles.Dt_txt,'String','')
    33653357
    3366 
    3367 
    3368 
    33693358set(handles.runplus,'BackgroundColor',[1 0 0])%paint the command button back in red
    33703359
    3371 %
    3372 % set(handles.runmin,'BackgroundColor',[1 1 0])%paint the command button in yellow
    3373 % drawnow
    3374 % increment=-str2double(get(handles.num_IndexIncrement,'String')); %get the field increment d
    3375 % if isnan(increment)% case of free increment: move to previous available field index
    3376 %     increment='-';
    3377 % end
    3378 % errormsg=runpm(hObject,eventdata,handles,increment);
    3379 % if ~isempty(errormsg)
    3380 %     msgbox_uvmat('ERROR',errormsg);
    3381 % end
    3382 % set(handles.runmin,'BackgroundColor',[1 0 0])%paint the command button back in red
    3383 %
    3384 % %% check the input file indexing:
    3385 % [RootPath,SubDir,RootFile,FileIndex,FileExt]=read_file_boxes(handles);
    3386 % NomType=get(handles.NomType,'String');
    3387 % if ~isempty(find(regexp(NomType,'-')))
    3388 %     msgbox_uvmat('ERROR','The movie pair requires file series with a single index on the first input line')
    3389 %     return
    3390 % end
    3391 % filename=[fullfile(RootPath,SubDir,RootFile) FileIndex FileExt];% build the input file name (first line)
    3392 %
    3393 % set(handles.movie_pair,'BusyAction','queue')%
    3394 % set(handles.CheckFixPair,'Value',1)% impose fixed pair (needed for function runpm)
    3395 % set(handles.REFRESH,'BackgroundColor',[1 1 0])%paint the command button in yellow to indicate its activity
    3396 % set(handles.movie_pair,'BackgroundColor',[1 1 0])%paint the command button in yellow to indicate its activity
    3397 % drawnow
    3398 %
    3399 % num_i1=str2num(get(handles.i1,'String'));
    3400 % num_j1=stra2num(get(handles.j1,'String'));
    3401 % num_i2=str2num(get(handles.i2,'String'));
    3402 % num_j2=stra2num(get(handles.j2,'String'));
    3403 %
    3404 % %% determine the name 'imaname_1' of the second file in the pair
    3405 % imaname_1='';
    3406 % if isempty(num_j2)% no second j index indicated
    3407 %     if isempty(num_i2)
    3408 %         if strcmp(get(handles.j2,'Visible'),'on') %if the j box is visible
    3409 %             imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,num_i1,[],num_j1+1);
    3410 %         end
    3411 %         if exist(imaname_1,'file')
    3412 %             num_j2=num_j1+1;% look by default for the next j index as the second file
    3413 %             set(handles.j2,'String',num2stra(num_j2,NomType));
    3414 %         else
    3415 %             imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,num_i1+1,[],num_j1);
    3416 %             if exist(imaname_1,'file')
    3417 %                 num_i2=num_i1+1;
    3418 %                 set(handles.i2,'String',num2str(num_i2));
    3419 %             else
    3420 %                 msgbox_uvmat('ERROR', 'a second image index i2 or j2 is needed to show the pair as a movie')
    3421 %                 set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
    3422 %                 set(handles.movie_pair,'Value',0)
    3423 %                 return
    3424 %             end
    3425 %         end
    3426 %     else
    3427 %         num_j2=num_j1;%repeat the index i1 by default
    3428 %     end
    3429 % end
    3430 % if isempty(num_i2)
    3431 %     num_i2=num_i1;%repeat the index i1 by default
    3432 % end
    3433 % if isempty(num_j1)
    3434 %     num_j1=1;
    3435 % end
    3436 % if isempty(num_j2)
    3437 %     num_j2=num_j1;%repeat the index i1 by default
    3438 % end
    3439 % imaname_1=fullfile_uvmat(RootPath,SubDir,RootFile,FileExt,NomType,num_i2,[],num_j2);
    3440 % if strcmp(NomType,'*')
    3441 %     num_frame=num_i2;
    3442 % else
    3443 %     num_frame=num_j2;
    3444 % end
    3445 % if ~exist(imaname_1,'file')
    3446 %       msgbox_uvmat('ERROR',['second input open (-)  ' imaname_1 ' not found']);
    3447 %       set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
    3448 %        set(handles.movie_pair,'Value',0)
    3449 %       return
    3450 % end
    3451 %
    3452 % %% display the first field in the pair (including possibly a background field from second line input filename_1)
    3453 % filename_1='';%default
    3454 % FileIndex_1='';
    3455 % if get(handles.SubField,'Value')
    3456 %     [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1]=read_file_boxes_1(handles);
    3457 %     filename_1=[fullfile(RootPath_1,SubDir_1,RootFile_1) FileIndex_1 FileExt_1];
    3458 % end
    3459 % [tild,tild,tild,i1_1,i2_1,j1_1,j2_1]=fileparts_uvmat(FileIndex_1);% get the indices of the second series from the string FileIndex_1
    3460 % if isempty(j1_1)% case of movies, the index is not given by file index
    3461 %     j1_1=num_j1;
    3462 % end
    3463 %
    3464 % errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2,i1_1,i2_1,j1_1,j2_1);
    3465 %
    3466 % if isempty(errormsg)
    3467 %     set(handles.REFRESH,'BackgroundColor',[1 0 0])% set button color to red, update successfull
    3468 % else
    3469 %      msgbox_uvmat('ERROR',errormsg);
    3470 %      set(handles.REFRESH,'BackgroundColor',[1 0 1])% keep button color magenta, input not succesfull
    3471 % end
    3472 % UvData=get(handles.uvmat,'UserData');
    3473 % Field_a=UvData.Field;% movie on the field defined by the second input line
    3474 %
    3475 % %% display time interval for the image pair
    3476 % if isfield(UvData,'XmlData')&&isfield(UvData.XmlData{1},'Time')...
    3477 %         && size(UvData.XmlData{1}.Time,1)>=num_i2+1 && size(UvData.XmlData{1}.Time,2)>=num_j2+1
    3478 %     dt=(UvData.XmlData{1}.Time(num_i2+1,num_j2+1)-UvData.XmlData{1}.Time(num_i1+1,num_j1+1));
    3479 %     if  isfield(UvData,'TimeUnit')
    3480 %         set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) '  m' UvData.TimeUnit] )
    3481 %     else
    3482 %         set(handles.Dt_txt,'String',['Dt=' num2str(1000*dt,3) '  10^(-3)'] )
    3483 %     end
    3484 % else
    3485 %     set(handles.Dt_txt,'String','')
    3486 % end
    3487 %
    3488 % %% read the second field
    3489 % if isempty(UvData.MovieObject)
    3490 %     [Field_b,ParamOut,errormsg] = read_field(imaname_1,UvData.FileInfo{index}.FileType,[],num_frame);
    3491 % else
    3492 %     [Field_b,ParamOut,errormsg] = read_field(imaname_1,UvData.FileInfo{1}.FileType,UvData.MovieObject{1},num_frame);
    3493 % end
    3494 % if ~isempty(errormsg)
    3495 %     msgbox_uvmat('ERROR',['Error in reading second image: ' errormsg])
    3496 %     return
    3497 % end
    3498 %
    3499 % %% apply phys or other transform on the two input fields
    3500 % transform=get(handles.TransformPath,'UserData');
    3501 % if  ~isempty(transform)
    3502 %     if isfield(UvData,'XmlData') && ~isempty(UvData.XmlData) %use geometry calib recorded from the ImaDoc xml file as first priority
    3503 %         if nargin(transform)>=2
    3504 %             Field_b=transform(Field_b,UvData.XmlData{1});
    3505 %         else
    3506 %             Field_b=transform(Field_b);
    3507 %         end
    3508 %     end
    3509 % end
    3510 %
    3511 % %% make movie until movie speed is set to 0 or STOP is activated
    3512 % hima=findobj(handles.PlotAxes,'Tag','ima');% %handles.PlotAxes =main plotting window (A GENERALISER)
    3513 % set(handles.STOP,'Visible','on')
    3514 % set(handles.speed,'Visible','on')
    3515 % set(handles.speed_txt,'Visible','on')
    3516 % while get(handles.speed,'Value')~=0 && isequal(get(handles.movie_pair,'BusyAction'),'queue') % enable STOP command
    3517 %     % read and plot the series of images in non erase mode
    3518 %     set(hima,'CData',Field_b.A); %TODO: generalise to other kinds of fields
    3519 %     pause(1.02-get(handles.speed,'Value'));% wait for next image
    3520 %     set(hima,'CData',Field_a.A);
    3521 %     pause(1.02-get(handles.speed,'Value'));% wait for next image
    3522 % end
    3523 % set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
    3524 % set(handles.movie_pair,'Value',0)
    3525 % set(handles.Dt_txt,'String','')
    35263360
    35273361%------------------------------------------------------------------------
     
    36603494end
    36613495switch UvData.FileInfo{1}.FieldType
    3662     case {'civdata','netcdf'}
     3496    case {'civdata','netcdf','mat'}
    36633497        list_fields=get(handles.FieldName,'String');% list menu fields
    36643498        FieldName= list_fields{get(handles.FieldName,'Value')}; % selected field
    3665         if ~strcmp(FieldName,'get_field...')
     3499        if strcmp(FieldName,'get_field...')
     3500            FieldName_Callback(hObject, eventdata, handles)
     3501            return
     3502        else
    36663503            if get(handles.FixVelType,'Value')
    36673504                VelTypeList=get(handles.VelType,'String');
     
    36973534    end
    36983535    ParamIn.Coord_z=get(handles.Coord_z,'String');
    3699     %ParamIn.CheckCoordIndex=strcmp(get(handles.SwitchCoordIndex,'String'),'dim');
    37003536    TimeName=get(handles.TimeName,'String');
    37013537    r=regexp(TimeName,'^(?<type>(dim:)|(var:))','names');%look for 'var:' or 'dim:' at the beginning of time name
     
    37683604    end
    37693605    switch UvData.FileInfo{2}.FileType
    3770         case {'civx','civdata','netcdf','pivdata_fluidimage'}
     3606        case {'civx','civdata','netcdf','pivdata_fluidimage','mat'}
    37713607            list_fields=get(handles.FieldName_1,'String');% list menu fields
    37723608            FieldName_1= list_fields{get(handles.FieldName_1,'Value')}; % selected field
     
    41704006            break
    41714007        end
    4172         if UvData.Field.NbDim==3
     4008        if isfield(UvData.Field,'NbDim') && UvData.Field.NbDim==3
    41734009            UvData.ProjObject{iobj}.NbDim=3;%test for 3D objects
    41744010            if ~isfield(UvData.ProjObject{iobj},'RangeZ')
     
    53565192    prev_path=fullfile(fileparts(which('uvmat')),'transform_field');
    53575193end
    5358 if strcmp(transform_name,'more...');
     5194if strcmp(transform_name,'more...')
    53595195    transform_fct_chosen=uigetfile_uvmat('Pick the transform function',prev_path,'.m');
    53605196    if ~isempty(transform_fct_chosen)
     
    54445280%% delete drawn objects if the output CooordUnit is different from the previous one
    54455281if  ~strcmp(CoordUnit,CoordUnitPrev)
    5446 %     for iobj=1:numel(UvData.ProjObject)
    5447 %         delete_object(iobj)
    5448 %     end
    54495282    set(handles.CheckFixLimits,'Value',0)
    54505283    hother=findobj('Tag','proj_object');%find all the proj objects
     
    58345667AxeData=[];
    58355668if isfield(UvData,'PlotAxes')
    5836 AxeData=UvData.PlotAxes;% retrieve the current plotted data
     5669    AxeData=UvData.PlotAxes;% retrieve the current plotted data
    58375670end
    58385671PlotParam=read_GUI(handles.uvmat);
Note: See TracChangeset for help on using the changeset viewer.