Changeset 1181 for trunk/src/series


Ignore:
Timestamp:
May 21, 2025, 6:14:05 PM (9 months ago)
Author:
sommeria
Message:

image rescale included in civ_series input

Location:
trunk/src/series
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/series/check_data_files.m

    r1164 r1181  
    176176            end
    177177        else
    178             datnum=datnum(datnum);%keep the non zero values corresponding to existing files
    179             filefound=filefound(datnum);
     178            datnum=datnum(datnum~=0);%keep the non zero values corresponding to existing files
     179            filefound=filefound(datnum~=0);
    180180            [first,ind]=min(datnum);
    181181            [last,indlast]=max(datnum);
  • trunk/src/series/civ_input.m

    r1180 r1181  
    9191if isfield(SeriesData,'FileInfo')
    9292    FileType=SeriesData.FileInfo{1}.FileType;% info on the first input file series
    93     FieldType=SeriesData.FileInfo{1}.FieldType;% info on the first input file series
     93    %FieldType=SeriesData.FileInfo{1}.FieldType;% info on the first input file series
    9494else
    9595    set(hhseries.REFRESH,'BackgroundColor',[1 0 1])% indicate that the file input in series needs to be refreshed
     
    207207    set(handles.TimeSource,'String',Param.IndexRange.TimeSource);
    208208else
     209    msgbox_uvmat('WARNING','timing not defined (check xml file), default values used')
    209210    set(handles.TimeSource,'String',''); %xml file not used for timing
    210211    TimeUnit='frame';
     
    377378%% list the possible index pairs, depending on the option set in ListPairMode
    378379ListPairMode_Callback([], [], handles)
    379 
     380if isfield(Param,'ActionInput')&& isfield(Param.ActionInput,'PairIndices')
     381    if isfield(Param.ActionInput.PairIndices,'ListPairCiv1')
     382        PairChoiceCiv1=find(strcmp(Param.ActionInput.PairIndices.ListPairCiv1,get(handles.ListPairCiv1,'String')));
     383        if ~isempty(PairChoiceCiv1)
     384            set(handles.ListPairCiv1,'Value',PairChoiceCiv1)
     385        end
     386    end
     387    if isfield(Param.ActionInput.PairIndices,'ListPairCiv2')
     388        PairChoiceCiv2=find(strcmp(Param.ActionInput.PairIndices.ListPairCiv2,get(handles.ListPairCiv2,'String')));
     389        if ~isempty(PairChoiceCiv2)
     390            set(handles.ListPairCiv2,'Value',PairChoiceCiv2)
     391        end
     392    end
     393end
     394 
    380395%% set the GUI to modal: wait for OK to close
    381396set(handles.civ_input,'WindowStyle','modal')% Make the GUI modal
     
    810825%reproduce by default the chosen pair in the checkciv2 menu
    811826set(handles.ListPairCiv2,'Value',get(handles.ListPairCiv1,'Value'))%civ2 selection the same as civ1 by default
    812 ListPairCiv2_Callback(hObject, eventdata, handles)
    813 
    814 %------------------------------------------------------------------------
    815 % --- Executes on selection change in ListPairCiv2.
    816 function ListPairCiv2_Callback(hObject, eventdata, handles)
    817 %------------------------------------------------------------------------
     827%ListPairCiv2_Callback(hObject, eventdata, handles)
     828
     829% %------------------------------------------------------------------------
     830% % --- Executes on selection change in ListPairCiv2.
     831% function ListPairCiv2_Callback(hObject, eventdata, handles)
     832% %------------------------------------------------------------------------
    818833
    819834%------------------------------------------------------------------------
     
    15271542    set(obj,'Visible','off')
    15281543end
     1544set(handles.ConfigSource,'String','NEW')
     1545set(handles.OK,'BackgroundColor',[1 0 1])
     1546
     1547
     1548%------------------------------------------------------------------------
     1549% --- Executes on button press in CheckRescale.
     1550function CheckRescale_Callback(hObject, eventdata, handles)
     1551%------------------------------------------------------------------------
     1552huipanel=get(hObject,'parent');
     1553obj(1)=findobj(huipanel,'Tag','num_Maxtanh');
     1554obj(2)=findobj(huipanel,'Tag','title_Maxtanh');
     1555if get(hObject,'Value')% if chck box has been selected
     1556    set(obj,'Visible','on')
     1557else
     1558    set(obj,'Visible','off')
     1559end
     1560set(handles.ConfigSource,'String','NEW')
     1561set(handles.OK,'BackgroundColor',[1 0 1])
     1562
     1563%------------------------------------------------------------------------
     1564% --- synchronise the image threshold for civ1 and civ2
     1565function num_MaxIma_Callback(hObject, eventdata, handles)
     1566MaxIma_string=get(hObject,'String');
     1567set(handles.num_MaxIma,'String',MaxIma_string);
     1568set(handles.num_MaxIma,'Visible','on');
     1569set(handles.title_Threshold,'Visible','on');
     1570set(handles.CheckThreshold,'Value',true);
     1571
     1572set(handles.ConfigSource,'String','NEW')
     1573set(handles.OK,'BackgroundColor',[1 0 1])
     1574
     1575%------------------------------------------------------------------------
     1576% --- synchronise the image rescaling threshold for civ1 and civ2
     1577function num_Maxtanh_Callback(hObject, eventdata, handles)
     1578Maxtanh_string=get(hObject,'String');
     1579set(handles.num_Maxtanh,'String',Maxtanh_string);
     1580set(handles.num_Maxtanh,'Visible','on');
     1581set(handles.title_Maxtanh,'Visible','on');
     1582set(handles.CheckRescale,'Value',true);
     1583
    15291584set(handles.ConfigSource,'String','NEW')
    15301585set(handles.OK,'BackgroundColor',[1 0 1])
     
    19522007
    19532008
    1954 function edit108_Callback(hObject, eventdata, handles)
    1955 % hObject    handle to edit108 (see GCBO)
    1956 % eventdata  reserved - to be defined in a future version of MATLAB
    1957 % handles    structure with handles and user data (see GUIDATA)
    1958 
    1959 % Hints: get(hObject,'String') returns contents of edit108 as text
    1960 %        str2double(get(hObject,'String')) returns contents of edit108 as a double
    1961 
    1962 
    19632009% --- Executes on button press in CheckBackground.
    19642010function CheckBackground_Callback(hObject, eventdata, handles)
  • trunk/src/series/civ_series.m

    r1180 r1181  
    6969    Data.VelType='off';% menu for selecting the velocity type (options 'off'/'one'/'two',  'off' by default)
    7070    Data.FieldName='on';% menu for selecting the field (s) in the input file(options 'off'/'one'/'two', 'off' by default)
    71     Data.FieldTransform = 'on';%can use a transform function
     71    Data.FieldTransform = 'off';%can use a transform function
    7272    Data.ProjObject='off';%can use projection object(option 'off'/'on',
    7373    Data.Mask='off';%can use mask option   (option 'off'/'on', 'off' by default)
     
    258258CheckRelabel=isfield(Param,'FileSeries' );%=true for index relabeling (PCO)
    259259
    260 %% introduce input image transform
    261 transform_fct=[];%default, no transform
    262 if isfield(Param,'FieldTransform')&&~isempty(Param.FieldTransform.TransformName)
    263         currentdir=pwd;
    264     cd(Param.FieldTransform.TransformPath)
    265     transform_fct=str2func(Param.FieldTransform.TransformName);
    266     cd (currentdir)
    267 end
     260% %% introduce input image transform
     261% transform_fct=[];%default, no transform
     262% if isfield(Param,'FieldTransform')&&~isempty(Param.FieldTransform.TransformName)
     263%         currentdir=pwd;
     264%     cd(Param.FieldTransform.TransformPath)
     265%     transform_fct=str2func(Param.FieldTransform.TransformName);
     266%     cd (currentdir)
     267% end
    268268
    269269%%%%% MAIN LOOP %%%%%%
     
    445445        end
    446446
    447 
    448         %% user defined image transform
    449         if ~isempty(transform_fct)
    450                par_civ1 =transform_fct(par_civ1,Param);
     447 % case of image luminosity rescaling
     448      if par_civ1.CheckRescale &&~isempty(par_civ1.Maxtanh)
     449               par_civ1.ImageA =par_civ1.Maxtanh*tanh(double(par_civ1.ImageA)/par_civ1.Maxtanh);
     450               par_civ1.ImageB=par_civ1.Maxtanh*tanh(double(par_civ1.ImageB)/par_civ1.Maxtanh);
    451451        end
    452452       
     
    672672        end
    673673       
    674                 %% user defined image transform
    675         if ~isempty(transform_fct)
    676                par_civ2 =transform_fct(par_civ2,Param);
    677         end
    678        
     674%                 %% user defined image transform
     675%         if ~isempty(transform_fct)
     676%                par_civ2 =transform_fct(par_civ2,Param);
     677%         end
     678         %% case of image luminosity rescaling
     679      if par_civ2.CheckRescale &&~isempty(par_civ2.Maxtanh)
     680               par_civ2.ImageA =par_civ2.Maxtanh*tanh(double(par_civ2.ImageA)/par_civ2.Maxtanh);
     681               par_civ2.ImageB=par_civ2.Maxtanh*tanh(double(par_civ2.ImageB)/par_civ2.Maxtanh);
     682        end
    679683       
    680684        % get the guess from patch1 or patch2 (case 'CheckCiv3')
  • trunk/src/series/filter_time_singlefile.m

    r1158 r1181  
    1 %'filter_time_single': apply a a sliding filter in a time series, put the time series in a single netcdf file (problematic...)
    2 %------------------------------------------------------------------------
     1%'filter_time_single': apply a a sliding filter to a time series and concatene the result in a single netcdf file
    32% function ParamOut=filter_time(Param)
    43%
     
    149148
    150149%%%%%%%%%%%%%%%% loop on field indices %%%%%%%%%%%%%%%%
    151 disp('loop for filtering started')
    152 tstart = tic;
    153  telapsed(zeros,1,NbField)       
     150disp('loop for filtering started') 
     151 ncid=[];
    154152for index=1:NbField
    155153    index
    156    
    157     Field= read_field(filecell{1,index},'netcdf',Param.InputFields);
    158    
     154   
     155    [Field,~,errormsg]= read_field(filecell{1,index},'netcdf',Param.InputFields);
     156    if ~isempty(errormsg)
     157        disp(errormsg)
     158        if ~isempty(ncid)
     159        netcdf.close(ncid)
     160        end
     161        return
     162    end
    159163    %%%%%%%%%%% MAIN RUNNING OPERATIONS  %%%%%%%%%%%%
    160164    if index==1 %first field, initialisation output data
    161165        DataOut.ListGlobalAttribute= {'Conventions'};
    162166        DataOut.Conventions='uvmat';
    163         DataOut.ListVarName={'Time','coord_y','coord_x','Ufilter','Vfilter'};
    164         DataOut.VarDimName={'Time','coord_y','coord_x',{'Time','coord_y','coord_x'},{'Time','coord_y','coord_x'}};
    165167        npy=numel(Field.coord_y);
    166168        npx=numel(Field.coord_x);
    167169        ListDimName={'Time','coord_y','coord_x'};
    168170        DimValue=[NbField npy npx];
    169         VarDimIndex={1,2,3,[1 2 3],[1 2 3]};
     171        ListFields=Param.InputFields.FieldName;
     172        DataOut.ListVarName=[{'Time','coord_y','coord_x'} ListFields'];
     173        %DataOut.VarDimName={'Time','coord_y','coord_x',{'Time','coord_y','coord_x'},{'Time','coord_y','coord_x'}};
     174        DataOut.VarDimName={'Time','coord_y','coord_x'};
     175        VarDimIndex={1,2,3};
     176        for ifield=1:numel(ListFields)
     177            DataOut.VarDimName{ifield+3}={'coord_y','coord_x','Time'};
     178            Field_varid(ifield)=ifield+2;
     179            VarDimIndex{ifield+3}=[2 3 1];
     180        end
     181
     182%         VarDimIndex={1,2,3,[1 2 3],[1 2 3]};
     183
    170184        DataOut.coord_x=Field.coord_x;
    171185        DataOut.coord_y=Field.coord_y;
    172186        DataOut.Time=0;
    173         DataOut.Ufilter=0;
    174         DataOut.Vfilter=0;
     187        for ifield=1:numel(ListFields)
     188            DataOut.(ListFields{ifield})=0;
     189        end
    175190        [errormsg,ncid]=struct2nc(ncfile_out,DataOut,'keep_open',ListDimName,DimValue,VarDimIndex);
    176191        netcdf.putVar(ncid,0,0,1,0)
    177192        netcdf.putVar(ncid,1,0,npy,Field.coord_y)
    178193        netcdf.putVar(ncid,2,0,npx,Field.coord_x)
    179         Uvarid=3;
    180         Vvarid=4;
     194%         Uvarid=3;
     195%         Vvarid=4;
    181196        TimeBlock=zeros(Param.ActionInput.WindowLength,1);
    182         Ublock=zeros(Param.ActionInput.WindowLength,npy,npx);
    183         Vblock=zeros(Param.ActionInput.WindowLength,npy,npx);
    184     end
     197        Fieldblock=zeros(numel(ListFields),Param.ActionInput.WindowLength,npy,npx);
     198        %Vblock=zeros(Param.ActionInput.WindowLength,npy,npx);
     199    end
     200
    185201    TimeBlock=circshift(TimeBlock,[-1 0 ]);
    186     Ublock=circshift(Ublock,[-1 0 0]); %shift U by ishift along the first index
    187     Vblock=circshift(Vblock,[-1 0 0]); %shift U by ishift along the first index
    188202    TimeBlock(end)=Field.Time;
    189     Ublock(end,:,:)=Field.U;
    190     Vblock(end,:,:)=Field.V;
    191203    sumindex=min(index,Param.ActionInput.WindowLength)-1;
    192204    Timefilter=mean(TimeBlock(end-sumindex:end,:,:));%mid time
    193     Ufilter=squeeze(mean(Ublock(end-sumindex:end,:,:),1,'omitnan'));
    194     Vfilter=squeeze(mean(Vblock(end-sumindex:end,:,:),1,'omitnan'));
     205    Fieldblock=circshift(Fieldblock,[0 -1 0 0]); %shift U by ishift along the first index
     206   % Vblock=circshift(Vblock,[-1 0 0]); %shift U by ishift along the first index
     207    for ifield=1:numel(ListFields)
     208    Fieldblock(ifield,end,:,:)=Field.(ListFields{ifield});
     209    end
     210    %Vblock(end,:,:)=Field.V;
     211    Fieldfilter=squeeze(mean(Fieldblock(:,end-sumindex:end,:,:),2,'omitnan'));
     212%     Ufilter=squeeze(mean(Ublock(end-sumindex:end,:,:),1,'omitnan'));
     213%     Vfilter=squeeze(mean(Vblock(end-sumindex:end,:,:),1,'omitnan'));
     214%     Uerror=Ufilter-Ublock(end-floor(sumindex/2),:,:);
     215%     Verror=Ufilter-Vblock(end-floor(sumindex/2),:,:);
    195216    %updating output the netcdf file
     217     tstart = tic;
    196218    netcdf.putVar(ncid,0,(index-1),Timefilter)
    197     netcdf.putVar(ncid,Uvarid,[(index-1) 0 0],[1 npy npx],Ufilter)
    198     netcdf.putVar(ncid,Vvarid,[(index-1) 0 0],[1 npy npx],Vfilter)
    199 
    200  telapsed(index) = toc(tstart);
     219    for ifield=1:numel(ListFields)
     220        netcdf.putVar(ncid,Field_varid(ifield),[ 0 0 (index-1)],[npy npx 1],squeeze(Fieldfilter(ifield,:,:)))
     221    end
     222%     netcdf.putVar(ncid,Uvarid,[ 0 0 (index-1)],[npy npx 1],Ufilter)
     223%      netcdf.putVar(ncid,Vvarid,[0 0 (index-1)],[npy npx 1],Vfilter)
     224
     225 telapsed = toc(tstart)% time for writting the field
    201226    % writing the result file as netcdf file
    202227    %     i1=i1_series{1}(index)-ceil(NpTime/2);
     
    212237figure
    213238plot(telapsed)
     239ylabel('time lapsed computation')
    214240'END'
Note: See TracChangeset for help on using the changeset viewer.