Changeset 174


Ignore:
Timestamp:
Jan 5, 2011, 9:43:28 AM (10 years ago)
Author:
sommeria
Message:

civ.m : clarification of .cmx : creation of .civ1.cmx and .civ2.cmx
uvmat: reading and projecting volume images (not yet successfull)

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r173 r174  
    267267    oldfile=filebase;
    268268end
    269 testall=get(handles.ImaDoc,'UserData');
     269% testall=get(handles.ImaDoc,'UserData');
    270270ind_opening=1;%default
    271271browse.incr_pair=[0 0]; %default
    272 if testall
    273     menu={'*.*', 'All Files (*.*)'; '*.xml; *.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ...
    274         '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc','.nc files'};
    275 else % menu selecting only .civ or .avi files
    276     menu={'*.xml;*.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ...
    277         '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc', '.nc files';...
    278         '*.*', 'All Files (*.*)'};
    279 end
     272% if testall
     273%     menu={'*.*', 'All Files (*.*)'; '*.xml; *.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ...
     274%         '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc','.nc files'};
     275% else % menu selecting only .civ or .avi files
     276 menu={'*.xml;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.nc;', ' (*.xml,*.civ,*.png,*.jpg ,.tif, *.avi,*.nc)';
     277       '*.xml',  '.xml files '; ...
     278        '*.civ',  '.civ files '; ...
     279        '*.png','.png image files'; ...
     280        '*.jpg',' jpeg image files'; ...
     281        '*.tif','.tif image files'; ...
     282        '*.avi;*.AVI','.avi movie files'; ...
     283        '*.nc','.netcdf files'; ...
     284        '*.*',  'All Files (*.*)'};
     285   % menu={'*.xml;*.avi;*.AVI;*.nc','(*.xml,*.avi,*.nc)'; ...
     286     %   '*.xml', '.xml files';'*.avi;*.AVI', '.avi files';'*.nc', '.nc files';...
     287    %    '*.*', 'All Files (*.*)'};
     288% end
    280289[FileName, PathName, filtindex] = uigetfile( menu, 'Pick a file',oldfile);
    281290fileinput=[PathName FileName];%complete file name
     
    431440end
    432441set(handles.browse_root,'UserData',browse);% store information from browser
    433 testall=isequal(menu(filtindex,1),{'*.*'});
    434 set(handles.ImaDoc,'UserData',testall);
     442% testall=isequal(menu(filtindex,1),{'*.*'});
     443% set(handles.ImaDoc,'UserData',testall);
    435444
    436445RootName_Callback(hObject, eventdata, handles);
     
    18681877            civAllxml=set(civAllxml,1,'name','CivDoc');
    18691878        end
    1870         filename_cmx=filecell.nc.civ1{ifile,j};%output netcdf file
    1871         filename_cmx(end-1:end+1)='cmx';%name of cmx file
     1879        %filename_cur=filecell.nc.civ1{ifile,j};%output netcdf file
     1880        [Rootbat,Filebat]=fileparts(filecell.nc.civ1{ifile,j});%output netcdf file (without extention)
     1881        %filename_cmx(end-1:end+6)='civ1.cmx';%name of cmx file
    18721882        if batch
    1873             [Rootbat,Filebat,extbat]=fileparts(filename_cmx);
    1874             filename_bat=fullfile(Rootbat,['job_' Filebat extbat]);
     1883%             [Rootbat,Filebat,extbat]=fileparts(filename_cmx);
     1884            filename_bat=fullfile(Rootbat,['job_' Filebat]);
    18751885         else
    1876             filename_bat=filename_cmx;
    1877         end
    1878         filename_bat(end-2:end)='bat';
     1886            filename_bat=fullfile(Rootbat,Filebat);
     1887        end
     1888        filename_bat=[filename_bat '.bat'];
    18791889       
    18801890        %CIV1
     
    18821892            par_civ1.filename_ima_a=filecell.ima1.civ1{ifile,j};
    18831893            par_civ1.filename_ima_b=filecell.ima2.civ1{ifile,j};
    1884             namelog=[filename_cmx([1:end-3]) 'log'];
     1894            namelog=[fullfile(Rootbat,Filebat) '.civ1.log'];
    18851895            par_civ1.Dt=num2str(time(num2_civ1(ifile),num_b_civ1(j))-time(num1_civ1(ifile),num_a_civ1(j)));
    18861896            par_civ1.T0=num2str((time(num2_civ1(ifile),num_b_civ1(j))+time(num1_civ1(ifile),num_a_civ1(j)))/2);
     
    19351945            i_cmd=i_cmd+1;
    19361946            if isequal(civAll,0)
    1937                 cmd=[cmd CIV1_CMD(filename_cmx(1:end-4),namelog,par_civ1,handles,sparam) '\n'];
     1947                cmd=[cmd CIV1_CMD(fullfile(Rootbat,Filebat),'',par_civ1,handles,sparam) '\n'];
    19381948            else
    19391949                civAllCmd=[civAllCmd ' civ1 '];
    1940                 str=CIV1_CMD_Unified(filename_cmx([1:end-4]),namelog,par_civ1);
     1950                str=CIV1_CMD_Unified(fullfile(Rootbat,Filebat),'',par_civ1);
    19411951                fieldnames=fields(str);
    19421952                [civAllxml,uid_civ1]=add(civAllxml,1,'element','civ1');
     
    20542064            par_civ2.filename_ima_b=filecell.ima2.civ2{ifile,j};
    20552065            %par_civ2.filename_ima_b([end-3:end])=[];%remove .png extension
    2056             namelog=[filename_cmx([1:end-3]) 'log'];
     2066            [Rootbat,Filebat]=fileparts(filecell.nc.civ2{ifile,j});%output netcdf file (without extention)
     2067            namelog=[fullfile(Rootbat,Filebat) '.civ2.log'];
    20572068            par_civ2.Dt=num2str(time(num2_civ2(ifile),num_b_civ2(j))-time(num1_civ2(ifile),num_a_civ2(j)));
    20582069            par_civ2.T0=num2str((time(num2_civ1(ifile),num_b_civ2(j))+time(num1_civ2(ifile),num_a_civ2(j)))/2);
     
    21082119            %endTESTgrid
    21092120            i_cmd=i_cmd+1;
    2110             cmd_CIV2=CIV2_CMD(filename_cmx(1:end-4),namelog,par_civ2,sparam);
     2121            cmd_CIV2=CIV2_CMD(fullfile(Rootbat,Filebat),[],par_civ2,sparam);%creates the cmx file [fullfile(Rootbat,Filebat) '.civ2.cmx]
    21112122            if isequal(civAll,0)
     2123                flname=fullfile(Rootbat,Filebat);
    21122124                if(isunix)
    2113                     cmd=[cmd 'cp -f ' filename_cmx '2 ' filename_cmx '\n' cmd_CIV2 '\n'];
     2125                     cmd=[cmd 'cp -f ' flname '.civ2.cmx ' flname '.cmx\n' cmd_CIV2 '\n'];
    21142126                else
    2115                     filename_cmx=regexprep(filename_cmx,'\\','\\\\');
    2116                     cmd=[cmd 'copy /Y "' filename_cmx '2" "' filename_cmx '"\n' cmd_CIV2 '\n'];
     2127                    flname=regexprep(flname,'\\','\\\\');
     2128                    cmd=[cmd 'copy /Y "' flname '.civ2.cmx" "' flname '.cmx"\n' cmd_CIV2 '\n'];
    21172129                end
    21182130            else
     
    22532265            end
    22542266            super_cmd=[super_cmd cmd_str '\n'];         
    2255             %             eval(cmd_str);
    22562267            disp(cmd_str);
    22572268        end
     
    24782489subdir_civ1=get(handles.subdir_civ1,'String');%subdirectory subdir_civ1 for the netcdf output data
    24792490subdir_civ2=get(handles.subdir_civ2,'String');
    2480 if isequal(subdir_civ1,''),subdir_civ1='A'; end% put default subdir
     2491if isequal(subdir_civ1,''),subdir_civ1='CIV'; end% put default subdir
    24812492if isequal(subdir_civ2,''),subdir_civ2=subdir_civ1; end% put default subdir
    24822493currentdir=pwd;%store the current working directory
     
    27082719        %create the new subdir_civ2_new
    27092720        if ~exist(fullfile(Path_ima,subdir_civ2_new),'dir')
    2710             [xx,m2]=mkdir(subdir_civ2_new);
     2721            [xx,m2]=mkdir(fullfile(Path_ima,subdir_civ2_new));
    27112722            [xx,msg2] = fileattrib(subdir_civ2_new,'+w','g'); %yield writing access (+w) to user group (g)
    27122723            if ~isequal(m2,'')
     
    40434054
    40444055%changes : filename_cmx -> filename ( no extension )
    4045 
     4056% input namelog not used
    40464057if isequal(par.Dt,'0')
    40474058    par.Dt='1' ;%case of 'displacement' mode
     
    40864097% namelog=regexprep(namelog,'\\','\\\\');
    40874098if(isunix)
    4088     [Rootbat,Filebat,extbat]=fileparts(namelog);
    4089     ncName=fullfile(Rootbat,[ Filebat '.nc']);
    4090     cmd_CIV1=[sparam.Civ1Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file
    4091     cmd_CIV1=[cmd_CIV1 '\n' 'mv ' namelog  ' ' regexprep(namelog,'\.log','') '.civ1.log' '\n' 'chmod g+w ' ncName];
     4099%     filename
     4100%     namelog
     4101%     
     4102%     [Rootbat,Filebat,extbat]=fileparts(namelog);
     4103%     ncName=fullfile(Rootbat,[ Filebat '.nc']);
     4104    cmd_CIV1=[sparam.Civ1Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx
     4105    cmd_CIV1=[cmd_CIV1 '\n' 'mv ' filename '.log' ' ' filename '.civ1.log' '\n' 'chmod g+w ' filename '.nc'];%rename .log as .civ1.log and set the netcdf result file for group user writting
     4106    cmd_CIV1=[cmd_CIV1 '\n' 'mv ' filename '.cmx' ' ' filename '.civ1.cmx' '\n'];%rename .cmx as .civ1.cmx
    40924107else %Windows system
     4108    filename=regexprep(filename,'\\','\\\\');
    40934109    cmd_CIV1=['"' sparam.Civ1Bin '" -f "' filename '.cmx" >"' filename '.log"' ]; % redirect standard output to the log file
    40944110    cmd_CIV1=regexprep(cmd_CIV1,'\\','\\\\');
    40954111    namelog=regexprep(namelog,'\\','\\\\');
    4096     cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y "' namelog '" "' regexprep(namelog,'\.log','') '.civ1.log"'];
     4112    cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y "' filename '.log' '" "' filename '.civ1.log"'];
     4113    cmd_CIV1=[cmd_CIV1 '\n' 'copy /Y "' filename '.cmx' '" "' filename '.civ1.cmx"'];
    40974114end
    40984115
     
    41974214    par.Dt='1' ;%case of 'displacement' mode
    41984215end
    4199 
    42004216par.filename_ima_a=regexprep(par.filename_ima_a,'.png','');
    42014217par.filename_ima_b=regexprep(par.filename_ima_b,'.png','');% bug : .png appears two times ?
    4202 fid=fopen([filename '.cmx2'],'w');
     4218[fid,errormsg]=fopen([filename '.civ2.cmx'],'w');
     4219if isequal(fid,-1)
     4220    msgbox_uvmat('ERROR',errormsg)
     4221    cmd_CIV2='';
     4222    return
     4223end
    42034224fprintf(fid,['##############   CMX file' '\n' ]);
    42044225fprintf(fid,   ['FirstImage ' regexprep(par.filename_ima_a,'\\','\\\\') '\n' ]);% for windows compatibility
     
    42344255
    42354256if(isunix)
    4236     cmd_CIV2=[sparam.Civ2Bin ' -f ' filename  '.cmx >' filename '.log' ]; % redirect standard output to the log file
    4237     [Rootbat,Filebat,extbat]=fileparts(namelog);
    4238     ncName=fullfile(Rootbat,[ Filebat '.nc']);
    4239     cmd_CIV2=[cmd_CIV2 '\n' 'mv ' namelog  ' ' regexprep(namelog,'\.log','') '.civ2.log' '\n' 'chmod g+w ' ncName];
     4257%         cmd_CIV1=[sparam.Civ1Bin ' -f ' filename '.cmx >' filename '.log' ]; % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx
     4258%     cmd_CIV1=[cmd_CIV1 '\n' 'mv ' filename '.log' ' ' filename '.civ1.log' '\n' 'chmod g+w ' filename '.nc'];
     4259%     cmd_CIV1=[cmd_CIV1 '\n' 'mv ' filename '.cmx' ' ' filename '.civ1.cmx' '\n'];%rename .cmx as .civ1.cmx, the result file is named [filename '.nc'] by CIVx
     4260   
     4261    cmd_CIV2=[sparam.Civ2Bin ' -f ' filename  '.cmx >' filename '.log' ]; % redirect standard output to the log file, the result file is named [filename '.nc'] by CIVx
     4262    cmd_CIV2=[cmd_CIV2 '\n' 'mv ' filename '.log' ' ' filename '.civ2.log' '\n' 'chmod g+w ' filename '.nc'];
     4263    cmd_CIV2=[cmd_CIV2 '\n' 'mv ' filename '.cmx' ' ' filename '.civ2.cmx' '\n'];%rename .cmx as .civ2.cmx, the result file is named [filename '.nc'] by CIVx
     4264%     [Rootbat,Filebat,extbat]=fileparts(namelog);
     4265%     ncName=fullfile(Rootbat,[ Filebat '.nc']);
     4266%    cmd_CIV2=[cmd_CIV2 '\n' 'mv ' namelog  ' ' regexprep(namelog,'\.log','') '.civ2.log' '\n' 'chmod g+w ' ncName];
    42404267else
     4268    filename=regexprep(filename,'\\','\\\\');
    42414269    cmd_CIV2=['"' sparam.Civ2Bin '" -f "' filename  '.cmx" >"' filename '.log"' ]; % redirect standard output to the log file
    42424270    cmd_CIV2=regexprep(cmd_CIV2,'\\','\\\\');
    4243     namelog=regexprep(namelog,'\\','\\\\');
    4244     cmd_CIV2=[cmd_CIV2 '\n' 'copy /Y "' namelog '" "' regexprep(namelog,'\.log','') '.civ2.log"'];
     4271    cmd_CIV2=[cmd_CIV2 '\n' 'copy /Y "' filename '.log' '" "' filename '.civ2.log"'];
     4272     cmd_CIV2=[cmd_CIV2 '\n' 'copy /Y "' filename '.cmx' '" "' filename '.civ2.cmx"'];
    42454273end
    42464274
  • trunk/src/proj_field.m

    r173 r174  
    918918%-----------------------------------------------------------------
    919919
    920 %initialisation of the input parameters of the projection plane
    921 %-----------------------------------------------------------------
     920%% initialisation of the input parameters of the projection plane
    922921ProjMode='projection';%direct projection by default
    923922if isfield(ObjectData,'ProjMode'),ProjMode=ObjectData.ProjMode; end;
     
    948947NormVec_Y=cos(Phi)*sin(Theta);
    949948NormVec_Z=cos(Theta);
    950 
    951 % test for 3D fields
    952 test3D=0;
    953 if isfield(FieldData,'nb_dim')
    954     test3D=isequal(FieldData.nb_dim,3);
    955 end
    956 test3C=test3D; %default 3 vel components
    957949
    958950%mesh sizes DX and DY
     
    12481240        Coord_y=[];
    12491241        Coord_x=[];   
    1250         nb_dim=numel(size(DimValue));
     1242        nb_dim=numel(DimValue);
    12511243        for idim=1:nb_dim %loop on space dimensions
    12521244            test_interp(idim)=0;%test for coordiate interpolation (non regular grid), =0 by default
     
    12961288        if nb_dim==3
    12971289            DZ=abs(DCoord_min(1));
    1298             Coord_z=linspace(Coord{1}(1),Coord{1}(end),npz);
     1290            Coord_z=linspace(Coord{1}(1),Coord{1}(end),DimValue(1));
    12991291            test_direct_z=test_direct(1);
    13001292        end 
     
    13421334        % case with no rotation and interpolation
    13431335        if isequal(ProjMode,'projection') && isequal(Phi,0) && isequal(Theta,0) && isequal(Psi,0)
    1344             if ~testXMin && ~testXMax && ~testYMin && ~testYMax
     1336            if ~testXMin && ~testXMax && ~testYMin && ~testYMax && nb_dim==2
    13451337                ProjData=FieldData;
    13461338            else
     
    13671359                    Xbound(1)=Coord{2}(1)+DXinit*(min_ind2-1);
    13681360                end
     1361                if nb_dim==3 %TODO: to update
     1362                    min_ind3=ceil((Coord{1}(1)-ZMax)/DZinit)+1;
     1363                    max_ind2=floor((Coord{1}(2)-XMin)/DZinit)+1;
     1364                    Zbound(2)=Coord{1}(1)+DXinit*(max_ind2-1);
     1365                    Zbound(1)=Coord{1}(1)+DXinit*(min_ind2-1);
     1366                end
    13691367                min_ind1=max(min_ind1,1);% deals with margin (bound lower than the first index)
    13701368                min_ind2=max(min_ind2,1);
  • trunk/src/uvmat.m

    r163 r174  
    426426end
    427427[FileName, PathName] = uigetfile( ...
    428        {'*.xml;*.xls;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol;*.nc;*.cmx;*.fig;*.log;*.dat;*.bat;', ' (*.xml,*.xls,*.civ,*.jpg ,*.png, .tif, *.avi,*.vol,*.nc,*.cmx ,*.fig,*.log,*.dat,*.bat)';
     428       {'*.xml;*.xls;*.civ;*.png;*.jpg;*.tif;*.avi;*.AVI;*.vol;*.nc;*.cmx;*.fig;*.log;*.dat;*.bat;', ' (*.xml,*.xls,*.civ,*.jpg ,*.png, .tif, *.avi,*.vol,*.nc,*.cmx,*.fig,*.log,*.dat,*.bat)';
    429429       '*.xml',  '.xml files '; ...
    430430        '*.xls',  '.xls files '; ...
     
    437437        '*.nc','.netcdf files'; ...
    438438        '*.cdf','.netcdf files'; ...
    439         '*.cmx','.cmx text files';...
    440         '*.cmx2','.cmx2 text files';...
     439        '*.cmx','.cmx text files ';...
    441440        '*.fig','.fig files (matlab fig)';...
    442441        '*.log','.log text files ';...
     
    22052204%read images
    22062205if ~isempty(filename) && isequal(FieldName,'image')
     2206    Npz=1;%default
    22072207     switch FileType
    22082208        case 'movie'
     
    22232223        case 'vol'
    22242224            A=imread(filename);
     2225            if isfield(UvData.XmlData,'Npy')
     2226                Npz=size(A,1)/UvData.XmlData.Npy;
     2227                A=reshape(A,Npz,UvData.XmlData.Npy,UvData.XmlData.Npx);
     2228            end
    22252229        case 'multimage'
    22262230            A=imread(filename,num_i1);
     
    22352239    Field{1}.AName='image';
    22362240    Field{1}.ListVarName={'AY','AX','A'}; %
    2237     if size(A,3)==3;%color
    2238         Field{1}.VarDimName={'AY','AX',{'AY','AX','rgb'}}; %
     2241    if ndims(A)==3
     2242        if Npz==1;%color
     2243             Field{1}.VarDimName={'AY','AX',{'AY','AX','rgb'}}; %
     2244             Field{1}.AY=[npxy(1)-0.5 0.5];
     2245             Field{1}.AX=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers
     2246        else
     2247            Field{1}.ListVarName=['AZ' Field{1}.ListVarName];
     2248            Field{1}.VarDimName={'AZ','AY','AX',{'AZ','AY','AX'}};
     2249            Field{1}.AZ=[0.5 npxy(1)-0.5];
     2250            Field{1}.AY=[npxy(2)-0.5 0.5];
     2251            Field{1}.AX=[0.5 npxy(3)-0.5]; % coordinates of the first and last pixel centers
     2252        end
    22392253    else
    22402254        Field{1}.VarDimName={'AY','AX',{'AY','AX'}}; %
    2241     end
    2242     Field{1}.AY=Rangy;
    2243     Field{1}.AX=Rangx;
     2255        Field{1}.AY=[npxy(1)-0.5 0.5];
     2256       Field{1}.AX=[0.5 npxy(2)-0.5]; % coordinates of the first and last pixel centers
     2257    end
    22442258    Field{1}.A=A;
    2245    % Field{1}.CoordType='px'; %used for mouse_motion
    22462259    Field{1}.CoordUnit='pixel'; %used for mouse_motion
    22472260end
     
    24882501test_x=0;
    24892502test_z=0;% test for unstructured z coordinate
    2490 UvData.ZMax=0;
    2491 UvData.ZMin=0;%default
     2503% UvData.ZMax=0;
     2504% UvData.ZMin=0;%default
    24922505%UvData.Mesh=1; %default
    24932506[UvData.Field,errormsg]=check_field_structure(UvData.Field);
     
    25222535    YName=UvData.Field.ListVarName{VarType{imax}.coord(2)};
    25232536    XName=UvData.Field.ListVarName{VarType{imax}.coord(3)};
    2524 end
    2525 
     2537    eval(['ZMax=max(UvData.Field.' ZName ');'])
     2538    eval(['ZMin=min(UvData.Field.' ZName ');'])
     2539end
    25262540eval(['XMax=max(UvData.Field.' XName ');'])
    25272541eval(['XMin=min(UvData.Field.' XName ');'])
     
    25652579UvData.Field.YMax=XMax;
    25662580UvData.Field.YMin=XMin;
    2567 if test_z
     2581if NbDim==3
    25682582    UvData.Field.ZMax=ZMax;
    25692583    UvData.Field.ZMin=ZMin;
     
    26422656if NbDim==3 && UvData.NewSeries
    26432657    UvData.Object{1}.NbDim=UvData.NbDim;%test for 3D objects
    2644     UvData.Object{1}.RangeZ=Field.Mesh;%main plotting plane
    2645     UvData.Object{1}.Coord(1,3)=(UvData.ZMin+UvData.ZMax)/2;%section at a middle plane chosen
     2658    UvData.Object{1}.RangeZ=UvData.Field.Mesh;%main plotting plane
     2659    UvData.Object{1}.Coord(1,3)=(UvData.Field.ZMin+UvData.Field.ZMax)/2;%section at a middle plane chosen
    26462660    UvData.Object{1}.Phi=0;
    26472661    UvData.Object{1}.Theta=0;
     
    26492663    UvData.Object{1}.HandlesDisplay=plot(0,0,'Tag','proj_object');% A REVOIR 
    26502664    PlotHandles=get_plot_handles(handles);
    2651     ZBounds(1)=UvData.ZMin; %minimum for the Z slider
    2652     ZBounds(2)=UvData.ZMax;%maximum for the Z slider
     2665    ZBounds(1)=UvData.Field.ZMin; %minimum for the Z slider
     2666    ZBounds(2)=UvData.Field.ZMax;%maximum for the Z slider
    26532667    UvData.Object{1}.Name='1-PLANE';
    26542668    UvData.Object{1}.enable_plot=1;
Note: See TracChangeset for help on using the changeset viewer.