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

cloud_cci

PURPOSE ^

SATREADERS.CLOUD_CCI

SYNOPSIS ^

function S = cloud_cci( file, varargin )

DESCRIPTION ^

 SATREADERS.CLOUD_CCI

 Read cloud cci 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.cloud_cci(file,varargin)

 IN

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

 OUT

   data    struct  At least 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


 Salomon Eliasson
 $Id: cloud_cci.m 8720 2013-10-21 20:41:39Z gerrit $

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

cloud_cci.m

SOURCE CODE ^

0001 function S = cloud_cci( file, varargin )
0002 % SATREADERS.CLOUD_CCI
0003 %
0004 % Read cloud cci data and output the data in the format common to all
0005 % satreaders.<dataset>.m readers in atmlab. Geodata and time data are
0006 % always retrieved from the data file.
0007 %
0008 % For info on the common format, see <a href="matlab:help SatDataset/reader">SatDataset/reader</a>.
0009 %
0010 % FORMAT
0011 %
0012 %   S = satreaders.cloud_cci(file,varargin)
0013 %
0014 % IN
0015 %
0016 %   file    string      Path to file
0017 %   fields  cell array (optional) extra fields.
0018 %
0019 % OUT
0020 %
0021 %   data    struct  At least with fields:
0022 %                   time    time in seconds since 00:00 UT
0023 %                   lat     latitude in degrees, one column per viewing angle
0024 %                   lon     longitude in [-180, 180] degrees, colums as for lat
0025 %
0026 %
0027 % Salomon Eliasson
0028 % $Id: cloud_cci.m 8720 2013-10-21 20:41:39Z gerrit $
0029 
0030 core_fields   = {'time','lat','lon'};
0031 extra_fields  = optargs(varargin, {{}});
0032 all_fields    = [core_fields(:); extra_fields(:)];
0033 
0034 S = loadncvar(file, all_fields );
0035 attr = loadncattr(file, all_fields);
0036 
0037 % -----------
0038 % Add offsets and scale the data if this is provided. Protect the invalid values
0039 for F = fieldnames(S)'
0040     if isfield(attr.(F{1}),'scale_factor')
0041         if isfield(attr.(F{1}),'x_FillValue')
0042             % unscale the fill value
0043             mask=S.(F{1})==attr.(F{1}).x_FillValue;
0044         end
0045 
0046         S.(F{1}) = (S.(F{1})*double(attr.(F{1}).scale_factor))+ ...
0047             double(attr.(F{1}).add_offset);
0048         
0049         if isfield(attr.(F{1}),'x_FillValue')
0050             S.(F{1})(mask)=attr.(F{1}).x_FillValue;
0051         end
0052     end
0053 end
0054 
0055 % is saved as column major. flip the data.
0056 refsz = size(S.lat);
0057 for F = fieldnames(S)'
0058     if isequal(size(S.(F{1})),refsz)
0059         S.(F{1}) = S.(F{1})';
0060     end
0061 end
0062 
0063 S.time = S.time(:,1); %Each scanline has the same time. 'Julian Date, days elapsed since 12:00 January 1, 4713 BC'
0064 [~,~,~,h,m,s] = jd2date(S.time);
0065 S.time = h*3600+m*60+s; % seconds since O:00 UTC
0066 
0067 S.lat = double(S.lat);
0068 S.lon = double(S.lon);
0069 
0070 % get additional stuff
0071 D = datasets;
0072 info = D.cloud_cci.find_info_from_granule(file);
0073 
0074 S.epoch = round(date2unixsecs(str2double(info.year), str2double(info.month), str2double(info.day)));
0075 
0076 S.path = file;
0077 ga = loadncglobalattr(file);
0078 S.version = ga.product_version;
0079 
0080 S = MaskInvalidGeoTimedataWithNaN(S);
0081 
0082 end

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