Changeset 526 for trunk/src/read_field.m


Ignore:
Timestamp:
Aug 20, 2012, 12:32:31 PM (12 years ago)
Author:
sommeria
Message:

bugs corrected; Posiibility of usual 1D plots introduced with the new way of using get_field. time_series and aver_stat updated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/read_field.m

    r521 r526  
    3939% end
    4040A=[];
    41 if ischar(ParamIn.FieldName)
    42     ParamIn.FieldName={ParamIn.FieldName};
     41if isstruct(ParamIn)
     42    if isfield(ParamIn,'FieldName')&& ischar(ParamIn.FieldName)
     43        ParamIn.FieldName={ParamIn.FieldName};
     44    end
     45    if isfield(ParamIn,'ColorVar')
     46        InputField=[ParamIn.FieldName {ParamIn.ColorVar}];
     47        check_colorvar=1;
     48    else
     49        InputField= ParamIn.FieldName;
     50        check_colorvar=0;
     51    end
    4352end
    44             if isfield(ParamIn,'ColorVar')
    45                 InputField=[ParamIn.FieldName {ParamIn.ColorVar}];
    46                 check_colorvar=1;
    47             else
    48                 InputField= ParamIn.FieldName;
    49                 check_colorvar=0;
    50             end
    5153%% distingush different input file types
    5254try
     
    7375                    Role{numel(ListVar)}='vector_y';
    7476                    Role{numel(ListVar)-1}='vector_x';
    75 %                     switch r.Operator
     77%                    TODO; introduce that for unstructured coordinates
     78%                     switch r.Operator TODO; introduce that for unstructured coordinates
    7679%                         case 'norm'
    7780%                             FieldRequest{numel(ListVar)-1}='interp_lin';%scalar field (requires interpolation for plot)
     
    8588                Role{numel(ListVar)}='ancillary';% scalar used for color vector (not projected)
    8689            end
    87             [Field,var_detect,ichoice]=nc2struct(FileName,[ParamIn.CoordName ListVar]);
     90            [Field,var_detect,ichoice]=nc2struct(FileName,[ParamIn.Coord_x ParamIn.Coord_y ListVar]);
    8891            for ivar=1:numel(ListVar)
    8992                Field.VarAttribute{ivar+2}.Role=Role{ivar};
    9093%                 Field.VarAttribute{ivar+2}.FieldRequest=FieldRequest{ivar};
    9194            end
    92             %             GUIName='get_field'; %default name of the GUI get_field
    93             %             if isfield(ParamIn,'GUIName')
    94             %                 GUIName=ParamIn.GUIName;
    95             %             end
    96             %             CivStage=0;
    97             % %             if ~strcmp(ParamIn.FieldName,'get_field...')% if get_field is not requested, look for Civx data
    98             %                 FieldList=calc_field;%list of possible fields for Civx data
    99             %                 ParamOut.ColorVar='';%default
    100             %                 if ischar(ParamIn.FieldName)
    101             %                     FieldName=ParamIn.FieldName;
    102             %                 else
    103             %                     FieldName=ParamIn.FieldName{1};
    104             %                 end
    105             %                 field_index=strcmp(FieldName,FieldList);%look for ParamIn.FieldName in the list of possible fields for Civx data
    106             %                 if isempty(find(field_index,1))% ParamIn.FieldName is not in the list, check whether Civx data exist
    107             %                     Data=nc2struct(FileName,'ListGlobalAttribute','Conventions','absolut_time_T0','civ','CivStage');
    108             %                     % case of new civdata conventions
    109             %                     if isequal(Data.Conventions,'uvmat/civdata')
    110             %
    111             %                         %case of old civx conventions
    112             %                     elseif ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0)
    113             %                         ParamOut.FieldName='velocity';%Civx data found, set .FieldName='velocity' by default
    114             %                         ParamOut.ColorVar='ima_cor';
    115             %                         InputField=[{ParamOut.FieldName} {ParamOut.ColorVar}];
    116             %                         [Field,ParamOut.VelType]=read_civxdata(FileName,InputField,ParamIn.VelType);
    117             %                         if ~isempty(errormsg),errormsg=['read_civxdata:' errormsg];return,end
    118             %                         CivStage=Field.CivStage;
    119             %                         ParamOut.CivStage=Field.CivStage;
    120             %                         % not cvix file, fields will be chosen through the GUI get_field
    121             %                     else
    122             %                         ParamOut.FieldName='get_field...';
    123             %                         hget_field=findobj(allchild(0),'Name',GUIName);%find the get_field... GUI
    124             %                         if ~isempty(hget_field)
    125             %                             delete(hget_field)%delete  get_field for reinitialisation
    126             %                         end
    127             %                     end
    128             %                 else
    129             %                     InputField=ParamOut.FieldName;
    130             %                     if ischar(InputField)
    131             %                         InputField={InputField};
    132             %                     end
    133             %                     if isfield(ParamIn,'ColorVar')
    134             %                         ParamOut.ColorVar=ParamIn.ColorVar;
    135             %                         InputField=[InputField {ParamOut.ColorVar}];
    136             %                     end
    137             %                     [Field,ParamOut.VelType,errormsg]=read_civxdata(FileName,InputField,ParamIn.VelType);
    138             %                     if ~isempty(errormsg),errormsg=['read_civxdata:' errormsg];return,end
    139             %                     CivStage=Field.CivStage;
    140             %                     ParamOut.CivStage=Field.CivStage;
    141             %                 end
    142             %                 ParamOut.FieldList=[{'image'};FieldList;{'get_field...'}];
    143             %             end
    144             %             if CivStage==0% read the field names on the interface get_field.
    145             %                 hget_field=findobj(allchild(0),'Name',GUIName);%find the get_field... GUI
    146             %                 if isempty(hget_field)% open the GUI get_field if it is not found
    147             %                     hget_field= get_field(FileName);%open the get_field GUI
    148             %                     set(hget_field,'Name',GUIName)%update the name of get_field (e.g. get_field_1)
    149             %                 end
    150             %                 hhget_field=guidata(hget_field);
    151             %                 %% update  the get_field GUI
    152             %                 set(hhget_field.inputfile,'String',FileName)
    153             %                 set(hhget_field.list_fig,'Value',1)
    154             %                 if exist('num','var')&&~isnan(num)
    155             %                     set(hhget_field.TimeIndexValue,'String',num2str(num))
    156             %                 end
    157             % %                 funct_list=get(hhget_field.ACTION,'UserData');
    158             % %                 funct_index=get(hhget_field.ACTION,'Value');
    159             % %                 funct=funct_list{funct_index};%select  the current action in get_field, e;g. PLOT
    160             % %                 Field=funct(hget_field); %%activate the current action selected in get_field, e;g.read the names of the variables to plot
    161             %                 [Field,errormsg]=read_get_field(hget_field);
    162             %                 Tabchar={''};%default
    163             %                 Tabcell=[];
    164             %                 set(hhget_field.inputfile,'String',FileName)
    165             %                 if isfield(Field,'ListGlobalAttribute')&& ~isempty(Field.ListGlobalAttribute)
    166             %                     for iline=1:length(Field.ListGlobalAttribute)
    167             %                         Tabcell{iline,1}=Field.ListGlobalAttribute{iline};
    168             %                         if isfield(Field, Field.ListGlobalAttribute{iline})
    169             %                             val=Field.(Field.ListGlobalAttribute{iline});
    170             %                             if ischar(val);
    171             %                                 Tabcell{iline,2}=val;
    172             %                             else
    173             %                                 Tabcell{iline,2}=num2str(val);
    174             %                             end
    175             %                         end
    176             %                     end
    177             %                     if ~isempty(Tabcell)
    178             %                         Tabchar=cell2tab(Tabcell,'=');
    179             %                         Tabchar=[{''};Tabchar];
    180             %                     end
    181             %                 end
    182             %                 ParamOut.CivStage=0;
    183             %                 ParamOut.VelType=[];
    184             %                 if isfield(Field,'TimeIndex')
    185             %                     ParamOut.TimeIndex=Field.TimeIndex;
    186             %                 end
    187             %                 if isfield(Field,'TimeValue')
    188             %                     ParamOut.TimeValue=Field.TimeValue;
    189             %                 end
    190             %                 ParamOut.FieldList={'get_field...'};
    19195           
    19296        case 'video'
Note: See TracChangeset for help on using the changeset viewer.