Ignore:
Timestamp:
Feb 26, 2026, 4:16:03 PM (5 days ago)
Author:
sommeria
Message:

format of PIV data made more compact/4

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/read_civdata.m

    r1169 r1195  
    9393
    9494%% reading data
    95 [Data,tild,tild,errormsg]=nc2struct(FileName,'ListGlobalAttribute','Conventions','CivStage');% read the global attributes to get Data.CivStage
     95[Data,~,~,errormsg]=nc2struct(FileName,'ListGlobalAttribute','Conventions','CivStage');% read the global attributes to get Data.CivStage
    9696if ~isempty(errormsg)
    9797     errormsg=['read_civdata: ' errormsg];
    9898    return
    9999end
     100
    100101% set the list of variables to read and their role
    101 [varlist,role,VelTypeOut]=varcivx_generator(ProjModeRequest,VelType,Data.CivStage);
     102CheckCompress=strcmp(Data.Conventions,'uvmat/civdata/compress');
     103[varlist,role,VelTypeOut]=varcivx_generator(ProjModeRequest,VelType,Data.CivStage,CheckCompress);
    102104if isempty(varlist)
    103105    errormsg=['read_civdata: unknow velocity type ' VelType];
     
    105107else
    106108    if strcmp(Data.Conventions,'uvmat/civdata_3D')
    107         [Field,vardetect]=nc2struct(FileName,'TimeDimName','npz',frame_index,varlist);%read the variables in the netcdf file
    108     else   
    109     [Field,vardetect]=nc2struct(FileName,varlist);%read the variables in the netcdf file
    110     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
     113end
     114if ~isempty(errormsg)
     115     errormsg=['read_civdata: ' errormsg];
    114116    return
    115117end
     
    117119     errormsg=[ 'requested field not available in ' FileName '/' VelType ': need to run patch'];
    118120     return
     121end
     122if 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;
    119125end
    120126switch VelTypeOut
     
    192198%            if vel_type=[] or'*', a  priority choice is done, civ2 considered better than civ1 )
    193199
    194 function [var,role,vel_type_out,errormsg]=varcivx_generator(ProjModeRequest,vel_type,CivStage)
     200function [var,role,vel_type_out,errormsg]=varcivx_generator(ProjModeRequest,vel_type,CivStage,CheckCompress)
    195201
    196202%% default input values
     
    223229end
    224230
    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');
     231if 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
     243else
     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
    244261end
    245262var=[varout;varin];
Note: See TracChangeset for help on using the changeset viewer.