Changeset 674 for trunk/src


Ignore:
Timestamp:
Aug 23, 2013, 2:56:17 PM (11 years ago)
Author:
sommeria
Message:

various bugs repaired, in particula timing

Location:
trunk/src
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/find_field_cells.m

    r648 r674  
    107107
    108108%% find scattered (unstructured) coordinates
    109 ivar_coord_x=find(strcmp('coord_x',Role));
    110 % VarDimCell=cell(numel(ivar_coord_x));
     109ivar_coord_x=find(strcmp('coord_x',Role));%find variables with Role='coord_x'
    111110check_select=false(1,nbvar);
    112111check_coord=false(1,nbvar);
    113112CellInfo=cell(1,numel(ivar_coord_x));
    114113NbDim=zeros(1,numel(ivar_coord_x));
     114% loop on unstructured coordinate x -> different field cells
    115115for icell=1:numel(ivar_coord_x)
    116     DimCell=Data.VarDimName{ivar_coord_x(icell)};
    117     if ischar(DimCell),DimCell={DimCell};end
     116    DimCell=Data.VarDimName{ivar_coord_x(icell)};% cell of dimension names for ivar_coord_x(icell)
     117    if ischar(DimCell),DimCell={DimCell};end % transform char to cell for a single dimension
     118    % look for variables sharing dimension(s) with ivar_coord_x(icell)
    118119    check_cell=zeros(numel(DimCell),nbvar);
    119120    for idim=1:numel(DimCell)
     
    123124    end
    124125    check_cell=sum(check_cell,1)==numel(DimCell);%logical array=1 for variables belonging to the current cell
    125     VarIndex=find(check_cell);
     126    VarIndex=find(check_cell);% list of detected variable indices
    126127    if ~(numel(VarIndex)==1 && numel(DimCell)==1)% exclude case of isolated coord_x variable (treated later)
    127128        if ~(numel(VarIndex)==1 && numel(DimCell)>1)% a variable is associated to coordinate
     
    132133            else
    133134                for idim=1:numel(DimCell)
    134                  check_index= strcmp(DimCell{idim},Data.ListDimName);
    135                  CellInfo{icell}.CoordSize(idim)=Data.DimValue(check_index);
     135                    check_index= strcmp(DimCell{idim},Data.ListDimName);
     136                    CellInfo{icell}.CoordSize(idim)=Data.DimValue(check_index);
    136137                end
    137138                CellInfo{icell}.CoordSize=prod(CellInfo{icell}.CoordSize);
     
    291292NbDim=[NbDim NewNbDim];
    292293CellInfo=[CellInfo NewCellInfo];
    293 %
    294 % %% suppress empty cells
    295 % check_empty=cellfun(@isempty,CellInfo);
    296 % CellInfo(check_empty)=[];
    297 % NbDim(check_empty)=[];
    298294
    299295%% suppress empty cells or cells with a single coordinate variable
     
    308304
    309305%% document roles of non-coordinate variables
    310 % ListRole={'vector_x','vector_y','vector_z','vector_x_tps','vector_y_tps','warnflag','errorflag',...
    311 %    'ancillary','image','color','discrete','scalar'};% except coord,coord_x,_y,_z,Coord_tps already taken, into account
    312306for icell=1:numel(CellInfo)
    313307    VarIndex=CellInfo{icell}.VarIndex;
  • trunk/src/find_imadoc.m

    r672 r674  
    1515    dotchar=regexp(SubDir,'\.');
    1616    for idot=1:numel(dotchar)
    17         XmlFileName=fullfile(RootPath,[SubDir(1:dotchar(end-idot+1)) '.xml']);
     17        XmlFileName=fullfile(RootPath,[SubDir(1:dotchar(end-idot+1)-1) '.xml']);
    1818        if exist(XmlFileName,'file')
    1919            SubDirBase=fullfile(RootPath,SubDir(1:dotchar(end-idot+1)));
  • trunk/src/geometry_calib.m

    r672 r674  
    9797ScreenSize=get(0,'ScreenSize');% get the size of the screen, to put the fig on the upper right
    9898Left=ScreenSize(3)- 460; %right edge close to the right, with margin=40 (GUI width=420 px)
    99 if ScreenSize(4)>880
     99if ScreenSize(4)>920
    100100    Height=840;%default height of the GUI
    101101    Bottom=ScreenSize(4)-Height-40; %put fig at top right
    102102else
    103     Height=ScreenSize(4)-40;
    104     Bottom=0; % GUI lies o the screen bottom
    105 end
    106 set(handles.calib_type,'Position',[1 Height-30 194 30])%  rank 1
    107 set(handles.APPLY,'Position',[197 Height-30 110 30])%  rank 1
    108 set(handles.REPLICATE,'Position',[309 Height-30 110 30])%  rank 1
    109 set(handles.Intrinsic,'Position',[1 Height-30-2-92 418 92])%  rank 2
    110 set(handles.Extrinsic,'Position',[1 Height-30-4-92-75 418 75])%  rank 3
    111 set(handles.PointLists,'Position',[1 Height-30-6-92-75-117 418 117]) %  rank 4
    112 set(handles.CheckEnableMouse,'Position',[3 Height-30-8-92-75-117-30 203 30])%  rank 5
    113 set(handles.PLOT,'Position',[3 Height-384 120 30])%  rank 6
    114 set(handles.Copy,'Position',[151 Height-384 120 30])%  rank 6
    115 set(handles.CLEAR_PTS,'Position',[297 Height-384 120 30])%  rank 6
    116 set(handles.phys_title,'Position',[38 Height-416 125 20])%  rank 7
    117 set(handles.CoordUnit,'Position',[151 Height-416 120 30])%  rank 7
    118 set(handles.px_title,'Position',[272 Height-416 125 20])%  rank 7
    119 set(handles.ListCoord,'Position',[1 20 418 Height-436])% rank 8
     103    Height=ScreenSize(4)-80;
     104    Bottom=40; % GUI lies o the screen bottom (with margin =40)
     105end
     106set(handles.calib_type,'Position',[1 Height-40 194 30])%  rank 1
     107set(handles.APPLY,'Position',[197 Height-40 110 30])%  rank 1
     108set(handles.REPLICATE,'Position',[309 Height-40 110 30])%  rank 1
     109set(handles.Intrinsic,'Position',[1 Height-40-2-92 418 92])%  rank 2
     110set(handles.Extrinsic,'Position',[1 Height-40-4-92-75 418 75])%  rank 3
     111set(handles.PointLists,'Position',[1 Height-40-6-92-75-117 418 117]) %  rank 4
     112set(handles.CheckEnableMouse,'Position',[3 Height-40-8-92-75-117-30 203 30])%  rank 5
     113set(handles.PLOT,'Position',[3 Height-394 120 30])%  rank 6
     114set(handles.Copy,'Position',[151 Height-394 120 30])%  rank 6
     115set(handles.CLEAR_PTS,'Position',[297 Height-394 120 30])%  rank 6
     116set(handles.phys_title,'Position',[38 Height-426 125 20])%  rank 7
     117set(handles.CoordUnit,'Position',[151 Height-426 120 30])%  rank 7
     118set(handles.px_title,'Position',[272 Height-426 125 20])%  rank 7
     119set(handles.ListCoord,'Position',[1 20 418 Height-446])% rank 8
    120120set(handles.geometry_calib,'Position',[Left Bottom 420 Height])
    121121
     
    11491149set(handles.ListCoordFiles,'string',listfile);
    11501150
    1151 %------------------------------------------------------------------------
    1152 % --- 'key_press_fcn:' function activated when a key is pressed on the keyboard
    1153 function key_press_fcn(hObject,eventdata,handles)
    1154 %------------------------------------------------------------------------
    1155 xx=double(get(handles.geometry_calib,'CurrentCharacter')); %get the keyboard character
    1156 %if ismember(xx,[8 127])%backspace or delete
    1157 if ismember(xx,[30 31 8 127])
    1158     Coord=get(handles.ListCoord,'Data');
    1159     ind=find(Coord(:,6));
    1160     Coord(:,6)=zeros(size(Coord,1),1);% desactivate the current line mark
    1161     switch xx
    1162         case 30 % arrow upward
    1163             Coord(ind-1,6)=1;
    1164         case 31% arrow downward
    1165             Coord(ind+1,6)=1;
    1166         case {8 127}% remove line
    1167             Coord(ind,:)=[];
    1168     end
    1169     set(handles.ListCoord,'Data',Coord);
    1170     PLOT_Callback(hObject,eventdata,handles)
    1171 end
    1172 
    1173 
    11741151
    11751152%------------------------------------------------------------------------
     
    12401217        set(handles.Psi,'String',num2str(GeometryCalib.omc(3),4))
    12411218    end
     1219    if isfield(GeometryCalib,'SourceCalib')
    12421220    calib=GeometryCalib.SourceCalib.PointCoord;
    12431221    Coord=[calib zeros(size(calib,1),1)];
    12441222    set(handles.ListCoord,'Data',Coord)
     1223    end
    12451224%     CoordCell=reshape(CoordCell,[],5);
    12461225%     Tabchar=cell2tab(CoordCell,' | ');%transform cells into table ready for display
     
    12841263% --- Executes when user attempts to close geometry_calib.
    12851264function geometry_calib_CloseRequestFcn(hObject, eventdata, handles)
    1286 % hObject    handle to geometry_calib (see GCBO)
    1287 % eventdata  reserved - to be defined in a future version of MATLAB
    1288 % handles    structure with handles and user data (see GUIDATA)
    1289 
    1290 % Hint: delete(hObject) closes the figure
    1291 delete(hObject);
     1265
     1266delete(hObject); % closes the figure
    12921267
    12931268%------------------------------------------------------------------------
     
    13311306
    13321307%------------------------------------------------------------------------
    1333 % --- Executes on button press in Copy.
     1308% --- Executes on button press in Copy: display Coord on the Matlab work space
    13341309%------------------------------------------------------------------------
    13351310function Copy_Callback(hObject, eventdata, handles)
     
    13411316commandwindow; %brings the Matlab command window to the front
    13421317
    1343 
     1318%------------------------------------------------------------------------
    13441319% --- Executes when selected cell(s) is changed in ListCoord.
     1320%------------------------------------------------------------------------
    13451321function ListCoord_CellSelectionCallback(hObject, eventdata, handles)
     1322
    13461323if ~isempty(eventdata.Indices)
    1347 iline=eventdata.Indices(1);% selected line number
    1348 Data=get(handles.ListCoord,'Data');
    1349 Data(:,6)=zeros(size(Data,1),1);
    1350 Data(iline,6)=1;% mark the selected line
    1351 set(handles.ListCoord,'Data',Data)
    1352 update_calib_marker(Data(iline,:))
    1353 end
    1354 
     1324    iline=eventdata.Indices(1);% selected line number
     1325    Data=get(handles.ListCoord,'Data');
     1326    Data(:,6)=zeros(size(Data,1),1);
     1327    Data(iline,6)=1;% mark the selected line
     1328    set(handles.ListCoord,'Data',Data)
     1329    update_calib_marker(Data(iline,:))
     1330end
     1331
     1332%------------------------------------------------------------------------
    13551333% --- Executes when entered data in editable cell(s) in ListCoord.
     1334%------------------------------------------------------------------------
    13561335function ListCoord_CellEditCallback(hObject, eventdata, handles)
    13571336
     
    13661345PLOT_Callback(hObject, eventdata, handles)
    13671346
     1347%------------------------------------------------------------------------
     1348% --- 'key_press_fcn:' function activated when a key is pressed on the keyboard
     1349%------------------------------------------------------------------------
     1350function key_press_fcn(hObject,eventdata,handles)
     1351
     1352xx=double(get(handles.geometry_calib,'CurrentCharacter')); %get the keyboard character
     1353%if ismember(xx,[8 127])%backspace or delete
     1354if ismember(xx,[30 31 8 127])% arrow upward, downward, backspace or delete
     1355    Coord=get(handles.ListCoord,'Data');
     1356    ind=find(Coord(:,6));
     1357    Coord(:,6)=zeros(size(Coord,1),1);% desactivate the current line mark
     1358    switch xx
     1359        case 30 % arrow upward
     1360            Coord(ind-1,6)=1;
     1361        case 31% arrow downward
     1362            Coord(ind+1,6)=1;
     1363        case {8 127}% remove line
     1364            Coord(ind,:)=[];
     1365    end
     1366    set(handles.ListCoord,'Data',Coord);
     1367    PLOT_Callback(hObject,eventdata,handles)
     1368end
     1369
     1370
     1371
     1372%------------------------------------------------------------------------
     1373% --- update the plot of calibration points
     1374%------------------------------------------------------------------------
    13681375function update_calib_marker(Coord)
    13691376%% update the plot on uvmat
  • trunk/src/get_field.m

    r672 r674  
    11%'get_field': display variables and attributes from a Netcdf file, and OK selected fields
    22%------------------------------------------------------------------------
    3 %function varargout = get_field(varargin)
     3% GetFieldData=get_field(FileName,ParamIn)
    44% associated with the GUI get_field.fig
     5%
     6% OUPUT:
     7% GetFieldData: structure containing the information on the selected
     8%      fields, obtained by applying the fct red_GUI to the GUI get_field
     9%   .FieldOption='vectors': variables are used for vector plot
     10%                  'scalar': variables are used for scalar plot,
     11%                  '1Dplot': variables are used for usual x-y plot,
     12%                  'civdata...': go back to automatic reading of civ data
     13%   .PanelVectors: sub-structure variables used as vector components
     14%   .PanelScalar:
     15% INPUT:
     16% FileName: name (including path) of the netcdf file to open
    517%
    618%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
     
    4254end
    4355% End initialization code - DO NOT EDIT
    44 
     56     
    4557%------------------------------------------------------------------------
    4658% --- Executes just before get_field is made visible.
     
    5466
    5567%% enter input data
    56 set(handles.inputfile,'String',filename)% fill the input file name
    57 Field=nc2struct(filename,[]);% reads the  field structure, without the variables
     68if ischar(filename)% input file name
     69    set(handles.inputfile,'String',filename)% fill the input file name
     70    Field=nc2struct(filename,[]);% reads the  field structure, without the variables
     71else
     72    'bad input to get_field'
     73end
     74if ~exist('ParamIn','var')
     75    ParamIn=[];
     76end
    5877if isfield(Field,'Txt')
    59     msgbox_uvmat('ERROR',['get_field/nc2struct/' Field.Txt])% display error message for input fiel reading
     78    msgbox_uvmat('ERROR',['get_field/nc2struct/' Field.Txt])% display error message for input file reading
    6079    return
    6180end
    6281if ~isfield(Field,'ListVarName')
    6382    return
    64 end
    65 if ~exist('ParamIn','var')
    66     ParamIn=[];
    6783end
    6884
     
    111127ListSwitchVarIndexTime={'file index'};% default setting: the time is the file index
    112128% look at global attributes with numerical values
    113 check_numvalue=false;
    114 check_time=false;
     129check_numvalue=false(1,numel(Field.ListGlobalAttribute));
    115130for ilist=1:numel(Field.ListGlobalAttribute)
    116131    Value=Field.(Field.ListGlobalAttribute{ilist});
    117132    check_numvalue(ilist)=isnumeric(Value);
    118     check_time(ilist)=~isempty(find(regexp(Field.ListGlobalAttribute{ilist},'Time'),1));
    119133end
    120134Field.Display.ListGlobalAttribute=Field.ListGlobalAttribute(check_numvalue);% select the attributes with float numerical value
     
    122136    ListSwitchVarIndexTime=[ListSwitchVarIndexTime; {'attribute'}];% the time can be chosen as a global attribute
    123137end
    124 nboption=numel(ListSwitchVarIndexTime);
    125138if Field.MaxDim>=2
    126139    ListSwitchVarIndexTime=[ListSwitchVarIndexTime;{'variable'};{'dim index'}];% the time can be chosen as a dim index
    127140end
    128 if ~isempty(find(check_time, 1))
     141
     142%% select the Time attribute from input
     143if isfield(ParamIn,'TimeAttrName')
     144    time_index=find(strcmp(ParamIn.TimeAttrName,Field.Display.ListGlobalAttribute),1);
     145else
     146    time_index=find(~cellfun('isempty',regexp(Field.Display.ListGlobalAttribute,'Time')),1);
     147end
     148if ~isempty(time_index)
    129149    set(handles.SwitchVarIndexTime,'Value',2);
     150    set(handles.TimeName,'UserData',time_index)
    130151else
    131152    set(handles.SwitchVarIndexTime,'Value',1);
     
    150171end
    151172if Field.MaxDim>=2 % case of 2D (or 3D) fields
    152     if isfield(CellInfo{imax},'VarIndex_vector_x') &&  isfield(CellInfo{imax},'VarIndex_vector_y')
     173    check_vec_input=0;
     174    if isfield(ParamIn,'vector_x')&& isfield(ParamIn,'vector_y')
     175        ichoice_x=find(strcmp(ParamIn.vector_x,Field.Display.ListVarName),1);
     176        ichoice_y=find(strcmp(ParamIn.vector_y,Field.Display.ListVarName),1);
     177        if ~isempty(ichoice_x)&&~isempty(ichoice_y)
     178            set(handles.vector_x,'UserData',ichoice_x)
     179            set(handles.vector_y,'UserData',ichoice_y)
     180            check_vec_input=1;
     181        end
     182    end
     183    if ~check_vec_input && isfield(CellInfo{imax},'VarIndex_vector_x') &&  isfield(CellInfo{imax},'VarIndex_vector_y')
     184        set(handles.vector_x,'UserData',CellInfo{imax}.VarIndex_vector_x(1))
     185        set(handles.vector_y,'UserData',CellInfo{imax}.VarIndex_vector_y(1))
     186        check_vec_input=1;
     187    end
     188    if check_vec_input
    153189        set(handles.FieldOption,'Value',3)% set vector selection option
    154         set(handles.vector_x,'Value',CellInfo{imax}.VarIndex_vector_x(1))
    155         set(handles.vector_y,'Value',CellInfo{imax}.VarIndex_vector_y(1))
    156         set(handles.FieldOption,'Value',3)
    157190    else
    158         set(handles.FieldOption,'Value',2)
     191        set(handles.FieldOption,'Value',2)% set scalar selection option
    159192    end
    160193else % case of 1D fields
     
    177210%% fill menus for coordinates and time
    178211FieldOption_Callback(handles.variables,[], handles)% list the global attributes
    179 %     if isfield(CellInfo{imax},'VarIndex_coord_x')&&  isfield(CellInfo{imax},'VarIndex_coord_y')
    180 %         set(handles.Coord_x,'Value',CellInfo{imax}.VarIndex_coord_x(1))
    181 %         set(handles.Coord_y,'Value',CellInfo{imax}.VarIndex_coord_y(1))
    182 %     end
    183212
    184213%% Make choices of coordinates from input
     
    214243return
    215244
    216 SwitchVarIndexTime_Callback([],[], handles)
    217 
    218245%% set z coordinate menu if relevant
    219246if Field.MaxDim>=3
     
    227254    set(handles.Coord_z,'Visible','off')
    228255    set(handles.Z_title,'Visible','off')
     256end
     257
     258%% make selections according to ParamIn
     259if isfield(ParamIn,'vector_x') && isfield(ParamIn,'vector_y')
     260   
    229261end
    230262
     
    300332            for iline=1:length(attr_list)
    301333                Tabcell{iline,1}=attr_list{iline};
    302                 eval(['val=VarAttr.' attr_list{iline} ';'])
     334                val=VarAttr.(attr_list{iline}) ;
    303335                if ischar(val);
    304336                    Tabcell{iline,2}=val;
     
    406438        end       
    407439        scalar_Callback(hObject, eventdata, handles)
    408        
     440             
    409441    case 'vectors'
     442        set(handles.PanelVectors,'Visible','on')
    410443        set(handles.Coordinates,'Visible','on')
    411444        set(handles.PanelOrdinate,'Visible','off')
    412445        set(handles.PanelScalar,'Visible','off')
    413         set(handles.PanelVectors,'Visible','on')
    414446        pos=get(handles.PanelVectors,'Position');
    415447        pos(1)=2;
     
    420452        set(handles.Y_title,'Visible','on')
    421453        %default vector selection
    422         test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordiante
    423         for ilist=1:numel(Field.Display.VarDimName)
    424             if isfield(Field.Display,'VarAttribute') && numel(Field.Display.VarAttribute)>=ilist && isfield(Field.Display.VarAttribute{ilist},'Role')
    425                 Role=Field.Display.VarAttribute{ilist}.Role;
    426                 if strcmp(Role,'coord_x')||strcmp(Role,'coord_y')
     454        vector_x_value=get(handles.vector_x,'UserData');
     455        vector_y_value=get(handles.vector_y,'UserData');
     456        if ~isempty(vector_x_value)&&~isempty(vector_y_value)
     457            set(handles.vector_x,'Value',vector_x_value)
     458            set(handles.vector_y,'Value',vector_y_value)
     459        else
     460            test_coord=zeros(size(Field.Display.VarDimName)); %=1 when variable #ilist is eligible as structured coordinate
     461            for ilist=1:numel(Field.Display.VarDimName)
     462                if isfield(Field.Display,'VarAttribute') && numel(Field.Display.VarAttribute)>=ilist && isfield(Field.Display.VarAttribute{ilist},'Role')
     463                    Role=Field.Display.VarAttribute{ilist}.Role;
     464                    if strcmp(Role,'coord_x')||strcmp(Role,'coord_y')
     465                        test_coord(ilist)=1;
     466                    end
     467                end
     468                dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist
     469                if numel(dimnames)==1 && strcmp(dimnames{1},Field.Display.ListVarName{ilist})%dimension variable
    427470                    test_coord(ilist)=1;
    428471                end
    429472            end
    430             dimnames=Field.Display.VarDimName{ilist}; %list of dimensions for variable #ilist
    431             if numel(dimnames)==1 && strcmp(dimnames{1},Field.Display.ListVarName{ilist})%dimension variable
    432                 test_coord(ilist)=1;
     473            vector_index=find(~test_coord,2);%get the two first variables not a coordinate
     474            if isempty(vector_index)
     475                set(handles.vector_x,'Value',1)
     476                set(handles.vector_y,'Value',2)
     477            else
     478                set(handles.vector_x,'Value',vector_index(1))
     479                set(handles.vector_y,'Value',vector_index(2))
    433480            end
    434481        end
    435         vector_index=find(~test_coord,2);%get the first variable not a coordiante
    436         if isempty(vector_index)
    437             set(handles.vector_x,'Value',1)
    438             set(handles.vector_y,'Value',2)
    439         else
    440             set(handles.vector_x,'Value',vector_index(1))
    441             set(handles.vector_y,'Value',vector_index(2))
    442         end       
    443482        vector_Callback(handles)
    444483       
     
    525564end 
    526565update_field(handles,YName)
    527 
     566         
    528567%------------------------------------------------------------------------
    529568% --- Executes on selection change in scalar menu.
     
    801840    case 'attribute'
    802841        set(handles.TimeName, 'Visible','on')% timeName menu represents the available attributes
    803         time_index=[];
    804         PreviousList=get(handles.TimeName, 'String');
    805         index=[];
    806         if ~isempty(PreviousList)
    807             PreviousAttr=PreviousList{get(handles.TimeName, 'Value')};
    808             index=find(strcmp(PreviousAttr,Field.Display.ListGlobalAttributes));
    809         end
    810         if isempty(index)
    811             time_index=find(~cellfun('isempty',regexp(Field.Display.ListGlobalAttribute,'Time')));% index of the attributes containing the string 'Time'
    812         end
     842        time_index=get(handles.TimeName,'UserData');    %select the input data
     843        if isempty(time_index)
     844            PreviousList=get(handles.TimeName, 'String');
     845            if ~isempty(PreviousList)
     846                PreviousAttr=PreviousList{get(handles.TimeName, 'Value')};
     847                index=find(strcmp(PreviousAttr,Field.Display.ListGlobalAttributes),1);
     848            end
     849        end
     850        if isempty(time_index)
     851            time_index=find(~cellfun('isempty',regexp(Field.Display.ListGlobalAttribute,'Time')),1);% index of the attributes containing the string 'Time'
     852        end     
    813853        if ~isempty(time_index)
    814             set(handles.TimeName,'Value',time_index(1))
     854            set(handles.TimeName,'Value',time_index)
    815855        else
    816856            set(handles.TimeName,'Value',1)
    817857        end
    818858        set(handles.TimeName, 'String',Field.Display.ListGlobalAttribute)
     859
    819860    case 'variable'% TimeName menu represents the available variables
    820861        set(handles.TimeName, 'Visible','on')
  • trunk/src/plot_field.m

    r652 r674  
    545545function [haxes,PlotParamOut,PlotType,errormsg]=plot_plane(Data,CellInfo,haxes,PlotParam,PosColorbar)
    546546%-------------------------------------------------------------------
    547 
     547PlotType='plane';
    548548grid(haxes, 'off')% remove grid (possibly remaining from other graphs)
     549
    549550%default plotting parameters
    550 PlotType='plane';%default
    551 % if ~exist('PlotParam','var')
    552 %     PlotParam=[];
    553 % end
    554 
    555551if ~isfield(PlotParam,'Scalar')
    556552    PlotParam.Scalar=[];
     
    559555    PlotParam.Vectors=[];
    560556end
    561 
    562557PlotParamOut=PlotParam;%default
    563 hfig=get(haxes,'parent');
     558errormsg='';%default
     559
     560hfig=get(haxes,'parent');%handle of the figure containing the plot axes
    564561hcol=findobj(hfig,'Tag','Colorbar'); %look for colorbar axes
    565562hima=findobj(haxes,'Tag','ima');% search existing image in the current axes
    566 errormsg='';%default
    567563test_ima=0; %default: test for image or map plot
    568564test_vec=0; %default: test for vector plots
     
    574570YName='';
    575571y_units='';
    576 for icell=1:numel(CellInfo) % length(CellVarIndex) =1 or 2 (from the calling function)
    577 %     VarRole=CellInfo{icell};
     572
     573% loop on the input field cells
     574for icell=1:numel(CellInfo)
    578575    if strcmp(CellInfo{icell}.CoordType,'tps') %do not plot directly tps data (used for projection only)
    579576        continue
     
    600597    ivar_F=[];
    601598    if isfield(CellInfo{icell},'VarIndex_warnflag')
    602     ivar_F=CellInfo{icell}.VarIndex_warnflag; %defines index (unique) for warning flag variable
    603     end
    604     ivar_FF=[];
    605     if isfield(CellInfo{icell},'VarIndex_errorflag')
    606     ivar_FF=CellInfo{icell}.VarIndex_errorflag; %defines index (unique) for error flag variable
    607     end
     599        ivar_F=CellInfo{icell}.VarIndex_warnflag; %defines index (unique) for warning flag variable
     600    end
     601    ivar_FF_vec=[];
    608602    if isfield(CellInfo{icell},'VarIndex_vector_x')&&isfield(CellInfo{icell},'VarIndex_vector_y') % vector components detected
    609         if test_vec
     603        if test_vec% a vector field has been already detected
    610604            errormsg='error in plot_field: attempt to plot two vector fields: to get the difference project on a plane with mode interp';
    611605            return
    612606        else
    613607            test_vec=1;
    614             vec_U=Data.(Data.ListVarName{CellInfo{icell}.VarIndex_vector_x});
     608            if isfield(CellInfo{icell},'VarIndex_errorflag')
     609                ivar_FF_vec=CellInfo{icell}.VarIndex_errorflag; %defines index (unique) for error flag variable
     610            end
     611            vec_U=Data.(Data.ListVarName{CellInfo{icell}.VarIndex_vector_x});
    615612            vec_V=Data.(Data.ListVarName{CellInfo{icell}.VarIndex_vector_y});
    616             if strcmp(CellInfo{icell}.CoordType,'scattered')%2D field with unstructured coordinates 
     613            if strcmp(CellInfo{icell}.CoordType,'scattered')%2D field with unstructured coordinates
    617614                XName=Data.ListVarName{CellInfo{icell}.CoordIndex(end)};
    618615                YName=Data.ListVarName{CellInfo{icell}.CoordIndex(end-1)};
    619616                vec_X=reshape(Data.(XName),[],1); %transform vectors in column matlab vectors
    620617                vec_Y=reshape(Data.(YName),[],1);
    621             elseif strcmp(CellInfo{icell}.CoordType,'grid')%2D field with structured coordinates 
     618            elseif strcmp(CellInfo{icell}.CoordType,'grid')%2D field with structured coordinates
    622619                y=Data.(Data.ListVarName{CellInfo{icell}.CoordIndex(end-1)});
    623620                x=Data.(Data.ListVarName{CellInfo{icell}.CoordIndex(end)});
     
    628625                    x=linspace(x(1),x(2),size(vec_U,2));
    629626                end
    630                 [vec_X,vec_Y]=meshgrid(x,y); 
     627                [vec_X,vec_Y]=meshgrid(x,y);
    631628            end
    632629            if isfield(PlotParam.Vectors,'ColorScalar') && ~isempty(PlotParam.Vectors.ColorScalar)
     
    637634                end
    638635            end
    639             if ~isempty(ivar_F)%~(isfield(PlotParam.Vectors,'HideWarning')&& isequal(PlotParam.Vectors.HideWarning,1)) 
    640                 if test_vec
     636            if ~isempty(ivar_F)%~(isfield(PlotParam.Vectors,'HideWarning')&& isequal(PlotParam.Vectors.HideWarning,1))
     637%                 if test_vec
    641638                    vec_F=Data.(Data.ListVarName{ivar_F}); % warning flags for  dubious vectors
    642                     if  ~(isfield(PlotParam.Vectors,'CheckHideWarning') && isequal(PlotParam.Vectors.CheckHideWarning,1)) 
     639                    if  ~(isfield(PlotParam.Vectors,'CheckHideWarning') && isequal(PlotParam.Vectors.CheckHideWarning,1))
    643640                        test_black=1;
    644641                    end
    645                 end
    646             end
    647             if ~isempty(ivar_FF) %&& ~test_false
    648                 if test_vec% TODO: deal with FF for structured coordinates
    649                     vec_FF=Data.(Data.ListVarName{ivar_FF}); % flags for false vectors
    650                 end
     642%                 end
     643            end
     644            if ~isempty(ivar_FF_vec) %&& ~test_false
     645%                 if test_vec% TODO: deal with FF for structured coordinates
     646                    vec_FF=Data.(Data.ListVarName{ivar_FF_vec}); % flags for false vectors
     647%                 end
    651648            end
    652649        end
    653650    elseif ~isempty(ivar_C) %scalar or image
    654651        if test_ima
    655              errormsg='attempt to plot two scalar fields or images';
     652            errormsg='attempt to plot two scalar fields or images';
    656653            return
    657654        end
    658655        A=squeeze(Data.(Data.ListVarName{ivar_C}));% scalar represented as color image
    659656        test_ima=1;
    660         if strcmp(CellInfo{icell}.CoordType,'scattered')%2D field with unstructured coordinates 
     657        if strcmp(CellInfo{icell}.CoordType,'scattered')%2D field with unstructured coordinates
    661658            A=reshape(A,1,[]);
    662659            XName=Data.ListVarName{ivar_X};
    663660            YName=Data.ListVarName{ivar_Y};
    664             eval(['AX=reshape(Data.' XName ',1,[]);']) 
     661            eval(['AX=reshape(Data.' XName ',1,[]);'])
    665662            eval(['AY=reshape(Data.' YName ',1,[]);'])
    666             [A,AX,AY]=proj_grid(AX',AY',A',[],[],'np>256');  % interpolate on a grid 
     663            [A,AX,AY]=proj_grid(AX',AY',A',[],[],'np>256');  % interpolate on a grid
    667664            if isfield(Data,'VarAttribute')
    668665                if numel(Data.VarAttribute)>=ivar_X && isfield(Data.VarAttribute{ivar_X},'units')
     
    672669                    y_units=[' (' Data.VarAttribute{ivar_Y}.units ')'];
    673670                end
    674             end       
    675         elseif strcmp(CellInfo{icell}.CoordType,'grid')%2D field with structured coordinates 
     671            end
     672        elseif strcmp(CellInfo{icell}.CoordType,'grid')%2D field with structured coordinates
    676673            YName=Data.ListVarName{CellInfo{icell}.CoordIndex(end-1)};
    677             AY=Data.(YName); 
     674            AY=Data.(YName);
    678675            AX=Data.(Data.ListVarName{CellInfo{icell}.CoordIndex(end)});
    679676            test_interp_X=0; %default, regularly meshed X coordinate
     
    686683                    y_units=Data.VarAttribute{CellInfo{icell}.CoordIndex(end-1)}.units;
    687684                end
    688             end 
     685            end
    689686            if numel(AY)>2
    690687                DAY=diff(AY);
     
    692689                DAY_max=max(DAY);
    693690                if sign(DAY_min)~=sign(DAY_max);% =1 for increasing values, 0 otherwise
    694                      errormsg=['errror in plot_field.m: non monotonic dimension variable ' Data.ListVarName{VarRole.coord(1)} ];
    695                       return
    696                 end 
     691                    errormsg=['errror in plot_field.m: non monotonic dimension variable ' Data.ListVarName{VarRole.coord(1)} ];
     692                    return
     693                end
    697694                test_interp_Y=(DAY_max-DAY_min)> 0.0001*abs(DAY_max);
    698695            end
     
    702699                DAX_max=max(DAX);
    703700                if sign(DAX_min)~=sign(DAX_max);% =1 for increasing values, 0 otherwise
    704                      errormsg=['errror in plot_field.m: non monotonic dimension variable ' Data.ListVarName{VarRole.coord(2)} ];
    705                       return
    706                 end 
     701                    errormsg=['errror in plot_field.m: non monotonic dimension variable ' Data.ListVarName{VarRole.coord(2)} ];
     702                    return
     703                end
    707704                test_interp_X=(DAX_max-DAX_min)> 0.0001*abs(DAX_max);
    708             end 
    709             if test_interp_Y         
     705            end
     706            if test_interp_Y
    710707                npxy(1)=max([256 floor((AY(end)-AY(1))/DAY_min) floor((AY(end)-AY(1))/DAY_max)]);
    711708                yI=linspace(AY(1),AY(end),npxy(1));
    712709                if ~test_interp_X
    713                     xI=linspace(AX(1),AX(end),size(A,2));%default 
     710                    xI=linspace(AX(1),AX(end),size(A,2));%default
    714711                    AX=xI;
    715712                end
    716713            end
    717             if test_interp_X 
     714            if test_interp_X
    718715                npxy(2)=max([256 floor((AX(end)-AX(1))/DAX_min) floor((AX(end)-AX(1))/DAX_max)]);
    719                 xI=linspace(AX(1),AX(end),npxy(2));   
     716                xI=linspace(AX(1),AX(end),npxy(2));
    720717                if ~test_interp_Y
    721                    yI=linspace(AY(1),AY(end),size(A,1));
    722                    AY=yI;
    723                 end
    724             end
    725             if test_interp_X || test_interp_Y               
     718                    yI=linspace(AY(1),AY(end),size(A,1));
     719                    AY=yI;
     720                end
     721            end
     722            if test_interp_X || test_interp_Y
    726723                [AX2D,AY2D]=meshgrid(AX,AY);
    727724                A=interp2(AX2D,AY2D,double(A),xI,yI');
    728725            end
    729             AX=[AX(1) AX(end)];% keep only the lower and upper bounds for image represnetation 
     726            AX=[AX(1) AX(end)];% keep only the lower and upper bounds for image represnetation
    730727            AY=[AY(1) AY(end)];
    731 %         else
    732 %             errormsg='error in plot_field: invalid coordinate definition ';
    733 %             return
    734728        end
    735729    end
     
    742736            y_units=Data.CoordUnit;
    743737        end
    744     end
    745        
    746 end
     738    end   
     739end
    747740
    748741%%   image or scalar plot %%%%%%%%%%%%%%%%%%%%%%%%%%
     
    10921085           vec_F=vec_F(ind_sel);
    10931086        end
    1094         if ~isempty(ivar_FF)
     1087        if ~isempty(ivar_FF_vec)
    10951088           vec_FF=vec_FF(ind_sel);
    10961089        end
     
    11061099       nbcolor=nbcolor+1;
    11071100       colorlist(nbcolor,:)=[0 0 0]; %add black to the list of colors
    1108        if ~isempty(ivar_FF)
    1109           %  ind_flag=find(vec_F~=1 & vec_F~=0 & vec_FF==0);  %flag warning but not false
     1101       if ~isempty(ivar_FF_vec)
    11101102            col_vec(vec_F~=1 & vec_F~=0 & vec_FF==0)=nbcolor;
    11111103       else
     
    11141106    end
    11151107    nbcolor=nbcolor+1;
    1116     if ~isempty(ivar_FF)
     1108    if ~isempty(ivar_FF_vec)
    11171109        if isfield(PlotParam.Vectors,'CheckHideFalse') && PlotParam.Vectors.CheckHideFalse==1
    11181110            colorlist(nbcolor,:)=[NaN NaN NaN];% no plot of false vectors
  • trunk/src/read_civdata.m

    r654 r674  
    133133for ivar=1:numel(var_ind)
    134134    Field.VarAttribute{ivar}.Role=role{var_ind(ivar)};
     135    Field.VarAttribute{ivar}.Mesh=0.1;%typical mesh for histograms O.1 pixel
     136    Field.VarAttribute{ivar}.ProjModeRequest=ProjModeRequest;
    135137    if strcmp(role{var_ind(ivar)},'vector_x')
    136138        Field.VarAttribute{ivar}.FieldName=FieldNames;
    137         Field.VarAttribute{ivar}.ProjModeRequest=ProjModeRequest;
     139%         Field.VarAttribute{ivar}.ProjModeRequest=ProjModeRequest;
    138140        ivar_U=ivar;
    139141    end
    140142    if strcmp(role{var_ind(ivar)},'vector_x_tps')
    141143        Field.VarAttribute{ivar}.FieldName=FieldNames;
    142         Field.VarAttribute{ivar}.ProjModeRequest=ProjModeRequest;
     144%         Field.VarAttribute{ivar}.ProjModeRequest=ProjModeRequest;
    143145        ivar_U_tps=ivar;
    144146    end
    145147    if strcmp(role{var_ind(ivar)},'vector_y')
    146148        Field.VarAttribute{ivar}.FieldName=FieldNames;
    147         Field.VarAttribute{ivar}.ProjModeRequest=ProjModeRequest;
     149%         Field.VarAttribute{ivar}.ProjModeRequest=ProjModeRequest;
    148150        ivar_V=ivar;
    149151    end
    150152    if strcmp(role{var_ind(ivar)},'vector_y_tps')
    151153        Field.VarAttribute{ivar}.FieldName=FieldNames;
    152         Field.VarAttribute{ivar}.ProjModeRequest=ProjModeRequest;
     154%         Field.VarAttribute{ivar}.ProjModeRequest=ProjModeRequest;
    153155        ivar_V_tps=ivar;
    154156    end
    155     Field.VarAttribute{ivar}.Mesh=0.1;%typical mesh for histograms O.1 pixel
    156157end
    157158if ~isempty(ivar_U_tps)
  • trunk/src/set_object.m

    r667 r674  
    9393    ZBounds=0; %default
    9494end
    95 set(hObject,'KeyPressFcn',{'keyboard_callback',handles})%set keyboard action function (allow action on uvmat when set_object is in front)
     95set(handles.Coord,'KeyPressFcn',{@key_press_fcn,handles})%set keyboard action function (allow action on uvmat when set_object is in front)
    9696set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function
    9797set(hObject,'DeleteFcn',{@closefcn})
     
    722722    % add lines if multi line input needed
    723723    case{'points','polyline','polygon'}
     724        Input=str2num(eventdata.EditData);%pasted input
    724725        Coord=get(handles.Coord,'Data');
    725         if ~isnan(Coord(end,1))
    726             if isequal(size(Coord,2),3)
    727                 %Coord=[Coord;{[]} {[]} {[]}];%add a line for edition (3D case)
    728                 Coord=[Coord;NaN NaN NaN]; %add a line for edition (3D case)
     726        iline=eventdata.Indices(1);% selected line number
     727        if size(Coord,1)<iline+numel(Input)
     728            Coord=[Coord ; zeros(iline+numel(Input)-size(Coord,1),size(Coord,2))];% append zeros to fit the new column
     729        end
     730        Coord(iline:iline+numel(Input)-1,eventdata.Indices(2))=Input';
     731        set(handles.Coord,'Data',Coord)
     732end
     733
     734% --- Executes when selected cell(s) is changed in ListCoord.
     735function Coord_CellSelectionCallback(hObject, eventdata, handles)
     736
     737if ~isempty(eventdata.Indices)
     738    iline=eventdata.Indices(1);% selected line number
     739    set(handles.Coord,'UserData',iline)
     740end
     741
     742%------------------------------------------------------------------------
     743% --- 'key_press_fcn:' function activated when a key is pressed on the keyboard
     744%------------------------------------------------------------------------
     745function key_press_fcn(hObject,eventdata,handles)
     746
     747xx=double(get(handles.set_object,'CurrentCharacter')); %get the keyboard character
     748if ismember(xx,[8 127 31])%backspace or delete, or downward
     749    Coord=get(handles.Coord,'Data');
     750    iline=get(handles.Coord,'UserData');
     751            if isequal(xx, 31)
     752                if isequal(iline,size(Coord,1))% arrow downward
     753                Coord=[Coord;zeros(1,size(Coord,2))];
     754                end
    729755            else
    730                 Coord=[Coord;NaN NaN]; %add a line for edition (2D case)
     756    Coord(iline,:)=[];% suppress the current line
    731757            end
    732             set(handles.Coord,'Data',Coord)
    733         end
    734 end
    735 
    736 
     758    set(handles.Coord,'Data',Coord);
     759end
    737760
    738761function num_Angle_3_Callback(hObject, eventdata, handles)
  • trunk/src/struct2nc.m

    r530 r674  
    4747    return
    4848end
    49 %  [Data,errormsg]=check_field_structure(Data);%check the validity of the input field structure
     49%check the validity of the input field structure
    5050[errormsg,ListDimName,DimValue,VarDimIndex]=check_field_structure(Data);
    5151if ~isempty(errormsg)
     
    139139%'check_field_structure': check the validity of the field struture representation consistant with the netcdf format
    140140%------------------------------------------------------------------------
    141 % function [DataOut,errormsg]=check_field_structure(Data)
     141% [errormsg,ListDimName,DimValue,VarDimIndex]=check_field_structure(Data)
    142142%
    143143% OUTPUT:
    144 % DataOut: structure reproducing the input structure Data (TODO: suppress this output)
    145144% errormsg: error message which is not empty when the input structure does not have the right form
     145% ListDimName: list of dimension names (cell array of cahr strings)
     146% DimValue: list of dimension values (numerical array with the same dimension as ListDimName)
     147% VarDimIndex: cell array of dimension index (in the list ListDimName) for each element of Data.ListVarName
    146148%
    147149% INPUT:
     
    179181    return
    180182end
    181 % if isfield(Data,'DimValue')
    182 %     Data=rmfield(Data,'DimValue');
    183 % end
    184183nbdim=0;
    185184ListDimName={};
    186185
    187186%% main loop on the list of variables
     187VarDimIndex=cell(1,nbfield);
    188188for ivar=1:nbfield
    189189    VarName=Data.ListVarName{ivar};
     
    198198    elseif ~iscell(DimCell)
    199199        errormsg=['wrong format for .VarDimName{' num2str(ivar) ' (must be the cell of dimension names of the variable ' VarName];
    200         return
    201        
     200        return       
    202201    end
    203202    nbcoord=numel(sizvar);%nbre of coordinates for variable named VarName
     
    209208        if nbcoord==2
    210209            if sizvar(1)==1
    211                 nbcoord=1;
    212210                sizvar(1)=sizvar(2);
    213211            elseif sizvar(2)==1
    214                 nbcoord=1;
    215212            else
    216213                errormsg=['1 dimension declared in .VarDimName{' num2str(ivar) '} inconsistent with the nbre of dimensions =2 of the variable ' VarName];
     
    227224        if numel(DimCell)>nbcoord
    228225            sizvar(nbcoord+1:numel(DimCell))=1;% case of singleton dimensions (not seen by the function size)
    229            % DimCell=DimCell(end-nbcoord+1:end)%first singleton diemensions omitted,
    230226        elseif nbcoord > numel(DimCell)
    231227            errormsg=['nbre of declared dimensions in .VarDimName{' num2str(ivar) '} smaller than the nbre of dimensions =' num2str(nbcoord) ' of the variable ' VarName];
     
    234230    end
    235231    DimIndex=[];
    236     %for idim=1:nbcoord
    237232    for idim=1:numel(DimCell) %loop on the coordinates of variable #ivar
    238233        DimName=DimCell{idim};
     
    261256    VarDimIndex{ivar}=DimIndex;
    262257end
    263 DataOut=Data;
  • trunk/src/sub_field.m

    r581 r674  
    2626    return
    2727end
     28
    2829%% global attributes
    2930SubData.ListGlobalAttribute={};%default
     
    107108%% look for coordinates common to Field in Field_1
    108109ind_remove=zeros(size(Field_1.ListVarName));
     110% loop on the variables of the second field Field_1
    109111for ilist=1:numel(Field_1.ListVarName)
    110     if ischar(Field_1.VarDimName{ilist})||numel(Field_1.VarDimName{ilist})==1
    111         OldDim=Field_1.VarDimName{ilist};
    112         if ischar(OldDim)
    113             OldDim=Field_1.VarDimName(ilist);
    114         end
    115         VarVal=Field_1.(Field_1.ListVarName{ilist});
     112    % case of variable with a single dimension
     113    OldDimName=Field_1.VarDimName{ilist};
     114    if ischar(OldDimName), OldDimName={OldDimName}; end% transform char string to cell if relevant
     115    if numel(OldDimName)==1
     116        OldDim=Field_1.(Field_1.ListVarName{ilist});% get variable
     117        %look for the existence of the variable OldDim in the first field Field
    116118        for i1=1:numel(Field.ListVarName)
    117             if (isempty(ProjModeRequest{i1})&&isempty(ProjModeRequest_1{ilist})||strcmp(ProjModeRequest{i1},ProjModeRequest_1{ilist})) && isequal(Field.(Field.ListVarName{i1}),VarVal)
     119            if  isequal(Field.(Field.ListVarName{i1}),OldDim) &&...
     120                   ((isempty(ProjModeRequest{i1}) && isempty(ProjModeRequest_1{ilist}))  || strcmp(ProjModeRequest{i1},ProjModeRequest_1{ilist}))               
    118121               ind_remove(ilist)=1;
    119                NewDim=Field.VarDimName{i1};
    120                if ischar(NewDim)
    121                    NewDim={NewDim};
    122                end
    123                Field_1.VarDimName=regexprep_r(Field_1.VarDimName,['^' OldDim{1} '$'],NewDim{1});
     122               NewDimName=Field.VarDimName{i1};
     123               if ischar(NewDimName), NewDimName={NewDimName}; end %transform char chain to cell if needed
     124               Field_1.VarDimName=regexprep_r(Field_1.VarDimName,['^' OldDimName{1} '$'],NewDimName{1});% change the var name of Field_1 to the corresponding var name of Field
    124125            end
    125126        end
    126127    end
    127128end
    128 Field_1.ListVarName(find(ind_remove))=[];%removes these redondent coordinates
     129Field_1.ListVarName(find(ind_remove))=[];%removes the redondent coordinate
    129130Field_1.VarDimName(find(ind_remove))=[];
    130131Field_1.VarAttribute(find(ind_remove))=[];
     
    150151
    151152%% substrat fields when possible
    152 %[CellVarIndex,NbDim,CellVarType,errormsg]=find_field_cells(SubData);
    153153[CellInfo,NbDim,errormsg]=find_field_cells(SubData);
    154154ind_remove=zeros(size(SubData.ListVarName));
     
    180180SubData.VarDimName(find(ind_remove))=[];
    181181SubData.VarAttribute(find(ind_remove))=[];
    182 %end
     182'end'
    183183
    184184function OutputCell=regexprep_r(InputCell,search_string,new_string)
     185OutputCell=InputCell;%default
    185186for icell=1:numel(InputCell)
    186187    OutputCell{icell}=regexprep(InputCell{icell},search_string,new_string);
  • trunk/src/tps_coeff_field.m

    r651 r674  
    4040        X=DataIn.(DataIn.ListVarName{CellInfo{icell}.CoordIndex(end)});% value of x coordinate
    4141        Y=DataIn.(DataIn.ListVarName{CellInfo{icell}.CoordIndex(end-1)});% value of x coordinate
    42         check_interp_tps=false(numel(CellInfo{icell}.VarIndex),1);
     42        check_interp_tps=false(numel(DataIn.ListVarName),1);
    4343        %for ivar=1:numel(CellInfo{icell}.VarIndex)
    4444        Index_interp=[];
     
    5252            Index_interp=[Index_interp CellInfo{icell}.VarIndex_vector_y];
    5353        end
    54         for ivar=Index_interp
    55             Attr=DataIn.VarAttribute{CellInfo{icell}.VarIndex(ivar)};
     54        for iselect=1:numel(Index_interp)
     55            Attr=DataIn.VarAttribute{Index_interp(iselect)};
    5656            if ~isfield(Attr,'VarIndex_tps')&& (checkall || (isfield(Attr,'ProjModeRequest')&&strcmp(Attr.ProjModeRequest,'interp_tps')))
    57                 check_interp_tps(ivar)=1;
     57                check_interp_tps(Index_interp(iselect))=1;
    5858            end
    5959        end
    60         VarIndexInterp=CellInfo{icell}.VarIndex(check_interp_tps);% indices of variables to interpolate through tps
    61         if ~isempty(VarIndexInterp)
    62             ListVarInterp=DataIn.ListVarName(VarIndexInterp);
     60       
     61        %VarIndexInterp=CellInfo{icell}.VarIndex(check_interp_tps);% indices of variables to interpolate through tps
     62        %         if ~isempty(VarIndexInterp)
     63        ListVarInterp=DataIn.ListVarName(check_interp_tps);
     64        VarIndexInterp=find(check_interp_tps);
     65        if ~isempty(ListVarInterp)
    6366            % exclude data points marked 'false' for interpolation
    6467            if isfield(CellInfo{icell},'VarIndex_errorflag')
     
    6669                X=X(FF==0);
    6770                Y=Y(FF==0);
    68                 for ilist=1:numel(VarIndexInterp)
     71                for ilist=1:numel(ListVarInterp)
    6972                    DataIn.(ListVarInterp{ilist})=DataIn.(ListVarInterp{ilist})(FF==0);
    7073                end
     
    7477                term=['_' num2str(nbtps-1)];
    7578            end
    76             ListNewVar=cell(1,numel(VarIndexInterp)+3);
     79            ListNewVar=cell(1,numel(ListVarInterp)+3);
    7780            ListNewVar(1:3)={['SubRange' term],['NbCentre' term],['Coord_tps' term]};
    78             for ilist=1:numel(VarIndexInterp)
     81            for ilist=1:numel(ListVarInterp)
    7982                ListNewVar{ilist+3}=[ListVarInterp{ilist} '_tps' term];
    8083            end
    8184            nbvar=numel(DataIn.ListVarName);
    8285            DataOut.ListVarName=[DataIn.ListVarName ListNewVar];
    83             %ListNewDim={['nb_tps' term],['nb_subdomain' term]};
    8486            DataOut.VarDimName=[DataIn.VarDimName {{'nb_coord','nb_bounds',['nb_subdomain' term]}} {['nb_subdomain' term]} ...
    8587                {{['nb_tps' term],'nb_coord',['nb_subdomain' term]}}];
     
    9193                DataOut.(['Coord_tps' term])(NbCentre(isub)+1:NbCentre(isub)+3,1:2,isub)=0;%matrix of zeros to complement the matrix Coord_tps (conveninent for file storage)
    9294                %fill=zeros(NbCoord+1,NbCoord,size(SubRange,3)); %matrix of zeros to complement the matrix Data.Civ1_Coord_tps (conveninent for file storage)
    93 %                 fill=zeros(NbCoord+1,NbCoord+1,NbCoord); %matrix of zeros to complement the matrix Data.Civ1_Coord_tps (conveninent for file storage)
    94 %                 Coord_tps=cat(1,Coord_tps,fill);
    95             end         
    96             for ivar=1:numel(VarIndexInterp)
     95                %                 fill=zeros(NbCoord+1,NbCoord+1,NbCoord); %matrix of zeros to complement the matrix Data.Civ1_Coord_tps (conveninent for file storage)
     96                %                 Coord_tps=cat(1,Coord_tps,fill);
     97            end
     98            for ivar=1:numel(ListVarInterp)
    9799                DataOut.VarDimName{nbvar+3+ivar}={['nb_tps' term],['nb_subdomain' term]};
    98100                DataOut.VarAttribute{nbvar+3+ivar}=DataIn.VarAttribute{CellInfo{icell}.VarIndex_vector_x};%reproduce attributes of velocity
     
    112114            DataOut.(['SubRange' term])=SubRange;
    113115            DataOut.(['NbCentre' term])=NbCentre;
    114 %             DataOut.(['Coord_tps' term])=Coord_tps;
     116            %             DataOut.(['Coord_tps' term])=Coord_tps;
    115117            for ilist=1:numel(VarIndexInterp)
    116 %                 Var_tps=zeros(size(IndSelSubDomain)+[NbCoord+1 0]);%default spline
     118                %                 Var_tps=zeros(size(IndSelSubDomain)+[NbCoord+1 0]);%default spline
    117119                for isub=1:size(SubRange,3)
    118120                    ind_sel=IndSelSubDomain(1:NbCentre(isub),isub);% array indices selected for the subdomain
  • trunk/src/uvmat.m

    r672 r674  
    442442%% display the selected field and related information
    443443if ~isempty(fileinput)
     444    set(handles.SubField,'Value',0)
     445    desable_subfield(handles)
    444446    display_file_name(handles,fileinput)
    445447end
     
    450452%------------------------------------------------------------------------
    451453fileinput=get(hObject,'Label');
     454    set(handles.SubField,'Value',0)
     455    desable_subfield(handles)
    452456display_file_name( handles,fileinput)
    453 %
    454 % % -----------------------------------------------------------------------
    455 % % --- Open again the file whose name has been recorded in MenuFile_2
    456 % function MenuFile_2_Callback(hObject, eventdata, handles)
    457 % %------------------------------------------------------------------------
    458 % fileinput=get(handles.MenuFile_2,'Label');
    459 % display_file_name(handles,fileinput)
    460 %
    461 % % -----------------------------------------------------------------------
    462 % % --- Open again the file whose name has been recorded in MenuFile_3
    463 % function MenuFile_3_Callback(hObject, eventdata, handles)
    464 % %------------------------------------------------------------------------
    465 % fileinput=get(handles.MenuFile_3,'Label');
    466 % display_file_name(handles,fileinput)
    467 %
    468 % % -----------------------------------------------------------------------
    469 % % --- Open again the file whose name has been recorded in MenuFile_4
    470 % function MenuFile_4_Callback(hObject, eventdata, handles)
    471 % %------------------------------------------------------------------------
    472 % fileinput=get(handles.MenuFile_4,'Label');
    473 % display_file_name(handles,fileinput)
    474 %
    475 % % -----------------------------------------------------------------------
    476 % % --- Open again the file whose name has been recorded in MenuFile_5
    477 % function MenuFile_5_Callback(hObject, eventdata, handles)
    478 % %------------------------------------------------------------------------
    479 % fileinput=get(handles.MenuFile_5,'Label');
    480 % display_file_name(handles,fileinput)
    481457
    482458
     
    681657    return
    682658end
    683 
    684 %% detect root name, nomenclature and indices in the input file name:
    685 [FilePath,FileName,FileExt]=fileparts(fileinput);
    686 % detect the file type, get the movie object if relevant, and look for the corresponding file series:
    687 % the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists
    688 [RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,FileInfo,MovieObject,i1,i2,j1,j2]=find_file_series(FilePath,[FileName FileExt]);
    689 
    690 if strcmp(FileType,'txt')
    691     edit(fileinput)
    692     return
    693 elseif strcmp(FileType,'xml')
    694     editxml(fileinput)
    695      return
    696 elseif strcmp(FileType,'figure')
    697     open(fileinput)
    698      return
    699 end
    700 
    701 %% set the mouse pointer to 'watch'
    702 set(handles.uvmat,'Pointer','watch')
    703 set(handles.RootPath,'BackgroundColor',[1 1 0])
    704 drawnow
    705659
    706660%% define the relevant handles for the first field series (index=1) or the second file series (index=2)
     
    728682    set(handles.FileExt_1,'Visible','on');
    729683    set(handles.NomType_1,'Visible','on');
     684    set(handles.TimeName_1,'Visible','on')
     685    set(handles.TimeValue_1,'Visible','on')
     686end
     687set(handles_RootPath,'BackgroundColor',[1 1 0])% paint edit box to yellow to visualise root file input
     688set(handles.uvmat,'Pointer','watch') % set the mouse pointer to 'watch'
     689drawnow
     690
     691%% detect root name, nomenclature and indices in the input file name:
     692[FilePath,FileName,FileExt]=fileparts(fileinput);
     693% detect the file type, get the movie object if relevant, and look for the corresponding file series:
     694% the root name and indices may be corrected by including the first index i1 if a corresponding xml file exists
     695[RootPath,SubDir,RootFile,i1_series,i2_series,j1_series,j2_series,NomType,FileType,FileInfo,MovieObject,i1,i2,j1,j2]=find_file_series(FilePath,[FileName FileExt]);
     696
     697if strcmp(FileType,'txt')
     698    edit(fileinput)
     699    return
     700elseif strcmp(FileType,'xml')
     701    editxml(fileinput)
     702     return
     703elseif strcmp(FileType,'figure')
     704    open(fileinput)
     705     return
    730706end
    731707
     
    820796        %enable other menus
    821797        set(handles.MenuOpenCampaign,'Enable','on')
    822 %         set(handles.MenuCampaign_1,'Enable','on')
    823 %         set(handles.MenuCampaign_2,'Enable','on')
    824 %         set(handles.MenuCampaign_3,'Enable','on')
    825 %         set(handles.MenuCampaign_4,'Enable','on')
    826 %         set(handles.MenuCampaign_5,'Enable','on')
    827798        set(handles.MenuExport,'Enable','on')
    828799        set(handles.MenuExportFigure,'Enable','on')
     
    854825end
    855826
    856 %% set back the mouse pointer to arrow
    857 set(handles.uvmat,'Pointer','arrow')
     827set(handles_RootPath,'BackgroundColor',[1 1 1])% paint back edit box to white to visualise end of root file input
     828set(handles.uvmat,'Pointer','arrow')% set back the mouse pointer to arrow
    858829
    859830
     
    869840end
    870841if index==1
    871     handles_RootPath=handles.RootPath;
    872842    handles_Fields=handles.FieldName;
    873843elseif index==2
    874     handles_RootPath=handles.RootPath_1;
    875844    handles_Fields=handles.FieldName_1;
    876845end
    877846
    878 set(handles_RootPath,'BackgroundColor',[1 1 0])
    879 drawnow
    880847set(handles.FieldName,'UserData',[])% reinialize data from uvmat opening
    881848UvData=get(handles.uvmat,'UserData');%huvmat=handles of the uvmat interface
     
    901868
    902869%% read timing and total frame number from the current file (movie files) !! may be overrid by xml file
     870TimeUnit='';%default
     871TimeName='';%default
    903872XmlData.Time=[];%default
    904 XmlData.GeometryCalib=[];%default
    905 TimeUnit='';%default
    906 Time=[];
    907873imainfo=[];
    908874ColorType='falsecolor'; %default
     
    912878    TimeUnit='s';
    913879    if isempty(j1_series); %frame index along i
    914         Time=zeros(imainfo.NumberOfFrames+1,2);
    915         Time(:,2)=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate)';
     880        XmlData.Time=zeros(imainfo.NumberOfFrames+1,2);
     881        XmlData.Time(:,2)=(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate)';
    916882    else
    917         Time=[0;ones(size(i1_series,3)-1,1)]*(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate);
     883        XmlData.Time=[0;ones(size(i1_series,3)-1,1)]*(0:1/imainfo.FrameRate:(imainfo.NumberOfFrames)/imainfo.FrameRate);
    918884    end
    919885    set(handles.Dt_txt,'String',['Dt=' num2str(1000/imainfo.FrameRate) 'ms']);%display the elementary time interval in millisec
    920     if index==1
    921     set(handles.TimeName,'String','video')
    922     else
    923         set(handles.TimeName_1,'String','video')
    924     end
     886    TimeName='video';
    925887    ColorType='truecolor';
    926888elseif ~isempty(FileExt(2:end))&&(~isempty(imformats(FileExt(2:end))) || isequal(FileExt,'.vol'))%&& isequal(NomType,'*')% multi-frame image
    927 %     testima=1;
    928889    if ~isequal(SubDir,'')
    929890        imainfo=imfinfo([fullfile(RootPath,SubDir,RootFile) FileIndices FileExt]);
     
    948909
    949910%% read parameters (time, geometric calibration..) from a documentation file (.xml advised)
     911XmlData.GeometryCalib=[];%default
    950912XmlFileName=find_imadoc(RootPath,SubDir,RootFile,FileExt);
    951913[tild,tild,DocExt]=fileparts(XmlFileName);
     
    964926    end
    965927    if ~isempty(XmlDataRead)
    966         ImaDoc_str=['view ' DocExt];   
     928        ImaDoc_str=['view ' DocExt];  % DocExt= '.xml' or .civ (obsolete case)
    967929        XmlData=XmlDataRead;
    968930        if isfield(XmlData,'TimeUnit')
     
    990952    end
    991953end
    992 if (strcmp(FileType,'civdata')||strcmp(FileType,'civx')) && ((isfield(XmlData,'Time')&& ~isempty(XmlData.Time)))
    993     if index==1
    994     set(handles.TimeName,'String','xml')
    995     else
    996        set(handles.TimeName_1,'String','xml')
    997     end
    998 else
    999     XmlData.Time=Time; %time set by video
    1000 end
    1001954if isempty(ImaDoc_str)
    1002     set(handles.view_xml,'Visible','off')
    1003 else
    1004     set(handles.view_xml,'String',ImaDoc_str)
     955    set(handles.view_xml,'Visible','off') % no .xml (or .civ) file detected
     956else
     957    set(handles.view_xml,'String',ImaDoc_str)% indicate that a xml file has been detected
     958end
     959
     960%% Define timing
     961% time not set by the input file: images or civ data: indicate that time is read from the xml file
     962if isfield(XmlData,'Time')&& ~isempty(XmlData.Time) && ...
     963        (strcmp(FileType,'image')|| strcmp(FileType,'multimage')||strcmp(FileType,'civdata')||strcmp(FileType,'civx'))
     964    TimeName='xml';
     965end
     966if index==1
     967    set(handles.TimeName,'String',TimeName)
     968else
     969    set(handles.TimeName_1,'String',TimeName)
     970    set(handles.TimeName_1,'Visible','on')
    1005971end
    1006972
     
    1014980    nbfield_j=max(max(max(j1_series)));
    1015981end
    1016 if ~isempty(XmlData.Time)
     982if isfield(XmlData,'Time')&& ~isempty(XmlData.Time)
    1017983    %transform .Time to a column vector if it is a line vector the nomenclature uses a single index
    1018984    if isequal(size(XmlData.Time,1),1)
     
    10751041
    10761042%% update the data attached to the uvmat interface
    1077 if ~isempty(TimeUnit)
    1078     set(handles.TimeName,'String',['time (' TimeUnit ')'])
    1079 end
    10801043UvData.TimeUnit=TimeUnit;
    10811044UvData.XmlData{index}=XmlData;
     
    13111274%------------------------------------------------------------------------
    13121275% --- Executes on button press in view_xml.
     1276%------------------------------------------------------------------------
    13131277function view_xml_Callback(hObject, eventdata, handles)
    1314 %------------------------------------------------------------------------
    1315 %[FileName,RootPath,FileBase,FileIndices,FileExt]=read_file_boxes(handles);
    1316  [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
    1317 FileBase=fullfile(RootPath,RootFile);
     1278
     1279% if TimeName defined, open the xml file corresponding to the first file
     1280% series, else open the xml file corresponding to the second series
     1281if isempty(get(handles.TimeName,'String'))% open the xml file corresponding to the secodn file series
     1282    [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes_1(handles);
     1283else
     1284   [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles);
     1285end
    13181286option=get(handles.view_xml,'String');
    1319 if isequal(option,'view .xml')
     1287if isequal(option,'view .xml')     
    13201288    FileXml=fullfile(RootPath,[SubDir '.xml']);
    13211289    if ~exist(FileXml,'file')% case of civ files , removes the extension for subdir
     
    16161584CheckFixPair=get(handles.CheckFixPair,'Value')||(isempty(i2)&&isempty(j2));
    16171585
     1586%         i1_1=i1;
     1587%         i2_1=i2;
     1588%         j1_1=j1;
     1589%         j2_1=j2;
    16181590% the pair i1-i2 or j1-j2 is imposed (check box CheckFixPair selected)
    1619         i1_1=i1;
    1620         i2_1=i2;
    1621         j1_1=j1;
    1622         j2_1=j2;
    16231591if CheckFixPair && isnumeric(increment)
    16241592    if get(handles.scan_i,'Value')==1% case of scanning along index i
     
    22142182        ParamIn_1.FieldName=FieldName_1;
    22152183        ParamIn_1.VelType=VelType_1;
    2216         ParamIn_1.GUIName='get_field_1';
     2184        %ParamIn_1.GUIName='get_field_1';
    22172185        end 
    22182186        [Field{2},ParamOut_1,errormsg] = read_field(FileName_1,UvData.FileType{2},ParamIn_1,frame_index_1);
     
    23202288end           
    23212289
    2322 %% display time
     2290%% display time value of the current file
    23232291abstime=[];%default inputs
    23242292dt=[];
    23252293TimeUnit='';
     2294if isfield(UvData,'TimeUnit')
     2295TimeUnit=UvData.TimeUnit;%retrieve info from update_rootinfo
     2296end
    23262297% time from xml file or video movie
    2327 if isfield(UvData,'XmlData') && isfield(UvData.XmlData{1},'Time')
     2298TimeName=get(handles.TimeName,'String');% indicate that time is from xml
     2299if strcmp(TimeName,'xml')||strcmp(TimeName,'video')
    23282300    if isempty(num_i2)||isnan(num_i2)
    23292301        num_i2=num_i1;
     
    23372309    siz=size(UvData.XmlData{1}.Time);
    23382310    if ~isempty(num_i1)&& ~isempty(num_i2) && num_i1>=0 &&siz(1)>=max(num_i1+1,num_i2+1) && siz(2)>=max(num_j1+1,num_j2+1)
    2339         set(handles.TimeName,'String','xml')% indicate that time is from xml
    23402311        abstime=(UvData.XmlData{1}.Time(num_i1+1,num_j1+1)+UvData.XmlData{1}.Time(num_i2+1,num_j2+1))/2;%overset the time read from files
    23412312        dt=(UvData.XmlData{1}.Time(num_i2+1,num_j2+1)-UvData.XmlData{1}.Time(num_i1+1,num_j1+1));
     
    23452316        end
    23462317    end
    2347     if numel(UvData.XmlData)==2
    2348         if isempty(i2_1)
    2349             i2_1=num_i1;
    2350         end
    2351         if isempty(j1_1)
    2352             j1_1=1;
    2353         end
    2354         if isempty(j2_1)
    2355             j2_1=j1_1;
    2356         end
    2357         siz=size(UvData.XmlData{2}.Time);
    2358         if ~isempty(i1_1) && siz(1)>=max(i1_1+1,i2_1+1) && siz(2)>=max(j1_1+1,j2_1+1)
    2359             abstime_1=(UvData.XmlData{2}.Time(i1_1+1,j1_1+1)+UvData.XmlData{2}.Time(i2_1+1,j2_1+1))/2;%overset the time read from files
    2360             Field{2}.Dt=(UvData.XmlData{2}.Time(i2_1+1,j2_1+1)-UvData.XmlData{2}.Time(i1_1+1,j1_1+1));
    2361         end
    2362     end
    2363 end
    2364 
    2365 %% look for timing in the input file if not defined in a xml file or movie
     2318end
     2319
     2320% get time in the input file, not defined in a xml file or movie
    23662321if isempty(abstime)
    2367     TimeName=get(handles.TimeName,'String');
    23682322    if ~isempty(regexp(TimeName,'^att:'))||~isempty(regexp(TimeName,'^dim:'))||~isempty(regexp(TimeName,'^var:'))
    23692323        abstime=Field{1}.(TimeName(5:end));%the time is an attribute or variale selected by get_file
     
    23822336end
    23832337set(handles.TimeValue,'String',num2str(abstime))
     2338
     2339%% display time value of the second current file if relevant
    23842340abstime_1=[];
    2385 TimeName_1=get(handles.TimeName_1,'String');
    2386 if ~isempty(regexp(TimeName_1,'^att:')) ||~isempty(regexp(TimeName_1,'^dim:'))||~isempty(regexp(TimeName_1,'^var:'))
     2341if ~isempty(FileName_1)
     2342    TimeName_1=get(handles.TimeName_1,'String');% indicate whether time is from xml or video
     2343    % time from xml file or video movie as a second file series
     2344    if strcmp(TimeName_1,'xml')||strcmp(TimeName_1,'video')
     2345        if numel(UvData.XmlData)==2
     2346            if isempty(i2_1)
     2347                i2_1=num_i1;
     2348            end
     2349            if isempty(j1_1)
     2350                j1_1=1;
     2351            end
     2352            if isempty(j2_1)
     2353                j2_1=j1_1;
     2354            end
     2355            siz=size(UvData.XmlData{2}.Time);
     2356            if ~isempty(i1_1) && siz(1)>=max(i1_1+1,i2_1+1) && siz(2)>=max(j1_1+1,j2_1+1)
     2357                abstime_1=(UvData.XmlData{2}.Time(i1_1+1,j1_1+1)+UvData.XmlData{2}.Time(i2_1+1,j2_1+1))/2;%overset the time read from files
     2358                Field{2}.Dt=(UvData.XmlData{2}.Time(i2_1+1,j2_1+1)-UvData.XmlData{2}.Time(i1_1+1,j1_1+1));
     2359            end
     2360        end
     2361    end
     2362   
     2363    % get time in the input file of the second series, not defined in a xml file or movie
     2364    if isempty(abstime_1) && numel(Field)==2 &&...
     2365            ~isempty(regexp(TimeName_1,'^att:')) ||~isempty(regexp(TimeName_1,'^dim:'))||~isempty(regexp(TimeName_1,'^var:'))
    23872366        abstime_1=Field{2}.(TimeName_1(5:end));%the time is an attribute or variale selected by get_file
    2388 end
    2389 set(handles.TimeValue_1,'String',num2str(abstime_1,5))
     2367    end
     2368    set(handles.TimeValue_1,'String',num2str(abstime_1,5))
     2369end
     2370
    23902371if isempty(dt)||isequal(dt,0)
    23912372    set(handles.Dt_txt,'String','')
     
    23972378    end
    23982379end
     2380
     2381%% Time title with unit
     2382if isempty(abstime)&&isempty(abstime_1)
     2383    Time_title='';
     2384else
     2385    Time_title='Time';
     2386    if ~isempty(TimeUnit)
     2387        Time_title=['Time (' TimeUnit ')'];
     2388    end
     2389end
     2390set(handles.Time_title,'String',Time_title)
    23992391
    24002392%% store the current open names, fieldname and vel types in uvmat interface
     
    24182410        end
    24192411    end
    2420     transform=get(handles.TransformPath,'UserData');
    24212412    switch nargin(transform)
    24222413        case 4
     
    25382529        set(handles.ListObject_1,'String',{'plane'})
    25392530    end
    2540     IndexObj(1)=get(handles.ListObject_1,'Value');%selected projection object for main view
    2541     if IndexObj(1)> numel(UvData.ProjObject)
    2542         IndexObj(1)=1;%select the first object if the selected one does not exist
     2531    IndexObj=get(handles.ListObject_1,'Value');%selected projection object for main view
     2532    if IndexObj> numel(UvData.ProjObject)
     2533        IndexObj=1;%select the first object if the selected one does not exist
    25432534        set(handles.ListObject_1,'Value',1)
    25442535    end
    2545     IndexObj(2)=get(handles.ListObject,'Value');%selected projection object for main view
    2546     if isequal(IndexObj(2),IndexObj(1))
    2547         IndexObj(2)=[];
     2536    if get(handles.CheckViewField,'Value')
     2537        IndexObj_2=get(handles.ListObject,'Value');%selected projection object for view_field
     2538        if ~isequal(IndexObj_2,IndexObj(1))
     2539            IndexObj(2)=IndexObj_2;
     2540        end
    25482541    end
    25492542    plot_handles{1}=handles;
     
    28942887fin=close(nc);
    28952888
    2896 %-------------------------------------------------------------------
     2889%-----------------------------------------------------------------------
    28972890% --- Executes on button press in SubField
     2891%-----------------------------------------------------------------------
    28982892function SubField_Callback(hObject, eventdata, handles)
    2899 %-------------------------------------------------------------------
    2900 UvData=get(handles.uvmat,'UserData');
    2901 if get(handles.SubField,'Value')==0% if the subfield button is desactivated   
    2902     set(handles.RootPath_1,'String','')
    2903     set(handles.RootFile_1,'String','')
    2904     set(handles.SubDir_1,'String','');
    2905     set(handles.FileIndex_1,'String','');
    2906     set(handles.FileExt_1,'String','');
    2907     set(handles.RootPath_1,'Visible','off')
    2908     set(handles.RootFile_1,'Visible','off')
    2909     set(handles.SubDir_1,'Visible','off');
    2910     set(handles.NomType_1,'Visible','off');
    2911     set(handles.TimeValue_1,'Visible','off')
    2912     set(handles.FileIndex_1,'Visible','off');
    2913     set(handles.FileExt_1,'Visible','off');
    2914     set(handles.FieldName_1,'Value',1);%set to blank state
    2915     set(handles.VelType_1,'Value',1);%set to blank state
    2916     set(handles.num_Opacity,'String','')% desactivate opacity setting
    2917     FieldList=get(handles.FieldName,'String');
    2918     if numel(FieldList)>1   % if a choice of fields exists
    2919         set(handles.FieldName_1,'Value',1)% set second field choice to blank
    2920         set(handles.FieldName_1,'String',[{''};FieldList])% reproduce the menu FieldName plus a blank option
    2921     else
    2922         set(handles.FieldName_1,'String',{''})% set second field choice to blank
    2923     end
    2924     if ~strcmp(get(handles.VelType,'Visible'),'on')
    2925         set(handles.VelType_1,'Visible','off')
    2926     end
    2927     if isfield(UvData,'XmlData_1')
    2928         UvData=rmfield(UvData,'XmlData_1');
    2929     end
    2930     set(handles.uvmat,'UserData',UvData);
     2893
     2894if get(handles.SubField,'Value')==0% if the subfield button is desactivated 
     2895    desable_subfield(handles)
    29312896    transform_fct_list=get(handles.TransformName,'String');
    29322897    transform_fct=transform_fct_list(get(handles.TransformName,'Value'));
     
    29382903    end 
    29392904else
    2940     %RootPath=get(handles.RootPath,'String');
    2941     %SubDir=get(handles.SubDir,'String');
    29422905    fileinput_1=uigetfile_uvmat('select a second input file:',get(handles.RootPath,'String'));
    29432906    if isempty(fileinput_1)
    29442907        set(handles.SubField,'Value',0)
    2945     else
    2946        
     2908    else       
    29472909        % refresh the current displayed field
    2948         set(handles.SubField,'Value',1)
    29492910        display_file_name(handles,fileinput_1,2)
    29502911       
     
    29612922        set(handles.MenuFile_5,'Label',MenuFile_5)
    29622923    end
    2963     %     MenuBrowse_1_Callback(hObject, eventdata, handles)
    2964 end
     2924end
     2925
     2926%-----------------------------------------------------------------------
     2927% --- desactivate display used for a second file series
     2928%-----------------------------------------------------------------------
     2929function desable_subfield(handles)
     2930   
     2931set(handles.RootPath_1,'String','')
     2932set(handles.RootFile_1,'String','')
     2933set(handles.SubDir_1,'String','');
     2934set(handles.FileIndex_1,'String','');
     2935set(handles.FileExt_1,'String','');
     2936set(handles.RootPath_1,'Visible','off')
     2937set(handles.RootFile_1,'Visible','off')
     2938set(handles.SubDir_1,'Visible','off');
     2939set(handles.NomType_1,'Visible','off');
     2940set(handles.FileIndex_1,'Visible','off');
     2941set(handles.FileExt_1,'Visible','off');
     2942set(handles.TimeName_1,'String','');
     2943set(handles.TimeName_1,'Visible','off');
     2944set(handles.TimeValue_1,'String','');
     2945set(handles.TimeValue_1,'Visible','off');
     2946set(handles.FieldName_1,'Value',1);%set to blank state
     2947set(handles.VelType_1,'Value',1);%set to blank state
     2948set(handles.num_Opacity,'String','')% desactivate opacity setting
     2949FieldList=get(handles.FieldName,'String');
     2950if numel(FieldList)>1   % if a choice of fields exists
     2951    set(handles.FieldName_1,'Value',1)% set second field choice to blank
     2952    set(handles.FieldName_1,'String',[{''};FieldList])% reproduce the menu FieldName plus a blank option
     2953else
     2954    set(handles.FieldName_1,'String',{''})% set second field choice to blank
     2955end
     2956if ~strcmp(get(handles.VelType,'Visible'),'on')
     2957    set(handles.VelType_1,'Visible','off')
     2958end
     2959UvData=get(handles.uvmat,'UserData');
     2960if isfield(UvData,'XmlData_1')
     2961    UvData=rmfield(UvData,'XmlData_1');
     2962end
     2963set(handles.uvmat,'UserData',UvData);
    29652964
    29662965%------------------------------------------------------------------------
    29672966% --- read the data displayed for the input rootfile windows (new): TODO use read_GUI
    2968 
     2967%------------------------------------------------------------------------
    29692968function [RootPath,SubDir,RootFile,FileIndices,FileExt]=read_file_boxes(handles)
    2970 %------------------------------------------------------------------------
     2969
    29712970InputFile=read_GUI(handles.InputFile);
    29722971RootPath=InputFile.RootPath;
     
    29792978%------------------------------------------------------------------------
    29802979% ---- read the data displayed for the second input rootfile windows
     2980%------------------------------------------------------------------------
    29812981function [RootPath_1,SubDir_1,RootFile_1,FileIndex_1,FileExt_1,NomType_1]=read_file_boxes_1(handles)
    2982 %------------------------------------------------------------------------
     2982
    29832983RootPath_1=get(handles.RootPath_1,'String'); % read the data from the file1_input window
    29842984if isequal(get(handles.RootPath_1,'Visible'),'off') || isequal(RootPath_1,'"')
     
    30213021[tild,tild,tild,i1,i2,j1,j2,tild,NomType]=fileparts_uvmat(['xxx' get(handles.FileIndex,'String') FileExt]);
    30223022
    3023 switch field 
     3023switch field
    30243024   
    30253025    case 'get_field...'
    3026     %% fill the coordinates and variables from selections in get_field
     3026        %% fill the coordinates and variables from selections in get_field
    30273027        ParamIn=[];
    30283028        % in case of civ data, we use the civ choice as default input for the GUI get_field
     
    30333033            switch VelType
    30343034                case 'civ1'
    3035                     ParamIn.TimeVarName='Civ1_Time';
     3035                    ParamIn.TimeAttrName='Civ1_Time';
    30363036                    ParamIn.vector_x='Civ1_U';
    30373037                    ParamIn.vector_y='Civ1_V';
    30383038                    ParamIn.vec_color='Civ1_C';
    30393039                case 'filter1'
    3040                     ParamIn.TimeVarName='Civ1_Time';
     3040                    ParamIn.TimeAttrName='Civ1_Time';
    30413041                    ParamIn.vector_x='Civ1_U_smooth';
    30423042                    ParamIn.vector_y='Civ1_V_smooth';
    30433043                case 'civ2'
    3044                     ParamIn.TimeVarName='Civ2_Time';
     3044                    ParamIn.TimeAttrName='Civ2_Time';
    30453045                    ParamIn.vector_x='Civ2_U';
    30463046                    ParamIn.vector_y='Civ2_V';
    30473047                case 'filter2'
    3048                     ParamIn.TimeVarName='Civ2_Time';
     3048                    ParamIn.TimeAttrName='Civ2_Time';
    30493049                    ParamIn.vector_x='Civ2_U_smooth';
    30503050                    ParamIn.vector_y='Civ2_V_smooth';
     
    30563056        set(handles.FixVelType,'visible','off')
    30573057        set(handles.VelType,'Visible','off')
    3058         %set(handles.VelType_1,'Visible','off')
    30593058       
    30603059        %read selection from get_field
     
    30773076            case '1D plot'
    30783077                YName=GetFieldData.PanelOrdinate.ordinate;
    3079             case 'civdata...'%return to civdata from get_field
    3080                % [FieldList,VecColorList]=set_field_list('U','V','C');
    3081                 set(handles.FieldName,'Value',2)
    3082                 set(handles.FixVelType,'visible','on')
    3083                 set(handles.VelType,'Visible','on')
     3078            case 'civdata...'%reinitiate input, return to automatic civ data reading
     3079                display_file_name(handles,FileName,1)
    30843080        end
    30853081        if ~strcmp(GetFieldData.FieldOption,'civdata...')
    30863082            XName=GetFieldData.Coordinates.Coord_x;
    3087         TimeNameStr=GetFieldData.Time.SwitchVarIndexTime;
    3088         if strcmp(TimeNameStr,'file index')
    3089             set(handles.TimeName,'String','');
    3090         else
    3091             set(handles.TimeName,'String',[TimeNameStr(1:3) ':' GetFieldData.Time.TimeName]);
    3092         end
    3093         if strcmp(TimeNameStr,'variable')||strcmp(TimeNameStr,'dim index')% we scan a variable index, not a file index
    3094             set(handles.NomType,'String','*')
    3095             set(handles.RootFile,FileName)
    3096         end
    3097         %     set(handles.TimeValue,'String' SwitchVarIndexTime
    3098         set(handles.Coord_x,'String',XName)
    3099         if ischar(YName)
    3100             YName={YName};
    3101         end
    3102         set(handles.Coord_y,'Data',YName)
    3103         set(handles.FieldName,'Value',1)
    3104         set(handles.FieldName,'String',[FieldList; {'get_field...'}]);
    3105         set(handles.ColorScalar,'Value',1)
    3106         set(handles.ColorScalar,'String',VecColorList);
    3107         UvData.FileType{1}='netcdf';
    3108         set(handles.uvmat,'UserData',UvData)
    3109         end
    3110         run0_Callback(hObject, eventdata, handles)
    3111         
     3083            TimeNameStr=GetFieldData.Time.SwitchVarIndexTime;
     3084            if strcmp(TimeNameStr,'file index')
     3085                set(handles.TimeName,'String','');
     3086            else
     3087                set(handles.TimeName,'String',[TimeNameStr(1:3) ':' GetFieldData.Time.TimeName]);
     3088            end
     3089            if strcmp(TimeNameStr,'variable')||strcmp(TimeNameStr,'dim index')% we scan a variable index, not a file index
     3090                set(handles.NomType,'String','*')
     3091                set(handles.RootFile,FileName)
     3092            end
     3093            %     set(handles.TimeValue,'String' SwitchVarIndexTime
     3094            set(handles.Coord_x,'String',XName)
     3095            if ischar(YName)
     3096                YName={YName};
     3097            end
     3098            set(handles.Coord_y,'Data',YName)
     3099            set(handles.FieldName,'Value',1)
     3100            set(handles.FieldName,'String',[FieldList; {'get_field...'}]);
     3101            set(handles.ColorScalar,'Value',1)
     3102            set(handles.ColorScalar,'String',VecColorList);
     3103            UvData.FileType{1}='netcdf';
     3104            set(handles.uvmat,'UserData',UvData)
     3105            run0_Callback(hObject, eventdata, handles)
     3106        end
     3107       
    31123108    case 'image'
    3113     %% look for image corresponding to civ data
     3109        %% look for image corresponding to civ data
    31143110        if  isfield(UvData.Field,'Civ2_ImageA')%get the corresponding input image in the netcdf file
    31153111            imagename=UvData.Field.Civ2_ImageA;
     
    31283124        % display the selected field and related information
    31293125        display_file_name(handles,imagename)%display the image
    3130      otherwise
    3131 %         ext=get(handles.FileExt,'String');
    3132 %         if ~isequal(ext,'.nc') %find the new NomType if the previous display was not already a netcdf file
    3133 %             [FileName,PathName] = uigetfile( ...
    3134 %                 {'*.nc', ' (*.nc)';
    3135 %                 '*.nc',' netcdf files'; ...
    3136 %                 '*.*',  'All Files (*.*)'}, ...
    3137 %                 'Pick a netcdf file',FileBase);
    3138 %             if ~ischar(FileName),return,end %abandon if the browser is cancelled
    3139 %             FullFileName=[PathName FileName];
    3140             % display the selected field and related information
    3141              run0_Callback(hObject, eventdata, handles)
     3126    otherwise
     3127        run0_Callback(hObject, eventdata, handles)
    31423128end
    31433129
     
    31923178        end
    31933179    case 'image'
    3194         % get the image name corresponding to the current netcdf name (no unique correspondance)
     3180        %% look for image corresponding to civ data
     3181        imagename='';
    31953182        if  isfield(UvData.Field,'Civ2_ImageA')%get the corresponding input image in the netcdf file
    31963183            imagename=UvData.Field.Civ2_ImageA;
     
    31983185            imagename=UvData.Field.Civ1_ImageA;
    31993186        else
    3200             SubDirBase=regexprep(SubDir_1,'\..*','');%take the root part of SubDir, before the first dot '.'
    3201             imagename=fullfile_uvmat(RootPath_1,SubDirBase,RootFile_1,'.png',get(handles.NomType,'String'),i1,[],j1);
    3202         end
    3203         if ~exist(imagename,'file') % browse for images if it is not found
    3204             [FileName,PathName] = uigetfile( ...
    3205                 {'*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol', ' (*.png, .tif, *.avi,*.vol)';
    3206                 '*.jpg',' jpeg image files'; ...
    3207                 '*.png','.png image files'; ...
    3208                 '*.tif','.tif image files'; ...
    3209                 '*.avi;*.AVI','.avi movie files'; ...
    3210                 '*.vol','.volume images (png)'; ...
    3211                 '*.*',  'All Files (*.*)'}, ...
    3212                 'Pick an image',imagename);
    3213             if ~ischar(FileName),return,end %abandon if the browser is cancelled
    3214             imagename=[PathName FileName];
    3215         end
    3216         if ~ischar(imagename)% quit if the browser has  been closed
     3187            SubDirBase=regexprep(SubDir,'\..*','');%take the root part of SubDir, before the first dot '.'
     3188            imagename=fullfile_uvmat(RootPath,SubDirBase,RootFile,'.png',NomType,i1,[],j1,[]);
     3189        end
     3190        if ~exist(imagename,'file')
     3191            imagename=uigetfile_uvmat('Pick an image file',imagename,'image');
     3192           
     3193        end
     3194        if isempty(imagename)
    32173195            set(handles.SubField,'Value',0)
    3218         else %valid browser input:  display the selected image
    3219             set(handles.TitleNpxy,'Visible','on')% visible npx,pxcm... buttons
    3220             set(handles.num_Npx,'Visible','on')
    3221             set(handles.num_Npy,'Visible','on')
    3222             display_file_name(handles,imagename,2)%display the imag
     3196            return
     3197        else
     3198            display_file_name(handles,imagename,2)%display the image as second field
    32233199        end
    32243200    otherwise
     
    32343210                set(handles.uvmat,'UserData',UvData)
    32353211                set(handles.TransformName,'value',2); % set transform fct to 'sub_field' if the current fct does not accept two input fields
    3236                 transform_fct_Callback(hObject, eventdata, handles)% activate transform_fct_Callback and refresh current plot
     3212                TransformName_Callback(hObject, eventdata, handles)% activate transform_fct_Callback and refresh current plot
    32373213                 check_refresh=0;
    32383214             end             
     
    45754551%------------------------------------------------------------------------
    45764552function Menuline_x_Callback(hObject, eventdata, handles)
    4577     msgbox_uvmat('ERROR','option not yet implemented, use line')
    4578     return
     4553
    45794554data.Type='line_x';
    45804555data.ProjMode='projection';%default
     
    45864561% -----------------------------------------------------------------------
    45874562function Menuline_y_Callback(hObject, eventdata, handles)
    4588     msgbox_uvmat('ERROR','option not yet implemented, use line')
    4589     return
     4563
    45904564data.Type='line_y';
    45914565data.ProjMode='projection';%default
     
    46764650data.Name=data.Type;% default name=type
    46774651data.Coord=[0 0]; %default
     4652check_plot=0;
    46784653if isfield(UvData,'Field')
    46794654    Field=UvData.Field;
     4655    if isfield(Field,'NbDim')&& isequal(Field.NbDim,3)
     4656         data.Coord=[0 0 0]; %default
     4657    end
     4658    if isfield(Field,'CoordUnit')
     4659        data.CoordUnit=Field.CoordUnit;
     4660    end
    46804661    if isfield(UvData.Field,'CoordMesh')&&~isempty(UvData.Field.CoordMesh)
    46814662        data.RangeX=[UvData.Field.XMin UvData.Field.XMax];
     
    46844665                data.RangeY=UvData.Field.CoordMesh;
    46854666            case 'line_x'
    4686                 data.RangeX=[UvData.Field.XMin UvData.Field.XMax];
     4667                check_plot=1; %plot the line directly when set_object is opened
     4668                data.Type='line';
     4669                data.RangeX=UvData.Field.XMin ;
    46874670                data.RangeY=UvData.Field.CoordMesh;
    4688                 data.Coord=[0 (UvData.Field.YMin +UvData.Field.YMax)/2];% put line at the middle of the y axis
     4671                data.Coord=[UvData.Field.XMin (UvData.Field.YMin +UvData.Field.YMax)/2;...
     4672                           UvData.Field.XMax (UvData.Field.YMin +UvData.Field.YMax)/2];% put line at the middle of the y axis
    46894673            case 'line_y'
     4674                check_plot=1; %plot the line directly when set_object is opened
     4675                data.Type='line';
     4676                data.RangeX=UvData.Field.YMin ;
    46904677                data.RangeY=UvData.Field.CoordMesh;
    4691                 data.Coord=[(UvData.Field.XMin +UvData.Field.XMax)/2 0];% put line at the middle of the x axis
     4678                data.Coord=[(UvData.Field.XMin+UvData.Field.XMax)/2 UvData.Field.YMin;...
     4679                            (UvData.Field.XMin +UvData.Field.XMax)/2 UvData.Field.YMax];% put line at the middle of the y axis
    46924680            case {'rectangle','ellipse'}
    46934681                data.RangeY=[UvData.Field.YMin UvData.Field.YMax];
     
    47004688        data.DY=UvData.Field.CoordMesh;
    47014689    end
    4702     if isfield(Field,'NbDim')&& isequal(Field.NbDim,3)
    4703          data.Coord=[0 0 0]; %default
    4704     end
    4705     if isfield(Field,'CoordUnit')
    4706         data.CoordUnit=Field.CoordUnit;
    4707     end
    4708 end
     4690end
     4691
    47094692hset_object=set_object(data,handles);% call the GUI set_object
    47104693hchild=get(hset_object,'children');
    47114694set(hchild,'enable','on')
    47124695set(handles.DeleteObject,'Visible','on')% make the object delete button visible
     4696if check_plot
     4697    hhset_object=guidata(hset_object);
     4698    set_object('PLOT_Callback',1,[],hhset_object);% call the GUI set_object
     4699end
    47134700
    47144701%------------------------------------------------------------------------
     
    47174704%get the object file
    47184705fileinput=uigetfile_uvmat('pick an xml object file:',get(handles.RootPath,'String'),'.xml');
    4719 
    47204706if ~isempty(fileinput)
    47214707    %read the file
Note: See TracChangeset for help on using the changeset viewer.