Changeset 227 for trunk/src/uvmat.m


Ignore:
Timestamp:
Mar 31, 2011, 1:42:51 PM (13 years ago)
Author:
sommeria
Message:

add function sub_field_series to apply the sub_field operation to a series of fileds (for instance subtracting a background to an image series)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/uvmat.m

    r221 r227  
    232232
    233233%% refresh projection plane
    234 %UvData.Object{1}.Style='plane';%main plotting plane
    235234UvData.Object{1}.ProjMode='projection';%main plotting plane
    236 % if ~isfield(UvData.Object{1},'plotaxes')
    237 %     UvData.Object{1}.plotaxes=handles.axes3;%default plotting axis
    238 %     set(handles.list_object_1,'Value',1);
    239 %    % set(handles.list_object_1,'String',{'1-PLANE'});
    240 %    set(handles.list_object_1,'String',{''});
    241 % end
    242235set(handles.Fields,'Value',1)
    243236set(handles.Fields,'string',{''})
     
    331324            inputfile=input.InputFile;
    332325        end
    333         Field=input;
     326        if isfield(Field,'TimeIndex')
     327            set(handles.i1,num2str(Field.TimeIndex))
     328        end
    334329    elseif ischar(input)% file name introduced as input
    335330           inputfile=input;
     
    347342    end
    348343    if ~isempty(inputfile)
    349         %%%%% display the indput field %%%%%%%
     344        %%%%% display the input field %%%%%%%
    350345        display_file_name(hObject, eventdata, handles,inputfile)
    351346        %%%%%%%
     
    366361   end
    367362end
    368 % set(handles.uvmat,'UserData',UvData)
    369363
    370364%% plot input field if exists
     
    437431        '*.*',  'All Files (*.*)'}, ...
    438432        'Pick a file',oldfile);
    439 %global filebase
    440433fileinput=[PathName FileName];%complete file name
    441 % testblank=findstr(fileinput,' ');%look for blanks
    442 % if ~isempty(testblank)
    443 %     msgbox_uvmat('ERROR',['The input file name ' fileinput ' contains blank character : This is not allowed. Please change name'])
    444 %     return
    445 % end
    446434sizf=size(fileinput);
    447435if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end
     
    484472% --- Open again the file whose name has been recorded in MenuFile_1
    485473function MenuFile_1_Callback(hObject, eventdata, handles)
     474%------------------------------------------------------------------------
    486475fileinput=get(handles.MenuFile_1,'Label');
    487476display_file_name(hObject, eventdata, handles,fileinput)
     
    490479% --- Open again the file whose name has been recorded in MenuFile_2
    491480function MenuFile_2_Callback(hObject, eventdata, handles)
     481%------------------------------------------------------------------------
    492482fileinput=get(handles.MenuFile_2,'Label');
    493483display_file_name(hObject, eventdata, handles,fileinput)
     
    496486% --- Open again the file whose name has been recorded in MenuFile_3
    497487function MenuFile_3_Callback(hObject, eventdata, handles)
     488%------------------------------------------------------------------------
    498489fileinput=get(handles.MenuFile_3,'Label');
    499490display_file_name(hObject, eventdata, handles,fileinput)
     
    502493% --- Open again the file whose name has been recorded in MenuFile_4
    503494function MenuFile_4_Callback(hObject, eventdata, handles)
     495%------------------------------------------------------------------------
    504496fileinput=get(handles.MenuFile_4,'Label');
    505497display_file_name(hObject, eventdata, handles,fileinput)
     
    508500% --- Open again the file whose name has been recorded in MenuFile_5
    509501function MenuFile_5_Callback(hObject, eventdata, handles)
     502%------------------------------------------------------------------------
    510503fileinput=get(handles.MenuFile_5,'Label');
    511504display_file_name(hObject, eventdata, handles,fileinput)
     
    514507% --- Fills the edit boxes RootPath, RootFile,NomType...from an input file name 'fileinput'
    515508function display_file_name(hObject, eventdata, handles,fileinput)
     509%------------------------------------------------------------------------
    516510if ~exist(fileinput,'file')
    517511    msgbox_uvmat('ERROR',['input file ' fileinput  ' does not exist'])
     
    871865% set default options in menu 'Fields'
    872866
    873 if testima
    874 elseif isequal(FileExt,'.nc')||isequal(FileExt,'.cdf')
    875    Data=nc2struct(FileName,'ListGlobalAttribute','absolut_time_T0','civ');
    876    %col_vec=get(handles.col_vec,'String');
    877    if ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0)%if the new input is Civx
    878        FieldList=calc_field;
    879        set(handles.Fields,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data
    880        set(handles.Fields,'Value',2) % set menu to 'velocity'
    881        col_vec=FieldList;
    882        col_vec(1)=[];%remove 'velocity' option for vector color (must be a scalar)
    883    else %general netcdf file (not civx)
    884        set(handles.Fields,'Value',1) % set menu to 'get_field...
    885        set(handles.Fields,'String',{'get_field...'})
    886        col_vec={'get_field...'};
    887        hget_field=findobj('Name','get_field');
    888        if ~isempty(hget_field)%delete any existing get_field GUI for reinitialisation withthe new file series
    889            hhget_field=guidata(hget_field);
    890            if ~strcmp(get(hhget_field.inputfile,'String'),FileName)%delete any existing get_field GUI with file name different than the input
    891                 delete(hget_field)
    892            end
    893        end
    894    end
    895    set(handles.col_vec,'String',col_vec)
    896 else
    897     msgbox_uvmat('ERROR',['invalid input file extension ' FileExt])
    898     return
    899 end 
     867if ~testima
     868    testcivx=0;
     869    hget_field=findobj('Name','get_field');
     870%     if isequal(FileExt,'.nc')||isequal(FileExt,'.cdf')
     871    if isempty(hget_field)
     872        Data=nc2struct(FileName,'ListGlobalAttribute','absolut_time_T0','civ');
     873        if ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0)%if the new input is Civx
     874            FieldList=calc_field;
     875            set(handles.Fields,'String',[{'image'};FieldList;{'get_field...'}]);%standard menu for civx data
     876            set(handles.Fields,'Value',2) % set menu to 'velocity'
     877            col_vec=FieldList;
     878            col_vec(1)=[];%remove 'velocity' option for vector color (must be a scalar)
     879            testcivx=1;
     880        end
     881    else
     882         hhget_field=guidata(hget_field);
     883        if ~strcmp(get(hhget_field.inputfile,'String'),FileName)%delete any existing get_field GUI with file name different than the input
     884            delete(hget_field)
     885        end
     886    end
     887    if ~testcivx
     888            set(handles.Fields,'Value',1) % set menu to 'get_field...
     889            set(handles.Fields,'String',{'get_field...'})
     890            col_vec={'get_field...'};
     891    end       
     892    set(handles.col_vec,'String',col_vec)
     893%     else
     894%         msgbox_uvmat('ERROR',['invalid input file extension ' FileExt])
     895%         return
     896%     end
     897end
    900898
    901899%% set index navigation options and refresh plots
     
    13911389    set(handles.scan_i,'Value',0)
    13921390    set(handles.scan_i,'BackgroundColor',[0.831 0.816 0.784])
    1393     NomType=get(handles.FileIndex,'UserData')
     1391    NomType=get(handles.FileIndex,'UserData');
    13941392    switch NomType
    13951393    case {'_i_j1-j2','#_ab','%3dab'},% pair with j index
     
    20472045num_j1=stra2num(get(handles.j1,'String'));
    20482046num_j2=stra2num(get(handles.j2,'String'));
     2047
    20492048errormsg=refresh_field(handles,filename,filename_1,num_i1,num_i2,num_j1,num_j2);
     2049
    20502050if ~isempty(errormsg)
    20512051      msgbox_uvmat('ERROR',errormsg);
     
    21672167        set(handles.npx,'String',num2str(ParamOut.Npx));% display image size on the interface
    21682168        set(handles.npy,'String',num2str(ParamOut.Npy));
     2169    end
     2170    if isfield(ParamOut,'TimeIndex')
     2171        set(handles.i1,'String',num2str(ParamOut.TimeIndex))
     2172    end
     2173    if isfield(ParamOut,'TimeValue')
     2174        Field{1}.Time=ParamOut.TimeValue;
    21692175    end
    21702176end
     
    24342440end
    24352441if exist('XName','var')
    2436     eval(['XMax=max(UvData.Field.' XName ');'])
    2437     eval(['XMin=min(UvData.Field.' XName ');'])
     2442    eval(['XMax=max(max(UvData.Field.' XName '));'])
     2443    eval(['XMin=min(min(UvData.Field.' XName '));'])
    24382444    UvData.Field.NbDim=NbDim;
    24392445    UvData.Field.XMax=XMax;
    24402446    UvData.Field.XMin=XMin;
    24412447    if NbDim >1
    2442         eval(['YMax=max(UvData.Field.' YName ');'])
    2443         eval(['YMin=min(UvData.Field.' YName ');'])
     2448        eval(['YMax=max(max(UvData.Field.' YName '));'])
     2449        eval(['YMin=min(min(UvData.Field.' YName '));'])
    24442450        UvData.Field.YMax=YMax;
    24452451        UvData.Field.YMin=YMin;
     
    32563262    % transform netc type to the corresponding image type
    32573263%     set(handles.FileExt_1,'String','.png');
    3258     if isequal(NomType_1,'_i1-i2_j')|isequal(NomType_1,'_i_j1-j2')| isequal(NomType_1,'#_ab')| isequal(NomType_1,'_i1-i2')
     3264    if isequal(NomType_1,'_i1-i2_j')||isequal(NomType_1,'_i_j1-j2')|| isequal(NomType_1,'#_ab')|| isequal(NomType_1,'_i1-i2')
    32593265        UvData.SubDir_1=get(handles.SubDir_1,'String'); %preserve the subdir in memory
    32603266%         set(handles.SubDir_1,'String','')
    32613267%         set(handles.FileExt_1,'String','.png');       
    3262         if isequal(NomType_1,'_i1-i2_j')|isequal(NomType_1,'_i_j1-j2')
     3268        if isequal(NomType_1,'_i1-i2_j')||isequal(NomType_1,'_i_j1-j2')
    32633269            NomTypeNew='_i_j';
    32643270        elseif isequal(NomType_1,'#_ab')
     
    40794085set(handles.FixScal,'Value',1) %suppress auto mode
    40804086set(handles.FixScal,'BackgroundColor',[1 1 0])
     4087MinA=str2double(get(handles.MinA,'String'));
     4088MaxA=str2double(get(handles.MaxA,'String'));
     4089if MinA>MaxA% switch minA and maxA in case of error
     4090    MinA_old=MinA;
     4091    MinA=MaxA;
     4092    MaxA=MinA_old;
     4093    set(handles.MinA,'String',num2str(MinA,5));
     4094    set(handles.MaxA,'String',num2str(MaxA,5));
     4095end
    40814096update_plot(handles);
    40824097
     
    40864101set(handles.FixScal,'Value',1) %suppress auto mode
    40874102set(handles.FixScal,'BackgroundColor',[1 1 0])
     4103MinA=str2double(get(handles.MinA,'String'));
     4104MaxA=str2double(get(handles.MaxA,'String'));
     4105if MinA>MaxA% switch minA and maxA in case of error
     4106        MinA_old=MinA;
     4107    MinA=MaxA;
     4108    MaxA=MinA_old;
     4109    set(handles.MinA,'String',num2str(MinA,5));
     4110    set(handles.MaxA,'String',num2str(MaxA,5));
     4111end
    40884112update_plot(handles);
    40894113
Note: See TracChangeset for help on using the changeset viewer.