Changeset 517 for trunk/src/read_field.m
- Timestamp:
- Aug 17, 2012, 11:47:16 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/read_field.m
r516 r517 42 42 try 43 43 switch FileType 44 case {'civx','civdata','netcdf'} %read the first nc field 45 GUIName='get_field'; %default name of the GUI get_field 46 if isfield(ParamIn,'GUIName') 47 GUIName=ParamIn.GUIName; 48 end 49 CivStage=0; 50 if ~strcmp(ParamIn.FieldName,'get_field...')% if get_field is not requested, look for Civx data 51 FieldList=calc_field;%list of possible fields for Civx data 52 ParamOut.ColorVar='';%default 53 if ischar(ParamIn.FieldName) 54 FieldName=ParamIn.FieldName; 55 else 56 FieldName=ParamIn.FieldName{1}; 57 end 58 field_index=strcmp(FieldName,FieldList);%look for ParamIn.FieldName in the list of possible fields for Civx data 59 if isempty(find(field_index,1))% ParamIn.FieldName is not in the list, check whether Civx data exist 60 Data=nc2struct(FileName,'ListGlobalAttribute','Conventions','absolut_time_T0','civ','CivStage'); 61 % case of new civdata conventions 62 if isequal(Data.Conventions,'uvmat/civdata') 63 ParamOut.FieldName='velocity';%Civx data found, set .FieldName='velocity' by default 64 ParamOut.ColorVar='ima_cor'; 65 InputField=[{ParamOut.FieldName} {ParamOut.ColorVar}]; 66 [Field,ParamOut.VelType,errormsg]=read_civdata(FileName,InputField,ParamIn.VelType,Data.CivStage); 44 case 'civdata' 45 % ParamOut.FieldName='velocity';%Civx data found, set .FieldName='velocity' by default 46 % ParamOut.ColorVar='ima_cor'; 47 InputField=[{ParamIn.FieldName} {ParamIn.ColorVar}]; 48 [Field,ParamOut.VelType,errormsg]=read_civdata(FileName,InputField,ParamIn.VelType); 67 49 if ~isempty(errormsg),errormsg=['read_civdata:' errormsg];return,end 68 CivStage=Field.CivStage;69 50 ParamOut.CivStage=Field.CivStage; 70 %case of old civx conventions 71 elseif ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0) 72 ParamOut.FieldName='velocity';%Civx data found, set .FieldName='velocity' by default 51 case 'civx' 52 ParamOut.FieldName='velocity';%Civx data found, set .FieldName='velocity' by default 73 53 ParamOut.ColorVar='ima_cor'; 74 54 InputField=[{ParamOut.FieldName} {ParamOut.ColorVar}]; 75 55 [Field,ParamOut.VelType]=read_civxdata(FileName,InputField,ParamIn.VelType); 76 56 if ~isempty(errormsg),errormsg=['read_civxdata:' errormsg];return,end 77 CivStage=Field.CivStage;78 57 ParamOut.CivStage=Field.CivStage; 79 % not cvix file, fields will be chosen through the GUI get_field 80 else 81 ParamOut.FieldName='get_field...'; 82 hget_field=findobj(allchild(0),'Name',GUIName);%find the get_field... GUI 83 if ~isempty(hget_field) 84 delete(hget_field)%delete get_field for reinitialisation 85 end 86 end 87 else 88 InputField=ParamOut.FieldName; 89 if ischar(InputField) 90 InputField={InputField}; 91 end 92 if isfield(ParamIn,'ColorVar') 93 ParamOut.ColorVar=ParamIn.ColorVar; 94 InputField=[InputField {ParamOut.ColorVar}]; 95 end 96 [Field,ParamOut.VelType,errormsg]=read_civxdata(FileName,InputField,ParamIn.VelType); 97 if ~isempty(errormsg),errormsg=['read_civxdata:' errormsg];return,end 98 CivStage=Field.CivStage; 99 ParamOut.CivStage=Field.CivStage; 58 case 'netcdf' 59 r=regexp(ParamIn.FieldName,'(^vec|^norm)\((?<UName>.+),(?<VName>.+)\)$','names'); 60 if isempty(r) 61 ListVar={ParamIn.FieldName}; 62 input='scalar'; 63 else 64 ListVar={r.UName,r.VName}; 65 input='vectors'; 66 end 67 if ~isempty(ParamIn.ColorVar) 68 r=regexp(ParamIn.ColorVar,'(^vec|^norm)\((?<UName>.+),(?<VName>.+)\)$','names'); 69 if isempty(r) 70 ListVar=[ListVar {ParamIn.ColorVar}]; 71 else 72 ListVar=[ListVar {r.UName,r.VName}]; 100 73 end 101 ParamOut.FieldList=[{'image'};FieldList;{'get_field...'}];102 end103 if CivStage==0% read the field names on the interface get_field.104 hget_field=findobj(allchild(0),'Name',GUIName);%find the get_field... GUI105 if isempty(hget_field)% open the GUI get_field if it is not found106 hget_field= get_field(FileName);%open the get_field GUI107 set(hget_field,'Name',GUIName)%update the name of get_field (e.g. get_field_1)74 end 75 [Field,var_detect,ichoice]=nc2struct(FileName,[ParamIn.CoordName ListVar]); 76 if strcmp(input,'vectors') 77 Field.VarAttribute{3}.Role='vector_x'; 78 Field.VarAttribute{4}.Role='vector_y'; 79 else 80 Field.VarAttribute{3}.Role='scalar'; 108 81 end 109 hhget_field=guidata(hget_field); 110 %% update the get_field GUI 111 set(hhget_field.inputfile,'String',FileName) 112 set(hhget_field.list_fig,'Value',1) 113 if exist('num','var')&&~isnan(num) 114 set(hhget_field.TimeIndexValue,'String',num2str(num)) 115 end 116 % funct_list=get(hhget_field.ACTION,'UserData'); 117 % funct_index=get(hhget_field.ACTION,'Value'); 118 % funct=funct_list{funct_index};%select the current action in get_field, e;g. PLOT 119 % Field=funct(hget_field); %%activate the current action selected in get_field, e;g.read the names of the variables to plot 120 [Field,errormsg]=read_get_field(hget_field); 121 Tabchar={''};%default 122 Tabcell=[]; 123 set(hhget_field.inputfile,'String',FileName) 124 if isfield(Field,'ListGlobalAttribute')&& ~isempty(Field.ListGlobalAttribute) 125 for iline=1:length(Field.ListGlobalAttribute) 126 Tabcell{iline,1}=Field.ListGlobalAttribute{iline}; 127 if isfield(Field, Field.ListGlobalAttribute{iline}) 128 val=Field.(Field.ListGlobalAttribute{iline}); 129 if ischar(val); 130 Tabcell{iline,2}=val; 131 else 132 Tabcell{iline,2}=num2str(val); 133 end 134 end 135 end 136 if ~isempty(Tabcell) 137 Tabchar=cell2tab(Tabcell,'='); 138 Tabchar=[{''};Tabchar]; 139 end 140 end 141 ParamOut.CivStage=0; 142 ParamOut.VelType=[]; 143 if isfield(Field,'TimeIndex') 144 ParamOut.TimeIndex=Field.TimeIndex; 145 end 146 if isfield(Field,'TimeValue') 147 ParamOut.TimeValue=Field.TimeValue; 148 end 149 ParamOut.FieldList={'get_field...'}; 150 end 82 % GUIName='get_field'; %default name of the GUI get_field 83 % if isfield(ParamIn,'GUIName') 84 % GUIName=ParamIn.GUIName; 85 % end 86 % CivStage=0; 87 % % if ~strcmp(ParamIn.FieldName,'get_field...')% if get_field is not requested, look for Civx data 88 % FieldList=calc_field;%list of possible fields for Civx data 89 % ParamOut.ColorVar='';%default 90 % if ischar(ParamIn.FieldName) 91 % FieldName=ParamIn.FieldName; 92 % else 93 % FieldName=ParamIn.FieldName{1}; 94 % end 95 % field_index=strcmp(FieldName,FieldList);%look for ParamIn.FieldName in the list of possible fields for Civx data 96 % if isempty(find(field_index,1))% ParamIn.FieldName is not in the list, check whether Civx data exist 97 % Data=nc2struct(FileName,'ListGlobalAttribute','Conventions','absolut_time_T0','civ','CivStage'); 98 % % case of new civdata conventions 99 % if isequal(Data.Conventions,'uvmat/civdata') 100 % 101 % %case of old civx conventions 102 % elseif ~isempty(Data.absolut_time_T0)&& ~isequal(Data.civ,0) 103 % ParamOut.FieldName='velocity';%Civx data found, set .FieldName='velocity' by default 104 % ParamOut.ColorVar='ima_cor'; 105 % InputField=[{ParamOut.FieldName} {ParamOut.ColorVar}]; 106 % [Field,ParamOut.VelType]=read_civxdata(FileName,InputField,ParamIn.VelType); 107 % if ~isempty(errormsg),errormsg=['read_civxdata:' errormsg];return,end 108 % CivStage=Field.CivStage; 109 % ParamOut.CivStage=Field.CivStage; 110 % % not cvix file, fields will be chosen through the GUI get_field 111 % else 112 % ParamOut.FieldName='get_field...'; 113 % hget_field=findobj(allchild(0),'Name',GUIName);%find the get_field... GUI 114 % if ~isempty(hget_field) 115 % delete(hget_field)%delete get_field for reinitialisation 116 % end 117 % end 118 % else 119 % InputField=ParamOut.FieldName; 120 % if ischar(InputField) 121 % InputField={InputField}; 122 % end 123 % if isfield(ParamIn,'ColorVar') 124 % ParamOut.ColorVar=ParamIn.ColorVar; 125 % InputField=[InputField {ParamOut.ColorVar}]; 126 % end 127 % [Field,ParamOut.VelType,errormsg]=read_civxdata(FileName,InputField,ParamIn.VelType); 128 % if ~isempty(errormsg),errormsg=['read_civxdata:' errormsg];return,end 129 % CivStage=Field.CivStage; 130 % ParamOut.CivStage=Field.CivStage; 131 % end 132 % ParamOut.FieldList=[{'image'};FieldList;{'get_field...'}]; 133 % end 134 % if CivStage==0% read the field names on the interface get_field. 135 % hget_field=findobj(allchild(0),'Name',GUIName);%find the get_field... GUI 136 % if isempty(hget_field)% open the GUI get_field if it is not found 137 % hget_field= get_field(FileName);%open the get_field GUI 138 % set(hget_field,'Name',GUIName)%update the name of get_field (e.g. get_field_1) 139 % end 140 % hhget_field=guidata(hget_field); 141 % %% update the get_field GUI 142 % set(hhget_field.inputfile,'String',FileName) 143 % set(hhget_field.list_fig,'Value',1) 144 % if exist('num','var')&&~isnan(num) 145 % set(hhget_field.TimeIndexValue,'String',num2str(num)) 146 % end 147 % % funct_list=get(hhget_field.ACTION,'UserData'); 148 % % funct_index=get(hhget_field.ACTION,'Value'); 149 % % funct=funct_list{funct_index};%select the current action in get_field, e;g. PLOT 150 % % Field=funct(hget_field); %%activate the current action selected in get_field, e;g.read the names of the variables to plot 151 % [Field,errormsg]=read_get_field(hget_field); 152 % Tabchar={''};%default 153 % Tabcell=[]; 154 % set(hhget_field.inputfile,'String',FileName) 155 % if isfield(Field,'ListGlobalAttribute')&& ~isempty(Field.ListGlobalAttribute) 156 % for iline=1:length(Field.ListGlobalAttribute) 157 % Tabcell{iline,1}=Field.ListGlobalAttribute{iline}; 158 % if isfield(Field, Field.ListGlobalAttribute{iline}) 159 % val=Field.(Field.ListGlobalAttribute{iline}); 160 % if ischar(val); 161 % Tabcell{iline,2}=val; 162 % else 163 % Tabcell{iline,2}=num2str(val); 164 % end 165 % end 166 % end 167 % if ~isempty(Tabcell) 168 % Tabchar=cell2tab(Tabcell,'='); 169 % Tabchar=[{''};Tabchar]; 170 % end 171 % end 172 % ParamOut.CivStage=0; 173 % ParamOut.VelType=[]; 174 % if isfield(Field,'TimeIndex') 175 % ParamOut.TimeIndex=Field.TimeIndex; 176 % end 177 % if isfield(Field,'TimeValue') 178 % ParamOut.TimeValue=Field.TimeValue; 179 % end 180 % ParamOut.FieldList={'get_field...'}; 181 151 182 case 'video' 152 183 if strcmp(class(ParamIn),'VideoReader')
Note: See TracChangeset
for help on using the changeset viewer.