Home > atmlab > deprecated > colloc_process_collocation_cpr_poes_avhrr.m

colloc_process_collocation_cpr_poes_avhrr

PURPOSE ^

colloc_process_collocation_cpr_poes_avhrr Gather collocation info

SYNOPSIS ^

function M_c = colloc_process_collocation_cpr_poes_avhrr(collocations,name1, date1, data1,name2, date2, data2)

DESCRIPTION ^

 colloc_process_collocation_cpr_poes_avhrr Gather collocation info

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

 FORMAT

   M_c = colloc_process_collocation_cpr_poes_avhrr(collocations, ...
       name1, date1, data1, ...
       name2, date2, data2);

 IN

   collocations    Nx4 matrix  As returned by collocate
   name1           string      Name of primary satellite
   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
                               colloc_read_collocation_cpr_poes
   name2           string      Name of secondary satellite
   date2           1x5 vector  As date1, but for secondary granule.
   data2           structure   As data1, but for secondary granule; as
                               returned by colloc_read_avhrr.

 OUT

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

 $Id: colloc_process_collocation_cpr_poes_avhrr.m 7553 2012-04-27 19:08:16Z gerrit $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

colloc_process_collocation_cpr_poes_avhrr.m

SOURCE CODE ^

0001 function M_c = colloc_process_collocation_cpr_poes_avhrr(collocations, ...
0002     name1, date1, data1, ...
0003     name2, date2, data2)
0004 
0005 
0006 % colloc_process_collocation_cpr_poes_avhrr Gather collocation info
0007 %
0008 % After collocating, we want to gather information about the collocations:
0009 % not only indices and columns, but also time, lat, long, distance,
0010 % interval. This function collects such data.
0011 %
0012 % FORMAT
0013 %
0014 %   M_c = colloc_process_collocation_cpr_poes_avhrr(collocations, ...
0015 %       name1, date1, data1, ...
0016 %       name2, date2, data2);
0017 %
0018 % IN
0019 %
0020 %   collocations    Nx4 matrix  As returned by collocate
0021 %   name1           string      Name of primary satellite
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
0026 %                               colloc_read_collocation_cpr_poes
0027 %   name2           string      Name of secondary satellite
0028 %   date2           1x5 vector  As date1, but for secondary granule.
0029 %   data2           structure   As data1, but for secondary granule; as
0030 %                               returned by colloc_read_avhrr.
0031 %
0032 % OUT
0033 %
0034 %   M_c             Nxp matrix  Matrix containing p fields of information for
0035 %                               all N collocations.
0036 %
0037 % $Id: colloc_process_collocation_cpr_poes_avhrr.m 7553 2012-04-27 19:08:16Z gerrit $
0038 
0039 % prepare
0040 c = colloc_constants('cols_collocation_cpr_mhs_avhrr');
0041 c = c.overlap;
0042 n = size(collocations, 1);
0043 M_c = nan*zeros(n, c.NCOLS);
0044 
0045 % row and column numbers.
0046 r1 = collocations(:, 1);
0047 r2 = collocations(:, 3);
0048 c2 = collocations(:, 4);
0049 
0050 % index for direct addressing
0051 i2 = sub2ind(size(data2.lat), r2, c2);
0052 
0053 % convert to cell array for easy passing into date2unixsecs
0054 date1_cell = num2cell(date1);
0055 date2_cell = num2cell(date2);
0056 
0057 %% store info
0058 
0059 % time
0060 M_c(:, c.CPR_MHS_START) = round(date2unixsecs(date1_cell{1:3}));
0061 M_c(:, c.AVHRR_START) = round(date2unixsecs(date2_cell{1:5}));
0062 
0063 
0064 time1 = data1.epoch + data1.time(r1);              
0065 M_c(:, c.AVHRR_TIME) = data2.epoch + data2.time(r2);
0066 
0067 % row/column
0068 M_c(:, c.CPR_MHS_MEAN_ROW) = r1;
0069 M_c(:, c.AVHRR_ROW) = r2;
0070 M_c(:, c.AVHRR_COL) = c2;
0071 
0072 % lat/long
0073 M_c(:, c.AVHRR_LAT) = data2.lat(i2);
0074 %M_c(:, c.CPR_POES_LAT) = data1.lat(r1);
0075 M_c(:, c.AVHRR_LONG) = data2.lon(i2);
0076 %M_c(:, c.CPR_POES_LONG) = data1.lon(r1);
0077 
0078 % angles
0079 
0080 M_c(:, c.AVHRR_RAA) = data2.raa(i2);
0081 M_c(:, c.SZA) = data2.sza(i2);
0082 M_c(:, c.AVHRR_LZA) = data2.lza(i2);
0083 
0084 % dist/int
0085 M_c(:, c.DIST_MHS_AVHRR) = sphdist(data1.lat(r1), data1.lon(r1), ...
0086     M_c(:, c.AVHRR_LAT), M_c(:, c.AVHRR_LONG), constants('EARTH_RADIUS')/1e3);
0087 M_c(:, c.INT_MHS_AVHRR) = M_c(:, c.AVHRR_TIME) - time1;
0088 
0089 Earth_radius = almanac('Earth', 'radius');
0090 %% Find closest CPR (inside MHS) for each AVHRR
0091 for i = 1:size(M_c, 1)
0092     range = data1.FIRST(r1(i)):data1.LAST(r1(i));
0093     % linearise for argmin calculation,
0094     [~, argmin] = min(abs(...
0095          M_c(i, c.AVHRR_LAT)-data1.C_LAT(range)) ...
0096         +abs(M_c(i,c.AVHRR_LONG)-data1.C_LONG(range)));
0097     cpr_mhs_row = range(argmin);
0098     dist_cpr_avhrr = sphdist(data1.C_LAT(cpr_mhs_row), data1.C_LONG(cpr_mhs_row), ...
0099         M_c(i, c.AVHRR_LAT), M_c(i, c.AVHRR_LONG), Earth_radius);
0100     M_c(i, c.CPR_MHS_ROW) = cpr_mhs_row;
0101     M_c(i, c.DIST_CPR_AVHRR) = dist_cpr_avhrr;
0102 end
0103 
0104 M_c = sortrows(M_c, [c.CPR_MHS_START c.CPR_MHS_ROW c.AVHRR_START c.AVHRR_TIME c.AVHRR_ROW c.AVHRR_COL]);
0105 
0106 %% remove doubles
0107 try
0108     wrongrows = M_c(:, c.AVHRR_ROW)< granule_first_line(name2, 'avhrr', date2);
0109     M_c(wrongrows, :) = [];
0110 catch ME
0111     switch ME.identifier
0112         case 'atmlab:granule_first_line'
0113             logtext(atmlab('ERR'), ...
0114                 'Warning: Unable to remove doubles: %s\n', ...
0115                 ME.message);
0116         otherwise
0117             ME.rethrow();
0118     end
0119 end

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