Home > atmlab > deprecated > colloc_process_cpr_avhrr.m

colloc_process_cpr_avhrr

PURPOSE ^

colloc_process_cpr_avhrr Gather collocation info to store for CloudSat+AVHRR

SYNOPSIS ^

function M = colloc_process_cpr_avhrr(collocations,name_cpr, date_cpr, data_cpr, name_avhrr, date_avhrr, data_avhrr)

DESCRIPTION ^

 colloc_process_cpr_avhrr Gather collocation info to store for CloudSat+AVHRR

 After the collocating process is done by 'collocate', one wants to
 collect some additional information: longitudes, latitudes, times,
 viewing angles, distances, intervals, etc. This function takes care of
 that in the case of CPR/AVHRR.

 All colloc_process_* functions are automatically called by
 collocate_granule and thus have the same interface. Not all arguments are
 used by all.
 
 FORMAT

   M = colloc_process_cpr_avhrr(collocations, ...
       name_cpr, date_cpr, data_cpr, ...
       name_avhrr, date_avhrr, data_avhrr)

 IN

   collocations    Nx4 matrix  Collocations as returned by collocate
   name_cpr        string      Name of satellite carrying CPR ('cloudsat')
   date_cpr        vector      Date vector for CPR starting time
   data_cpr        structure   Data for CPR, as returned by read_cpr
   name_avhrr      string      Name of AVHRR-carrying satellite
   date_avhrr      vector      Date vector for AVHRR starting time
   data_avhrr      structure   Data for AVHRR, as returned by read_avhrr

 OUT

   M               matrix      Matrix with one row for each collocation
                               and columns as in
                               colloc_constants('cols_cpr_avhrr').overlap

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

colloc_process_cpr_avhrr.m

SOURCE CODE ^

0001 function M = colloc_process_cpr_avhrr(collocations, ...
0002     name_cpr, date_cpr, data_cpr, name_avhrr, date_avhrr, data_avhrr)
0003 
0004 % colloc_process_cpr_avhrr Gather collocation info to store for CloudSat+AVHRR
0005 %
0006 % After the collocating process is done by 'collocate', one wants to
0007 % collect some additional information: longitudes, latitudes, times,
0008 % viewing angles, distances, intervals, etc. This function takes care of
0009 % that in the case of CPR/AVHRR.
0010 %
0011 % All colloc_process_* functions are automatically called by
0012 % collocate_granule and thus have the same interface. Not all arguments are
0013 % used by all.
0014 %
0015 % FORMAT
0016 %
0017 %   M = colloc_process_cpr_avhrr(collocations, ...
0018 %       name_cpr, date_cpr, data_cpr, ...
0019 %       name_avhrr, date_avhrr, data_avhrr)
0020 %
0021 % IN
0022 %
0023 %   collocations    Nx4 matrix  Collocations as returned by collocate
0024 %   name_cpr        string      Name of satellite carrying CPR ('cloudsat')
0025 %   date_cpr        vector      Date vector for CPR starting time
0026 %   data_cpr        structure   Data for CPR, as returned by read_cpr
0027 %   name_avhrr      string      Name of AVHRR-carrying satellite
0028 %   date_avhrr      vector      Date vector for AVHRR starting time
0029 %   data_avhrr      structure   Data for AVHRR, as returned by read_avhrr
0030 %
0031 % OUT
0032 %
0033 %   M               matrix      Matrix with one row for each collocation
0034 %                               and columns as in
0035 %                               colloc_constants('cols_cpr_avhrr').overlap
0036 %
0037 % $Id: colloc_process_cpr_avhrr.m 7553 2012-04-27 19:08:16Z gerrit $
0038 
0039 %% prepare
0040 c = colloc_constants('cols_cpr_avhrr');
0041 c = c.overlap;
0042 n = size(collocations, 1);
0043 M = nan*zeros(n, c.NCOLS);
0044 if n==0
0045     return % don't bother
0046 end
0047 
0048 % convert to cell array for easy passing into date2unixsecs
0049 date_cpr_cell = num2cell(date_cpr);
0050 date_avhrr_cell = num2cell(date_avhrr);
0051 
0052 % row and column numbers
0053 cr = collocations(:, 1);
0054 ar = collocations(:, 3);
0055 ac = collocations(:, 4);
0056 
0057 % index for direct addressing
0058 ai = sub2ind(size(data_avhrr.lat), ar, ac);
0059 
0060 %% cloudsat info
0061 
0062 % lat/long
0063 M(:, c.C_LONG) = data_cpr.lon(cr);
0064 M(:, c.C_LAT) = data_cpr.lat(cr);
0065 
0066 % time
0067         
0068 M(:, c.C_START, :) = round(date2unixsecs(date_cpr_cell{1:5}));
0069 M(:, c.C_TIME, :) = data_cpr.epoch + data_cpr.time(cr);
0070 M(:, c.C_I, :) = cr;
0071 
0072 %% avhrr
0073 
0074 M(:, c.AVHRR_LAT) = data_avhrr.lat(ai);
0075 M(:, c.AVHRR_LONG) = data_avhrr.lon(ai);
0076 M(:, c.AVHRR_START) = round(date2unixsecs(date_avhrr_cell{1:5}));
0077 M(:, c.AVHRR_TIME) = data_avhrr.epoch + data_avhrr.time(ar);
0078 M(:, c.AVHRR_ROW) = ar;
0079 M(:, c.AVHRR_COL) = ac;
0080 M(:, c.AVHRR_RAA) = data_avhrr.raa(ai);
0081 M(:, c.AVHRR_SZA) = data_avhrr.sza(ai);
0082 M(:, c.AVHRR_LZA) = data_avhrr.lza(ai);
0083 M(:, c.DIST) = sphdist(data_cpr.lat(cr), data_cpr.lon(cr), ...
0084     data_avhrr.lat(ai), data_avhrr.lon(ai), constants('EARTH_RADIUS')/1e3);
0085 M(:, c.INT) = M(:, c.AVHRR_TIME) - M(:, c.C_TIME);
0086 
0087 %% remove doubles
0088 
0089 wrongrows = M(:, c.AVHRR_ROW)< granule_first_line(name_avhrr, 'avhrr', date_avhrr);
0090 M(wrongrows, :) = [];
0091 
0092 % %% select only the nearest one
0093 %
0094 % M = sortrows(M, [c.C_ROW c.DIST]);
0095 % [~, I_first] = unique(M(:, c.C_ROW), 'first');
0096 % M = M(I_first, :);

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