Changeset 47


Ignore:
Timestamp:
Mar 15, 2010, 5:43:08 PM (11 years ago)
Author:
gostiaux
Message:

various bug fixes

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/RUN_FIX.m

    r19 r47  
    44%
    55%filename: name of the netcdf file (used as input and output)
    6 %field: structure specifying the field to fix (field.vel_type='civ1' or 'civ2')
     6%field: structure specifying the names of the fields to fix (depending on civ1 or civ2)
     7    %.vel_type='civ1' or 'civ2';
     8    %.nb=name of the dimension common to the field to fix ('nb_vectors' for civ1);
     9    %.fixflag=name of fix flag variable ('vec_FixFlag' for civ1)
    710%flagindex: flag specifying which values of vec_f are removed:
    811        % if flagindex(1)=1: vec_f=-2 vectors are removed
     
    2124error=[]; %default
    2225vel_type{1}=field.vel_type;
    23 Field=read_civxdata(filename,[],field.vel_type);
     26%check writing access
     27[errorread,message]=fileattrib(filename);
     28if ~isempty(message) && ~isequal(message.UserWrite,1)
     29     msgbox_uvmat('ERROR',['no writting access to ' filename ' (RUN_FIX.m)']);
     30    return
     31end
     32Field=read_civxdata(filename,'ima_cor',field.vel_type);
    2433if isfield(Field,'Txt')
    2534    error=Field.Txt; %error in reading
     
    8291    delta_v=Field.V-vec_V_ref;
    8392end
    84 
    8593thresh_vel_x=thresh_vel;
    8694thresh_vel_y=thresh_vel;
     
    123131end   
    124132flagmagenta=flag1|flag2|flag3|flag4|flag5|flag7;
     133fixflag_unit=Field.FF-10*floor(Field.FF/10); %unity term of fix_flag
    125134
    126 %write fix flags
    127 [errorread,message]=fileattrib(filename);
    128 
    129 if ~isempty(message) && ~isequal(message.UserWrite,1)
    130      msgbox_uvmat('ERROR',['no writting access to ' filename ' (RUN_FIX.m)']);
    131     return
     135%write fix flags in the netcdf file
     136hhh=which('netcdf.open');% look for built-in matlab netcdf library
     137if ~isequal(hhh,'')% case of new builtin Matlab netcdf library
     138    nc=netcdf.open(filename,'NC_WRITE');
     139    netcdf.reDef(nc)
     140    if iter==1
     141        netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),'fix1',1)
     142    elseif iter==2
     143        netcdf.putAtt(nc,netcdf.getConstant('NC_GLOBAL'),'fix2',1)
     144    end
     145    dimid = netcdf.inqDimID(nc,field.nb);
     146    try
     147        varid = netcdf.inqVarID(nc,field.fixflag);% look for already existing fixflag variable
     148    catch
     149        varid=netcdf.defVar(nc,field.fixflag,'double',dimid);%create fixflag variable if it does not exist
     150    end
     151    netcdf.endDef(nc)
     152    netcdf.putVar(nc,varid,fixflag_unit+10*flagmagenta);
     153    netcdf.close(nc)
     154else %old netcdf library
     155    nc=netcdf(filename,'write'); %open netcdf file for writing
     156    result=redef(nc);
     157    if isempty(result), msgbox_uvmat('ERROR','##Bad redef operation.'),end 
     158    if iter==1
     159        nc.fix=1;
     160    elseif iter==2
     161        nc.fix2=1;
     162    end
     163    nc{field.fixflag}=ncfloat(field.nb);
     164    fixflag_unit=Field.FF-10*floor(Field.FF/10); %unity term of fix_flag
     165    nc{field.fixflag}(:)=fixflag_unit+10*flagmagenta;
     166    close(nc);
    132167end
    133 nc=netcdf(filename,'write'); %open netcdf file for writing
    134 result=redef(nc);
    135 if isempty(result), errordlg('##Bad redef operation.'),end 
    136 if iter==1
    137     nc.fix=1;
    138 elseif iter==2
    139     nc.fix2=1;
    140 end
    141 %theDim=nc(field.nb) ;% get the number of velocity vectors
    142 nc{field.fixflag}=ncfloat(field.nb);
    143 fixflag_unit=Field.FF-10*floor(Field.FF/10); %unity term of fix_flag
    144 nc{field.fixflag}(:)=fixflag_unit+10*flagmagenta;
    145 close(nc);
  • trunk/src/read_get_field.m

    r34 r47  
    588588    end
    589589    ind_select=find(npxy~=1);%look for non singleton dimensions
    590     DimCellU=DimCellU(ind_select);
     590    if numel(DimCellU)>=ind_select
     591        DimCellU=DimCellU(ind_select);
     592    end
    591593    npxy=npxy(ind_select);
    592594    dimU=[];
  • trunk/src/update_obj.m

    r19 r47  
    6868        name_str=get(plotfig,'Name');
    6969        if ~isequal(name_str,'uvmat')
    70             set(plotfig,'Name',['Projection on' num2str(IndexObj) '-' set_title(ObjectData.Style,ObjectData.ProjMode)]);
     70            set(plotfig,'Name',['Projection on' num2str(IndexObj) '-' ObjectData.Style]);
    7171        end
    7272    end
Note: See TracChangeset for help on using the changeset viewer.