Home > atmlab > datasets > +satreaders > cpr.m

cpr

PURPOSE ^

SATREADERS.CPR reads cloudsat data

SYNOPSIS ^

function S = cpr(file, varargin)

DESCRIPTION ^

 SATREADERS.CPR reads cloudsat data
 
 Read CloudSat data and output the data in the format common to all
 satreaders.<dataset>.m readers in atmlab. Geodata and time data are
 always retrieved from the data file.
 
 For info on the common format, see <a href="matlab:help SatDataset/reader">SatDataset/reader</a>.

 FORMAT

   S = satreaders.cpr(file,varargin)

 IN

   file    string      Path to zipped CPR file
   extra   cell array (optional) extra fields.

 OUT

   data    struct  With fields:
                   time    time in seconds since 00:00 UT
                   lat     latitude in degrees, one column per viewing angle
                   lon     longitude in [-180, 180] degrees, colums as for lat

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

cpr.m

SOURCE CODE ^

0001 function S = cpr(file, varargin)
0002 
0003 % SATREADERS.CPR reads cloudsat data
0004 %
0005 % Read CloudSat data and output the data in the format common to all
0006 % satreaders.<dataset>.m readers in atmlab. Geodata and time data are
0007 % always retrieved from the data file.
0008 %
0009 % For info on the common format, see <a href="matlab:help SatDataset/reader">SatDataset/reader</a>.
0010 %
0011 % FORMAT
0012 %
0013 %   S = satreaders.cpr(file,varargin)
0014 %
0015 % IN
0016 %
0017 %   file    string      Path to zipped CPR file
0018 %   extra   cell array (optional) extra fields.
0019 %
0020 % OUT
0021 %
0022 %   data    struct  With fields:
0023 %                   time    time in seconds since 00:00 UT
0024 %                   lat     latitude in degrees, one column per viewing angle
0025 %                   lon     longitude in [-180, 180] degrees, colums as for lat
0026 
0027 % $Id: cpr.m 8720 2013-10-21 20:41:39Z gerrit $
0028 % Gerrit Holl
0029 
0030 % NB: CloudSat appears not to have attributes in E05 and E06, implement a
0031 % workaround for that...
0032 
0033 % get info from filename
0034 D = datasets;
0035 info = D.cpr.find_info_from_granule(file);
0036 date = dayofyear_inverse(str2double(info.year), str2double(info.doy));
0037 
0038 switch info.epoch
0039     case {'E00', 'E01', 'E02', 'E03', 'E04'}
0040         haspv = true;
0041     case {'E05', 'E06'}
0042         haspv = false;
0043     otherwise
0044         error(['atmlab:' mfilename ':unkownepoch'], ...
0045             'Got epoch %s, I don''t like that :(', info.epoch);
0046 end
0047 
0048 core_fields = {'Longitude'; 'Latitude'; 'UTC_start'; 'Profile_time'};
0049 
0050 if haspv
0051     core_fields = [core_fields; 'product_version'];
0052 end
0053 
0054 extra_fields = optargs(varargin, {{}});
0055 all_fields = [core_fields(:); extra_fields(:)];
0056 
0057 S = read_cloudsat_hdf(file, all_fields);
0058 
0059 S.epoch = round(date2unixsecs(date.year, date.month, date.day));
0060 
0061 % rename some fields
0062 S.lon = double(S.Longitude);
0063 S.lat = double(S.Latitude);
0064 % construct time axis with same dimensions. Must convert to double because
0065 % otherwise unixsecstodate will give the wrong time.
0066 S.time = double( S.UTC_start + S.Profile_time);
0067 
0068 
0069 S.path = file;
0070 if haspv
0071     S.version = S.product_version;
0072 else
0073     S.version = 'not_given';
0074 end
0075 
0076 % remove redundant fields
0077 S = rmfield(S, core_fields);
0078 
0079 % convert 1-D fields into column vectors. This is required for processing.
0080 flds = fieldnames(S);
0081 for i = 1:length(flds)
0082     fld = flds{i};
0083     if isvector(S.(fld))
0084         S.(fld) = S.(fld)(:);
0085     end
0086 end
0087 
0088 S = MaskInvalidGeoTimedataWithNaN(S);
0089 
0090 end
0091

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