Home > atmlab > deprecated > colloc_process_x_to_x.m

colloc_process_x_to_x

PURPOSE ^

colloc_process_x_to_x Gather collocation info to store for identical sensors

SYNOPSIS ^

function M = colloc_process_x_to_x(collocations,sat1, sensor1, date1, data1,sat2, sensor2, date2, data2)

DESCRIPTION ^

 colloc_process_x_to_x Gather collocation info to store for identical sensors

 After collocating, we want to gather information about the collocations: not
 only indices and columns, but also time, lat, long, distance, interval. This
 file collects such data.

 FORMAT

   M = colloc_process_x_to_x(collocations, ...
       sat1, sensor1, date1, data1, ...
       sat2, sensor2, date2, data2);

 IN

   collocations    Nx4 matrix  As returned by collocate
   sat1            string      Name of primary satellite
   sensor1
   date1           1x5 vector  Contains [year month day hour minute] for the
                               start of the primary granule.
   data1           structure   Fields time, lat and lon should be present; as
                               returned by read_mhs
   sat2            string      Name of secondary satellite
   sensor2
   date2           1x5 vector  As date1, but for secondary granule.
   data2           structure   As data1, but for secondary granule.

 OUT

   M               Nxp matrix  Matrix containing p fields of information for
                               all N collocations.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

colloc_process_x_to_x.m

SOURCE CODE ^

0001 function M = colloc_process_x_to_x(collocations, ...
0002     sat1, sensor1, date1, data1, ...
0003     sat2, sensor2, date2, data2)
0004 
0005 % colloc_process_x_to_x Gather collocation info to store for identical sensors
0006 %
0007 % After collocating, we want to gather information about the collocations: not
0008 % only indices and columns, but also time, lat, long, distance, interval. This
0009 % file collects such data.
0010 %
0011 % FORMAT
0012 %
0013 %   M = colloc_process_x_to_x(collocations, ...
0014 %       sat1, sensor1, date1, data1, ...
0015 %       sat2, sensor2, date2, data2);
0016 %
0017 % IN
0018 %
0019 %   collocations    Nx4 matrix  As returned by collocate
0020 %   sat1            string      Name of primary satellite
0021 %   sensor1
0022 %   date1           1x5 vector  Contains [year month day hour minute] for the
0023 %                               start of the primary granule.
0024 %   data1           structure   Fields time, lat and lon should be present; as
0025 %                               returned by read_mhs
0026 %   sat2            string      Name of secondary satellite
0027 %   sensor2
0028 %   date2           1x5 vector  As date1, but for secondary granule.
0029 %   data2           structure   As data1, but for secondary granule.
0030 %
0031 % OUT
0032 %
0033 %   M               Nxp matrix  Matrix containing p fields of information for
0034 %                               all N collocations.
0035 
0036 % Created by Gerrit Holl
0037 %
0038 % $Id: colloc_process_x_to_x.m 7553 2012-04-27 19:08:16Z gerrit $
0039 
0040 % prepare
0041 c = colloc_constants(sprintf('cols_%s_%s', sensor1, sensor2));
0042 c = c.overlap;
0043 n = size(collocations, 1);
0044 M = nan*zeros(n, c.NCOLS);
0045 
0046 % convert to cell array for easy passing into date2unixsecs
0047 date1_cell = num2cell(date1);
0048 date2_cell = num2cell(date2);
0049 
0050 % row and column numbers
0051 r1 = collocations(:, 1);
0052 c1 = collocations(:, 2);
0053 r2 = collocations(:, 3);
0054 c2 = collocations(:, 4);
0055 
0056 % index for direct addressing
0057 i1 = sub2ind(size(data1.lat), r1, c1);
0058 i2 = sub2ind(size(data2.lat), r2, c2);
0059 
0060 %% store info
0061 
0062 % lat/long
0063 M(:, c.LAT1) = data1.lat(i1);
0064 M(:, c.LAT2) = data2.lat(i2);
0065 M(:, c.LONG1) = data1.lon(i1);
0066 M(:, c.LONG2) = data2.lon(i2);
0067 
0068 % time
0069 M(:, c.START1) = round(date2unixsecs(date1_cell{1:5}));
0070 M(:, c.START2) = round(date2unixsecs(date2_cell{1:5}));
0071 
0072 M(:, c.TIME1) = data1.epoch + data1.time(r1);
0073 M(:, c.TIME2) = data2.epoch + data2.time(r2);
0074 
0075 % index/column
0076 M(:, c.I1) = r1;
0077 M(:, c.I2) = r2;
0078 M(:, c.C1) = c1;
0079 M(:, c.C2) = c2;
0080 
0081 % angles
0082 M(:, c.LAA1) = data1.laa(i1);
0083 M(:, c.LZA1) = data1.lza(i1);
0084 M(:, c.LAA2) = data2.laa(i2);
0085 M(:, c.LZA2) = data2.lza(i2);
0086 M(:, c.SZA1) = data1.sza(i1);
0087 M(:, c.SZA2) = data2.sza(i2);
0088 M(:, c.SAA1) = data1.saa(i1);
0089 M(:, c.SAA2) = data2.saa(i2);
0090 
0091 % distance and interval
0092 M(:, c.DIST) = sphdist(M(:, c.LAT1), M(:, c.LONG1), ...
0093     M(:, c.LAT2), M(:, c.LONG2), constants('EARTH_RADIUS')/1e3);
0094 M(:, c.INT) = M(:, c.TIME2) - M(:, c.TIME1);
0095 
0096 %% remove doubles
0097 
0098 wrongrows = (M(:, c.I1) < granule_first_line(sat1, sensor1, date1)) & ...
0099             (M(:, c.I2) < granule_first_line(sat2, sensor2, date2));
0100 M(wrongrows, :) = [];
0101 end

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