Changeset 45 for trunk/src


Ignore:
Timestamp:
Mar 15, 2010, 5:39:44 PM (14 years ago)
Author:
gostiaux
Message:

adaptation for movies

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r41 r45  
    6565%default initial parameters
    6666filebase=''; % root file name ('filebase'.civ)
    67 nom_type=[]; % nomenclature type
     67%nom_type=[]; % nomenclature type
    6868ext=[];
    6969testall=0;
     
    111111path_uvmat=which('uvmat');% check the path detected for source file uvmat
    112112path_UVMAT=fileparts(path_uvmat); %path to UVMAT
     113errormsg=[];%default error message
    113114if isunix
    114115    syst='LINUX';
    115     %fid = fopen(fullfile(path_UVMAT,'PARAM_LINUX.txt'),'r');%open the file with civ binary names
    116116    xmlfile=fullfile(path_UVMAT,'PARAM_LINUX.xml');
    117     display(xmlfile)
    118117    if exist(xmlfile,'file')
     118        try
    119119        t=xmltree(xmlfile);
    120120        sparam=convert(t);
     121        catch
     122             errormsg={[' Problem for reading ' xmlfile]; lasterr};   
     123        end
     124    else
     125        erromsg=[xmlfile ' not found: path to civx binaries undefined'];
    121126    end
    122127else
     
    124129    xmlfile=fullfile(path_UVMAT,'PARAM_WIN.xml');
    125130    if exist(xmlfile,'file')
     131        try
    126132        t=xmltree(xmlfile);
    127133        sparam=convert(t);
    128     end
    129 end
    130 display(syst) 
     134        catch
     135             errormsg={[' Problem for reading ' xmlfile]; lasterr};
     136        end
     137    else
     138        erromsg=[xmlfile ' not found: path to civx binaries undefined'];
     139    end
     140end
     141display(syst)
     142if ~isempty(errormsg)
     143       msgbox_uvmat('ERROR',errormsg);
     144end
    131145patch_new_exe='';
    132146% todo_patch='';
     
    143157end   
    144158name_todo=fullfile(todo_path,'TODO.txt');
    145 display(name_todo)
    146159test_batch=1;
    147160if ~sge
     
    296309    t_browse=xmltree(fileinput);
    297310    head_element=get(t_browse,1);
    298     if isfield(head_element,'name')& isequal(head_element.name,'ImaDoc')
     311    if isfield(head_element,'name')&& isequal(head_element.name,'ImaDoc')
    299312        testeditxml=0;
    300313    end
    301314end
    302 if testeditxml==1 | isequal(ext,'.xls')
     315if testeditxml==1 || isequal(ext,'.xls')
    303316   heditxml=editxml({fileinput});
    304317   set(heditxml,'Tag','browser')
     
    314327   end
    315328end
    316 [RootPath,RootFile,field_count,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput);
     329[RootPath,RootFile,str1,str2,str_a,str_b,ext,nom_type,subdir]=name2display(fileinput)
    317330filebase=fullfile(RootPath,RootFile);
     331if isequal(nom_type,'*')% all fields in a single file ( movie files)
     332    num_i1=1;num_i2=1;num_j1=1;num_j2=1;
     333else
     334    num_i1=str2double(str1);
     335    num_i2=str2double(str2);
     336    num_j1=str2double(str_a);
     337    num_j2=str2double(str_b);
     338end
    318339if isequal(get(handles.compare,'Value'),1)
    319340    browse=[];%initialisation
     
    321342    browse=get(handles.browse_root,'UserData');
    322343end
    323 if length(ext)>1 & (~isempty(imformats(ext([2:end])))|...
    324                        isequal(ext,'.avi')|isequal(ext,'.AVI'));%if an image file has been opened by uvmat
     344if length(ext)>1 && (~isempty(imformats(ext([2:end])))||...
     345                       isequal(ext,'.avi')||isequal(ext,'.AVI'));%if an image file has been opened by uvmat
    325346    set(handles.ext_ima,'String',ext)
    326347    browse.nom_type_ima=nom_type;
    327     browse.field_count=str2num(field_count);
    328     A=imread(fileinput);
    329     npxy=size(A);
    330     set(handles.ext_ima,'UserData',npxy)
     348    browse.field_count=num_i1;
     349%     A=imread(fileinput);
     350%     npxy=size(A);
     351%     set(handles.ext_ima,'UserData',npxy)
    331352end
    332353set(handles.ImaDoc,'String',ext);
     
    362383set(handles.displ_filebase,'String',filebase);
    363384set(handles.ImaDoc,'String',ext);
    364 if ~isempty(str2num(field_count))
    365     ref_i=str2num(field_count);
    366     if ~isempty(str2num(str2))
    367         ref_i=floor((ref_i+str2num(str2))/2);% reference image number corresponding to the file
    368         browse.incr_pair(1)=str2num(str2)-str2num(field_count);
     385if ~isempty(num_i1)
     386    ref_i=num_i1;
     387    if ~isempty(num_i2)
     388        ref_i=floor((ref_i+num_i2)/2);% reference image number corresponding to the file
     389        browse.incr_pair(1)=num_i2-num_i1;
    369390        browse.incr_pair(2)=0;
    370391    end
     
    373394    set(handles.ref_i,'String',num2str(ref_i));
    374395end
    375 if isempty(str2num(str_a))
     396if isempty(num_j1)
    376397    set(handles.ref_j,'String','1');
    377398else
    378     ref_j=str2num(str_a);
    379     if ~isempty(str2num(str_b))
    380         ref_j=floor((str2num(str_a)+str2num(str_b))/2);
    381         browse.incr_pair(2)=str2num(str_b)-str2num(str_a);
     399    ref_j=num_j1;
     400    if ~isempty(num_j2)
     401        ref_j=floor((num_j1+num_j2)/2);
     402        browse.incr_pair(2)=num_j2-num_j1;
    382403    end
    383404    set(handles.first_j,'String',num2str(ref_j));
     
    448469field_count=1;%default
    449470nom_type_nc=[];
    450 % npx=[];%default
    451 % npy=[];
    452471time=[];
    453472TimeUnit=[]; %default
     
    555574        [PP,FF,fc,str2,str_a,str_b,ext_ima_read,nom_type_read]=name2display(XmlData.Heading.ImageName);
    556575        fullname=fullfile(fileparts(filebase),XmlData.Heading.ImageName); %full name (including path) of the first image defined by the xmle file,
    557         if exist(fullname,'file')
    558             testima_xml=1;
    559         else
     576        if ~exist(fullname,'file')
     577%             testima_xml=1;
     578%         else
    560579            msgbox_uvmat('WARNING',['FirstImage ' fullname ' defined in the xml file does not exist'])
    561580        end
     
    569588           if ~isempty(ImageSize)&& ~isempty(ImageSize)
    570589               xindex=findstr(ImageSize,'x');
    571                if length(xindex)>=2
    572                     npx=str2num(ImageSize(1:xindex(1)-1));
    573                     npy=str2num(ImageSize(xindex(1)+1:xindex(2)-1));
    574                end
     590%                if length(xindex)>=2
     591%                     npx=str2num(ImageSize(1:xindex(1)-1));
     592%                     npy=str2num(ImageSize(xindex(1)+1:xindex(2)-1));
     593%                end
    575594           end
    576595       end
     
    9941013%reads .nc subdirectoy and image numbers from the interface
    9951014subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf data
    996 first_i=str2num(get(handles.first_i,'String'));
    997 last_i=str2num(get(handles.last_i,'String'));
    998 incr=str2num(get(handles.incr_i,'String'));
    999 num1=first_i:incr:last_i;
    1000 if isempty(num1)
    1001     set(handles.list_pair_civ1,'String',{''});
    1002     return
    1003 end
    1004 ref_i=str2num(get(handles.ref_i,'String'));
     1015% first_i=str2num(get(handles.first_i,'String'));
     1016% last_i=str2num(get(handles.last_i,'String'));
     1017% incr=str2num(get(handles.incr_i,'String'));
     1018% num1=first_i:incr:last_i;
     1019% if isempty(num1)
     1020%     set(handles.list_pair_civ1,'String',{''});
     1021%     return
     1022% end
     1023ref_i=str2double(get(handles.ref_i,'String'));
    10051024if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2')
    10061025    ref_j=0;
    10071026else
    1008     ref_j=str2num(get(handles.ref_j,'String'));
     1027    ref_j=str2double(get(handles.ref_j,'String'));
    10091028end
    10101029time=get(handles.displ_filebase,'UserData');%get the set of times
     
    10121031    time=[0 1];
    10131032end
    1014 dt_unit=str2num(get(handles.dt,'String'));% used when there is no image documentation file
     1033dt_unit=str2double(get(handles.dt,'String'));% used when there is no image documentation file
    10151034displ_num=get(handles.list_pair_civ1,'UserData');
    10161035
     
    10341053testpair=0;
    10351054if get(handles.CIV1,'Value')==0 %
    1036     dirname=fullfile(filepath,subdir_civ1,ext_dir);
    10371055    if ~exist(fullfile(filepath,subdir_civ1,ext_dir),'dir')
    10381056         msgbox_uvmat('ERROR',['no civ1 file available: subdirectory ' subdir_civ1 ' does not exist']);
     
    11211139set(handles.list_pair_civ1,'String',displ_pair');
    11221140ichoice=min(find(select));
    1123 if (isempty(ichoice) | ichoice < 1); ichoice=1; end;
    1124 initial=get(handles.list_pair_civ1,'Value');
    1125 if initial>nbpair |~isequal(select(initial),1)
     1141if (isempty(ichoice) || ichoice < 1); ichoice=1; end;
     1142initial=get(handles.list_pair_civ1,'Value');%initial choice of pair
     1143if initial>nbpair
     1144     set(handles.list_pair_civ1,'Value',ichoice);% first valid pair proposed by default in the menu
     1145end
     1146if numel(select)>=initial && ~isequal(select(initial),1)
    11261147    set(handles.list_pair_civ1,'Value',ichoice);% first valid pair proposed by default in the menu
    11271148end
     1149
    11281150%set(handles.list_pair_civ2,'String',displ_pair');
    11291151initial=get(handles.list_pair_civ2,'Value');
     
    11871209subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf data
    11881210subdir_civ2=get(handles.subdir_civ2,'String');%subdirectory subdir_civ2 for the netcdf data
    1189 first_i=str2num(get(handles.first_i,'String'));
    1190 last_i=str2num(get(handles.last_i,'String'));
    1191 incr=str2num(get(handles.incr_i,'String'));
    1192 num1=first_i:incr:last_i;
    1193 if isempty(num1)
    1194     set(handles.list_pair_civ2,'Value',1);
    1195     set(handles.list_pair_civ2,'String',{''});
    1196     return
    1197 end
     1211% first_i=str2num(get(handles.first_i,'String'));
     1212% last_i=str2num(get(handles.last_i,'String'));
     1213% incr=str2num(get(handles.incr_i,'String'));
     1214% num1=first_i:incr:last_i;
     1215% if isempty(num1)
     1216%     set(handles.list_pair_civ2,'Value',1);
     1217%     set(handles.list_pair_civ2,'String',{''});
     1218%     return
     1219% end
    11981220ref_i=str2num(get(handles.ref_i,'String'));
    11991221if isequal(mode,'pair j1-j2')%|isequal(mode,'st_pair j1-j2')
     
    13191341    find_pair_indices(handles,mode)
    13201342%------------------------------------------------------------------------
    1321 first_i=str2num(get(handles.first_i,'String'));%first index i
    1322 last_i=str2num(get(handles.last_i,'String'));%last index i
    1323 incr=str2num(get(handles.incr_i,'String'));% increment
     1343first_i=str2double(get(handles.first_i,'String'));%first index i
     1344last_i=str2double(get(handles.last_i,'String'));%last index i
     1345incr=str2double(get(handles.incr_i,'String'));% increment
    13241346num_i=[first_i:incr:last_i];% list of i indices (reference values for each pair)
    13251347if isequal(get(handles.first_j,'Visible'),'on')
    1326     first_j=str2num(get(handles.first_j,'String'));%first index j
    1327     last_j=str2num(get(handles.last_j,'String'));%last index j
    1328     incr_j=str2num(get(handles.incr_j,'String'));% increment
     1348    first_j=str2double(get(handles.first_j,'String'));%first index j
     1349    last_j=str2double(get(handles.last_j,'String'));%last index j
     1350    incr_j=str2double(get(handles.incr_j,'String'));% increment
    13291351else
    13301352    first_j=1;
     
    13601382    str_raw=str_civ1(indsel);
    13611383    indsepar=find(str_raw=='|'); %character index of the separator
    1362     d1=str2num(str_civ1([indsel(indsepar-1)+1:indsel(indsepar)-1]));
     1384    d1=str2double(str_civ1([indsel(indsepar-1)+1:indsel(indsepar)-1]));
    13631385    if indsepar==length(str_raw)
    1364         d2=str2num(str_civ1([indsel(indsepar)+1:end]));
     1386        d2=str2double(str_civ1([indsel(indsepar)+1:end]));
    13651387    else
    1366         d2=str2num(str_civ1([indsel(indsepar)+1:indsel(indsepar+1)-1]));
     1388        d2=str2double(str_civ1([indsel(indsepar)+1:indsel(indsepar+1)-1]));
    13671389    end   
    13681390    num1_civ1=num_i-d1;% set of first image numbers
     
    16091631
    16101632%read names of the .exe file
    1611 if box_test(1)==1 | box_test(3)==1 | box_test(4)==1 | box_test(6)==1
     1633if box_test(1)==1 || box_test(3)==1 || box_test(4)==1 || box_test(6)==1
    16121634    path_uvmat=which('uvmat');% check the path detected for source file uvmat
    16131635    path_UVMAT=fileparts(path_uvmat); %path to UVMAT
     
    16291651    if isfield(sparam,'Civ1_exe')
    16301652        civ1_exe=sparam.Civ1_exe;
     1653        if isequal(civ1_exe(1:4),'civx')%the binary is defined in /civx, default setting
     1654            civ1_exe=fullfile(path_UVMAT,civ1_exe);
     1655        end
    16311656    end
    16321657    if isfield(sparam,'Civ2_exe')
    16331658        civ2_exe=sparam.Civ2_exe;
     1659        if isequal(civ2_exe(1:4),'civx')%the binary is defined in /civx, default setting
     1660            civ2_exe=fullfile(path_UVMAT,civ2_exe);
     1661        end
    16341662    end
    16351663    if isfield(sparam,'Patch_exe')
    16361664        patch_exe=sparam.Patch_exe;
     1665        if isequal(patch_exe(1:4),'civx')%the binary is defined in /civx, default setting
     1666            patch_exe=fullfile(path_UVMAT,patch_exe);
     1667        end
    16371668    end
    16381669    if isfield(sparam,'Stinterp_exe')
     
    16401671    end
    16411672    if isfield(sparam,'SGE')
    1642         sge=str2num(sparam.SGE);
     1673        sge=str2double(sparam.SGE);
    16431674    end
    16441675    if ~isunix % for windows system, check whether the Matlab working dir is a UBC name
     
    16921723    field1.vel_type='civ1';
    16931724    field1.nb='nb_vectors';
    1694     field1.X='vec_X';
    1695     field1.Y='vec_Y';
    1696     field1.U='vec_U';
    1697     field1.V='vec_V';
     1725%     field1.X='vec_X';
     1726%     field1.Y='vec_Y';
     1727%     field1.U='vec_U';
     1728%     field1.V='vec_V';
    16981729    field1.fixflag='vec_FixFlag';
    16991730    flagindex(1)=get(handles.vec_Fmin2, 'Value');
    17001731    flagindex(2)=get(handles.vec_F3, 'Value');
    17011732    flagindex(3)=get(handles.vec_F2, 'Value');
    1702     thresh_vecC=str2num(get(handles.thresh_vecC,'String'));%threshold on image correlation vec_C
    1703     thresh_vel=str2num(get(handles.thresh_vel,'String'));%threshold on velocity modulus
     1733    thresh_vecC=str2double(get(handles.thresh_vecC,'String'));%threshold on image correlation vec_C
     1734    thresh_vel=str2double(get(handles.thresh_vel,'String'));%threshold on velocity modulus
    17041735    inf_sup=get(handles.inf_sup1,'Value');
    17051736    menu=get(handles.field_ref1,'String');
     
    17101741        fieldchoice=menu{index};
    17111742    end   
    1712     h = waitbar(0,['removing velocity vectors, fix1']);% display a wait bar
     1743    h = waitbar(0,'removing velocity vectors, fix1');% display a wait bar
    17131744    test_mask=get(handles.get_mask_fix1,'Value');   
    17141745    if test_mask
     
    17281759                maskflag=0;
    17291760            elseif test_mask==1
    1730                 nbslice_mask=str2num(maskdispl(1:end-4)); %
     1761                nbslice_mask=str2double(maskdispl(1:end-4)); %
    17311762                num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1;
    17321763                maskname=name_generator(maskbase,num1_mask,1,'.png','_i');% mask corresponding to the first image of the pair
     
    32913322
    32923323%COPY IMAGES TO THE FORMAT .png IF NEEDED
    3293 if isequal(nom_type_ima1,'*')
    3294     nom_type_imanew='_i';
     3324if isequal(nom_type_ima1,'*')%case of movie files
     3325    nom_type_imanew1='_i';
    32953326else
    32963327    nom_type_imanew1=nom_type_ima1;
    32973328end
    3298 if isequal(nom_type_ima2,'*')
    3299     nom_type_imanew='_i';
     3329if isequal(nom_type_ima2,'*')%case of movie files
     3330    nom_type_imanew2='_i';
    33003331else
    33013332    nom_type_imanew2=nom_type_ima2;
    33023333end
    33033334if ~isequal(ext_ima,'.png')
     3335    %%type of image file
     3336    type_ima1='none';%default
     3337    movieobject1=[];%default
     3338    if isequal(lower(ext_ima),'.avi')
     3339        hhh=which('mmreader');
     3340        if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab)
     3341            type_ima1='movie';
     3342            movieobject1=mmreader([filebase_ima2 ext_ima]);
     3343        else
     3344            type_ima1='avi';
     3345        end
     3346    else
     3347       form=imformats(ext_ima(2:end));
     3348       if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
     3349           if isequal(nom_type_ima1,'*');
     3350               type_ima1='multimage';%image series in a single image file
     3351           else
     3352               type_ima1='image';
     3353           end
     3354       end
     3355    end
     3356    type_ima2='none';%default
     3357    movieobject2=[];
     3358    if isequal(lower(ext_ima),'.avi')
     3359        hhh=which('mmreader');
     3360        if ~isequal(hhh,'')&& mmreader.isPlatformSupported()% if the mmreader function is found (recent version of matlab)
     3361            type_ima2='movie';
     3362            movieobject2=mmreader([filebase_ima2 ext_ima]);
     3363        else
     3364            type_ima2='avi';
     3365        end
     3366    else
     3367       form=imformats(ext_ima(2:end));
     3368       if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
     3369           if isequal(nom_type_ima1,'*');
     3370               type_ima2='multimage';%image series in a single image file
     3371           else
     3372               type_ima2='image';
     3373           end
     3374       end
     3375    end
    33043376    %npxy=get(handles.ext_ima,'UserData');
    33053377% %     if numel(npxy)<2
     
    33183390                    filename=name_generator(filebase_ima1,num1_civ1(ifile),num_a_civ1(j),'.png',nom_type_imanew1);
    33193391                    if ~exist(filename,'file')
    3320                         A=read_image(filecell.ima1.civ1{ifile,j},nom_type_ima2,num1_civ1(ifile));
     3392                        A=read_image(filecell.ima1.civ1{ifile,j},type_ima1,num1_civ1(ifile),movieobject1);
    33213393                        imwrite(A,filename,'BitDepth',16);
    33223394                    end
     
    33243396                    filename=name_generator(filebase_ima2, num2_civ1(ifile),num_b_civ1(j),'.png',nom_type_imanew2);
    33253397                    if ~exist(filename,'file')
    3326                         A=read_image(filecell.ima2.civ1{ifile,j},nom_type_ima2,num2_civ1(ifile));
     3398                        A=read_image(filecell.ima2.civ1{ifile,j},type_ima2,num2_civ1(ifile),movieobject2);
    33273399                        imwrite(A,filename,'BitDepth',16);
    33283400                    end
     
    49705042path_to_uvmat=which ('uvmat');% check the path of uvmat
    49715043pathelp=fileparts(path_to_uvmat);
    4972 helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html');
     5044helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html')
    49735045if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package')
    49745046else
     
    49795051%------------------------------------------------------------------------
    49805052%--read images and convert them to the uint16 format used for PIV
    4981 function A=read_image(filename,nom_type,npx,npy,num);
    4982 %------------------------------------------------------------------------
    4983 %npx, npy are the dimensions needed for the raw SMD images
     5053function A=read_image(filename,type_ima,num,movieobject)
     5054%------------------------------------------------------------------------
    49845055%num is the view number needed for an avi movie
    4985 if isequal(nom_type,'avi')
    4986     mov=aviread(filename,num);
    4987     A=frame2im(mov(1));
     5056switch type_ima
     5057    case 'movie'
     5058        A=read(movieobject,num);
     5059    case 'avi'
     5060        mov=aviread(filename,num);
     5061        A=frame2im(mov(1));
     5062    case 'multimage'
     5063        A=imread(filename,num);
     5064    case 'image'   
     5065        A=imread(filename);
     5066end
     5067siz=size(A);
     5068if length(siz)==3;%color images
    49885069    A=sum(double(A),3);
    49895070    A=uint16(A);
    4990 elseif isequal(nom_type,'raw_SMD')
    4991     [fid,message]=fopen(filename,'r');   
    4992     B=fread(fid,Inf,'int16',0,'ieee-le');%read 16 bit binary file
    4993     A=(reshape(B,npx,npy))'; %remplissage ligne par ligne avec une matrice colonne ? transposer(uB) pour avoir une matrice ligne
    4994     A=uint16(A);
    4995     fclose(fid);
    4996 else
    4997     A=imread(filename);
    4998     siz=size(A);
    4999     if length(siz)==3;%color images
    5000         A=sum(double(A),3);
    5001     end
    5002     A=uint16(A);
    5003 end
    5004 
    5005 % %----------------------------------------------------------------
    5006 % %Executes on carriage return on the time interval dt
    5007 % %----------------------------------------------------------------
    5008 % function dt_Callback(hObject, eventdata, handles)
    5009 % %determine the set of times and possible intervals for CIV
    5010 % %                 answer=inputdlg('time interval between images?');
    5011 %                 dt=(1/1000)*str2num(get(handles.dt,'String'));
    5012 %                 nbfield=str2num(get(handles.nb_field,'String')); %last image number selected in the processing series
    5013 %                 time=(dt*[0:nbfield-1])';
    5014 % %                 set(handles.incr_i,'UserData',dt);%store the time interval between successive images
    5015 %                 set(handles.displ_filebase,'UserData',time); %store the set of times
    5016 %                 for index=1:min(nbfield-1,200)
    5017 %                     displ_num(1,index)=1;
    5018 %                     displ_num(2,index)=1;
    5019 %                     displ_num(3,index)=-floor(index/2);
    5020 %                     displ_num(4,index)=ceil(index/2);
    5021 %                 end
    5022 % set(handles.list_pair_civ1,'Value',1);
    5023 % set(handles.list_pair_civ1,'UserData',displ_num);
    5024 % set(handles.list_pair_civ2,'Value',1);
    5025 % %update the list of time intervals
    5026 % find_netcpair_civ1(hObject, eventdata, handles)
    5027 % find_netcpair_civ2(hObject, eventdata, handles)
     5071end
    50285072
    50295073%------------------------------------------------------------------------
     
    50335077mode_value=get(handles.mode,'Value');
    50345078mode=mode_list{mode_value};
    5035 %if isequal(get(handles.CIV1,'Value'),0)|| isequal(mode,'series(Di)')
    5036     find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files
    5037 %end
     5079find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files
    50385080if isequal(mode,'series(Di)') || ...% we do patch2 only
    5039    (get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0)
     5081   (get(handles.CIV2,'Value')==0 && get(handles.CIV1,'Value')==0 && get(handles.FIX1,'Value')==0 && get(handles.PATCH1,'Value')==0)
    50405082    find_netcpair_civ2(hObject, eventdata, handles);
    50415083end
     
    50475089mode_value=get(handles.mode,'Value');
    50485090mode=mode_list{mode_value};
    5049 if isequal(get(handles.CIV1,'Value'),0)| isequal(mode,'series(Dj)')
     5091if isequal(get(handles.CIV1,'Value'),0)|| isequal(mode,'series(Dj)')
    50505092    find_netcpair_civ1(hObject, eventdata, handles);% update the menu of pairs depending on the available netcdf files
    50515093end
    5052 if isequal(mode,'series(Dj)') | ...
    5053    (get(handles.CIV2,'Value')==0 & get(handles.CIV1,'Value')==0 & get(handles.FIX1,'Value')==0 & get(handles.PATCH1,'Value')==0)
     5094if isequal(mode,'series(Dj)') || ...
     5095   (get(handles.CIV2,'Value')==0 && get(handles.CIV1,'Value')==0 && get(handles.FIX1,'Value')==0 && get(handles.PATCH1,'Value')==0)
    50545096    find_netcpair_civ2(hObject, eventdata, handles);
    50555097end
     
    51535195menu_field{1}='civ1';
    51545196Data=nc2struct(fileinput,[]);
    5155 if isfield(Data,'patch') & isequal(Data.patch,1)
     5197if isfield(Data,'patch') && isequal(Data.patch,1)
    51565198    menu_field{2}='filter1';
    51575199end
    5158 if isfield(Data,'civ2') & isequal(Data.civ2,1)
     5200if isfield(Data,'civ2') && isequal(Data.civ2,1)
    51595201    menu_field{3}='civ2';
    51605202end
    5161 if isfield(Data,'patch2') & isequal(Data.patch2,1)
     5203if isfield(Data,'patch2') && isequal(Data.patch2,1)
    51625204    menu_field{4}='filter2';
    51635205end
     
    51815223    fileinput=[PathName FileName];
    51825224    sizf=size(fileinput);
    5183     if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end %stop if fileinput not a character string
     5225    if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end %stop if fileinput not a character string
    51845226    [Path,File,field_count,str2,str_a,str_b,ref.ext,ref.nom_type,ref.subdir]=name2display(fileinput);
    51855227    ref.filebase=fullfile(Path,File);
  • trunk/src/nc2struct.m

    r19 r45  
    7575    if isequal(List{1},'ListGlobalAttribute')
    7676        for ilist=2:numel(List)
     77            try
    7778            valuestr = netcdf.getAtt(nc,netcdf.getConstant('NC_GLOBAL'),List{ilist});
     79            catch
     80                valuestr=[];
     81            end
    7882            eval(['Data.' List{ilist} '=valuestr;'])
    7983        end
  • trunk/src/struct2nc.m

    r19 r45  
    102102                for iattr=1:length(attr_names)
    103103                    eval(['attr_val=VarAttribute{ivar}.' attr_names{iattr} ';']);
    104                     netcdf.putAtt(nc,varid(ivar),attr_names{iattr},attr_val);
     104                    if ~isempty(attr_names{iattr})&& ~isempty(attr_val)
     105                        netcdf.putAtt(nc,varid(ivar),attr_names{iattr},attr_val);
     106                    end
    105107                end
    106108            end
  • trunk/src/uvmat.m

    r42 r45  
    55%OUTPUT
    66% huvmat=current handles of the GUI uvmat.fig
     7%%
    78%
    89%INPUT:
     
    8081%               Main input open   second input open(_1)        second image (pair animation)
    8182% read_ncfield.m         |                 |                             
    82 % read_image.m           |                 |                                               
     83% read image.m           |                 |                                               
    8384%                     Field{1}         Field{2}               
    8485%                                                                         |
     
    225226menu_str={'';'phys';'px';'phys_polar'};
    226227nb_builtin=numel(menu_str); %number of functions
    227 [path_uvmat,name,ext]=fileparts(which('uvmat'));
     228path_uvmat=fileparts(which('uvmat'));
    228229addpath(fullfile(path_uvmat,'transform_field'))
    229230fct_handle{1,1}=[];
     231testexist=zeros(size(menu_str));%default
    230232testexist(1)=1;
    231233for ilist=2:length(menu_str)
     
    270272             if exist(file,'file')
    271273                h_func=str2func(file);
    272                 testexist=[testexist 1];
     274                testexist=[testexist 1]; %#ok<AGROW>
    273275             else
    274276                h_func=[];
    275                 testexist=[testexist 0];
     277                testexist=[testexist 0];  %#ok<AGROW>
    276278             end
    277              fct_handle=[fct_handle; {h_func}];%concatene the list of paths
     279             fct_handle=[fct_handle; {h_func}];%#ok<AGROW> %concatene the list of paths
    278280             rmpath(path)
    279              menu_str=[menu_str; {file}];
     281             menu_str=[menu_str; {file}]; %#ok<AGROW>
    280282         end
    281283      end
    282284 end
    283 menu_str=menu_str(find(testexist));
    284 fct_handle=fct_handle(find(testexist));
     285menu_str=menu_str(testexist==1);%=menu_str(testexist~=0)
     286fct_handle=fct_handle(testexist==1);
    285287menu_str=[menu_str;{'more...'}];
    286288set(handles.transform_fct,'String',menu_str)
     
    295297path_to_uvmat=which ('uvmat');% check the path detected for source file uvmat
    296298[errormsg,date_str]=check_functions;%check the path of the functions called by uvmat.m
    297 
     299date_str=['last modification: ' date_str];
    298300%case of an input argument for uvmat
    299301testinputfield=0;
     
    346348       if fid~=-1
    347349        a=textscan(fid,'%s%s%s',1,'HeaderLines',1,'Delimiter','|');
    348         set(handles.UVMAT_title,'String',[{'Copyright Joel Sommeria, 2008, Coriolis/ LEGI / CNRS-UJF-INPG';'GNU General Public License'; path_to_uvmat; ['at revision ' a{1}{1}]};a{3}{1};errormsg]);
     350        set(handles.UVMAT_title,'String',[{'Copyright Joel Sommeria, 2008, Coriolis/ LEGI / CNRS-UJF-INPG';'GNU General Public License'; path_to_uvmat; ['at revision ' a{1}{1}]};a{3}{1};date_str;errormsg]);
    349351        fclose(fid);
    350352       else
     
    819821   set(handles.Fields,'Value',1) % set menu to 'image'
    820822   set(handles.Fields,'String',{'image';'get_field...';'velocity';'vort';'div';'more...'})
    821 elseif isequal(FileExt,'.nc')|isequal(FileExt,'.cdf')
     823elseif isequal(FileExt,'.nc')||isequal(FileExt,'.cdf')
    822824   Data=nc2struct(FileName,[]);
    823825   col_vec=get(handles.col_vec,'String');
    824    if isfield(Data,'absolut_time_T0')&& (isfield(Data,'civ1')||isfield(Data,'civ'))
     826   if isfield(Data,'absolut_time_T0')%&& (isfield(Data,'civ1')||isfield(Data,'civ'))
    825827       set(handles.Fields,'String',{'image';'get_field...';'velocity';'vort';'div';'more...'})
    826828       set(handles.Fields,'Value',3) % set menu to 'velocity'
    827829       col_vec{1}='ima_cor';
    828    else
     830   else %general netcdf file (not civx)
    829831       set(handles.Fields,'Value',1) % set menu to 'get_field...
    830832       set(handles.Fields,'String',{'get_field...'})
     
    12701272set_scan_options(hObject, eventdata, handles)
    12711273
    1272 
    12731274%---------------------------------------------------
    12741275% switch file index scanning options scan_i and scan_j in an exclusive way
     
    12841285    set(handles.scan_j,'BackgroundColor',[1 1 0])
    12851286end
    1286 %-------------------------------------------------------------------
    1287 %---------------------------------------------------
     1287
     1288%-------------------------------------------------------------------
    12881289% switch file index scanning options scan_i and scan_j in an exclusive way
    12891290function scan_j_Callback(hObject, eventdata, handles)
    1290 %---------------------------------------------------
    12911291%-------------------------------------------------------------------
    12921292if get(handles.scan_j,'Value')==1
     
    13041304%-------------------------------------------------------------------
    13051305% [filebase,num1,num_a,num2,num_b,ext,NomType,subdir]=read_input_file(handles);
    1306 [FileName,RootPath,filebase,xx,FileExt]=read_file_boxes(handles);
     1306%[FileName,RootPath,filebase,xx,FileExt]=read_file_boxes(handles);
    13071307NomType=get(handles.FileIndex,'UserData');
    13081308num1=stra2num(get(handles.i1,'String'));
     
    16901690index_fields=get(handles.Fields,'Value');% selected string index
    16911691FieldName=list_fields{index_fields}; % selected field
    1692 huvmat=get(handles.movie_pair,'parent');
     1692%huvmat=get(handles.movie_pair,'parent');
    16931693if isequal(FieldName,'image')
    16941694    run0_Callback(hObject, eventdata, handles)%display the first image
    1695     UvData=get(huvmat,'UserData');
     1695    UvData=get(handles.uvmat,'UserData');
    16961696else
    16971697    msgbox_uvmat('ERROR','an image or movie must be first introduced as input')
     
    17271727Field.AY=UvData.Field.AY;
    17281728Field.CoordType='px';
    1729 [Field.A,error]=read_image(imaname_1,NomType,num_i2);
    1730 
     1729%determine the input file type
     1730if isfield(UvData,'MovieObject')
     1731    FileType='movie';
     1732elseif isequal(lower(Ext),'.avi')
     1733    FileType='avi';
     1734elseif isequal(lower(Ext),'.vol')
     1735    FileType='vol';
     1736else
     1737   form=imformats(Ext([2:end]));
     1738   if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
     1739       if isequal(NomType,'*');
     1740           FileType='multimage';
     1741       else
     1742           FileType='image';
     1743       end
     1744   end
     1745end
     1746switch FileType
     1747        case 'movie'
     1748            Field.A=read(UvData.MovieObject,num_i2);
     1749        case 'avi'
     1750            mov=aviread(imaname_1,num_i2);
     1751            Field.A=frame2im(mov(1));
     1752        case 'vol'
     1753            Field.A=imread(imaname_1);
     1754        case 'multimage'
     1755            Field.A=imread(imaname_1,num_i2);
     1756        case 'image'
     1757            Field.A=imread(imaname_1);
     1758end
    17311759
    17321760%px to phys or other transform on field
     
    17471775set(handles.speed,'Visible','on')
    17481776set(handles.speed_txt,'Visible','on')
    1749 while get(handles.speed,'Value')~=0 & isequal(get(handles.run0,'BusyAction'),'queue'); % enable STOP command
     1777while get(handles.speed,'Value')~=0 && isequal(get(handles.run0,'BusyAction'),'queue'); % enable STOP command
    17501778    % read and plot the series of images in non erase mode
    17511779    set(hima,'CData',Field.A);
     
    17551783end
    17561784set(handles.movie_pair,'BackgroundColor',[1 0 0])%paint the command button in red
    1757 
    1758 %run0_Callback(hObject, eventdata, handles)
    17591785
    17601786%-------------------------------------------------------
     
    17691795abstime_1=[];
    17701796dt=[];
    1771 CalibCell={};%default
     1797% CalibCell={};%default
    17721798Field={};
    1773 huvmat=get(handles.run0,'parent');
    1774 UvData=get(huvmat,'UserData');
     1799%huvmat=get(handles.run0,'parent');
     1800UvData=get(handles.uvmat,'UserData');
    17751801if isfield(UvData,'Txt')
    17761802    UvData=rmfield(UvData,'Txt');%erase previous error message
     
    17871813end
    17881814num_i1=[];%default
     1815FileType=[];%default
    17891816if TestInputFile
    1790     [filename,RootPath,filebase,xx,Ext,SubDir]=read_file_boxes(handles);
     1817    [filename,RootPath,filebase,xx,Ext]=read_file_boxes(handles);
    17911818    if ~exist(filename,'file')
    17921819        msgbox_uvmat('ERROR',['input file ' filename ' does not exist'])
     
    18021829%         set(handles.z_index,'String',get(handles.j1,'String'));
    18031830%     else
    1804     nbslice=str2num(get(handles.nb_slice,'String'));
    1805     z_index=mod(num_i1-1,nbslice)+1;
     1831    nbslice=str2double(get(handles.nb_slice,'String'));
     1832%     z_index=mod(num_i1-1,nbslice)+1;
    18061833    if ~isempty(nbslice)
    18071834        z_index=mod(num_i1-1,nbslice)+1;
     
    18131840        end
    18141841    end
    1815 %     end
    1816     % choose the main field
    1817     testima=0;
    1818     if isequal(lower(Ext),'.avi')||isequal(lower(Ext),'.vol')
    1819        testima=1;
    1820        FieldName='image';
     1842    % determine the input file type
     1843    if isequal(Ext,'.nc')||isequal(Ext,'.cdf')
     1844        FileType='netcdf';
     1845    elseif isfield(UvData,'MovieObject')
     1846        FileType='movie';
     1847        FieldName='image';
     1848    elseif isequal(lower(Ext),'.avi')
     1849        FileType='avi';
     1850        FieldName='image';
     1851    elseif isequal(lower(Ext),'.vol')
     1852        FileType='vol';
     1853        FieldName='image';
    18211854    else
    18221855       form=imformats(Ext([2:end]));
    18231856       if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
    1824            testima=1;
     1857           if isequal(NomType,'*');
     1858               FileType='multimage';
     1859           else
     1860               FileType='image';
     1861           end
    18251862           FieldName='image';
    18261863       end
     
    18281865else
    18291866    filename=[];
     1867    FileType='netcdf';
    18301868    FieldName='get_field...';
    1831     testima=0;
    18321869end
    18331870VelType=[];%default
    1834 
    1835 if ~testima
     1871if isequal(FileType,'netcdf')
    18361872    list_fields=get(handles.Fields,'String');% list menu fields
    18371873    index_fields=get(handles.Fields,'Value');% selected string index
     
    18421878    else
    18431879       VelType=setfield(handles);
    1844        %enable_transform(handles,'on')% no field transform (possible transform in the GUI get_field)
    18451880    end
    18461881end
     
    18481883% choose a second field if Subfield option is 'on'
    18491884filename_1=[];
    1850 VelType_1=[];%default
    18511885FieldName_1=[];
    18521886scal_color=[];
    1853 testvel=0;
    1854 testX=0;%default
     1887% testvel=0;
     1888% testX=0;%default
    18551889VelType_1=setfield_1(handles);
    18561890sub_value=get(handles.SubField,'Value');
     1891FileType_1='none';%default
    18571892if sub_value==1
    18581893    filename_1=read_file_boxes_1(handles);
     
    18621897    end
    18631898    NomType_1=get(handles.FileIndex_1,'UserData');
    1864     list_fields=get(handles.Fields_1,'String');% list menu fields
    1865     index_fields=get(handles.Fields_1,'Value');% selected string index
    1866     FieldName_1= list_fields{index_fields}; % selected field
    1867     if isequal(VelType_1,'*')% free veltype choice
    1868         VelType_1=[];
    1869     elseif isequal(VelType_1,'"')% veltype the same as for the first field
    1870         if isempty(VelType)
     1899    Ext_1=get(handles.FileExt_1,'String');
     1900    % determine the input file type
     1901    if isequal(Ext_1,'.nc')||isequal(Ext_1,'.cdf')
     1902        FileType_1='netcdf';
     1903    elseif isfield(UvData,'MovieObject_1')
     1904        FileType_1='movie';
     1905        FieldName_1='image';
     1906    elseif isequal(lower(Ext_1),'.avi')
     1907        FileType='avi';
     1908        FieldName_1='image';
     1909    elseif isequal(lower(Ext_1),'.vol')
     1910        FileType_1='vol';
     1911        FieldName_1='image';
     1912    else
     1913       form=imformats(Ext([2:end]));
     1914       if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
     1915           if isequal(NomType_1,'*');
     1916               FileType_1='multimage';
     1917           else
     1918               FileType_1='image';
     1919           end
     1920           FieldName_1='image';
     1921       end
     1922    end
     1923    if ~isequal(FieldName_1,'image')
     1924        list_fields=get(handles.Fields_1,'String');% list menu fields
     1925        index_fields=get(handles.Fields_1,'Value');% selected string index
     1926        FieldName_1= list_fields{index_fields}; % selected field
     1927        if isequal(VelType_1,'*')% free veltype choice
    18711928            VelType_1=[];
    1872         else
    1873             VelType_1=VelType;
     1929        elseif isequal(VelType_1,'"')% veltype the same as for the first field
     1930            if isempty(VelType)
     1931                VelType_1=[];
     1932            else
     1933                VelType_1=VelType;
     1934            end
    18741935        end
    18751936    end
     
    18811942if sub_value>=2
    18821943    if ~isequal(NomType_1,'*')%in cas of a series of files (not avi movie)
    1883         if isfield(UvData,'filename_1')& isfield(UvData,'VelType_1') & isfield(UvData,'FieldName_1')
    1884             test_keepdata_1= isequal(filename_1,UvData.filename_1)&...
    1885                 isequal(VelType_1,UvData.filename_1) & isequal(FieldName_1,UvData.FieldName_1);
     1944        if isfield(UvData,'filename_1')&& isfield(UvData,'VelType_1') && isfield(UvData,'FieldName_1')
     1945            test_keepdata_1= isequal(filename_1,UvData.filename_1)&&...
     1946                isequal(VelType_1,UvData.filename_1) && isequal(FieldName_1,UvData.FieldName_1);
    18861947
    18871948        end
     
    18901951
    18911952%read the input field(s)
    1892 testima_1=isequal(FieldName_1,'image');
     1953% testima_1=isequal(FieldName_1,'image');
     1954
    18931955%read images
    1894 if  ~isempty(filename) && testima
    1895     if isfield(UvData,'MovieObject')
    1896         A=read(UvData.MovieObject,num_i1);
    1897     else
    1898         [A,error]=read_image(filename,NomType,num_i1);
    1899         if ~isequal(error,0)
    1900             msgbox_uvmat('ERROR',error)
    1901             return
    1902         end
     1956if ~isempty(filename) && isequal(FieldName,'image')
     1957     switch FileType
     1958        case 'movie'
     1959            A=read(UvData.MovieObject,num_i1);
     1960        case 'avi'
     1961            mov=aviread(filename,num_i1);
     1962            A=frame2im(mov(1));
     1963        case 'vol'
     1964            A=imread(filename);
     1965        case 'multimage'
     1966            A=imread(filename,num_i1);
     1967        case 'image'
     1968            A=imread(filename);
    19031969    end
    19041970    npxy=size(A);
     
    19071973    Rangx=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers
    19081974    Rangy=[npxy(1)-0.5 0.5]; %
    1909     npx=str2num(get(handles.npx,'String'));
    1910     npy=str2num(get(handles.npy,'String'));
    1911     if isfield(UvData.XmlData,'Time')
    1912         abs_time=UvData.XmlData.Time;
    1913     end
    19141975    Field{1}.AName='image';
    19151976    Field{1}.ListVarName={'AY','AX','A'}; %
     
    19251986    Field{1}.CoordUnit='pixel'; %used for mouse_motion
    19261987end
    1927 if ~isfield(UvData,'Txt')& ~isempty(filename_1) & testima_1
    1928     [A,error]=read_image(filename_1,NomType_1,num_i1);
    1929     if ~isequal(error,0)
    1930         msgbox_uvmat('ERROR',error)
    1931         return
    1932     end
     1988if ~isfield(UvData,'Txt')&& ~isempty(filename_1) && isequal(FieldName_1,'image')
     1989    switch FileType_1
     1990        case 'movie'
     1991            A=read(UvData.MovieObject_1,num_i1);
     1992        case 'avi'
     1993            mov=aviread(filename,num_i1);
     1994            A=frame2im(mov(1));
     1995        case 'vol'
     1996            A=imread(filename);
     1997        case 'multimage'
     1998            A=imread(filename,num_i1);
     1999        case 'image'
     2000            A=imread(filename);
     2001    end
    19332002    npxy=size(A);
    19342003    set(handles.npx,'String',num2str(npxy(2)));% display image size on the interface
     
    19362005    Rangx=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers
    19372006    Rangy=[npxy(1)-0.5 0.5]; %
    1938     npx=str2num(get(handles.npx,'String'));
    1939     npy=str2num(get(handles.npy,'String'));
    1940     if isfield(UvData,'XmlData_1') && isfield(UvData.XmlData_1,'Time')
    1941         abs_time=UvData.XmlData_1.Time;
    1942     end
     2007%     npx=str2num(get(handles.npx,'String'));
     2008%     npy=str2num(get(handles.npy,'String'));
     2009%     if isfield(UvData,'XmlData_1') && isfield(UvData.XmlData_1,'Time')
     2010%         abs_time=UvData.XmlData_1.Time;
     2011%     end
    19432012    Field{2}.AName='image';
    19442013    Field{2}.ListVarName={'AY','AX','A'}; %
     
    19602029InputField={FieldName};
    19612030InputField_1={FieldName_1};
    1962 if ~isfield(UvData,'Txt') && ((~isempty(filename)&~testima) || (~isempty(filename_1)&~testima_1)) ;
     2031if ~isfield(UvData,'Txt') && ((~isempty(filename)&& isequal(FileType,'netcdf')) || (~isempty(filename_1)&& isequal(FileType,'netcdf'))) ;
    19632032    %read the velocity field(s) from netcdf rootfile(s)
    19642033    list_code=get(handles.col_vec,'String');% list menu fields
     
    19712040        InputField_1=[InputField_1 scal_color];
    19722041    end
    1973     if ~testima  %read the first nc field
     2042    if isequal(FileType,'netcdf')  %read the first nc field
    19742043        if isequal(FieldName,'get_field...')% read the field names on the interface get_field.
    1975             test_detect=0;%default
     2044%             test_detect=0;%default
    19762045            VelType=get(handles.Fields,'UserData');
    19772046            hget_field=findobj(allchild(0),'Name','get_field');%find the get_field... GUI
     
    19792048                hget_field= get_field(filename);%open the get_field GUI   
    19802049            end
    1981             test_detect=1;
     2050%             test_detect=1;
    19822051            hhget_field=guidata(hget_field);
    19832052            set(hhget_field.inputfile,'String',filename)% update the list of input fields in get_field
     
    20012070        end
    20022071    end
    2003     if ~isempty(filename_1) && ~testima_1 %read the second file
     2072    if ~isempty(filename_1) && isequal(FileType_1,'netcdf') %read the second file
    20042073        if isequal(FieldName_1,'get_field...')% read the field names on the interface get_field.
    2005             test_detect=0;%default
     2074%             test_detect=0;%default
    20062075            hget_field=findobj(allchild(0),'Name','get_field_1');%find the get_field... GUI
    20072076             if isempty(hget_field)
     
    20102079%                 enable_transform(handles,'off')% no field transform (possible transform in the GUI get_field)
    20112080             end
    2012             test_detect=1;
     2081%             test_detect=1;
    20132082            hhget_field=guidata(hget_field);%handles of GUI elements in get_field
    20142083            SubField=get_field('read_var_names',hObject,eventdata,hhget_field); %read the names of the variables to plot in the get_field GUI
     
    20232092%                 end
    20242093%             end
    2025 
    20262094            %update the display on get_field
    20272095            set(hhget_field.inputfile,'String',filename_1)
     
    20512119            CivStage_1=Field{2}.CivStage;
    20522120        end
    2053         if testima
     2121        if ~isequal(FileType,'netcdf')
    20542122            VelType_out=VelType_out_1;
    20552123        end
     
    20592127%update the display buttons for the first velocity type (first menuline)
    20602128veltype_handles=[handles.civ1 handles.interp1 handles.filter1 handles.civ2 handles.interp2 handles.filter2];
    2061 if testima
     2129if ~isequal(FileType,'netcdf')
    20622130    reset_vel_type(veltype_handles)
    20632131elseif isempty(VelType)
     
    20732141%update the display buttons for the second velocity type (second menuline)
    20742142veltype_handles_1=[handles.civ1_1 handles.interp1_1 handles.filter1_1 handles.civ2_1 handles.interp2_1 handles.filter2_1];
    2075 if testima_1
     2143if ~isequal(FileType_1,'netcdf')
    20762144    reset_vel_type(veltype_handles_1)
    20772145elseif isempty(VelType_1)
     
    20902158end
    20912159%put W as background image by default if NbDim=2:
    2092 if ~isfield(UvData,'NbDim')|isempty(UvData.NbDim)|~isequal(UvData.NbDim,3)
     2160if ~isfield(UvData,'NbDim')||isempty(UvData.NbDim)||~isequal(UvData.NbDim,3)
    20932161    if UvData.NewSeries && isequal(get(handles.SubField,'Value'),0) && isfield(Field{1},'W') && ~isempty(Field{1}.W);
    20942162        set(handles.SubField,'Value',1);
    2095         menu=update_menu(handles.Fields_1,'w');%update the menu for the background scalar nd set the choice to 'w'
     2163        %menu=update_menu(handles.Fields_1,'w');%update the menu for the background scalar nd set the choice to 'w'
    20962164        set(handles.RootPath_1,'String','"')
    20972165        set(handles.RootFile_1,'String','"')
     
    21762244
    21772245%calculate scalar
    2178 if ~testima && ~isequal(FieldName,'get_field...')%
     2246if isequal(FileType,'netcdf') && ~isequal(FieldName,'get_field...')%
    21792247    Field{1}=calc_field(InputField,Field{1});
    21802248end
    2181 if length(Field)==2 && ~testima_1 && ~isequal(FieldName,'get_field...')
     2249if length(Field)==2 && isequal(FileType_1,'netcdf') && ~isequal(FieldName_1,'get_field...')
    21822250    Field{2}=calc_field(InputField_1,Field{2});
    21832251end
     
    21852253% combine the two input fields (e.g. substract velocity fields)
    21862254if numel(Field)==2
    2187     if ~(isequal(get(handles.movie_pair,'Value'),1) & isequal(FieldName,'image') & isequal(FieldName_1,'image')) %combine fields if not viewing image pairs
     2255    if ~(isequal(get(handles.movie_pair,'Value'),1) && isequal(FieldName,'image') && isequal(FieldName_1,'image')) %combine fields if not viewing image pairs
    21882256        UvData.Field=sub_field(Field{1},Field{2}); %TO UPDATE FOR MORE GENERAL INPUT
    21892257    end
     
    22062274[NbDim,imax]=max(NbDim);
    22072275if isempty(imax)
    2208    DimVarIndex=0;   
     2276%    DimVarIndex=0;   
    22092277    coord_x=[];
    22102278else
    2211     VarIndex=CellVarIndex{imax};
     2279%     VarIndex=CellVarIndex{imax};
    22122280    coord_x=VarType{imax}.coord_x;
    22132281end
    2214 if isfield(UvData,'NbDim') & ~isempty(UvData.NbDim)
     2282if isfield(UvData,'NbDim') && ~isempty(UvData.NbDim)
    22152283    NbDim=UvData.NbDim;
    22162284else 
    22172285    UvData.NbDim=NbDim;
    22182286end
    2219 if ~isempty(CellVarIndex) & ~isempty(VarType{imax}.coord_x)  & ~isempty(VarType{imax}.coord_y)    %unstructured coordinate z
     2287if ~isempty(CellVarIndex) && ~isempty(VarType{imax}.coord_x)  && ~isempty(VarType{imax}.coord_y)    %unstructured coordinate z
    22202288    XName=UvData.Field.ListVarName{VarType{imax}.coord_x};
    22212289    YName=UvData.Field.ListVarName{VarType{imax}.coord_y};
    22222290    test_x=1;
    2223 elseif isfield(UvData.Field,'X')&isfield(UvData.Field,'Y')
     2291elseif isfield(UvData.Field,'X') && isfield(UvData.Field,'Y')
    22242292    XName='X';
    22252293    YName='Y';
     
    22332301    eval(['nbvec=length(UvData.Field.' XName ');'])
    22342302    if NbDim==3%
    2235         if ~isempty(CellVarIndex) & ~isempty(VarType{imax}.coord_z)%unstructured coordinate z
     2303        if ~isempty(CellVarIndex) && ~isempty(VarType{imax}.coord_z)%unstructured coordinate z
    22362304            ZName=UvData.Field.ListVarName{VarType{imax}.coord_z};
    22372305            eval(['UvData.ZMax=max(UvData.Field.' ZName ');'])
     
    24562524%display the updated plotting parameters for the base menuplane
    24572525write_plot_param(handles,UvData.Object{1}.PlotParam);% update the display of the plotting parameters
    2458 set(huvmat,'UserData',UvData)
     2526set(handles.uvmat,'UserData',UvData)
    24592527
    24602528%update the mask
     
    26062674%-------------------------------------------------------------------
    26072675function zoom_Callback(hObject, eventdata, handles)
    2608 huvmat=get(handles.zoom,'parent');%general input
    2609 UvData=get(huvmat,'UserData');
     2676%huvmat=get(handles.zoom,'parent');%general input
     2677UvData=get(handles.uvmat,'UserData');
    26102678if (get(handles.zoom,'Value') == 1);
    26112679    set(handles.zoom,'BackgroundColor',[1 1 0])
     
    26172685    %UvData.ZoomOn=0;  %test for mouse action
    26182686end
    2619 set(huvmat,'UserData',UvData);
     2687set(handles.uvmat,'UserData',UvData);
    26202688
    26212689%-------------------------------------------------------------------
     
    28452913    if isequal(NomType,'_i1-i2_j')||isequal(NomType,'_i_j1-j2')|| isequal(NomType,'#_ab')|| isequal(NomType,'_i1-i2')
    28462914        UvData.SubDir=get(handles.SubDir,'String'); %preserve the subdir in memory
    2847         if ~isempty(UvData.SubDir) && (isequal(UvData.SubDir(1),'/')|isequal(UvData.SubDir(1),'/'))
     2915        if ~isempty(UvData.SubDir) && (isequal(UvData.SubDir(1),'/')||isequal(UvData.SubDir(1),'/'))
    28482916            UvData.SubDir(1)=[];
    28492917        end
    28502918        set(handles.SubDir,'String','')
    28512919        set(handles.FileExt,'String','.png');
    2852         if isequal(NomType,'_i1-i2_j')|isequal(NomType,'_i_j1-j2')
     2920        if isequal(NomType,'_i1-i2_j')||isequal(NomType,'_i_j1-j2')
    28532921            NomTypeNew='_i_j';
    28542922        elseif isequal(NomType,'#_ab')
     
    28742942        set(handles.civ2,'BackgroundColor',[0.702 0.702 0.702])
    28752943        str=calc_field;%get the list of available scalars by the function calc_scal
    2876         [ind_answer,v] = listdlg('PromptString','Select a file:',...
     2944        [ind_answer] = listdlg('PromptString','Select a file:',...
    28772945                'SelectionMode','single',...
    28782946                'ListString',str);
     
    28842952    end
    28852953end
    2886 indices=name_generator('',str2num(str1),str2num(str_a),'',NomTypeNew,1,str2num(str2),str2num(str_b),'');
     2954indices=name_generator('',str2double(str1),str2double(str_a),'',NomTypeNew,1,str2double(str2),str2double(str_b),'');
    28872955set(handles.FileIndex,'String',indices)
    28882956set(handles.FileIndex,'UserData',NomTypeNew)
    28892957%common to Fields_1_Callback
    2890 if isequal(field,'image')|isequal(field_1,'image')
     2958if isequal(field,'image')||isequal(field_1,'image')
    28912959    set(handles.npx_title,'Visible','on')% visible npx,pxcm... buttons
    28922960    set(handles.npy_title,'Visible','on')
     
    29012969    set(handles.fix_pair,'Value',1)
    29022970end
    2903 if isequal(field,'velocity')|isequal(field_1,'velocity');
    2904     state_vect='on';
    2905 else
    2906     state_vect='off';
    2907 end
    2908 if ~isequal(field,'velocity')|(~isequal(field_1,'velocity'));
    2909     state_scal='on';
    2910 else
    2911     state_scal='off';
    2912 end
     2971% if isequal(field,'velocity')|isequal(field_1,'velocity');
     2972%     state_vect='on';
     2973% else
     2974%     state_vect='off';
     2975% end
     2976% if ~isequal(field,'velocity')|(~isequal(field_1,'velocity'));
     2977%     state_scal='on';
     2978% else
     2979%     state_scal='off';
     2980% end
    29132981setfield(handles);% update the field structure ('civ1'....)
    29142982
    2915 if ~isfield(UvData,'NewSeries')|isequal(UvData.NewSeries,0)
     2983if ~isfield(UvData,'NewSeries')||isequal(UvData.NewSeries,0)
    29162984    run0_Callback(hObject, eventdata, handles)
    29172985end
     
    47514819 
    47524820[FileName,RootPath,filebase,FileIndices,ext,SubDir]=read_file_boxes(handles);
    4753 [P,F,str1,str2,str_a,str_b]=name2display(FileName);
    4754 num1=stra2num(str1);
    4755 num2=stra2num(str2);
    4756 num_a=stra2num(str_a);
    4757 num_b=stra2num(str_b);
     4821num1=stra2num(get(handles.i1,'String'));
     4822num2=stra2num(get(handles.i2,'String'));
     4823num_a=stra2num(get(handles.j1,'String'));
     4824num_b=stra2num(get(handles.j2,'String'));
    47584825NomType=get(handles.FileIndex,'UserData');
    47594826ind_opening=1; % default (images): will advice civ1 option by default in the civ interface
     
    48404907% ------------------------------------------------------------------
    48414908function Menupolygon_Callback(hObject, eventdata, handles)
    4842 set(handles.create,'Visible','on')
    4843 set(handles.create,'Value',1)
    4844 PATCH_Callback(hObject,eventdata,handles)
     4909% set(handles.create,'Visible','on')
     4910% set(handles.create,'Value',1)
     4911% PATCH_Callback(hObject,eventdata,handles)
     4912data.Style='polygon';
     4913data.ProjMode='inside';%default
     4914PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters
     4915create_object(data,handles.uvmat,PlotHandles)
    48454916
    48464917%------------------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.