Changeset 1131 for trunk/src/read_pivdata_fluidimage.m
- Timestamp:
- Apr 11, 2024, 7:30:52 PM (3 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/read_pivdata_fluidimage.m
r1127 r1131 99 99 end 100 100 101 %% reading data 102 103 104 % Data=nc2struct(FileName,'ListGlobalAttribute','CivStage'); 105 % if isfield(Data,'Txt') 106 % erromsg=['error in read_civdata: ' Data.Txt]; 107 % return 108 % end 109 % % set the list of variables to read and their role 110 %[varlist,role,VelTypeOut]=varcivx_generator(ProjModeRequest,VelType,Datasets.CivStage); 111 % if isempty(varlist) 112 % erromsg=['error in read_civdata: unknow velocity type ' VelType]; 113 % return 114 % else 115 Datasets=hdf5load(FileName);%read the variables in the netcdf file 116 %[varlist,role,VelTypeOut]=varcivx_generator(ProjModeRequest,VelType,Datasets.CivStage); 117 role={'coord_x','coord_y','vector_x','vector_y','ancillary','warnflag','errorflag'}; 118 vardetect=ones(size(role)); 119 Field.ListGlobalAttribute= {'Dt','Time','CivStage'}; 101 %% read the hdf file 102 Datasets=hdf5load(FileName);%read the hdf file 103 104 %% Global attributes 105 Field.ListGlobalAttribute={'Dt','Time','CivStage','NbCoord','NbDim','TimeUnit','CoordUnit'}; 120 106 Field.Dt=1; 121 107 Field.Time=0; … … 125 111 Field.CivStage=3; 126 112 end 113 Field.NbCoord=2; 114 Field.NbDim=2; 115 Field.TimeUnit='s'; 116 Field.CoordUnit='pixel'; 117 118 %% reading data 119 Field.ListVarName={'X' 'Y' 'U' 'V' 'C' 'F' 'FF'}; 120 Field.VarDimName={'nb_vec' 'nb_vec' 'nb_vec' 'nb_vec' 'nb_vec' 'nb_vec' 'nb_vec'}; 127 121 VelTypeOut=VelType; 128 122 switch VelType 129 123 case {'civ1','filter1'} 130 124 Data=Datasets.piv0; 131 VelTypeOut='filter1';125 %VelTypeOut='filter1'; 132 126 case {'civ2','filter2'} 133 127 Data=Datasets.piv1; 134 VelTypeOut='filter2';135 case '' 128 %VelTypeOut='filter2'; 129 case ''% no field specified as input, choose the most appropriate 136 130 if isfield(Datasets, 'piv1') 137 131 Data=Datasets.piv1; … … 142 136 end 143 137 end 138 npy=double(Datasets.couple.shape_images(1)); %number of pixels along y for the image sources 144 139 switch VelType 145 140 case {'civ1','civ2'} 146 141 Field.X= double(Data.xs); 147 Field.Y= double(Data.ys);142 Field.Y= npy-double(Data.ys); 148 143 Field.U= double(Data.deltaxs); 149 Field.U(isnan(Field.U)) = 0; 150 Field.V= double(Data.deltays); 151 Field.V(isnan(Field.V)) = 0; 152 case {'filter1','filter2',''} 144 Field.V= -double(Data.deltays); 145 checkcolor=1;%color representation of the correlation and errors 146 case 'filter1' 147 Field.X= double(Data.ixvecs_approx); 148 Field.Y= npy-double(Data.iyvecs_approx); 149 Field.U= double(Data.deltaxs_approx); 150 Field.V= -double(Data.deltays_approx); 151 checkcolor=0;%no color representation of the correlation and errors 152 case {'filter2',''} 153 153 Field.X= double(Data.ixvecs_final); 154 Field.Y= double(Data.iyvecs_final);154 Field.Y= npy-double(Data.iyvecs_final); 155 155 Field.U= double(Data.deltaxs_final); 156 Field.U(isnan(Field.U)) = 0; 157 Field.V= double(Data.deltays_final); 158 Field.V(isnan(Field.V)) = 0; 159 end 160 Field.ListVarName={'X' 'Y' 'U' 'V' 'C' 'F' 'FF'}; 161 Field.VarDimName={'nb_vec' 'nb_vec' 'nb_vec' 'nb_vec' 'nb_vec' 'nb_vec' 'nb_vec'}; 162 Field.C = double(Data.correls_max); 163 Field.F=zeros(size(Field.U)); Field.F(Data.errors.keys + 1)=1; % !!! convention matlab vs python 164 Field.FF=zeros(size(Field.U)); Field.FF(Data.errors.keys + 1)=1; 165 % if vardetect(1)==0 166 % errormsg=[ 'requested field not available in ' FileName '/' VelType ': need to run patch']; 167 % return 168 % end 169 switch VelTypeOut 170 case {'civ1','filter1'} 171 if isfield(Field,'Patch1_SubDomain') 172 Field.SubDomain=Field.Patch1_SubDomain; 173 Field.ListGlobalAttribute=[Field.ListGlobalAttribute {'SubDomain'}]; 174 end 175 if isfield(Field,'Civ1_Dt') 176 Field.Dt=Field.Civ1_Dt; 177 end 178 if isfield(Field,'Civ1_Time') 179 Field.Time=Field.Civ1_Time; 180 end 181 case {'civ2','filter2'} 182 if isfield(Field,'Patch2_SubDomain') 183 Field.SubDomain=Field.Patch2_SubDomain; 184 Field.ListGlobalAttribute=[Field.ListGlobalAttribute {'SubDomain'}]; 185 end 186 if isfield(Field,'Civ2_Dt') 187 Field.Dt=Field.Civ2_Dt; 188 end 189 if isfield(Field,'Civ2_Time') 190 Field.Time=Field.Civ2_Time; 191 end 192 end 193 %Field.ListGlobalAttribute=[Field.ListGlobalAttribute {'Dt','Time'}]; 156 Field.V= -double(Data.deltays_final); 157 checkcolor=1;%color representation of the correlation and errors 158 end 159 Field.U(isnan(Field.U)) = 0; 160 Field.V(isnan(Field.V)) = 0; 161 Field.C=ones(size(Field.U));%default 162 Field.F=zeros(size(Field.U)); 163 Field.FF=zeros(size(Field.U)); 164 if checkcolor 165 Field.C = double(Data.correls_max); 166 Field.F(Data.errors.keys + 1)=1; % !!! convention matlab vs python 167 Field.FF(Data.errors.keys + 1)=1; 168 end 169 170 %% set variable attributes 194 171 ivar_U_tps=[]; 195 172 ivar_V_tps=[]; 173 role={'coord_x','coord_y','vector_x','vector_y','ancillary','warnflag','errorflag'}; 174 vardetect=ones(size(role)); 196 175 var_ind=find(vardetect); 197 176 for ivar=1:numel(var_ind) 198 177 Field.VarAttribute{ivar}.Role=role{var_ind(ivar)}; 199 %Field.VarAttribute{ivar}.Mesh=0.025;%typical mesh for histograms O.025 pixel (used in series)178 Field.VarAttribute{ivar}.Mesh=0.025;%typical mesh for histograms O.025 pixel (used in series) 200 179 Field.VarAttribute{ivar}.ProjModeRequest=ProjModeRequest; 201 180 if strcmp(role{var_ind(ivar)},'vector_x') … … 223 202 end 224 203 225 %% update list of global attributes 226 Field.ListGlobalAttribute=[Field.ListGlobalAttribute {'NbCoord','NbDim','TimeUnit','CoordUnit'}]; 227 Field.NbCoord=2; 228 Field.NbDim=2; 229 Field.TimeUnit='s'; 230 Field.CoordUnit='pixel'; 204
Note: See TracChangeset
for help on using the changeset viewer.