Home > atmlab > gridcreation > annealing > apply_annealing.m

apply_annealing

PURPOSE ^

APPLY_ANNEALING control the simulated annealing for an individual channel

SYNOPSIS ^

function result=apply_annealing(filename_H,filename_y_mono,nlos,Cloop,C)

DESCRIPTION ^

 APPLY_ANNEALING control the simulated annealing for an individual channel

 apply_annealing reads the required input from xml files (ARTS
 output), and uses the provided accuracy to initiate the loop to
 obtain the simulated annealing grid. The loop continues until the
 desired accuracy is reached. This run should be applied for each
 individual channel

 FORMAT

   Result=apply_annealing(filename_H,filename_y_mono,nlos,Cloop,C)

 IN
        filename_H:      File containing the H matrix (ARTS-xml)

        filename_y_mono: File containing the ARTS monochromatic
                         radiances on a fine frequency grid for
                         nspec atmospheric states (ARTS-xml)

        nlos:            number of geometries used to calculate
                         the spectra 

        Cloop:           Structure containing parameters
                         controling the iteration loops during the
                         annealing procedure

        Cloop.accuracy:  desired accuray for the iterative
                         annealing result. (obligatory)
        Cloop.n_start:   The initial minimum number of frequencies
                         for the annealing frequency grid. (You
                         should take at least one per channel.)
                         (OPTIONAL: Default=1) 
   
        Cloop.n_incr     Increment n in each iteration by which
                         the number of annealing frequencies is
                         increased. (OPTIONAL: Default=1)
  
        Cann:            (Optional) control-parameters for the
                         actual annealing algorithm 
                         (see function find_best_freq_set_anneal)
 OUT

       result            An array of n-iter structures. Each
                         structure has elements:
                         sb = Solution as a logical array
                              (selected gridpoints).
                         Wb = Associated weight matrix.
                         eb = Associated error.
                         h  = Structure with the history of the
                              annealing 

 By Stefan Buehler/Mathias Milz

 Default contol options

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

apply_annealing.m

SOURCE CODE ^

0001 function result=apply_annealing(filename_H,filename_y_mono,nlos,Cloop,C)
0002 % APPLY_ANNEALING control the simulated annealing for an individual channel
0003 %
0004 % apply_annealing reads the required input from xml files (ARTS
0005 % output), and uses the provided accuracy to initiate the loop to
0006 % obtain the simulated annealing grid. The loop continues until the
0007 % desired accuracy is reached. This run should be applied for each
0008 % individual channel
0009 %
0010 % FORMAT
0011 %
0012 %   Result=apply_annealing(filename_H,filename_y_mono,nlos,Cloop,C)
0013 %
0014 % IN
0015 %        filename_H:      File containing the H matrix (ARTS-xml)
0016 %
0017 %        filename_y_mono: File containing the ARTS monochromatic
0018 %                         radiances on a fine frequency grid for
0019 %                         nspec atmospheric states (ARTS-xml)
0020 %
0021 %        nlos:            number of geometries used to calculate
0022 %                         the spectra
0023 %
0024 %        Cloop:           Structure containing parameters
0025 %                         controling the iteration loops during the
0026 %                         annealing procedure
0027 %
0028 %        Cloop.accuracy:  desired accuray for the iterative
0029 %                         annealing result. (obligatory)
0030 %        Cloop.n_start:   The initial minimum number of frequencies
0031 %                         for the annealing frequency grid. (You
0032 %                         should take at least one per channel.)
0033 %                         (OPTIONAL: Default=1)
0034 %
0035 %        Cloop.n_incr     Increment n in each iteration by which
0036 %                         the number of annealing frequencies is
0037 %                         increased. (OPTIONAL: Default=1)
0038 %
0039 %        Cann:            (Optional) control-parameters for the
0040 %                         actual annealing algorithm
0041 %                         (see function find_best_freq_set_anneal)
0042 % OUT
0043 %
0044 %       result            An array of n-iter structures. Each
0045 %                         structure has elements:
0046 %                         sb = Solution as a logical array
0047 %                              (selected gridpoints).
0048 %                         Wb = Associated weight matrix.
0049 %                         eb = Associated error.
0050 %                         h  = Structure with the history of the
0051 %                              annealing
0052 %
0053 % By Stefan Buehler/Mathias Milz
0054 %
0055 % Default contol options
0056 Cloopdef = struct(...
0057     'n_start', 1, ...          % The starting number of frequencies.
0058     'n_incr',  1 ...          % increment.
0059     );
0060 % User gave control structure, check which elements are present.
0061   if ~isstruct(Cloop)
0062     error('Input argument ''Cloop'' is not a structure.')
0063   end
0064   if ~isfield(Cloop,'accuracy')
0065     error('Structure ''Cloop'' has to contain the element accuracy!')
0066   end
0067   fs = {'n_start', 'n_incr'};
0068   for nm=1:length(fs)
0069     if ~isfield(Cloop,fs{nm})
0070       Cloop.(fs{nm}) = Cloopdef.(fs{nm}); 
0071     end
0072   end
0073 
0074 % read H matrix
0075 H=xmlLoad(filename_H);
0076 % read monochromatic spectra
0077 y_mono_array=xmlLoad(filename_y_mono);
0078 % use absolute error
0079 % C.use_rel_error=false;
0080 nspec=length(y_mono_array);
0081 ngrid=length(y_mono_array{1})/nlos;
0082 ngridH=length(H);
0083 % Do matrix dimenaions agree?
0084 if (ngridH ~= ngrid) 
0085     error('Gridsize of ''H'' and spectra do not agree, check input');
0086 end
0087 % Reformat spectra
0088 y_mono=zeros(ngrid,nspec*nlos);
0089 for ii=1:nspec
0090     for ilos=1:nlos
0091        % tmp=nlos*(ii-1)+ilos
0092         y_mono(:,(nlos*(ii-1))+ilos)=[y_mono_array{ii}((ilos-1)*ngrid+1:ilos*ngrid)];
0093     end
0094 end
0095 %call Annealing
0096 Cgiven=exist ('Cann');
0097 if (Cgiven==1)
0098     result=loop_anneal(H,y_mono,Cloop.n_start,Cloop.n_incr,Cloop.accuracy,Cann);
0099 else
0100 % use default settings for Cann
0101   result=loop_anneal(H,y_mono,Cloop.n_start,Cloop.n_incr,Cloop.accuracy);
0102 end

Generated on Mon 15-Sep-2014 13:31:28 by m2html © 2005