Changeset 890 for trunk


Ignore:
Timestamp:
Apr 18, 2015, 11:03:01 PM (6 years ago)
Author:
sommeria
Message:

bugs solved for reading general netcdf files

Location:
trunk/src
Files:
2 added
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/find_field_cells.m

    r809 r890  
    210210%            2)the coordinate variable contains only two elements, representing the coordinate bounds for the dimension with the same name as the cordinate
    211211ivar_remain=find(~check_select);% indices of remaining variables, not already taken into account
    212 ListVarName=Data.ListVarName(~check_select);%list of remaining variables
     212ListVarName=Data.ListVarName(~check_select);%list of names of remaining variables
    213213VarDimName=Data.VarDimName(~check_select);%dimensions of remaining variables
    214214check_coord_select= cellfun(@numel,VarDimName)==1|cellfun(@ischar,VarDimName)==1;% find remaining variables with a single dimension
    215215check_coord_select=check_coord_select & ~strcmp('ancillary',Role(~check_select));% do not select ancillary variables as coordinates
    216 %check_coord(~check_select)=check_coord_select;
    217216ListCoordIndex=ivar_remain(check_coord_select);% indices of remaining variables with a single dimension
    218217ListCoordName=ListVarName(check_coord_select);% corresponding names of remaining variables with a single dimension
     
    220219
    221220%remove redondant variables -> keep only one variable per dimension
    222 check_keep=logical(ones(size(ListDimName)));
     221check_keep=true(size(ListDimName));
    223222for idim=1:numel(ListDimName)
    224     prev_ind=strcmp(ListDimName{idim},ListDimName(1:idim-1));% check whether the dimension is already taken into account
    225     if ~isempty(prev_ind)
     223    prev_ind=find(strcmp(ListDimName{idim},ListDimName(1:idim-1)));% check whether the dimension is already taken into account
     224    if ~isempty(prev_ind)% in case of multiple coord variable
    226225        if strcmp(ListCoordName{idim},ListDimName{idim}) %variable with the same name as the coordinate taken in priority
    227             check_keep(prev_ind)=0;
     226            check_keep(prev_ind)=0;% choose a variable with the same name as coordinate in priority
    228227        else
    229            check_keep(idim)=0;
     228           check_keep(idim)=0; %keep the first coordiante variable found
    230229        end
    231230    end
     
    256255NewCellDimIndex={};
    257256NewNbDim=[];
    258 for ivardim=1:numel(VarDimName) % loop at the list of remaining variables
     257for ivardim=1:numel(VarDimName) % loop at the list of dimensions for the remaining variables
    259258    DimCell=VarDimName{ivardim};% dimension names of the current variable
    260259    if ischar(DimCell), DimCell={DimCell}; end %transform char to cell if needed
  • trunk/src/get_field.m

    r879 r890  
    951951% --- Executes on button press in CheckDimensionY.
    952952function CheckDimensionX_Callback(hObject, eventdata, handles)
    953 FieldList=get(handles.FieldOption,'String');
    954 FieldOption=FieldList{get(handles.FieldOption,'Value')};
    955 switch FieldOption
    956     case '1D plot'
    957        
    958     case {'scalar'}
    959        scalar_Callback(hObject, eventdata, handles)
    960     case 'vectors'
    961 end
     953CheckDimensionX=get(handles.CheckDimensionX,'value')
     954if CheckDimensionX
     955    set(handles.Coordinates,'visible','off')
     956else
     957    set(handles.Coordinates,'visible','on')
     958end
     959% FieldList=get(handles.FieldOption,'String');
     960% FieldOption=FieldList{get(handles.FieldOption,'Value')};
     961% switch FieldOption
     962%     case '1D plot'
     963%         
     964%     case {'scalar'}
     965%        scalar_Callback(hObject, eventdata, handles)
     966%     case 'vectors'
     967% end
    962968
    963969% % --- Executes on button press in CheckDimensionY.
  • trunk/src/proj_field.m

    r888 r890  
    123123end
    124124
    125 % %% take the difference of projected input fields if relevant
    126 % [CellInfo,NbDim,errormsg]=find_field_cells(ProjData);
    127 % ind_remove=zeros(size(ProjData.ListVarName));
    128 % ivar=[];
    129 % ivar_1=[];
    130 % for icell=1:numel(CellInfo)
    131 %     if ~isempty(CellInfo{icell})
    132 %         % if two scalar are in the same cell
    133 %         if isfield(CellInfo{icell},'VarIndex_scalar') && numel(CellInfo{icell}.VarIndex_scalar)==2 && ProjData.VarAttribute{CellInfo{icell}.VarIndex_scalar(2)}.CheckSub;
    134 %             ivar=[ivar CellInfo{icell}.VarIndex_scalar(1)];
    135 %             ivar_1=[ivar_1 CellInfo{icell}.VarIndex_scalar(2)];
    136 %         end
    137 %         % if two vector u components are in the same cell
    138 %         if isfield(CellInfo{icell},'VarIndex_vector_x') && numel(CellInfo{icell}.VarIndex_vector_x)==2 && ProjData.VarAttribute{CellInfo{icell}.VarIndex_vector_x(2)}.CheckSub;
    139 %             ivar=[ivar CellInfo{icell}.VarIndex_vector_x(1)];
    140 %             ivar_1=[ivar_1 CellInfo{icell}.VarIndex_vector_x(2)];
    141 %         end
    142 %          % if two vector v components are in the same cell
    143 %         if isfield(CellInfo{icell},'VarIndex_vector_y') && numel(CellInfo{icell}.VarIndex_vector_y)==2 && ProjData.VarAttribute{CellInfo{icell}.VarIndex_vector_y(2)}.CheckSub;
    144 %             ivar=[ivar CellInfo{icell}.VarIndex_vector_y(1)];
    145 %             ivar_1=[ivar_1 CellInfo{icell}.VarIndex_vector_y(2)];
    146 %         end
    147 %     end
    148 % end
    149 % % subtract fields if relevant
    150 % for imod=1:numel(ivar)
    151 %         VarName=ProjData.ListVarName{ivar(imod)};
    152 %         VarName_1=ProjData.ListVarName{ivar_1(imod)};
    153 %         ProjData.(VarName)=double(ProjData.(VarName))-double(ProjData.(VarName_1));
    154 %         ind_remove(ivar_1(imod))=1;
    155 % end
    156 % ProjData.ListVarName(find(ind_remove))=[];
    157 % ProjData.VarDimName(find(ind_remove))=[];
    158 % ProjData.VarAttribute(find(ind_remove))=[];
    159 
    160125%-----------------------------------------------------------------
    161126%project on a set of points
     
    11431108        end
    11441109        [XI,YI]=meshgrid(coord_x_proj,coord_y_proj);%grid in the new coordinates
     1110        ProjData.VarDimName={AYName,AXName};
    11451111%         XI=ObjectData.Coord(1,1)+(X)*cos(PlaneAngle(3))-YI*sin(PlaneAngle(3));%corresponding coordinates in the original system
    11461112%         YI=ObjectData.Coord(1,2)+(X)*sin(PlaneAngle(3))+YI*cos(PlaneAngle(3));
     
    11491115        AYName=FieldData.ListVarName{CellInfo{icell_grid}.CoordIndex(NbDim-1)};%name of input x coordinate (name preserved on projection)
    11501116        AXName=FieldData.ListVarName{CellInfo{icell_grid}.CoordIndex(NbDim)};%name of input y coordinate (name preserved on projection)
     1117        AYDimName=FieldData.VarDimName{CellInfo{icell_grid}.CoordIndex(NbDim-1)};%
     1118        AXDimName=FieldData.VarDimName{CellInfo{icell_grid}.CoordIndex(NbDim)};%
     1119         ProjData.VarDimName={AYDimName,AXDimName};
    11511120        ProjData.(AYName)=FieldData.(AYName); % new (projected ) y coordinates
    11521121        ProjData.(AXName)=FieldData.(AXName); % new (projected ) y coordinates
    11531122    end
    11541123    ProjData.ListVarName={AYName,AXName};
    1155     ProjData.VarDimName={AYName,AXName};
     1124   
    11561125    ProjData.VarAttribute={[],[]};
    11571126end
  • trunk/src/read_field.m

    r880 r890  
    8080    case 'civdata'% new format for civ results
    8181        [Field,ParamOut.VelType,errormsg]=read_civdata(FileName,InputField,ParamIn.VelType);
    82         if ~isempty(errormsg),errormsg=['read_civdata / ' errormsg];return,end
    83 %         if ~isempty(strcmp('C',ParamIn.FieldName))% if C image correlation is requested as field (not color visu)
    84 %             ScalarIndex=strcmp('C',Field.ListVarName);
    85 %             Field.VarAttribute{ScalarIndex}.Role='scalar';%put role as 'scalar' instead of ancillary
    86 %         end     
     82        if ~isempty(errormsg),errormsg=['read_civdata / ' errormsg];return,end     
    8783        ParamOut.CivStage=Field.CivStage;
    8884    case 'civx'% old (obsolete) format for civ results
     
    128124                    ProjModeRequest=[ProjModeRequest {ProjModeRequestVar}];
    129125                    ListInputField=[ListInputField InputField(ilist)];
    130                     %ListOperator=[ListOperator {[r.Operator '_U']}];
    131126                else
    132127                    checkU=1;
     
    137132                    ProjModeRequest=[ProjModeRequest {ProjModeRequestVar}];
    138133                    ListInputField=[ListInputField InputField(ilist)];
    139                     %ListInputField=[ListInputField {''}];
     134                   
    140135                else
    141136                    checkV=1;
     
    211206            end
    212207        end
     208        % insert coordinates as indices in case of plots vs matrix index
     209        if isfield(ParamIn,'CheckCoordIndex') && ParamIn.CheckCoordIndex
     210            Field.ListVarName=[Field.ListDimName Field.ListVarName];
     211            Field.VarDimName=[Field.ListDimName Field.VarDimName];
     212            for idim=1:numel(Field.ListDimName)
     213                CoordName=Field.ListDimName{idim};
     214                Field.(CoordName)=1:Field.DimValue(idim);
     215            end
     216            Field.VarAttribute=[cell(1,numel(Field.ListDimName)) Field.VarAttribute]
     217        end
    213218    case 'video'
    214219        if strcmp(class(ParamIn),'VideoReader')
  • trunk/src/uvmat.m

    r874 r890  
    32493249    ParamIn.Coord_y=get(handles.Coord_y,'String');
    32503250    ParamIn.Coord_z=get(handles.Coord_z,'String');
     3251    ParamIn.CheckCoordIndex=strcmp(get(handles.SwitchCoordIndex,'String'),'dim');
    32513252    TimeName=get(handles.TimeName,'String');
    32523253    r=regexp(TimeName,'^(?<type>(dim:)|(var:))','names');%look for 'var:' or 'dim:' at the beginning of time name
     
    32603261    end
    32613262end
    3262 % check_tps = 0;         
    3263 % if strcmp(UvData.FileType{1},'civdata')&&~strcmp(ParamIn.FieldName,'velocity')&&~strcmp(ParamIn.FieldName,'get_field...')
    3264 %        check_tps=1;%tps needed to get the requested field
    3265 % end
     3263
    32663264[Field{1},ParamOut,errormsg] = read_field(FileName,UvData.FileType{1},ParamIn,frame_index);
    32673265if ~isempty(errormsg)
     
    42704268        FieldList={};
    42714269        VecColorList={''};
     4270        XName='';
     4271        YName='';
    42724272        ZName='';
    42734273        switch GetFieldData.FieldOption
     
    42754275                UName=GetFieldData.PanelVectors.vector_x;
    42764276                VName=GetFieldData.PanelVectors.vector_y;
    4277                 YName=GetFieldData.Coordinates.Coord_y;
    4278                 if isfield(GetFieldData.Coordinates,'Coord_z')
    4279                 ZName=GetFieldData.Coordinates.Coord_z;
    4280                 end
     4277                if isfield(GetFieldData,'Coordinates')
     4278                    YName=GetFieldData.Coordinates.Coord_y;
     4279                    if isfield(GetFieldData.Coordinates,'Coord_z')
     4280                        ZName=GetFieldData.Coordinates.Coord_z;
     4281                    end
     4282                end             
    42814283                CName=GetFieldData.PanelVectors.vec_color;
    42824284                FieldList={['vec(' UName ',' VName ')'];...
     
    42904292            case 'scalar'
    42914293                AName=GetFieldData.PanelScalar.scalar;
    4292                 YName=GetFieldData.Coordinates.Coord_y;
    4293                 if isfield(GetFieldData.Coordinates,'Coord_z')
    4294                 ZName=GetFieldData.Coordinates.Coord_z;
     4294                if isfield(GetFieldData,'Coordinates')
     4295                    YName=GetFieldData.Coordinates.Coord_y;
     4296                    if isfield(GetFieldData.Coordinates,'Coord_z')
     4297                        ZName=GetFieldData.Coordinates.Coord_z;
     4298                    end
    42954299                end
    42964300                FieldList={AName};
     
    43024306        % get time as file index, attribute, variable or matrix index
    43034307        if ~strcmp(GetFieldData.FieldOption,'civdata...')
    4304             XName=GetFieldData.Coordinates.Coord_x;
     4308            if isfield(GetFieldData,'Coordinates')
     4309                XName=GetFieldData.Coordinates.Coord_x;
     4310                set(handles.SwitchCoordIndex,'String','var'); % variable used as coordinate
     4311            else
     4312                set(handles.SwitchCoordIndex,'String','dim'); % matrix index used a coordinate
     4313            end
    43054314            TimeNameStr=GetFieldData.Time.SwitchVarIndexTime;
    43064315            switch TimeNameStr
Note: See TracChangeset for help on using the changeset viewer.