Ignore:
Timestamp:
Jun 30, 2013, 11:16:45 PM (10 years ago)
Author:
sommeria
Message:

various bugs corrected

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/calc_field_interp.m

    r650 r654  
    1 %'calc_field_interp': defines fields (velocity, vort, div...) from civ data and calculate them
    2 % for projection with linear interpolation
     1%'calc_field_interp': calculate fields (velocity, vort, div...) using linear interpolation if requested
    32%---------------------------------------------------------------------
    43% [VarVal,ListVarName,VarAttribute,errormsg]=calc_field_interp(Coord,Data,FieldName,XI,YI)
     
    109%
    1110% INPUT:
    12 % Coord(nbpoints,2): matrix of x,y coordinates of theinput data points
     11% Coord(nbpoints,2): matrix of x,y coordinates of the input data points
    1312% Data: inputfield structure
    1413% FieldName: string representing the field to calculate, or cell array of fields (as displayed in uvmat/FieldName)
    15 % XI, YI: set of x and y coordiantes where the fields need to be linearly interpolated
    16 
     14% XI, YI: set of x and y coordinates where the fields need to be linearly interpolated,
     15%        if XI, YI are missing, there is no interpolation (case of colors in vector plots)
     16%
    1717function [VarVal,ListVarName,VarAttribute,errormsg]=calc_field_interp(Coord,Data,FieldName,XI,YI)
    1818
     
    2525if ischar(FieldName),FieldName={FieldName};end
    2626check_skipped=zeros(size(FieldName));% default, =1 to mark the variables which can be calculated
     27check_interp=ones(size(FieldName));% default, =1 to mark the variables which can be interpolated (not ancillary)
    2728Operator=cell(size(FieldName));
    2829
     
    3536        if isempty(ivar)
    3637            check_skipped(ilist)=1; %variable not found
    37         else
     38        elseif isempty(find(strcmp(FieldName{ilist},InputVarList), 1));
    3839            if isfield(Data.VarAttribute{ivar},'Role') &&...
    3940                (strcmp(Data.VarAttribute{ivar}.Role,'ancillary')||strcmp(Data.VarAttribute{ivar}.Role,'warnflag')||strcmp(Data.VarAttribute{ivar}.Role,'errorflag'))
    40                 check_skipped(ilist)=1; % ancillary variable, not interpolated     
    41             elseif isempty(find(strcmp(FieldName{ilist},InputVarList), 1));
    42                 InputVarList=[InputVarList FieldName{ilist}];% the variable is added to the list of input variables if it is not already in the list
     41                check_interp(ilist)=0; % ancillary variable, not interpolated     
    4342            end
     43            InputVarList=[InputVarList FieldName{ilist}];% the variable is added to the list of input variables if it is not already in the list
    4444        end
    4545    else
     
    8888            case 'vec'
    8989                if exist('XI','var')
     90                    if check_interp
    9091                    VarVal{nbvar+1}=F.(UName{ilist})(XI,YI);
    9192                    VarVal{nbvar+2}=F.(VName{ilist})(XI,YI);
     93                    end
    9294                else
    9395                    VarVal{nbvar+1}=Data.(UName{ilist});
     
    100102            case 'norm'
    101103                if exist('XI','var')
     104                    if check_interp
    102105                    U2=F.(UName{ilist})(XI,YI).*F.(UName{ilist})(XI,YI);
    103106                    V2=F.(VName{ilist})(XI,YI).*F.(VName{ilist})(XI,YI);
     107                    end
    104108                else
    105109                    U2=Data.(UName{ilist}).*Data.(UName{ilist});
     
    111115            case {'curl','div','strain'}
    112116                if exist('XI','var')
     117                    if check_interp
    113118                    VarVal{nbvar+1}=F.(UName{ilist})(XI,YI);
     119                    end
    114120                else
    115121                    VarVal{nbvar+1}=Data.(UName{ilist});
     
    120126                if ~isempty(FieldName{ilist})
    121127                    if exist('XI','var')
     128                        if check_interp
    122129                        VarVal{nbvar+1}=F.(FieldName{ilist})(XI,YI);
     130                        end
    123131                    else
    124132                        VarVal{nbvar+1}= Data.(FieldName{ilist});
Note: See TracChangeset for help on using the changeset viewer.