Changeset 1195 for trunk/src/read_civdata.m
- Timestamp:
- Feb 26, 2026, 4:16:03 PM (5 days ago)
- File:
-
- 1 edited
-
trunk/src/read_civdata.m (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/read_civdata.m
r1169 r1195 93 93 94 94 %% reading data 95 [Data, tild,tild,errormsg]=nc2struct(FileName,'ListGlobalAttribute','Conventions','CivStage');% read the global attributes to get Data.CivStage95 [Data,~,~,errormsg]=nc2struct(FileName,'ListGlobalAttribute','Conventions','CivStage');% read the global attributes to get Data.CivStage 96 96 if ~isempty(errormsg) 97 97 errormsg=['read_civdata: ' errormsg]; 98 98 return 99 99 end 100 100 101 % set the list of variables to read and their role 101 [varlist,role,VelTypeOut]=varcivx_generator(ProjModeRequest,VelType,Data.CivStage); 102 CheckCompress=strcmp(Data.Conventions,'uvmat/civdata/compress'); 103 [varlist,role,VelTypeOut]=varcivx_generator(ProjModeRequest,VelType,Data.CivStage,CheckCompress); 102 104 if isempty(varlist) 103 105 errormsg=['read_civdata: unknow velocity type ' VelType]; … … 105 107 else 106 108 if strcmp(Data.Conventions,'uvmat/civdata_3D') 107 [Field,vardetect ]=nc2struct(FileName,'TimeDimName','npz',frame_index,varlist);%read the variables in the netcdf file108 else 109 [Field,vardetect]=nc2struct(FileName,varlist);%read the variables in the netcdf file110 end 111 end 112 if isfield(Field,'Txt')113 errormsg=Field.Txt;109 [Field,vardetect,~,errormsg]=nc2struct(FileName,'TimeDimName','npz',frame_index,varlist);%read the variables in the netcdf file 110 else 111 [Field,vardetect,~,errormsg]=nc2struct(FileName,varlist);%read the variables in the netcdf file 112 end 113 end 114 if ~isempty(errormsg) 115 errormsg=['read_civdata: ' errormsg]; 114 116 return 115 117 end … … 117 119 errormsg=[ 'requested field not available in ' FileName '/' VelType ': need to run patch']; 118 120 return 121 end 122 if strcmp(Data.Conventions,'uvmat/civdata/compress') 123 Field.X=Field.X-0.5+Field.U/2;% shift to the convected position 124 Field.Y=Field.Y-0.5+Field.V/2; 119 125 end 120 126 switch VelTypeOut … … 192 198 % if vel_type=[] or'*', a priority choice is done, civ2 considered better than civ1 ) 193 199 194 function [var,role,vel_type_out,errormsg]=varcivx_generator(ProjModeRequest,vel_type,CivStage )200 function [var,role,vel_type_out,errormsg]=varcivx_generator(ProjModeRequest,vel_type,CivStage,CheckCompress) 195 201 196 202 %% default input values … … 223 229 end 224 230 225 var={}; 226 switch vel_type 227 case{'civ1','civ2'} 228 varout={'X','Y','Z','U','V','W','C','FF'}; 229 varin= {'Civ1_X','Civ1_Y','Civ1_Z','Civ1_U','Civ1_V','Civ1_W','Civ1_C','Civ1_FF'}; 230 role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','errorflag'}; 231 case{'filter1','filter2'} 232 varout={'X','Y','Z','U','V','W','C','FF','Coord_tps','U_tps','V_tps','W_tps','SubRange','NbCentre','NbCentre','NbCentre'}; 233 varin={'Civ1_X','Civ1_Y','Civ1_Z','Civ1_U_smooth','Civ1_V_smooth','Civ1_W','Civ1_C','Civ1_FF',... 234 'Civ1_Coord_tps','Civ1_U_tps','Civ1_V_tps','Civ1_W_tps','Civ1_SubRange','Civ1_NbCentre','Civ1_NbCentres','Civ1_NbSites'}; 235 role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','errorflag','coord_tps','vector_x_tps',... 236 'vector_y_tps','vector_z_tps','ancillary','ancillary','ancillary','ancillary'}; 237 % rmq: NbCentres and NbSites obsolete replaced by NbCentre, kept for consistency with previous data 238 end 239 switch vel_type 240 case {'civ2','filter2'} 241 varin=regexprep(varin,'1','2'); 242 % case {'civ3','filter3'} 243 % varin=regexprep(varin,'1','3'); 231 if CheckCompress 232 switch vel_type 233 case{'civ1','civ2'} 234 varout={'X','Y','Z','U','V','W','C','FF'}; 235 varin= {'X','Y','Z','U','V','W','C','FF'}; 236 role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','errorflag'}; 237 case{'filter1','filter2'} 238 varout={'X','Y','Z','U','V','W','C','FF'}; 239 varin={'X','Y','Z','U_smooth','V_smooth','W_smooth','C','FF'}; 240 role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','errorflag'}; 241 % rmq: NbCentres and NbSites obsolete replaced by NbCentre, kept for consistency with previous data 242 end 243 else 244 switch vel_type 245 case{'civ1','civ2'} 246 varout={'X','Y','Z','U','V','W','C','FF'}; 247 varin= {'Civ1_X','Civ1_Y','Civ1_Z','Civ1_U','Civ1_V','Civ1_W','Civ1_C','Civ1_FF'}; 248 role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','errorflag'}; 249 case{'filter1','filter2'} 250 varout={'X','Y','Z','U','V','W','C','FF','Coord_tps','U_tps','V_tps','W_tps','SubRange','NbCentre','NbCentre','NbCentre'}; 251 varin={'Civ1_X','Civ1_Y','Civ1_Z','Civ1_U_smooth','Civ1_V_smooth','Civ1_W','Civ1_C','Civ1_FF',... 252 'Civ1_Coord_tps','Civ1_U_tps','Civ1_V_tps','Civ1_W_tps','Civ1_SubRange','Civ1_NbCentre','Civ1_NbCentres','Civ1_NbSites'}; 253 role={'coord_x','coord_y','coord_z','vector_x','vector_y','vector_z','ancillary','errorflag','coord_tps','vector_x_tps',... 254 'vector_y_tps','vector_z_tps','ancillary','ancillary','ancillary','ancillary'}; 255 % rmq: NbCentres and NbSites obsolete replaced by NbCentre, kept for consistency with previous data 256 end 257 switch vel_type 258 case {'civ2','filter2'} 259 varin=regexprep(varin,'1','2'); 260 end 244 261 end 245 262 var=[varout;varin];
Note: See TracChangeset
for help on using the changeset viewer.
