Changeset 313


Ignore:
Timestamp:
Dec 1, 2011, 12:44:42 PM (12 years ago)
Author:
sommeria
Message:

bug reapirs in view of vector colors and grid in civ

Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/civ.m

    r312 r313  
    342342set(handles.RootName,'String',RootName)
    343343set(handles.RootName,'BackgroundColor',[1 1 0])%paint RootName edit box in yellow to indicate that the file input is proceeding
    344 num_i1=str2double(i1_str);
    345 num_i2=str2double(i2_str);
    346 num_j1=str2double(j1_str);
    347 num_j2=str2double(j2_str);
    348 num_ref_i=num_i1;%efaulmt ref index
    349 num_ref_j=num_j1;
     344i1=str2double(i1_str);
     345i2=str2double(i2_str);
     346j1=str2double(j1_str);
     347j2=str2double(j2_str);
     348num_ref_i=i1;%efaulmt ref index
     349num_ref_j=j1;
    350350browse.incr_pair=[0 0];%default
    351351
     
    356356else %case of netcdf input file, look for corresponding images
    357357    nom_type_nc=nom_type_input;
    358     if ~isempty(num_i2)
    359         num_ref_i=floor((num_ref_i+num_i2)/2);% reference image number corresponding to the file
    360         browse.incr_pair(1)=num_i2-num_i1;
     358    if ~isnan(i2)
     359        num_ref_i=floor((num_ref_i+i2)/2);% reference image number corresponding to the file
     360        browse.incr_pair(1)=i2-i1;
    361361        browse.incr_pair(2)=0;
    362362    end
     
    378378    end
    379379    for ilist=1:numel(dirima)
    380         [pp,ff,i1,i2,j1,j2,ext_list,nom_type_list]=name2display(dirima(ilist).name);
     380        [pp,ff,i1_str,i2_str,j1_str,j2_str,ext_list,nom_type_list]=name2display(dirima(ilist).name);
    381381        form=imformats(ext_list(2:end));
    382382        if ~isempty(form)% if the extension corresponds to an image format recognized by Matlab
    383383            ext_ima=ext_list;
    384384            nom_type_ima=nom_type_list;
    385             num_i1=str2double(i1);
    386             num_j1=str2double(j1);
    387             num_i2=str2double(i2);
    388             num_j2=str2double(j2);
    389            
     385            i1=str2double(i1_str);
     386            j1=str2double(j1_str);
     387            i2=str2double(i2_str);
     388            j2=str2double(j2_str);         
    390389            % set the range of fields (1:1 by default) and selected pair
    391             if isequal(num_i2,num_i1)||isnan(num_i2)
    392                 num_ref_i=num_i1;
     390            if isequal(i2,i1)||isnan(i2)
     391                num_ref_i=i1;
    393392            else
    394                 num_ref_i=floor((num_i1+num_i2)/2);
    395                 browse.incr_pair(1)=num_i2-num_i1;
     393                num_ref_i=floor((i1+i2)/2);
     394                browse.incr_pair(1)=i2-i1;
    396395                browse.incr_pair(2)=0;
    397396            end
    398             if isequal(num_j1,num_j2)||isnan(num_j2)
    399                 if isnan(num_j1)
     397            if isequal(j1,j2)||isnan(j2)
     398                if isnan(j1)
    400399                    num_ref_j=1;
    401400                else
    402                     num_ref_j=num_j1;
     401                    num_ref_j=j1;
    403402                end
    404403            else
    405                 num_ref_j=floor((num_j1+num_j2)/2);
    406                 browse.incr_pair(2)=num_j2-num_j1;
     404                num_ref_j=floor((j1+j2)/2);
     405                browse.incr_pair(2)=j2-j1;
    407406            end
    408407            break
     
    937936%-----------------------------------------------------------------------
    938937errormsg='';%default
    939 %% read the civ GUI
     938
     939%% read the input parameters from the  GUI civ
    940940Param=read_GUI(handles.civ);
    941941
     
    943943operations={'Civ1','Fix1','Patch1','Civ2','Fix2','Patch2'};
    944944box_test=[Param.CheckCiv1 Param.CheckFix1 Param.CheckPatch1 Param.CheckCiv2 Param.CheckFix2 Param.CheckPatch2];
    945 
    946945index_first=find(box_test==1,1);
    947946if isempty(index_first)
     
    989988    status_Callback(hObject, eventdata, handles)
    990989end
    991 
    992 %% set the list of files and check them
    993 display('checking the files...')
    994 [ref_i,ref_j,errormsg]=find_ref_indices(handles);
    995 if ~isempty(errormsg)
    996     return
    997 end
    998 [filecell,num1_civ1,num2_civ1,num_a_civ1,num_b_civ1,num1_civ2,num2_civ2,num_a_civ2,num_b_civ2,nom_type_nc,xx,yy,compare]=...
    999     set_civ_filenames(handles,ref_i,ref_j,box_test);
    1000 % ADDED
    1001    [Rootbat,Filebat]=fileparts(filecell.nc.civ1{1,1});%output netcdf file (without extention)
    1002 %ADDED
    1003 set(handles.civ,'UserData',filecell);%store for futur use of status callback
    1004 if isempty(filecell)% (error message displayed in fct set_civ_filenames)
    1005     return
    1006 end
    1007 nbfield=numel(num1_civ1);
    1008 nbslice=numel(num_a_civ1);
    1009990
    1010991%% read the PARAM.xml file to get the binaries (and batch_mode if batch)
     
    10981079display('files OK, processing...')
    10991080
     1081%% set the list of files and check them
     1082display('checking the files...')
     1083[ref_i,ref_j,errormsg]=find_ref_indices(handles);
     1084if ~isempty(errormsg)
     1085    return
     1086end
     1087[filecell,i1_civ1,i2_civ1,j1_civ1,j2_civ1,i1_civ2,i2_civ2,j1_civ2,j2_civ2,nom_type_nc,xx,yy,compare]=...
     1088    set_civ_filenames(handles,ref_i,ref_j,box_test);
     1089Rootbat=fileparts(filecell.nc.civ1{1,1});%output netcdf file (without extention)
     1090set(handles.civ,'UserData',filecell);%store for futur use of status callback
     1091if isempty(filecell)% (error message displayed in fct set_civ_filenames)
     1092    return
     1093end
     1094nbfield=numel(i1_civ1);
     1095nbslice=numel(j1_civ1);
    11001096
    11011097%% MAIN LOOP
     
    11181114                end
    11191115            case 'CivAll'
    1120                 %         if CivAll
    11211116                CivAllxml=xmltree;% xml contents,  all parameters
    11221117                CivAllCmd='';
    11231118                CivAllxml=set(CivAllxml,1,'name','CivDoc');
    11241119        end
    1125        
    1126        
     1120           
    11271121        % define output file name
    11281122        if Param.CheckCiv2==1 || Param.CheckFix2==1 || Param.CheckPatch2==1
     
    11371131            Param.Civ1.filename_ima_a=filecell.ima1.civ1{ifile,j};
    11381132            Param.Civ1.filename_ima_b=filecell.ima2.civ1{ifile,j};
    1139             if size(time,1)>=num2_civ1(ifile) && size(time,2)>=num_b_civ1(ifile)
    1140                 Param.Civ1.Dt=(time(num2_civ1(ifile),num_b_civ1(j))-time(num1_civ1(ifile),num_a_civ1(j)));
    1141                 Param.Civ1.T0=((time(num2_civ1(ifile),num_b_civ1(j))+time(num1_civ1(ifile),num_a_civ1(j)))/2);
     1133            if size(time,1)>=i2_civ1(ifile) && size(time,2)>=j2_civ1(j)
     1134                Param.Civ1.Dt=(time(i2_civ1(ifile),j2_civ1(j))-time(i1_civ1(ifile),j1_civ1(j)));
     1135                Param.Civ1.T0=((time(i2_civ1(ifile),j2_civ1(j))+time(i1_civ1(ifile),j1_civ1(j)))/2);
    11421136            else
    11431137                Param.Civ1.Dt=1;
    11441138                Param.Civ1.T0=0;
    11451139            end
    1146             Param.Civ1.term_a=num2stra(num_a_civ1(j),nom_type_nc);%UTILITE?
    1147             Param.Civ1.term_b=num2stra(num_b_civ1(j),nom_type_nc);%
     1140            Param.Civ1.term_a=num2stra(j1_civ1(j),nom_type_nc);%UTILITE?
     1141            Param.Civ1.term_b=num2stra(j2_civ1(j),nom_type_nc);%
    11481142            Param.Civ1.pxcmx=1; %velocities are expressed in pixel dispalcement
    11491143            Param.Civ1.pxcmy=1;     
     
    11601154                    maskbase=[filecell.filebase '_' Param.Civ1.MaskName]; %
    11611155                    nbslice_mask=str2double(maskdispl(1:end-4)); %
    1162                     num1_mask=mod(num1_civ1(ifile)-1,nbslice_mask)+1;
    1163                     Param.Civ1.MaskName=name_generator(maskbase,num1_mask,1,'.png','_i');
     1156                    i1_mask=mod(i1_civ1(ifile)-1,nbslice_mask)+1;
     1157                    Param.Civ1.MaskName=name_generator(maskbase,i1_mask,1,'.png','_i');
    11641158                    if exist(Param.Civ1.MaskName,'file')
    11651159                        Param.Civ1.maskflag='y';
     
    11741168            end
    11751169           
    1176             % read grid parameters=
     1170            % read grid parameters
    11771171            if Param.Civ1.CheckGrid
    1178                 Param.Civ1.GridFlag='y';
     1172%                 Param.Civ1.GridFlag='y';
    11791173                if isequal(Param.Civ1.GridName(end-3:end),'grid')
    11801174                    nbslice_grid=str2double(Param.Civ1.GridName(1:end-4)); %
    11811175                    if ~isnan(nbslice_grid)
    1182                         num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1;
    1183                         Param.Civ1.GridName=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')];
     1176                        i1_grid=mod(i1_civ1(ifile)-1,nbslice_grid)+1;
     1177                        Param.Civ1.GridName=[filecell.filebase '_' name_generator(Param.Civ1.GridName,i1_grid,1,'.grid','_i')];
    11841178                        if ~exist(Param.Civ1.GridName,'file')
    11851179                            msgbox_uvmat('ERROR','grid file absent for civ1')
     
    11891183                    end
    11901184                end
    1191             else
    1192                 Param.Civ1.GridName='noFile use default';
    1193                 Param.Civ1.GridFlag='n';
     1185%            else
     1186%                 Param.Civ1.GridName='noFile use default';
     1187%                 Param.Civ1.GridFlag='n';
    11941188            end
    11951189           
     
    12191213                    cmd=[cmd...
    12201214                        cmd_fix(filecell.nc.civ1{ifile,j},Param,'Fix1') '\n'];
    1221                 case 'CivAll'
     1215                case 'CivAll'%to abandon
    12221216                    fix1.inputFileName=filecell.nc.civ1{ifile,j} ;
    12231217                    fix1.fi1=num2str(param.fix1.flagindex1(1));
     
    12571251                            nbslice_grid=str2double(gridname(1:end-4)); %
    12581252                            if ~isnan(nbslice_grid)
    1259                                 num1_grid=mod(num1_civ1(ifile)-1,nbslice_grid)+1;
    1260                                 patch1.gridPatch=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')];
     1253                                i1_grid=mod(i1_civ1(ifile)-1,nbslice_grid)+1;
     1254                                patch1.gridPatch=[filecell.filebase '_' name_generator(gridname,i1_grid,1,'.grid','_i')];
    12611255                                if ~exist(patch1.gridPatch,'file')
    12621256                                    msgbox_uvmat('ERROR','grid file absent for patch1')
     
    12901284            Param.Civ2.filename_ima_a=filecell.ima1.civ2{ifile,j};
    12911285            Param.Civ2.filename_ima_b=filecell.ima2.civ2{ifile,j};
    1292             if size(time,1)>=num2_civ2(ifile) && size(time,2)>=num_b_civ2(ifile)
    1293                 Param.Civ2.Dt=num2str(time(num2_civ2(ifile),num_b_civ2(j))-time(num1_civ2(ifile),num_a_civ2(j)));
    1294                 Param.Civ2.T0=num2str((time(num2_civ2(ifile),num_b_civ2(j))+time(num1_civ2(ifile),num_a_civ2(j)))/2);
     1286            if size(time,1)>=i2_civ2(ifile) && size(time,2)>=j2_civ2(j)
     1287                Param.Civ2.Dt=num2str(time(i2_civ2(ifile),j2_civ2(j))-time(i1_civ2(ifile),j1_civ2(j)));
     1288                Param.Civ2.T0=num2str((time(i2_civ2(ifile),j2_civ2(j))+time(i1_civ2(ifile),j1_civ2(j)))/2);
    12951289            else
    12961290                Param.Civ2.Dt=1;
    12971291                Param.Civ2.T0=0;
    12981292            end
    1299             Param.Civ2.term_a=num2stra(num_a_civ2(j),nom_type_nc);
    1300             Param.Civ2.term_b=num2stra(num_b_civ2(j),nom_type_nc);
     1293            Param.Civ2.term_a=num2stra(j1_civ2(j),nom_type_nc);
     1294            Param.Civ2.term_b=num2stra(j2_civ2(j),nom_type_nc);
    13011295            Param.Civ2.filename_nc1=filecell.nc.civ1{ifile,j};
    13021296            Param.Civ2.filename_nc1(end-2:end)=[]; % remove '.nc'
     
    13111305                    maskbase=[filecell.filebase '_' maskdispl]; %
    13121306                    nbslice_mask=str2double(maskdispl(1:end-4)); %
    1313                     num1_mask=mod(num1_civ2(ifile)-1,nbslice_mask)+1;
    1314                     Param.Civ2.MaskName=name_generator(maskbase,num1_mask,1,'.png','_i');
     1307                    i1_mask=mod(i1_civ2(ifile)-1,nbslice_mask)+1;
     1308                    Param.Civ2.MaskName=name_generator(maskbase,i1_mask,1,'.png','_i');
    13151309                    if exist(Param.Civ2.MaskName,'file')
    13161310                        Param.Civ2.MaskFlag='y';
     
    13291323                if ~isnan(nbslice_grid)
    13301324                    Param.Civ2.GridFlag='y';
    1331                     num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1;
    1332                     Param.Civ2.GridName=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')];
    1333                     if exist(Param.Civ2.GridName,'file')
    1334                         Param.Civ2.GridFlag='y';
    1335                     else
    1336                         Param.Civ2.GridName='noFile use default';
    1337                         Param.Civ2.GridFlag='n';
    1338                     end
     1325                    i1_grid=mod(i1_civ2(ifile)-1,nbslice_grid)+1;
     1326                    Param.Civ2.GridName=[filecell.filebase '_' name_generator(gridname,i1_grid,1,'.grid','_i')];
     1327%                     if exist(Param.Civ2.GridName,'file')
     1328%                         Param.Civ2.GridFlag='y';
     1329%                     else
     1330%                         Param.Civ2.GridName='noFile use default';
     1331%                         Param.Civ2.GridFlag='n';
     1332%                     end
    13391333                elseif exist(gridname,'file')
    1340                     Param.Civ2.GridFlag='y';
    1341                 else
    1342                     Param.Civ2.GridName='noFile use default';
    1343                     Param.Civ2.GridFlag='n';
     1334%                     Param.Civ2.GridFlag='y';
     1335%                 else
     1336%                     Param.Civ2.GridName='noFile use default';
     1337%                     Param.Civ2.GridFlag='n';
    13441338                end
    1345             else
    1346                 Param.Civ2.GridName='noFile use default';
    1347                 Param.Civ2.GridFlag='n';
     1339%             else
     1340%                 Param.Civ2.GridName='noFile use default';
     1341%                 Param.Civ2.GridFlag='n';
    13481342            end
    13491343%             A=imread(filecell.ima1.civ2{1,1});%read the first image to get the size
    13501344%             sizim=size(A);
    1351             Param.Civ2.ImageInfo=imfinfo(filecell.ima1.civ1{1,1});%read the first image to get the size
     1345            Param.Civ2.ImageInfo=imfinfo(filecell.ima1.civ2{1,1});%read the first image to get the size
     1346            % TODO: case of movie
    13521347%             Param.Civ2.npx=(sizim(2));
    13531348%             Param.Civ2.npy=(sizim(1));     
     
    13991394        %CheckPatch2
    14001395        if Param.CheckPatch2==1
     1396           
    14011397            switch CivMode
     1398               
    14021399                case 'CivX'
    14031400                    cmd=[cmd...
    14041401                        cmd_patch(filecell.nc.civ1{ifile,j},Param,'Patch2') '\n'];
     1402                   
    14051403                case 'CivAll'
    14061404                    patch2.inputFileName=filecell.nc.civ1{ifile,j} ;
     
    14151413                            nbslice_grid=str2double(gridname(1:end-4)); %
    14161414                            if ~isnan(nbslice_grid)
    1417                                 num1_grid=mod(num1_civ2(ifile)-1,nbslice_grid)+1;
    1418                                 patch2.gridPatch=[filecell.filebase '_' name_generator(gridname,num1_grid,1,'.grid','_i')];
     1415                                i1_grid=mod(i1_civ2(ifile)-1,nbslice_grid)+1;
     1416                                patch2.gridPatch=[filecell.filebase '_' name_generator(gridname,i1_grid,1,'.grid','_i')];
    14191417                                if ~exist(patch2.gridPatch,'file')
    14201418                                    msgbox_uvmat('ERROR','grid file absent for patch2')
     
    14471445       
    14481446        switch CivMode
     1447           
    14491448            case {'CivX','CivAll'}
    14501449                if isequal(CivMode,'CivAll')
    14511450                    save(CivAllxml,[OutputFile '.xml']);
    14521451                    cmd=[cmd sparam.CivBin ' -f ' OutputFile '.xml '  CivAllCmd ' >' OutputFile '.log' '\n'];
    1453                 end
    1454                
     1452                end             
    14551453                % create the .bat file used in run or batch
    14561454                filename_bat=[OutputFile '.bat'];
     
    14611459                end
    14621460                fprintf(fid,cmd);
    1463                 fclose(fid);
    1464                
     1461                fclose(fid);           
    14651462                if isunix
    14661463                    system(['chmod +x ' filename_bat]);
    1467                 end
    1468                
     1464                end             
    14691465                batch_file_list{length(batch_file_list)+1}=filename_bat;
    14701466               
     
    14831479end
    14841480
    1485 if batch
    1486     switch batch_mode                       
     1481if batch 
     1482    switch batch_mode   
     1483       
    14871484        case 'sge'
    14881485            for p=1:length(batch_file_list)
     
    14901487                display(cmd);eval(cmd);
    14911488            end
     1489           
    14921490        case 'oar_old'
    14931491                for p=1:length(batch_file_list)
     
    14961494                    '-l "/core=1+{type = ''smalljob''}/licence=1,walltime=00:60:00"   ' batch_file_list{p}];
    14971495                display(oar_command);eval(oar_command);
    1498                 end   
     1496                end
    14991497       case 'oar' %oar-dispatch.pl
     1498           
     1499                filename_joblist=fullfile(Rootbat,'job_list.txt');
     1500                fid=fopen(filename_joblist,'w');
     1501                walltime_onejob=600;%seconds
     1502                for p=1:length(batch_file_list)
     1503                    oar_command=['oarsub -n CIVX '...
     1504                   '-E ' regexprep(batch_file_list{p},'\.bat\>','.errors') ' -O ' regexprep(batch_file_list{p},'\.bat\>','.log ')...
     1505                        '-l "/core=1,walltime=' datestr(walltime_onejob/86400,13) '"   ' batch_file_list{p}];
     1506                    fprintf(fid,[oar_command '\n']);
     1507                end
     1508                fclose(fid);
     1509                ncores=36;
     1510                oar_command=['oarsub -t container -n civx-container '...
     1511                    '-l /core=' num2str(ncores)...
     1512                    ',walltime=' datestr(1.05*walltime_onejob/86400*max(length(batch_file_list),ncores)/ncores,13)...
     1513                    ' "oar-dispatch -f ' filename_joblist '"'];
     1514                filename_oarcommand=fullfile(Rootbat,'oar_command');
     1515                fid=fopen(filename_oarcommand,'w');
     1516                fprintf(fid,[oar_command '\n']);
     1517                fclose(fid);
     1518                display(oar_command);
     1519                eval(['! . ' filename_oarcommand])
     1520               
     1521        case 'oar_mpi'
     1522                filename_joblist=fullfile(Rootbat,'job_list.txt');
     1523                fid=fopen(filename_joblist,'w');
     1524
     1525                for p=1:length(batch_file_list)
     1526                    fprintf(fid,[batch_file_list{p} '\n']);
     1527                end
     1528                fclose(fid)
     1529                text_oarscript=[...
     1530                    '#!/bin/bash \n'...
     1531                    '#OAR -n Mylauncher \n'...
     1532                    '#OAR -l node=4/core=5,walltime=0:15:00 \n'...
     1533                    '#OAR -E stderrfile.log \n'...
     1534                    '#OAR -O stdoutfile.log \n'...
     1535                    '# ========================================================= \n'...
     1536                    '# This simple program launch a multinode parallel OpenMPI mpilauncher \n'...
     1537                    '# application for coriolis PIV post-processing. \n'...
     1538                    '# OAR uses oarshmost wrapper to propagate the user environement. \n'...
     1539                    '# This wrapper assert that the user has the same environment on all the \n'...
     1540                    '# allocated nodes (basic behavior needed by most MPI applications).  \n'...
     1541                    '# \n'...
     1542                    '# REQUIREMENT: \n'...
     1543                    '# the oarshmost wrapper should be installed in $HOME/bin directory. \n'...
     1544                    '# If a different location is used, change the line following the comment "Bidouille" \n'...
     1545                    '# ========================================================= \n'...
     1546                    '#   USER should only modify these 2 lines  \n'...
     1547                    'WORKDIR=/home/users/gostiaux/tmp/begou \n'...
     1548                    'COMMANDE="/home/users/gostiaux/tmp/begou/mpilauncher  -f ' filename_joblist '" \n'...
     1549                    '# ========================================================= \n'...
     1550                    '# DO NOT MODIFY the FOLOWING LINES. (or be carefull) \n'...
     1551                    'echo "job starting on: "`hostname` \n'...
     1552                    'MPINODES="-host `tr [\\\\\\n] [,] <$OAR_NODEFILE |sed -e "s/,$/ /"`" \n'...
     1553                    'NCPUS=`cat $OAR_NODEFILE |wc -l` \n'...
     1554                    '#========== Bidouille ============== \n'...
     1555                    'export OMPI_MCA_plm_rsh_agent=$HOME/tmp/begou/oarshmost \n'...
     1556                    'cd $WORKDIR \n'...
     1557                    'CMD="mpirun -np $NCPUS  -wdir $WORKDIR $MPINODES $COMMANDE" \n'...
     1558                    'echo "I run: $CMD"  \n'...
     1559                    '$CMD \n'...
     1560                    'echo "job ending" \n'...
     1561                    ];
     1562%                 oarsub -S ./oar.sub
     1563                filename_oarscript=fullfile(Rootbat,'oar_command');
     1564                fid=fopen(filename_oarscript,'w');
     1565                fprintf(fid,[text_oarscript]);
     1566                fclose(fid);
     1567                eval(['!chmod +x  ' filename_oarscript]);
     1568                eval(['!oarsub -S ' filename_oarscript]);
     1569               
     1570        case 'oar_new' % to be develloped with Patrick Begou
     1571                filename_joblist=fullfile(Rootbat,'job_list.txt');
     1572                fid=fopen(filename_superbat,'w');
     1573                if fid==-1
     1574                    msgbox_uvmat('ERROR',['cannot create the command file ' filename_superbat])
     1575                    return
     1576                end
     1577                for p=1:length(batch_file_list)
     1578                    fprintf(fid,[batch_file_list{p} '\n']);
     1579                end
     1580                fclose(fid);
     1581                walltime=datestr(length(super_cmd)*10/24/60,13);
     1582                eval(  ['!oarsub -n CIVX -q nicejob -l "/core=1+{type = ''smalljob''}/licence=1,walltime=' walltime '"   ' filename_superbat]);
    15001583           oar_modes={'oar-dispatch','mpilauncher'};
    15011584           text={'Batch processing on servcalcul3 LEGI';...
     
    16001683        end
    16011684        system([filename_superbat ' &']);% execute main commmand
    1602     end
    1603    
     1685    end
    16041686end
    16051687
     
    40684150fprintf(fid,   ['SearchBoxeSize ' num2str(Param.Civ1.Searchx) ' ' num2str(Param.Civ1.Searchy) '\n' ]);
    40694151fprintf(fid,   ['RO ' num2str(Param.Civ1.Rho) '\n' ]);
    4070 fprintf(fid,   ['GridSpacing ' num2str(Param.Civ1.Dx) ' ' num2str(Param.Civ1.Dy) '\n' ]);
     4152if isfield(Param.Civ1,'GridName')
     4153    fprintf(fid,   ['GridSpacing ' '25' ' ' '25' '\n' ]);
     4154else
     4155    fprintf(fid,   ['GridSpacing ' num2str(Param.Civ1.Dx) ' ' num2str(Param.Civ1.Dy) '\n' ]);
     4156end
    40714157fprintf(fid,   ['XX 1.0' '\n' ]);
    40724158fprintf(fid,   ['Dt_TO ' num2str(Param.Civ1.Dt) ' ' num2str(Param.Civ1.T0) '\n' ]);
     
    40744160fprintf(fid,  ['XX 1' '\n' ]);
    40754161fprintf(fid,   ['ShiftXY ' num2str(Param.Civ1.Shiftx) ' '  num2str(Param.Civ1.Shifty) '\n' ]);
    4076 fprintf(fid,  ['Grid ' Param.Civ1.GridFlag '\n' ]);
    4077 fprintf(fid,   ['GridName ' regexprep(Param.Civ1.GridName,'\\','\\\\') '\n' ]);
     4162if isfield(Param.Civ1,'GridName')
     4163    fprintf(fid,  ['Grid ' 'y' '\n' ]);
     4164    fprintf(fid,   ['GridName ' regexprep(Param.Civ1.GridName,'\\','\\\\') '\n' ]);
     4165else
     4166    fprintf(fid,  ['Grid ' 'n' '\n' ]);
     4167    fprintf(fid,   ['GridName ' 'noFile use default' '\n' ]);
     4168end
    40784169fprintf(fid,   ['XX 85' '\n' ]);
    40794170fprintf(fid,   ['XX 1.0' '\n' ]);
     
    41894280fprintf(fid, ['SearchBoxeSize ' num2str(Param.Civ2.Bx) ' ' num2str(Param.Civ2.By) '\n']);
    41904281fprintf(fid, ['RO ' num2str(Param.Civ2.Rho) '\n']);
    4191 fprintf(fid, ['GridSpacing ' num2str(Param.Civ2.Dx) ' ' num2str(Param.Civ2.Dy) '\n']);
     4282if isfield(Param.Civ2,'GridName')
     4283    fprintf(fid,   ['GridSpacing ' '25' ' ' '25' '\n' ]);
     4284else
     4285    fprintf(fid,   ['GridSpacing ' num2str(Param.Civ2.Dx) ' ' num2str(Param.Civ2.Dy) '\n' ]);
     4286end
     4287% fprintf(fid, ['GridSpacing ' num2str(Param.Civ2.Dx) ' ' num2str(Param.Civ2.Dy) '\n']);
    41924288fprintf(fid, ['XX 1.0' '\n' ]);
    41934289fprintf(fid, ['Dt_TO ' num2str(Param.Civ2.Dt) ' ' num2str(Param.Civ2.T0) '\n' ]);
     
    41954291fprintf(fid, ['XX 1' '\n' ]);
    41964292fprintf(fid, 'ShiftXY 0 0\n');
    4197 fprintf(fid, ['Grid ' Param.Civ2.GridFlag '\n' ]);
    4198 fprintf(fid, ['GridName ' regexprep(Param.Civ2.GridName,'\\','\\\\') '\n']);
     4293if isfield(Param.Civ2,'GridName')
     4294    fprintf(fid,  ['Grid ' 'y' '\n' ]);
     4295    fprintf(fid,   ['GridName ' regexprep(Param.Civ2.GridName,'\\','\\\\') '\n' ]);
     4296else
     4297    fprintf(fid,  ['Grid ' 'n' '\n' ]);
     4298    fprintf(fid,   ['GridName ' 'noFile use default' '\n' ]);
     4299end
     4300% fprintf(fid, ['Grid ' Param.Civ2.GridFlag '\n' ]);
     4301% fprintf(fid, ['GridName ' regexprep(Param.Civ2.GridName,'\\','\\\\') '\n']);
    41994302fprintf(fid, ['XX 85' '\n' ]);
    42004303fprintf(fid, ['XX 1.0' '\n' ]);
  • trunk/src/plot_field.m

    r294 r313  
    524524        else
    525525            test_vec=1;
    526             eval(['vec_U=Data.' Data.ListVarName{ivar_U} ';'])
    527             eval(['vec_V=Data.' Data.ListVarName{ivar_V} ';'])
     526            vec_U=Data.(Data.ListVarName{ivar_U});
     527            vec_V=Data.(Data.ListVarName{ivar_V});
    528528            if ~isempty(ivar_X) && ~isempty(ivar_Y)% 2D field (with unstructured coordinates or structured ones (then ivar_X and ivar_Y empty)
    529529                XName=Data.ListVarName{ivar_X};
     
    552552            if ~isempty(ivar_F)%~(isfield(PlotParam.Vectors,'HideWarning')&& isequal(PlotParam.Vectors.HideWarning,1))
    553553                if test_vec
    554                     eval(['vec_F=Data.' Data.ListVarName{ivar_F} ';']) % warning flags for  dubious vectors
     554                    vec_F=Data.(Data.ListVarName{ivar_F}); % warning flags for  dubious vectors
    555555                    if  ~(isfield(PlotParam.Vectors,'CheckHideWarning') && isequal(PlotParam.Vectors.CheckHideWarning,1))
    556556                        test_black=1;
     
    560560            if ~isempty(ivar_FF) %&& ~test_false
    561561                if test_vec% TODO: deal with FF for structured coordinates
    562                     eval(['vec_FF=Data.' Data.ListVarName{ivar_FF} ';']) % flags for false vectors
     562                    vec_FF=Data.(Data.ListVarName{ivar_FF}); % flags for false vectors
    563563                end
    564564            end
  • trunk/src/set_col_vec.m

    r102 r313  
    11%'set_col_vec': sets the color code for vectors depending on a scalar vec_C and parameters given by the struct colcode
    2 %function [colorlist,col_vec,minC,colcode1,colcode2,maxC]=colvec(colcode,vec_C)
     2%function [colorlist,col_vec,minC,ColCode1,ColCode2,maxC]=colvec(colcode,vec_C)
    33%OUTPUT
    44%colorlist(nb,3); %list of nb colors
    55%col_vec, size=[length(vec_C),3)];%list of color indices corresponding to vec_C
    66%minC, maxC: min and max of vec_C
    7 %colcode1, colcode2: absolute threshold in vec_C corresponding to colcode.colcode1 and colcode.colcode2
     7%ColCode1, ColCode2: absolute threshold in vec_C corresponding to colcode.ColCode1 and colcode.ColCode2
    88%INPUT
    99% colcode: struture setting the colorcode for vectors
    1010            % colcode.CName: 'ima_cor','black','white',...
    11             % colcode.ColorCode ='black', 'white', 'rgb','brg', '64 colors'
     11            % colcode.ListColorCode ='black', 'white', 'rgb','brg', '64 colors'
    1212            % colcode.FixedCbounds =0; thresholds scaling relative to min and max, =1 fixed thresholds
    1313            % colcode.MinC; min
    1414            % colcode.MaxC; max
    15             % colcode.colcode1: first threshold for rgb, relative to min (0) and max (1)
    16             % colcode.colcode2: second threshold for rgb, relative to min (0) and max (1),
    17             % rmq: we need min <= colcode1 <= colcode2 <= max, otherwise
    18             % colcode1 and colcode2 are adjusted to the bounds
     15            % colcode.ColCode1: first threshold for rgb, relative to min (0) and max (1)
     16            % colcode.ColCode2: second threshold for rgb, relative to min (0) and max (1),
     17            % rmq: we need min <= ColCode1 <= ColCode2 <= max, otherwise
     18            % ColCode1 and ColCode2 are adjusted to the bounds
    1919% vec_C: matlab vector representing the scalar setting the color
    2020function [colorlist,col_vec,colcode_out]=set_col_vec(colcode,vec_C)
     
    2727    return
    2828end
    29 if (isfield(colcode,'FixedCbounds') && isequal(colcode.FixedCbounds,1))
    30     minC=colcode.MinC;
    31     maxC=colcode.MaxC;
     29if (isfield(colcode,'CheckFixVecColor') && isequal(colcode.CheckFixVecColor,1))
     30    minC=colcode.MinVec;
     31    maxC=colcode.MaxVec;
    3232else
    3333    minC=min(vec_C);
     
    3737%default input parameters
    3838if ~isstruct(colcode),colcode=[];end;
    39 if ~isfield(colcode,'ColorCode') || isempty(colcode.ColorCode)
     39if ~isfield(colcode,'ListColorCode') || isempty(colcode.ListColorCode)
    4040    colorlist=[0 0 1]; %blue 
    4141    col_vec=ones(size(vec_C));
    4242    return
    4343end
    44 if  isfield(colcode,'colcode1')
    45     colcode1=minC+colcode.colcode1*(maxC-minC);
     44if  isfield(colcode,'ColCode1')
     45    ColCode1=minC+colcode.ColCode1*(maxC-minC);
    4646else
    47     colcode1=minC+(maxC-minC)/3;%default
     47    ColCode1=minC+(maxC-minC)/3;%default
    4848end
    49 if isfield(colcode,'colcode2')
    50     colcode2=minC+colcode.colcode2*(maxC-minC);
     49if isfield(colcode,'ColCode2')
     50    ColCode2=minC+colcode.ColCode2*(maxC-minC);
    5151else
    52     colcode2=minC+2*(maxC-minC)/3;%default
     52    ColCode2=minC+2*(maxC-minC)/3;%default
    5353end
    5454colcode_out.MinC=minC;
    5555colcode_out.MaxC=maxC;
    56 if strcmp(colcode.ColorCode,'black')
     56if strcmp(colcode.ListColorCode,'black')
    5757    colorlist(1,:)=[0 0 0];%black
    5858    col_vec=ones(size(vec_C));%all vectors at color#1
    59 elseif strcmp(colcode.ColorCode,'white')
     59elseif strcmp(colcode.ListColorCode,'white')
    6060    colorlist(1,:)=[1 1 1];%white
    6161    col_vec=ones(size(vec_C));%all vectors at color#1
    62 elseif strcmp(colcode.ColorCode,'rgb')|| strcmp(colcode.ColorCode,'bgr')% 3 color representation
    63     ind1=find(vec_C < colcode1); % =1 for red vectors
    64     ind_green=find((vec_C >= colcode1) & (vec_C < colcode2));% =1 for green vectors
    65     ind3=find(vec_C >= colcode2);% =1 for blue vectors
     62elseif strcmp(colcode.ListColorCode,'rgb')|| strcmp(colcode.ListColorCode,'bgr')% 3 color representation
     63    ind1=find(vec_C < ColCode1); % =1 for red vectors
     64    ind_green=find((vec_C >= ColCode1) & (vec_C < ColCode2));% =1 for green vectors
     65    ind3=find(vec_C >= ColCode2);% =1 for blue vectors
    6666    colorlist(2,:)=[0 1 0];%green
    6767    col_vec(ind1)=1;
    6868    col_vec(ind_green)=2;
    6969    col_vec(ind3)=3;
    70     if strcmp(colcode.ColorCode,'rgb')
     70    if strcmp(colcode.ListColorCode,'rgb')
    7171        colorlist(1,:)=[1 0 0];%red
    7272        colorlist(3,:)=[0 0 1];%blue
  • trunk/src/write_plot_param.m

    r295 r313  
    5252        MinC=PlotParam.Vectors.MinC;
    5353        MaxC=PlotParam.Vectors.MaxC;
    54         set(handles.min_vec,'String', num2str(MinC,3));
    55         set(handles.max_vec,'String',num2str(MaxC,3));
    56         list=get(handles.color_code,'String');
    57         ichoice=get(handles.color_code,'Value');
     54        set(handles.num_MinVec,'String', num2str(MinC,3));
     55        set(handles.num_MaxVec,'String',num2str(MaxC,3));
     56        list=get(handles.ListColorCode,'String');
     57        ichoice=get(handles.ListColorCode,'Value');
    5858        color_option=list{ichoice};
    5959        test3color=strcmp(color_option,'rgb')||strcmp(color_option,'bgr');
    6060        if test3color% need to update color thresholds
    61             set(handles.colcode1,'Visible','on')
    62             set(handles.colcode2,'Visible','on')
    63             set(handles.slider1,'Visible','on')
    64             set(handles.slider2,'Visible','on')
    65             colcode1=MinC+(MaxC-MinC)*PlotParam.Vectors.colcode1;
    66             colcode2=MinC+(MaxC-MinC)*PlotParam.Vectors.colcode2;
    67             set(handles.colcode1,'String',num2str(colcode1,3))
    68             set(handles.colcode2,'String',num2str(colcode2,3))
    69             set(handles.slider1,'Value',PlotParam.Vectors.colcode1)
    70             set(handles.slider2,'Value',PlotParam.Vectors.colcode2)
     61            set(handles.num_ColCode1,'Visible','on')
     62            set(handles.num_ColCode2,'Visible','on')
     63            set(handles.Slider1,'Visible','on')
     64            set(handles.Slider2,'Visible','on')
     65            ColCode1=MinC+(MaxC-MinC)*PlotParam.Vectors.ColCode1;
     66            ColCode2=MinC+(MaxC-MinC)*PlotParam.Vectors.ColCode2;
     67            set(handles.num_ColCode1,'String',num2str(ColCode1,3))
     68            set(handles.num_ColCode2,'String',num2str(ColCode2,3))
     69            set(handles.Slider1,'Value',PlotParam.Vectors.ColCode1)
     70            set(handles.Slider2,'Value',PlotParam.Vectors.ColCode2)
    7171        else
    72             set(handles.colcode1,'Visible','off')
    73             set(handles.colcode2,'Visible','off')
    74             set(handles.slider1,'Visible','off')
    75             set(handles.slider2,'Visible','off')
     72            set(handles.num_ColCode1,'Visible','off')
     73            set(handles.num_ColCode2,'Visible','off')
     74            set(handles.Slider1,'Visible','off')
     75            set(handles.Slider2,'Visible','off')
    7676        end
    7777    end
Note: See TracChangeset for help on using the changeset viewer.