Changeset 9895


Ignore:
Timestamp:
09/22/11 16:17:31 (13 years ago)
Author:
jschierm
Message:

flaim: Allow re-use of kml targets file.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/m/solutions/flaim_sol.m

    r9894 r9895  
    3434[pathstr,name,ext,versn] = fileparts(md.flaim.tracks);
    3535fm_tracks=fullfile('',[name ext versn]);
    36 %system(['cp -p ' md.flaim.tracks ' ' options.fmdir]);
    37 system(['ln -s ' md.flaim.tracks ' ' [options.fmdir filesep fm_tracks]]);
     36system(['cp -p ' md.flaim.tracks ' ' options.fmdir]);
    3837
    3938if ~isempty(md.flaim.targets)
     
    4241        ext='.kml';
    4342    end
    44     fm_targets=fullfile(pathstr,[name ext versn]);
     43    fm_targets=fullfile('',[name ext versn]);
    4544    ext='.log';
    46     filelog=fullfile(pathstr,[name ext versn]);
     45    filelog=fullfile('',[name ext versn]);
    4746else
    4847    fm_targets='fm_targets.kml';
     
    5049end
    5150md.flaim.targets=fm_targets;
     51
    5252if ~isempty(md.flaim.solution)
    5353        [pathstr,name,ext,versn] = fileparts(md.flaim.solution);
     
    5757end
    5858
     59%  copy target file if it exists
     60
     61if any(isnan(md.flaim.criterion)) || isempty(md.flaim.criterion)
     62        display('Copying existing target file.');
     63        system(['cp -p ' md.flaim.targets ' ' options.fmdir]);
     64        cd(options.fmdir)
     65
    5966%  calculate latitude and longitude, if necessary
    6067
    61 if isempty(md.mesh.lat)  || ((numel(md.mesh.lat) == 1)  && isnan(md.mesh.lat)) || ...
    62    isempty(md.mesh.long) || ((numel(md.mesh.long) == 1) && isnan(md.mesh.long))
    63         if     ~isfield(options,'latsgn')
    64                 error(['Missing ''latsgn'' parameter to calculate missing lat/long values.']);
    65         elseif (abs(options.latsgn) ~= 1)
    66                 error(['Incorrect latsgn=' num2str(options.latsgn) ' parameter to calculate missing lat/long values.']);
    67         else
    68                 display('Converting x/y values to lat/long values.');
    69                 [md.mesh.lat,md.mesh.long]=xy2ll(md.mesh.x,md.mesh.y,options.latsgn);
     68else
     69        if isempty(md.mesh.lat)  || ((numel(md.mesh.lat) == 1)  && isnan(md.mesh.lat)) || ...
     70           isempty(md.mesh.long) || ((numel(md.mesh.long) == 1) && isnan(md.mesh.long))
     71                if     ~isfield(options,'latsgn')
     72                        error(['Missing ''latsgn'' parameter to calculate missing lat/long values.']);
     73                elseif (abs(options.latsgn) ~= 1)
     74                        error(['Incorrect latsgn=' num2str(options.latsgn) ' parameter to calculate missing lat/long values.']);
     75                else
     76                        display('Converting x/y values to lat/long values.');
     77                        [md.mesh.lat,md.mesh.long]=xy2ll(md.mesh.x,md.mesh.y,options.latsgn);
     78                end
    7079        end
    71 end
    7280
    7381%  colormap command operates on a figure, so create an invisible one
    7482%  (could also directly call colormaps, e.g. jet(64), but risky)
    7583
    76 if ~isempty(md.flaim.criterion)
    77         hfig=figure('Visible','off');
    78         if isfield(options,'cmap') && ~isempty(options.cmap)
    79                 colormap(options.cmap)
     84        if ~isempty(md.flaim.criterion)
     85                hfig=figure('Visible','off');
     86                if isfield(options,'cmap') && ~isempty(options.cmap)
     87                        colormap(options.cmap)
     88                end
     89                options.cmap=colormap;
     90                close(hfig)
    8091        end
    81         options.cmap=colormap;
    82         close(hfig)
    83 end
    84 if ~isfield(options,'cmap')
    85         options.cmap=[];
    86 end
     92        if ~isfield(options,'cmap')
     93                options.cmap=[];
     94        end
    8795
    8896%  write the target kml file
    8997
    90 cd(options.fmdir)
    91 display('Calling KMLMeshWrite.');
    92 KMLMeshWrite(md.miscellaneous.name,md.miscellaneous.notes,md.mesh.elements,md.mesh.vertexconnectivity,md.mesh.lat,md.mesh.long,md.qmu.partition,md.flaim.criterion,options.cmap,fm_targets);
     98        cd(options.fmdir)
     99        display('Calling KMLMeshWrite.');
     100        KMLMeshWrite(md.miscellaneous.name,md.miscellaneous.notes,md.mesh.elements,md.mesh.vertexconnectivity,md.mesh.lat,md.mesh.long,md.qmu.partition,md.flaim.criterion,options.cmap,fm_targets);
    93101%  for testing
    94 %fm_targets='issm-split-geikie1-targets.kml';
     102%       fm_targets='issm-split-geikie1-targets.kml';
     103end
    95104
    96105%  call flaim
     
    112121
    113122display(['Post-processing the flaim output in the ''' options.fmdir ''' sub-directory.']);
     123
    114124if exist('solution_best.kml','file')
    115125        if ~strcmp(filesol,'solution_best')
     
    119129                md.results.FlaimSolution.solution=[filesol];
    120130        else
    121                 md.results.FlaimSolution.solution=[options.fmdir '/' filesol];
     131                md.results.FlaimSolution.solution=[options.fmdir filesep filesol];
    122132        end
    123133else
    124134        md.results.FlaimSolution.solution='';
    125135end
     136
    126137if exist(filelog,'file')
    127138        [status,fline]=system(['grep -i quality ' filelog]);
     
    155166cd ..
    156167if ~strncmpi(options.keep,'y',1)
    157         system(['mv ' options.fmdir '/' filesol '.kml .']);
    158         system(['mv ' options.fmdir '/' filesol '.log .']);
     168        system(['mv ' options.fmdir filesep fm_targets ' .']);
     169        system(['mv ' options.fmdir filesep filesol '.kml .']);
     170        system(['mv ' options.fmdir filesep filesol '.log .']);
    159171        system(['rm -rf ' options.fmdir]);
    160172end
Note: See TracChangeset for help on using the changeset viewer.