Home > atmlab > deprecated > colloc_concatenate_colloc_data_mean.m

colloc_concatenate_colloc_data_mean

PURPOSE ^

colloc_concatenate_colloc_data_mean Concatenate collocation structures

SYNOPSIS ^

function [overlap_cat, data_cat, meandata_cat] =colloc_concatenate_colloc_data_mean(overlap_old, overlap_new,data_old, data_new,meandata_old, meandata_new)

DESCRIPTION ^

 colloc_concatenate_colloc_data_mean Concatenate collocation structures

 Concatenate collocation structures: a structure where each field is a
 matrix, and those are concatenated vertically by field. 
 Meandata is a special case.
 Meandata, as processed by process_meandata_*, contains columns (the first
 two) referring to the first and the last line in the collocation matrix
 that is being averaged over. For example, each row in the
 meandata_cpr_mhs describes between what two rows all the CloudSat pixels
 in the corresponding collocation matrix are described. Since this works
 by row-numbers, when the collocation tables and the corresponding
 meandata tables are concatenated, those row numbers need to be corrected.

 FORMAT

    [overlap_cat, data_cat, meandata_cat] = ...
       colloc_concatenate_colloc_data_mean(...
           overlap_old, overlap_new, ...
           data_old, data_new, ...
           meandata_old, meandata_new)

 IN

   overlap_old     structure
   overlap_new     structure
   data_old        structure
   data_new        structure
   meandata_old    structure
   meandata_new    structure

 OUT

   overlap_cat     structure
   data_cat        structure
   meandata_cat    structure

 $Id$

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

colloc_concatenate_colloc_data_mean.m

SOURCE CODE ^

0001 function [overlap_cat, data_cat, meandata_cat] = ...
0002     colloc_concatenate_colloc_data_mean(...
0003     overlap_old, overlap_new, ...
0004     data_old, data_new, ...
0005     meandata_old, meandata_new)
0006 
0007 % colloc_concatenate_colloc_data_mean Concatenate collocation structures
0008 %
0009 % Concatenate collocation structures: a structure where each field is a
0010 % matrix, and those are concatenated vertically by field.
0011 % Meandata is a special case.
0012 % Meandata, as processed by process_meandata_*, contains columns (the first
0013 % two) referring to the first and the last line in the collocation matrix
0014 % that is being averaged over. For example, each row in the
0015 % meandata_cpr_mhs describes between what two rows all the CloudSat pixels
0016 % in the corresponding collocation matrix are described. Since this works
0017 % by row-numbers, when the collocation tables and the corresponding
0018 % meandata tables are concatenated, those row numbers need to be corrected.
0019 %
0020 % FORMAT
0021 %
0022 %    [overlap_cat, data_cat, meandata_cat] = ...
0023 %       colloc_concatenate_colloc_data_mean(...
0024 %           overlap_old, overlap_new, ...
0025 %           data_old, data_new, ...
0026 %           meandata_old, meandata_new)
0027 %
0028 % IN
0029 %
0030 %   overlap_old     structure
0031 %   overlap_new     structure
0032 %   data_old        structure
0033 %   data_new        structure
0034 %   meandata_old    structure
0035 %   meandata_new    structure
0036 %
0037 % OUT
0038 %
0039 %   overlap_cat     structure
0040 %   data_cat        structure
0041 %   meandata_cat    structure
0042 %
0043 % $Id$
0044 
0045 % in case nothing to be done
0046 overlap_cat = overlap_old;
0047 data_cat = data_old;
0048 meandata_cat = meandata_old;
0049 
0050 fields = fieldnames(overlap_new); % fields that exist in NEW one will be used
0051 for n = 1:length(fields) % loop through all fields
0052     sat = fields{n};
0053     if strcmp(sat, 'version') % FIXME/UGLY: special case
0054 %         if isfield(overlap_old, 'version')
0055 %             assert(isequal(overlap_old.version, overlap_new.version), ...
0056 %                 'atmlab:colloc_concatenate_colloc_data_mean', ...
0057 %                 'Concatenating different versions, no good');
0058 %         end
0059         overlap_cat.version = overlap_new.version;
0060         continue
0061     end
0062     
0063     if ~isfield(overlap_new, sat) || isempty(overlap_new.(sat)) % ignore
0064         continue
0065     end
0066     
0067     overlap_cat.(sat) = [overlap_old.(sat); overlap_new.(sat)];
0068     
0069     if ~isempty(data_new.(sat)) % that have anything this iteration
0070         data_cat.(sat) = [data_old.(sat); data_new.(sat)];
0071     end
0072     
0073     %% correct meandata FIRST/LAST columns
0074     % the first two columns of meandata should always be FIRST and LAST;
0075     % those refer to line numbers in the overlap matrices. From
0076     % collocate_granule, this is per granule. When concatenating
0077     % granules, those numbers need to be corrected.
0078     if any(meandata_new.(sat)(:)) % that have anything this iteration
0079         n_before = size(overlap_old.(sat), 1);
0080 
0081         meandata_new.(sat)(:, 1:2) = meandata_new.(sat)(:, 1:2) + n_before;
0082         % and proceed with cat'ing
0083         meandata_cat.(sat) = [meandata_cat.(sat); meandata_new.(sat)];
0084     end
0085 end

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