Home > atmlab > datasets > define_datasets.m

define_datasets

PURPOSE ^

define datasets

SYNOPSIS ^

function varargout = define_datasets(varargin)

DESCRIPTION ^

 define datasets

 This function defines datasets. It has two modes:

 - no inputs and no outputs, just define datasets
 - one input 'check', return logical scalar to say if it has been defined

 See also: SatDataset, CollocatedDataset, FieldCopier, Collapser

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

DOWNLOAD ^

define_datasets.m

SOURCE CODE ^

0001 function varargout = define_datasets(varargin)
0002 % define datasets
0003 %
0004 % This function defines datasets. It has two modes:
0005 %
0006 % - no inputs and no outputs, just define datasets
0007 % - one input 'check', return logical scalar to say if it has been defined
0008 %
0009 % See also: SatDataset, CollocatedDataset, FieldCopier, Collapser
0010 
0011 % $Id: define_datasets.m 8901 2014-06-19 08:12:54Z seliasson $
0012 % Gerrit Holl
0013 
0014 persistent defined;
0015 
0016 if nargin > 0 && strcmp(varargin{1}, 'check')
0017     varargout{1} = ~isempty(defined);
0018     return
0019 end
0020 
0021 if ~isempty(defined)
0022     logtext(atmlab('OUT'), 'Datasets were already defined, doing nothing.\n');
0023     return
0024 end
0025 
0026 %% datasets generated elsewhere
0027 
0028 SatDataset('name', 'amsua', ...
0029     'reader', @satreaders.poes_radiometer, ...
0030     'granule_duration', 6130, ...
0031     'sats', {'noaa15', 'noaa16', 'noaa17', 'noaa18', 'noaa19', 'metopa'});
0032 
0033 SatDataset('name', 'amsub', ...
0034     'reader', @satreaders.poes_radiometer, ...
0035     'granule_duration', 6130, ...
0036     'sats', {'noaa15', 'noaa16', 'noaa17'}); 
0037 
0038 SatDataset('name','avhrr_cmsaf_gac',...
0039     'reader', @satreaders.avhrr_cmsaf_gac, ...
0040     'granule_duration',7200);
0041 
0042 SatDataset('name', 'avhrr', ...
0043     'reader', @satreaders.avhrr, ...
0044     'granule_duration', 6130);
0045 
0046 SatDataset('name', 'calipso', ...
0047     'satname', 'calipso', ...
0048     'reader', @satreaders.calipso, ...
0049     'granule_duration', 5932);
0050 
0051 SatDataset('name','cloud_cci',...
0052     'reader', @satreaders.cloud_cci, ...
0053     'granule_duration',7200);
0054 
0055 SatDataset('name', 'cpr', ...
0056     'satname', 'cloudsat', ...
0057     'reader', @satreaders.cpr, ...
0058     'granule_duration', 5932);
0059 
0060 SatDataset('name', 'CPR_RVOD', ...
0061     'satname', 'cloudsat', ...
0062     'reader', @satreaders.cpr, ...
0063     'granule_duration', 5932);
0064 
0065 SatDataset('name', 'cprCloud', ...
0066     'satname', 'cloudsat', ...
0067     'reader', @satreaders.cpr, ...
0068     'granule_duration', 5932);
0069 
0070 SatDataset('name', 'cprCloudLidar', ...
0071     'satname', 'cloudsat', ...
0072     'reader', @satreaders.cpr, ...
0073     'granule_duration', 5932);
0074 
0075 SatDataset('name', 'CPR_1B', ...
0076     'satname', 'cloudsat', ...
0077     'reader', @satreaders.cpr, ...
0078     'granule_duration', 5932);
0079 
0080 SatDataset('name', 'CPR_2C_ICE', ...
0081     'satname', 'cloudsat', ...
0082     'reader', @satreaders.cpr, ...
0083     'granule_duration', 5932);
0084 
0085 SatDataset('name', 'CPR_ECMWF', ...
0086     'satname', 'cloudsat', ...
0087     'reader', @satreaders.cpr, ...
0088     'granule_duration', 5932);
0089 
0090 SatDataset('name','dardar',...
0091     'satname', 'atrain', ...
0092     'reader', @satreaders.dardar, ...
0093     'granule_duration',5932);
0094 
0095 SatDataset('name', 'hirs', ...
0096     'reader', @satreaders.poes_radiometer, ...
0097     'granule_duration', 6130, ...
0098     'sats', {'noaa15', 'noaa16', 'noaa17', 'noaa18', 'noaa19', 'metopa'});
0099 
0100 SatDataset('name', 'gras_per_day', ...
0101     'reader', @satreaders.grasdir, ...
0102     'satname', 'any', ...
0103     'granule_duration', 86400);
0104 
0105 SatDataset('name','isccp_dx',...
0106     'reader',@satreaders.isscp_dx,...
0107     'granule_duration',3*60); %data var 3:de timme och var 15:de km
0108 
0109 SatDataset('name','isccp_d2',...
0110     'reader',@satreaders.isscp_d2);
0111 
0112 SatDataset('name', 'mhs', ...
0113     'reader', @satreaders.poes_radiometer, ...
0114     'granule_duration', 6130, ...
0115     'sats', {'noaa18', 'noaa19', 'metopa'});
0116 
0117 SatDataset('name', 'mirs', ...
0118     'reader', @satreaders.mirs, ...
0119     'granule_duration', 7200);
0120                 
0121 SatDataset('name', 'modis_aqua_L2', ...
0122     'reader', @satreaders.modis, ...
0123     'granule_duration', 300);
0124 
0125 SatDataset('name', 'modis_L3'); % no reader defined yet
0126 
0127 SatDataset('name', 'mspps', ...
0128     'reader', @satreaders.mspps, ...
0129     'granule_duration', 6130);
0130 
0131 SatDataset('name', 'patmosx', ...
0132     'reader', @satreaders.patmosx, ...
0133     'granule_duration', 86400);
0134 
0135 SatDataset('name', 'patmosxL3', ...
0136     'satname', 'NOAAx', ...
0137     'reader', @satreaders.patmosxL3);
0138 
0139 SatDataset('name', 'saphir_l1a', ...
0140     'needs_starttimesfile', true, ...
0141     'reader', @satreaders.saphir, ...
0142     'satname', 'meghatropiques', ...
0143     'granule_duration', 7000); % FIXME: verify granule_duration
0144 
0145 SatDataset('name', 'saphir_l1a2', ...
0146     'needs_starttimesfile', false, ...
0147     'reader', @satreaders.saphir, ...
0148     'satname', 'meghatropiques', ...
0149     'granule_duration', 7000); % FIXME: verify granule_duration
0150 
0151 SatDataset('name', 'saphir_l2a', ...
0152     'needs_starttimesfile', true, ...
0153     'reader', @satreaders.saphir, ...
0154     'satname', 'meghatropiques', ...
0155     'granule_duration', 7000); % FIXME: verify granule_duration
0156 
0157 SatDataset('name', 'ssmt2', ...
0158     'needs_starttimesfile', false, ...
0159     'reader', @satreaders.ssmt2, ...
0160     'granule_duration', 7000); % FIXME: verify granule_duration
0161 
0162 GriddedDataset('name', 'CFSR', ...
0163     'reader', @satreaders.ncep_cfsr_day);
0164 
0165 %% datasets generated here (non-collocated)
0166 
0167 % dardarsub
0168 HomemadeDataset('name', 'dardarsub', ...
0169                 'satname', 'atrain', ...
0170                 'granule_duration', 5932, ...
0171                 'reader', @satreaders.dardarsub, ...
0172                 'metadata',struct('height',(25080:-60:-1020)),...
0173                 'members', struct(...
0174                     'iwc', struct(...
0175                         'type', 'float', ...
0176                         'dims', {{'HEIGHT', 436}}, ...
0177                         'atts', struct(...
0178                             'long_name', 'Retrieved Ice Water Content', ...
0179                             'units', 'kg m-3',...
0180                             'missing_value',-999)), ...
0181                     'ln_iwc_error', struct(...
0182                         'type', 'float', ...
0183                         'dims', {{'HEIGHT', 436}}, ...
0184                         'atts', struct(...
0185                             'long_name', 'Fractional error in IWC', ...
0186                             'units','ln(kg m-3)',...
0187                             'missing_value',-999)), ...
0188                     'vis_optical_depth', struct(...
0189                         'type', 'float', ...
0190                         'atts', struct(...
0191                             'long_name', 'Optical Thickness forward model',...
0192                             'units','-',...
0193                             'missing_value',-999)), ...
0194                     'vis_optical_depth_error', struct(...
0195                         'type', 'float', ...
0196                         'atts', struct(...
0197                             'long_name', 'Error in optical thickness forward model',...
0198                             'units','-',...
0199                             'missing_value',-999)), ...
0200                     'effective_radius',struct(...
0201                         'type','float',...
0202                         'dims', {{'HEIGHT', 436}}, ...                        
0203                         'atts', struct(...
0204                             'long_name','Retrieved effective radius', ...
0205                             'units','m',...
0206                             'missing_value',-999)), ...
0207                     'ln_effective_radius_error',struct(...
0208                         'type','float',...
0209                         'dims', {{'HEIGHT', 436}}, ...                        
0210                         'atts', struct(...
0211                             'long_name','Fractional error in effective radius', ...
0212                             'units','ln(m)',...
0213                             'missing_value',-999)), ...
0214                     'instrument_flag', struct(...
0215                         'type', 'byte', ...
0216                         'dims', {{'HEIGHT', 436}}, ...
0217                         'atts', struct(...
0218                             'long_name', 'Instrument flag (0==nothing/1==lidar/2==radar/3==radar+lidar)', ...
0219                             'units', 'dimensionless')), ...
0220                     'DARMASK_Simplified_Categorization', struct(...
0221                         'type', 'byte', ...
0222                         'dims', {{'HEIGHT', 436}}, ...
0223                         'atts', struct(...
0224                             'long_name', 'DARMASK Simplified Categorization',...
0225                             'description',['DARDAR flags (-9 -> ground, -1 -> don''t know, 0 -> clear, ' ...
0226                             '1 -> ice, 2 -> ice + supercooled, 3 ->liquid warm, 4 -> supercooled, 5 -> rain, '...
0227                             '6 -> aerosol, 7 -> maybe insects, 8 -> stratospheric feature)'], ...
0228                             'units', '-')), ...
0229                     'temperature', struct(...
0230                         'type', 'short', ...
0231                         'dims', {{'HEIGHT', 436}}, ...
0232                         'atts', struct(...
0233                             'long_name', 'Temperature from ECMWF', ...
0234                             'units', 'K', ...
0235                             'scale_factor', .01, ...
0236                             'add_offset', 100, ...
0237                             'missing_value', -999, ...
0238                             'valid_range', [0 40000])), ...
0239                     'time', struct(...
0240                         'type', 'float', ...
0241                         'atts', struct(...
0242                             'long_name', 'UTC time', ...
0243                             'units', 's',...
0244                             'missing_value',-999)), ...
0245                     'lat', struct(...
0246                         'type', 'float', ...
0247                         'atts', struct(...
0248                             'long_name','Latitude',...
0249                             'units', 'degree',...
0250                             'missing_value',-999)), ...
0251                     'lon', struct(...
0252                         'type', 'float', ...
0253                         'atts', struct(...
0254                             'long_name','Longitude',...
0255                             'units', 'degree',...
0256                             'missing_value',-999)), ...
0257                     'day_night_flag', struct(...
0258                         'type', 'byte', ...
0259                         'atts', struct(...
0260                             'long_name', 'Day Night Flag for lidar Night (1) Day (0)',...
0261                             'units','-',...
0262                             'missing_value',-999)), ...
0263                     'land_water_mask', struct(...
0264                         'type', 'byte', ...
0265                         'atts', struct(...
0266                             'long_name', 'Land Water Mask from Calipso files',...
0267                             'description',['Land Water Mask from Calipso files, '...
0268                                         'indicating the surface type at the laser '...
0269                                         'footprint 0=shallow ocean 1=land 2=coastlines '...
0270                                         '3=shallow inland water 4=intermittent water '...
0271                                         '5=deep inland water 6=continental ocean 7=deep ocean'],... 
0272                             'units','-'))));
0273     
0274     
0275                         
0276 cmoiwp = CollocatedMicrowaveOnlyIWP('name', 'cmoiwp','granule_duration', 6130); % reader set in this constructor
0277 
0278 % old versions thereof
0279 
0280 for v = {'v0_0', 'v0_1', 'v0_2', 'v0_3', 'v0_4', 'v0_5', 'v0_6'}
0281     SatDataset('name', sprintf('cmoiwp_%s', v{1}), ...
0282     'granule_duration', cmoiwp.granule_duration, ...
0283     'reader', cmoiwp.reader);
0284 end
0285 
0286 % special case; collocated, but not in the standard system
0287 
0288 HomemadeDataset('name', 'cdpc_2dcp', ...
0289                 'granule_duration', 5932, ...
0290                 'reader', @satreaders.cdpc2dcp, ...
0291                 'members', struct(...
0292                     'POES_START', struct(...
0293                         'type', 'int', ...
0294                         'atts', struct(...
0295                             'long_name', 'AMSU-B/MHS granule starting time', ...
0296                             'units', 'seconds since 1970-01-01T00:00:00Z')), ...
0297                     'POES_TIME', struct(...
0298                         'type', 'int', ...
0299                         'atts', struct(...
0300                             'long_name', 'AMSU-B/MHS measurement time', ...
0301                             'units', 'seconds since 1970-01-01T00:00:00Z', ...
0302                             'valid_range', [0 intmax])), ...
0303                     'AMSUB_LINE', struct(...
0304                         'type', 'short', ...
0305                         'atts', struct(...
0306                             'long_name', 'AMSU-B/MHS scanline number')), ...
0307                     'AMSUB_POS', struct(...
0308                         'type', 'byte', ...
0309                         'atts', struct(...
0310                             'long_name', 'AMSU-B/MHS scanline position')), ...
0311                     'AMSUB_LAT', struct(...
0312                         'type', 'float', ...
0313                         'atts', struct(...
0314                             'long_name', 'AMSU-B/MHS latitude', ...
0315                             'units', 'degrees_north', ...
0316                             'valid_range', [-90 90])), ...
0317                     'AMSUB_LONG', struct(...
0318                         'type', 'float', ...
0319                         'atts', struct(...
0320                             'long_name', 'AMSU-B/MHS longitude', ...
0321                             'units', 'degrees_east', ...
0322                             'valid_range', [-180 180])), ...
0323                     'AMSUB_BT', struct(...
0324                         'type', 'float', ...
0325                         'dims', {{'AMSUB_CHANS', 5}}, ...
0326                         'atts', struct(...
0327                             'long_name', 'AMSU-B/MHS Brightness Temperature', ...
0328                             'units', 'Kelvin')), ...
0329                     'AMSUA_LINE', struct(...
0330                         'type', 'short', ...
0331                         'atts', struct(...
0332                             'long_name', 'AMSU-A scanline number')), ...
0333                     'AMSUA_POS', struct(...
0334                         'type', 'byte', ...
0335                         'atts', struct(...
0336                             'long_name', 'AMSU-A scanline position')), ...
0337                     'AMSUA_LAT', struct(...
0338                         'type', 'float', ...
0339                         'atts', struct(...
0340                             'long_name', 'AMSU-A latitude', ...
0341                             'units', 'degrees_north', ...
0342                             'valid_range', [-90 90])), ...
0343                     'AMSUA_LONG', struct(...
0344                         'type', 'float', ...
0345                         'atts', struct(...
0346                             'long_name', 'AMSU-A longitude', ...
0347                             'units', 'degrees_east', ...
0348                             'valid_range', [-180 180])), ...
0349                     'AMSUA_BT', struct(...
0350                         'type', 'float', ...
0351                         'dims', {{'AMSUA_CHANS', 15}}, ...
0352                         'atts', struct(...
0353                             'long_name', 'AMSU-A Brightness Temperature', ...
0354                             'units', 'Kelvin')), ...
0355                     'HIRS_LINE', struct(...
0356                         'type', 'short', ...
0357                         'atts', struct(...
0358                             'long_name', 'HIRS scanline number', ...
0359                             'missing_value', 0)), ...
0360                     'HIRS_POS', struct(...
0361                         'type', 'byte', ...
0362                         'atts', struct(...
0363                             'long_name', 'HIRS scanline position', ...
0364                             'missing_value', 0)), ...
0365                     'HIRS_LAT', struct(...
0366                         'type', 'float', ...
0367                         'atts', struct(...
0368                             'long_name', 'HIRS latitude', ...
0369                             'units', 'degrees_north', ...
0370                             'valid_range', [-90 90], ...
0371                             'missing_value', -9999)), ...
0372                     'HIRS_LONG', struct(...
0373                         'type', 'float', ...
0374                         'atts', struct(...
0375                             'long_name', 'HIRS longitude', ...
0376                             'units', 'degrees_east', ...
0377                             'valid_range', [-180 180], ...
0378                             'missing_value', -9999)), ...
0379                     'HIRS_BT', struct(...
0380                         'type', 'float', ...
0381                         'dims', {{'HIRS_CHANS', 20}}, ...
0382                         'atts', struct(...
0383                             'long_name', 'HIRS Brightness Temperature', ...
0384                             'units', 'Kelvin', ...
0385                             'missing_value', -9999)), ...
0386                     'CPR_LINERANGE', struct(...
0387                         'type', 'int', ...
0388                         'dims', {{'CPR_RANGE', 2}}, ...
0389                         'atts', struct(...
0390                             'long_name', 'CloudSat CPR line range within granule')), ...
0391                     'MIN_DIST', struct(...
0392                         'type', 'float', ...
0393                         'atts', struct(...
0394                             'long_name', 'Shortest distance CPR to AMSU-B/MHS', ...
0395                             'units', 'km', ...
0396                             'valid_range', [0 15.02])), ...
0397                     'MAX_DIST', struct(...
0398                         'type', 'float', ...
0399                         'atts', struct(...
0400                             'long_name', 'Longest distance CPR to AMSU-B/MHS', ...
0401                             'units', 'km', ...
0402                             'valid_range', [0 15.02])), ...
0403                     'MIN_INT', struct(...
0404                         'type', 'short', ...
0405                         'atts', struct(...
0406                             'long_name', 'Shortest time-interval CPR to AMSU-B/MHS (absolute)', ...
0407                             'units', 'seconds', ...
0408                             'valid_range', [0 900])), ...
0409                     'MAX_INT', struct(...
0410                         'type', 'short', ...
0411                         'atts', struct(...
0412                             'long_name', 'Longest time-interval CPR to AMSU-B/MHS (absolute)', ...
0413                             'units', 'seconds', ...
0414                             'valid_range', [0 900]))));
0415                         
0416 %% Pseudo fields (fields created by postprocessing)
0417 %
0418 
0419 D = datasets();
0420 
0421 fields = listOfDatasetsFields();
0422 
0423 D.cprCloud.pseudo_fields.Cloud_Types                = fields.cpr.Cloud_Types;
0424 D.cprCloud.pseudo_fields.Cloud_Types.dependencies   = fieldnames(fields.cpr.Cloud_Types.dependencies_struct)';
0425 D.cprCloud.pseudo_fields.Cloud_Types_multiLayer                = fields.cpr.Cloud_Types_multiLayer;
0426 D.cprCloud.pseudo_fields.Cloud_Types_multiLayer.dependencies   = fieldnames(fields.cpr.Cloud_Types_multiLayer.dependencies_struct)';
0427 D.cprCloud.reader_processor                         = @cpr_postprocessor;
0428 
0429 D.cprCloudLidar.pseudo_fields.Cloud_Types_Lidar                 = fields.cpr.Cloud_Types_Lidar;
0430 D.cprCloudLidar.pseudo_fields.Cloud_Types_Lidar.dependencies    = fieldnames(fields.cpr.Cloud_Types_Lidar.dependencies_struct)';
0431 D.cprCloudLidar.pseudo_fields.Cloud_Types_Lidar_multiLayer              = fields.cpr.Cloud_Types_Lidar_multiLayer;
0432 D.cprCloudLidar.pseudo_fields.Cloud_Types_Lidar_multiLayer.dependencies = fieldnames(fields.cpr.Cloud_Types_Lidar_multiLayer.dependencies_struct)';
0433 D.cprCloudLidar.reader_processor                                = @cpr_postprocessor;
0434 
0435 D.cloud_cci.pseudo_fields.iwp                   = fields.cloud_cci.iwp;
0436 D.cloud_cci.pseudo_fields.iwp.dependencies      = fieldnames(fields.cloud_cci.iwp.dependencies_struct)';
0437 D.cloud_cci.pseudo_fields.iwp_error             = fields.cloud_cci.iwp_error;
0438 D.cloud_cci.pseudo_fields.iwp_error.dependencies= fieldnames(fields.cloud_cci.iwp_error.dependencies_struct)';
0439 D.cloud_cci.pseudo_fields.ref_ice               = fields.cloud_cci.ref_ice;
0440 D.cloud_cci.pseudo_fields.ref_ice.dependencies  = fieldnames(fields.cloud_cci.ref_ice.dependencies_struct)';
0441 D.cloud_cci.pseudo_fields.cot_ice               = fields.cloud_cci.cot_ice;
0442 D.cloud_cci.pseudo_fields.cot_ice.dependencies  = fieldnames(fields.cloud_cci.cot_ice.dependencies_struct)';
0443 D.cloud_cci.reader_processor                    = @cloud_cci_postprocessor;
0444 
0445 D.modis_aqua_L2.pseudo_fields.modis_IWP             = fields.modis.modis_IWP;
0446 D.modis_aqua_L2.pseudo_fields.modis_IWP.dependencies= fieldnames(fields.modis.modis_IWP.dependencies_struct)';
0447 D.modis_aqua_L2.pseudo_fields.modis_IWP_uncertainty             = fields.modis.modis_IWP_uncertainty;
0448 D.modis_aqua_L2.pseudo_fields.modis_IWP_uncertainty.dependencies= fieldnames(fields.modis.modis_IWP_uncertainty.dependencies_struct)';
0449 D.modis_aqua_L2.pseudo_fields.Re_ice                = fields.modis.Re_ice;
0450 D.modis_aqua_L2.pseudo_fields.Re_ice.dependencies   = fieldnames(fields.modis.Re_ice.dependencies_struct)';
0451 D.modis_aqua_L2.pseudo_fields.Re_ice_uncertainty                = fields.modis.Re_ice_uncertainty;
0452 D.modis_aqua_L2.pseudo_fields.Re_ice_uncertainty.dependencies   = fieldnames(fields.modis.Re_ice_uncertainty.dependencies_struct)';
0453 D.modis_aqua_L2.pseudo_fields.Tau_ice               = fields.modis.Tau_ice;
0454 D.modis_aqua_L2.pseudo_fields.Tau_ice.dependencies  = fieldnames(fields.modis.Tau_ice.dependencies_struct)';
0455 D.modis_aqua_L2.pseudo_fields.Tau_ice_uncertainty               = fields.modis.Tau_ice_uncertainty;
0456 D.modis_aqua_L2.pseudo_fields.Tau_ice_uncertainty.dependencies  = fieldnames(fields.modis.Tau_ice_uncertainty.dependencies_struct)';
0457 D.modis_aqua_L2.reader_processor                    = @modis_postprocessor;
0458 
0459 D.dardarsub.pseudo_fields.dardar_IWP              = fields.dardarsub.dardar_IWP;
0460 D.dardarsub.pseudo_fields.dardar_IWP.dependencies = fieldnames(fields.dardarsub.dardar_IWP.dependencies_struct)';
0461 D.dardarsub.pseudo_fields.dardar_ln_IWP_error              = fields.dardarsub.dardar_ln_IWP_error;
0462 D.dardarsub.pseudo_fields.dardar_ln_IWP_error.dependencies = fieldnames(fields.dardarsub.dardar_ln_IWP_error.dependencies_struct)';
0463 D.dardarsub.reader_processor = @dardarsub_postprocessor;
0464 
0465 %% Collocated datasets (the core)
0466     
0467 % MW datasets
0468 
0469 CollocatedDataset(D.mhs, D.mhs, ...
0470     'name', 'collocation_mhs_mhs', ...
0471     'distance', 15, ...
0472     'interval', 900);
0473 
0474 CollocatedDataset(D.mhs, D.amsub, ...
0475     'name', 'collocation_mhs_amsub', ...
0476     'distance', 15, ...
0477     'interval', 900);
0478 
0479 CollocatedDataset(D.amsub, D.mhs, ...
0480     'name', 'collocation_amsub_mhs', ...
0481     'distance', 15, ...
0482     'interval', 900);
0483 
0484 CollocatedDataset(D.amsub, D.amsub, ...
0485     'name', 'collocation_amsub_amsub', ...
0486     'distance', 15, ...
0487     'interval', 900);
0488 
0489 CollocatedDataset(D.mhs, D.saphir_l1a2, ...
0490     'name', 'collocation_mhs_saphir', ...
0491     'distance', 15, ...
0492     'interval', 900);
0493 
0494 CollocatedDataset(D.amsub, D.saphir_l1a2, ...
0495     'name', 'collocation_amsub_saphir', ...
0496     'distance', 15, ...
0497     'interval', 900);
0498 
0499 CollocatedDataset(D.ssmt2, D.ssmt2, ...
0500     'name', 'collocation_ssmt2_ssmt2', ...
0501     'distance', 40, ...
0502     'interval', 900);
0503 
0504 CollocatedDataset(D.ssmt2, D.mhs, ...
0505     'name', 'collocation_ssmt2_mhs', ...
0506     'distance', 40, ...
0507     'interval', 900);
0508 
0509 CollocatedDataset(D.ssmt2, D.amsub, ...
0510     'name', 'collocation_ssmt2_amsub', ...
0511     'distance', 40, ...
0512     'interval', 900);
0513 
0514 CollocatedDataset(D.gras_per_day, D.amsua, ...
0515     'name', 'collocation_gras_amsua', ...
0516     'distance', 150, ...
0517     'interval', 3600);
0518 
0519 % NB: not intended to be stored, only used on-the-fly; storing will explode
0520 % storage requirements, repeating each AVHRR footprint many times!
0521 CollocatedDataset(D.mhs, D.avhrr, ...
0522     'name', 'collocation_mhs_avhrr', ...
0523     'distance', 15, ...
0524     'interval', 30, ...
0525     'gridsize', 0.2); % for sure very many collocations -> smaller gridsize.  Should consider special algorithm or different solution altogether
0526 
0527 % CPR as reference
0528 
0529 CollocatedDataset(D.avhrr_cmsaf_gac, D.cpr,...
0530     'name','CollocatedDataset_avhrrCMSAF_cpr', ...
0531     'distance', 5, ...
0532     'interval', 300);
0533 
0534 CollocatedDataset(D.cmoiwp_v0_4, D.cpr,...
0535     'name','CollocatedDataset_cmoiwp_v0_4_cpr',...
0536     'distance', 15, ...
0537     'interval', 900);
0538 
0539 CollocatedDataset(D.cmoiwp_v0_3, D.cpr,...
0540     'name','CollocatedDataset_cmoiwp_v0_3_cpr',...
0541     'distance', 15, ...
0542     'interval', 900);
0543 
0544 % calipso is a 5km product and must therefore be the primary dataset
0545 CollocatedDataset(D.calipso, D.cpr,...
0546     'name', 'CollocatedDataset_calipso_cpr', ...
0547     'distance', 5, ...
0548     'interval',300);
0549 
0550 CollocatedDataset(D.cpr, D.modis_aqua_L2,...
0551     'name', 'CollocatedDataset_cpr_modis', ...
0552     'distance', 2, ...
0553     'interval', 120);
0554 
0555 CollocatedDataset(D.cpr, D.dardarsub,...
0556     'name', 'CollocatedDataset_cpr_dardarsub', ...
0557     'distance', 1, ...
0558     'interval', 1); % these are always collocated
0559 
0560 CollocatedDataset(D.mhs, D.cpr,...
0561     'name','CollocatedDataset_mhs_cpr',...
0562     'distance', 15, ...
0563     'interval', 900); %16.6m/s
0564 
0565 CollocatedDataset(D.amsub, D.cpr, ...
0566     'name', 'CollocatedDataset_amsub_cpr', ...
0567     'distance', 15, ...
0568     'interval', 900);
0569 
0570 CollocatedDataset(D.mspps, D.cpr,...
0571     'name', 'CollocatedDataset_mspps_cpr', ...
0572     'distance', 20, ...
0573     'interval', 1200); % assume 20m/s
0574 
0575 CollocatedDataset(D.mirs, D.cpr,...
0576     'name', 'CollocatedDataset_mirs_cpr', ...
0577     'distance', 60, ...
0578     'interval', 3000);
0579 
0580 CollocatedDataset(D.patmosx, D.cpr,...
0581     'name', 'CollocatedDataset_patmosx_cpr', ...
0582     'distance', 8, ...
0583     'interval', 480);
0584 
0585 % DARDAR as reference
0586 
0587 CollocatedDataset(D.avhrr_cmsaf_gac, D.dardarsub,...
0588     'name','CollocatedDataset_avhrrCMSAF_dardarsub', ...
0589     'distance', 5, ...
0590     'interval', 300);
0591 
0592 % calipso is a 5km product and must therefore be the primary dataset
0593 CollocatedDataset(D.calipso, D.dardarsub,...
0594     'name', 'CollocatedDataset_calipso_dardarsub', ...
0595     'distance', 5, ...
0596     'interval',180);
0597 
0598 CollocatedDataset(D.cmoiwp_v0_6, D.dardarsub,...
0599     'name','CollocatedDataset_cmoiwp_v0_6_dardarsub',...
0600     'distance', 15, ...
0601     'interval', 900);
0602 
0603 CollocatedDataset(D.cloud_cci, D.dardarsub,...
0604     'name','CollocatedDataset_cloud_cci_dardarsub',...
0605     'distance', 2, ...
0606     'interval', 120); % same limits as for MODIS for better comparison of like-datasets
0607 
0608 CollocatedDataset(D.cmoiwp_v0_4, D.dardarsub,...
0609     'name','CollocatedDataset_cmoiwp_v0_4_dardarsub',...
0610     'distance', 15, ...
0611     'interval', 900);
0612 
0613 
0614 CollocatedDataset(D.dardarsub, D.modis_aqua_L2,...
0615     'name', 'CollocatedDataset_dardarsub_modis', ...
0616     'distance', 2, ...
0617     'interval', 120);
0618 
0619 CollocatedDataset(D.hirs, D.dardarsub,...
0620     'name', 'CollocatedDataset_hirs_dardarsub', ...
0621     'distance', 15, ...
0622     'interval', 900);
0623 
0624 CollocatedDataset(D.mhs, D.dardarsub,...
0625     'name', 'CollocatedDataset_mhs_dardarsub', ...
0626     'distance', 15, ...
0627     'interval', 900);
0628 
0629 CollocatedDataset(D.mspps, D.dardarsub,...
0630     'name', 'CollocatedDataset_mspps_dardarsub', ...
0631     'distance', 15, ...
0632     'interval', 900);
0633 
0634 CollocatedDataset(D.mirs, D.dardarsub,...
0635     'name', 'CollocatedDataset_mirs_dardarsub', ...
0636     'distance', 50, ...
0637     'interval', 3000);
0638 
0639 CollocatedDataset(D.patmosx, D.dardarsub,...
0640     'name', 'CollocatedDataset_patmosx_dardarsub', ...
0641     'distance', 8, ...
0642     'interval', 480);
0643 
0644 % ---------------------------------
0645 % Collocated collocated datasets
0646 % ---------------------------------
0647 
0648 CollocatedDataset(D.CollocatedDataset_dardarsub_modis,D.cprCloud,...
0649     'name', 'CollocatedDataset_dardarsub_modis_cprCloud', ...
0650     'distance', 1,...
0651     'interval', 1);
0652 
0653 CollocatedDataset(D.CollocatedDataset_dardarsub_modis,D.cprCloudLidar,...
0654     'name', 'CollocatedDataset_dardarsub_modis_cprCloudLidar', ...
0655     'distance', 1,...
0656     'interval', 1);
0657 
0658 % NB: one collocated dataset uses a collapser as a reference and follows
0659 % further down
0660 
0661 %% AssociatedDatasets (FieldCopier, Collapser, etc.)
0662  
0663 % ------
0664 % POES
0665 % ------
0666 
0667 poes_cpr_selection = getSelection(fields.cpr, ...
0668                  {'ROIWP', 'dROIWP', 'IOROIWP', 'dIOROIWP', ...
0669                   'IWP_2C', 'dardar_IWP', 'dardar_ln_IWP_error', ...
0670                   'RO_liq_water_path', 'LO_RO_liquid_water_path', ...
0671                   'ECMWF_Surface_pressure', ...
0672                   'ECMWF_Skin_temperature', 'ECMWF_Temperature_2m', ...
0673                   'ECMWF_elevation'});
0674 % not including due to memory: 'ECMWF_Pressure', 'ECMWF_Specific_humidity',
0675 
0676 AssociatedPOESPlusCPR(D.CollocatedDataset_mhs_cpr, fields.mhs, fields.amsua, fields.hirs, ...
0677     poes_cpr_selection, 'name', 'associated_CPR_MHS_AMSU_HIRS');
0678 
0679 AssociatedPOESPlusCPR(D.CollocatedDataset_amsub_cpr, fields.amsub, fields.amsua, fields.hirs, ...
0680     poes_cpr_selection, 'name', 'associated_CPR_AMSUB_AMSUA_HIRS');
0681 
0682 % -----------------------
0683 % define FieldCopiers
0684 % -----------------------
0685 
0686 FieldCopier(D.collocation_mhs_mhs, fields.mhs1, fields.mhs2, ...
0687     'name', 'associated_mhs_mhs');
0688 
0689 FieldCopier(D.collocation_mhs_amsub, fields.mhs1, fields.amsub2, ...
0690     'name', 'associated_mhs_amsub');
0691 
0692 FieldCopier(D.collocation_amsub_mhs, fields.amsub1, fields.mhs2, ...
0693     'name', 'associated_amsub_mhs');
0694 
0695 FieldCopier(D.collocation_amsub_amsub, fields.amsub1, fields.amsub2, ...
0696     'name', 'associated_amsub_amsub');
0697 
0698 FieldCopier(D.collocation_mhs_saphir, fields.mhs, fields.saphir, ...
0699     'name', 'associated_mhs_saphir');
0700 
0701 FieldCopier(D.collocation_amsub_saphir, fields.amsub, fields.saphir, ...
0702     'name', 'associated_amsub_saphir');
0703 
0704 FieldCopier(D.collocation_ssmt2_mhs, fields.ssmt2, fields.mhs, ...
0705     'name', 'associated_ssmt2_mhs');
0706 
0707 FieldCopier(D.collocation_ssmt2_amsub, fields.ssmt2, fields.amsub, ...
0708     'name', 'associated_ssmt2_amsub');
0709 
0710 FieldCopier(D.collocation_ssmt2_mhs, fields.ssmt2_1, fields.ssmt2_2, ...
0711     'name', 'associated_ssmt2_ssmt2');
0712 
0713 FieldCopier(D.collocation_gras_amsua, fields.gras, fields.amsua, ...
0714     'name', 'associated_gras_amsua');
0715 
0716 FieldCopier(D.CollocatedDataset_cloud_cci_dardarsub, ...
0717     getSelection(fields.cloud_cci,{'iwp','iwp_error','ref_ice','ref_uncertainty','cot_ice','cot_uncertainty'}),...
0718      getSelection(fields.dardarsub,{'dardar_IWP','dardar_ln_IWP_error','dardar_Re'}),...
0719      'name','cloud_cci_dardarsub_ice_clouds');
0720 
0721 FieldCopier(D.CollocatedDataset_cpr_dardarsub, ...
0722     getSelection(fields.cpr,{'Cloud_Types'}),struct(),...
0723     'name','cpr_dardarsub_cloudTypes');
0724 
0725 FieldCopier(D.CollocatedDataset_cpr_dardarsub, ...
0726     getSelection(fields.cpr,{'IWP_2C'}),getSelection(fields.dardarsub,{'dardar_ln_IWP_error','dardar_IWP'}),...
0727     'name','fields_2C_ice_dardarsub');
0728 
0729 FieldCopier(D.CollocatedDataset_cpr_dardarsub, ...
0730     getSelection(fields.cpr,{'RO_liq_water_path'}),struct(),...
0731     'name','fields_CPR_LWP_added_to_dardar');
0732 
0733 FieldCopier(D.CollocatedDataset_cpr_dardarsub, ...
0734     struct(),getSelection(fields.dardarsub,{'dardar_IWP',}),...
0735     'name','cpr_dardarsub_IWP');
0736 
0737 FieldCopier(D.CollocatedDataset_dardarsub_modis, ...
0738     getSelection(fields.dardarsub,{'dardar_IWP','dardar_ln_IWP_error'}),...
0739     getSelection(fields.modis,{'modis_IWP','Re_ice','Tau_ice'}),...
0740     'name','dardarsub_modis_IWP'); % this will be deprecated when 'dardarsub_modis_ice_clouds' is fully run
0741 
0742 FieldCopier(D.CollocatedDataset_dardarsub_modis, ...
0743     getSelection(fields.dardarsub,{'dardar_IWP','dardar_ln_IWP_error'}),...
0744     getSelection(fields.modis,{'modis_IWP','modis_IWP_uncertainty','Re_ice','Tau_ice'}),...
0745     'name','dardarsub_modis_ice_clouds'); % this will be deprecated
0746 
0747 FieldCopier(D.CollocatedDataset_mhs_dardarsub, ...
0748     getSelection(fields.mhs,{'B_LZA','B_BT'}),...
0749     getSelection(fields.dardarsub,{'iwc'}),...
0750     'name','mhs_dardarsub');
0751                               
0752 FieldCopier(D.CollocatedDataset_hirs_dardarsub, ...
0753     getSelection(fields.hirs,{'H_LZA','H_BT'}),...
0754     getSelection(fields.dardarsub,{'iwc'}),...
0755     'name','hirs_dardarsub');
0756 
0757 % NB: do not try to store, too large
0758 FieldCopier(D.collocation_mhs_avhrr, ...
0759     getfields(fields.mhs, 'B_BT', 'B_LZA', 'B_LAA', 'B_SZA', 'B_SAA'), ...
0760     getfields(fields.avhrr, 'AVHRR_Y', 'AVHRR_FLAG_3AB'), ...
0761     'name', 'associated_mhs_avhrr');
0762 
0763 % ----------------------------
0764 % FieldCopiers for collocated collocated datasets
0765 % ----------------------------
0766 
0767 FieldCopier(D.CollocatedDataset_dardarsub_modis_cprCloud,...
0768      D.dardarsub_modis_IWP.members, getSelection(fields.cpr,{'Cloud_Types'}),...
0769     'name','dardarsub_modis_cprCloud');
0770 
0771 FieldCopier(D.CollocatedDataset_dardarsub_modis_cprCloudLidar, ...
0772     getSelection(D.dardarsub_modis_IWP.members,{'dardar_IWP','modis_IWP'}),getSelection(fields.cpr,{'Cloud_Types_Lidar_multiLayer','CloudPhase'}),...
0773     'name','dardarsub_modis_cprCloudLidar');
0774 
0775 % -----------------------
0776 % Collapser datasets
0777 % -----------------------
0778 
0779 
0780 % LIMITERS
0781 limitators_scalar = {@(X)(X>=0)}; % meaning not flagged
0782 %limitators_scalar_vectorised = {@(x)x};
0783 limitators_profile = {@(X)(true(size(X, 1), 1))};
0784 %limitators_profile_vectorised = {@(x)true(size(X))};
0785 closest.fn = @(x, ~)(x(1)); %workaround, see this collapser
0786 closest.ln = 'Only the closest measurement pair';
0787 % ----------
0788 % MHS -CPR
0789 % ----------
0790 %mw_global = {@(X)(X(:, D.CollocatedDataset_mhs_cpr.cols.DIST)<7.5), ...
0791 %               @(X)(abs(X(:, D.CollocatedDataset_mhs_cpr.cols.INT))<600)};
0792 mw_global_vec = {{{'DIST'}, @(X)(X<7.5)}, ...
0793                  {{'INT'}, @(X)(abs(X)<600)}};
0794 
0795 % FIXME: put those back after bugfix
0796 cpr_iwp_fields = vec2row({'ROIWP', 'IOROIWP', 'IWP_2C', 'dardar_IWP', 'RO_liq_water_path', 'LO_RO_liquid_water_path'});
0797 %cpr_ecmwf_prof_fields = vec2row({'ECMWF_Temperature', 'ECMWF_Pressure', 'ECMWF_Specific_humidity'});
0798 %cpr_ecmwf_prof_fields = vec2row({'ECMWF_Temperature'});
0799 cpr_ecmwf_prof_fields = {};
0800 cpr_ecmwf_scal_fields = vec2row({'ECMWF_Surface_pressure', 'ECMWF_Skin_temperature', 'ECMWF_Temperature_2m', 'ECMWF_elevation'});
0801 for cprf = vec2row(union(cpr_iwp_fields, union(cpr_ecmwf_prof_fields, cpr_ecmwf_scal_fields)))
0802     f = cprf{1};
0803     appccs.(f).limitators = limitators_scalar;
0804     if ismember(f, union(cpr_iwp_fields, cpr_ecmwf_scal_fields))
0805         appccs.(f).limitators = limitators_scalar;
0806 
0807         %len = @length;
0808         len_vec = @(X, ~)(vec2col(sum(~isnan(X), 1)));
0809         %mn = @mean;
0810         mn_vec = @(X, ~)(vec2col(nanmean(X, 1)));
0811         %st = @std;
0812         st_vec = @(X, ~)(vec2col(nanstd(X, 0, 1)));
0813         %cv = @(X)(std(X) ./ mean(X));
0814     elseif ismember(f, cpr_ecmwf_prof_fields)
0815         appccs.(f).limitators = limitators_profile;
0816         len = @(X, ~)(size(X, 1));
0817         len_vec = len;
0818         mn = @(X, ~)(mean(X, 1));
0819         mn_vec = mn;
0820         st = @(X, ~)(std(X, 0, 1));
0821         st_vec = st;
0822         %cv = @(X)(std(X, 0, 1) ./ mean(X, 1));
0823     end
0824     
0825     appccs.(f).processors.NO = len_vec;
0826     appccs.(f).stored.NO.type = 'short';
0827     appccs.(f).stored.NO.atts.long_name = 'Number of CloudSat footprints used for statistics inside AMSU-B/MHS';
0828     appccs.(f).stored.NO.atts.missing_value = 0;
0829     appccs.(f).processors.MEAN = mn_vec;
0830     appccs.(f).stored.MEAN.type = 'float';
0831     appccs.(f).stored.MEAN.atts.long_name = ['MHS-averaged ' fields.cpr.(f).atts.long_name];
0832     appccs.(f).stored.MEAN.atts.units = fields.cpr.(f).atts.units;
0833     appccs.(f).stored.MEAN.atts.missing_value = -1;
0834     appccs.(f).processors.STD = st_vec;
0835     appccs.(f).stored.STD.type = 'float';
0836     appccs.(f).stored.STD.atts.long_name = ['CPR-in-MHS standard deviation for ' fields.cpr.(f).atts.long_name];
0837     appccs.(f).stored.STD.atts.units = fields.cpr.(f).atts.units;
0838     appccs.(f).stored.STD.atts.missing_value = -1;
0839 %     appccs.(f).processors.CV = cv;
0840 %     appccs.(f).stored.CV.type = 'float';
0841 %     appccs.(f).stored.CV.atts.long_name = ['Coefficient of variation of CPR ' fields.cpr.(f).atts.long_name];
0842 %     appccs.(f).stored.CV.atts.missing_value = 0;
0843     
0844     if ismember(f, cpr_iwp_fields)
0845         for iwp = [1, 10, 40, 1000]
0846             fn = sprintf('FRAC%d', iwp);
0847             %appccs.(f).processors.(fn) = @(X)(sum(X>=iwp) / length(X));
0848             appccs.(f).processors.(fn) = @(X, ~)vec2col(sum(X>=iwp, 1) ./ sum(~isnan(X), 1));
0849             appccs.(f).stored.(fn).type = 'float';
0850             appccs.(f).stored.(fn).atts.long_name = sprintf('Cloud fraction according to %s >= %d %s', ...
0851                 fields.cpr.(f).atts.long_name, iwp, fields.cpr.(f).atts.units);
0852             appccs.(f).stored.(fn).atts.missing_value = -1;
0853         end
0854     end
0855 end
0856 %appccs.ECMWF_Temperature.stored.NO.profile = false;
0857 
0858 %appccs.ROIWP.limitators = limitators; % not flagged
0859 %appccs.ROIWP.processors.NO = @length;
0860 %appccs.ROIWP.stored.NO.type = 'int';
0861 %appccs.ROIWP.stored.NO.atts.long_name = 'Number of CloudSat footprints used for statistics inside AMSU-B/MHS';
0862 %appccs.ROIWP.processors.MEAN = @mean;
0863 %appccs.ROIWP.stored.MEAN.type = 'float';
0864 %appccs.ROIWP.stored.MEAN.atts.long_name = ['MHS-averaged ' fields.cpr.ROIWP.atts.long_name];
0865 %appccs.ROIWP.stored.MEAN.atts.units = fields.cpr.ROIWP.atts.units;
0866 %appccs.ROIWP.processors.STD = @std;
0867 %appccs.ROIWP.stored.STD.type = 'float';
0868 %appccs.ROIWP.stored.STD.atts.long_name = ['CPR-in-MHS standard deviation for ' fields.cpr.ROIWP.atts.long_name];
0869 %appccs.ROIWP.stored.STD.atts.units = fields.cpr.ROIWP.atts.units;
0870 %appccs.ROIWP.processors.CV = @(X)(std(X) ./ mean(X));
0871 %appccs.ROIWP.stored.CV.type = 'int';
0872 %appccs.ROIWP.stored.CV.atts.long_name = ['Coefficient of variation of CPR ' fields.cpr.ROIWP.atts.long_name];
0873 %appccs.ROIWP.stored.CV.atts.missing_value = 0;
0874 %
0875 %for iwp = [1 10 100 1000]
0876 %    fn = sprintf('FRAC%d', iwp);
0877 %    appccs.ROIWP.processors.(fn) = @(X)(sum(X>=iwp) / length(X));
0878 %    appccs.ROIWP.stored.(fn).type = 'float';
0879 %    appccs.ROIWP.stored.(fn).atts.long_name = sprintf('Cloud fraction according to %s >= %d %s', ...
0880 %        fields.cpr.ROIWP.atts.long_name, iwp, fields.cpr.ROIWP.atts.units);
0881 %end
0882 
0883 % -------
0884 % cloud_cci
0885 % -------
0886 cloud_cci_global = {@(X)(X(:,D.CollocatedDataset_cloud_cci_dardarsub.cols.DIST)==min(X(:,D.CollocatedDataset_cloud_cci_dardarsub.cols.DIST)))};
0887 vars = {'iwp','iwp_error','ref_ice','cot_ice'};
0888 for V = vars
0889     cloud_cci.(V{1}).atts = fields.cloud_cci.(V{1}).atts;
0890     cloud_cci.(V{1}).processors.CLOSEST = closest.fn;
0891     cloud_cci.(V{1}).stored.CLOSEST.atts = fields.cloud_cci.(V{1}).atts;
0892     cloud_cci.(V{1}).stored.CLOSEST.atts.long_name  = [V{1} ': ' closest.ln];
0893     cloud_cci.(V{1}).stored.CLOSEST.type = D.cloud_cci.pseudo_fields.(V{1}).type;
0894     cloud_cci.(V{1}).limitators = limitators_scalar;
0895 end
0896 
0897 % Collapsed MODIS (will be depricated)
0898 % ----------
0899 modis_global = {@(X)(X(:,D.CollocatedDataset_dardarsub_modis.cols.DIST)==min(X(:,D.CollocatedDataset_dardarsub_modis.cols.DIST)))};
0900 vars={'modis_IWP','Re_ice','Tau_ice'};
0901 for V = vars
0902     modis.(V{1}).atts = fields.modis.(V{1}).atts;
0903     modis.(V{1}).processors.CLOSEST = closest.fn;
0904     modis.(V{1}).stored.CLOSEST.atts = fields.modis.(V{1}).atts;
0905     modis.(V{1}).stored.CLOSEST.atts.long_name  = [V{1} ': ' closest.ln];
0906     modis.(V{1}).stored.CLOSEST.type = D.modis_aqua_L2.pseudo_fields.(V{1}).type;
0907     modis.(V{1}).limitators = limitators_scalar;
0908 end
0909 
0910 % ----------
0911 % Collapsed MODIS
0912 
0913 additionalvars={'modis_IWP_uncertainty','Cloud_Multi_Layer_Flag','modis_IWP','Re_ice','Tau_ice'};
0914 for V = additionalvars
0915     modis2.(V{1}).atts = fields.modis.(V{1}).atts;
0916     modis2.(V{1}).processors.CLOSEST = closest.fn;
0917     modis2.(V{1}).stored.CLOSEST.atts = fields.modis.(V{1}).atts;
0918     modis2.(V{1}).stored.CLOSEST.atts.long_name  = [V{1} ': ' closest.ln];
0919     modis2.(V{1}).stored.CLOSEST.type = fields.modis.(V{1}).type;
0920     modis2.(V{1}).limitators = limitators_scalar;
0921 end
0922 
0923 % -------
0924 % amsua over gras
0925 % -------
0926 
0927 amsua_global_lim =  {@(X)(X(:, D.collocation_gras_amsua.cols.DIST)<100), ...
0928                  @(X)(abs(X(:, D.collocation_gras_amsua.cols.INT))<3600)};
0929 
0930             
0931 % comment out, because I have no good way to handle the case where some
0932 % channels are flagged but others are not; I don't want to skip an entire
0933 % primary footprint because ONE of the channels is flagged, but I still
0934 % need a value for each channel; handle this in the processors instead
0935 %capsed_amsua.A_BT.limitators = limitators_scalar;
0936 capsed_amsua.A_BT.processors.NO = @(X, ~)(sum(X>0, 1));
0937 capsed_amsua.A_BT.stored.NO.type = 'int';
0938 capsed_amsua.A_BT.stored.NO.atts.long_name = 'Number of AMSU-A used for stats within GRAS';
0939 capsed_amsua.A_BT.stored.NO.atts.valid_min = 0;
0940 %capsed_amsua.A_BT.stored.NO.profile = false;
0941 capsed_amsua.A_BT.processors.MEAN = @(X, ~)(ignoreNeG(X, @mean, 1));
0942 capsed_amsua.A_BT.stored.MEAN.type = 'float';
0943 capsed_amsua.A_BT.stored.MEAN.atts.units = fields.amsua.A_BT.atts.units;
0944 capsed_amsua.A_BT.stored.MEAN.atts.long_name = ['Mean ' fields.amsua.A_BT.atts.long_name];
0945 capsed_amsua.A_BT.stored.MEAN.atts.valid_range = [200, 350];
0946 capsed_amsua.A_BT.stored.MEAN.atts.missing_value = -9999;
0947 capsed_amsua.A_BT.processors.STD = @(X, ~)(ignoreNeG(X, @std, 1));
0948 capsed_amsua.A_BT.stored.STD.type = 'float';
0949 capsed_amsua.A_BT.stored.STD.atts.units = fields.amsua.A_BT.atts.units;
0950 capsed_amsua.A_BT.stored.STD.atts.long_name = ['Std. of ' fields.amsua.A_BT.atts.long_name];
0951 capsed_amsua.A_BT.stored.STD.atts.valid_min = 0;
0952 capsed_amsua.A_BT.stored.STD.atts.missing_value = -9999;
0953 %capsed_amsua.A_BT.limitators.CLOSEST = {@(X)(X(:, D.collocation_gras_amsua.cols.DIST)==min(X(:, D.collocation_gras_amsua.cols.DIST)))};
0954 capsed_amsua.A_BT.processors.CLOSEST = @(X, Y)(flagneg(X(Y(:, D.collocation_gras_amsua.cols.DIST)==min(Y(:, D.collocation_gras_amsua.cols.DIST)), :)));
0955 %capsed_amsua.A_BT.processors.CLOSEST = @closest_nonneg;
0956 capsed_amsua.A_BT.stored.CLOSEST.type = 'float';
0957 capsed_amsua.A_BT.stored.CLOSEST.atts.units = fields.amsua.A_BT.atts.units;
0958 capsed_amsua.A_BT.stored.CLOSEST.atts.long_name = ['Closest ' fields.amsua.A_BT.atts.long_name];
0959 capsed_amsua.A_BT.stored.CLOSEST.atts.valid_range = capsed_amsua.A_BT.stored.MEAN.atts.valid_range;
0960 capsed_amsua.A_BT.stored.CLOSEST.atts.missing_value = capsed_amsua.A_BT.stored.MEAN.atts.missing_value;
0961 % FIXME: this one for use in gras/amsua.  Does not work yet.
0962 % capsed_amsua.LAT2.incore = true;
0963 % capsed_amsua.LAT2.processors.CLOSEST = capsed_amsua.A_BT.processors.CLOSEST;
0964 % capsed_amsua.LAT2.stored.CLOSEST.type = D.collocation_gras_amsua.members.LAT2.type;
0965 % capsed_amsua.LAT2.stored.CLOSEST.atts.units = D.collocation_gras_amsua.members.LAT2.atts.units;
0966 % capsed_amsua.LAT2.stored.CLOSEST.atts.long_name = ['Closest ' D.collocation_gras_amsua.members.LAT2.atts.long_name];
0967 % capsed_amsua.LAT2.stored.CLOSEST.atts.valid_range = D.collocation_gras_amsua.members.LAT2.atts.valid_range;
0968 % capsed_amsua.LAT2.stored.CLOSEST.atts.missing_value = -9999;
0969 % capsed_amsua.LON2.incore = true;
0970 % capsed_amsua.LON2.processors.CLOSEST = capsed_amsua.A_BT.processors.CLOSEST;
0971 % capsed_amsua.LON2.stored.CLOSEST.type = D.collocation_gras_amsua.members.LON2.type;
0972 % capsed_amsua.LON2.stored.CLOSEST.atts.units = D.collocation_gras_amsua.members.LON2.atts.units;
0973 % capsed_amsua.LON2.stored.CLOSEST.atts.long_name = ['Closest ' D.collocation_gras_amsua.members.LON2.atts.long_name];
0974 % capsed_amsua.LON2.stored.CLOSEST.atts.valid_range = D.collocation_gras_amsua.members.LON2.atts.valid_range;
0975 % capsed_amsua.LON2.stored.CLOSEST.atts.missing_value = -9999;
0976 
0977 % ------
0978 % avhrr
0979 % ------
0980 
0981 %avhrr_capsed.AVHRR_Y.processors.NO = @(X)(size(X, 1));
0982 avhrr_capsed.AVHRR_Y.processors.NO = @(X, ~)(vec2col(par(sum(~isnan(X), 1), ':', ':', 3)));
0983 avhrr_capsed.AVHRR_Y.stored.NO.type = 'short';
0984 avhrr_capsed.AVHRR_Y.stored.NO.atts.long_name = 'Number of AVHRR footprints used for statistics inside AMSU-B/MHS';
0985 avhrr_capsed.AVHRR_Y.stored.NO.atts.missing_value = 0;
0986 avhrr_capsed.AVHRR_Y.stored.NO.profile = false;
0987 %avhrr_capsed.AVHRR_Y.processors.MEAN = @(X)(mean(X, 1));
0988 avhrr_capsed.AVHRR_Y.processors.MEAN = @(X, ~)(squeeze(nanmean(X, 1)));
0989 avhrr_capsed.AVHRR_Y.stored.MEAN.type = 'float';
0990 avhrr_capsed.AVHRR_Y.stored.MEAN.atts.long_name = 'MHS-averaged AVHRR BT';
0991 avhrr_capsed.AVHRR_Y.stored.MEAN.atts.units = 'albedo or BT';
0992 avhrr_capsed.AVHRR_Y.stored.MEAN.atts.missing_value = -1;
0993 %avhrr_capsed.AVHRR_Y.processors.STD = @(X)(std(X, 0, 1));
0994 avhrr_capsed.AVHRR_Y.processors.STD = @(X, ~)(squeeze(nanstd(X, 0, 1)));
0995 avhrr_capsed.AVHRR_Y.stored.STD.type = 'float';
0996 avhrr_capsed.AVHRR_Y.stored.STD.atts.long_name = 'AVHRR-in-MHS standard deviation';
0997 avhrr_capsed.AVHRR_Y.stored.STD.atts.units = avhrr_capsed.AVHRR_Y.stored.MEAN.atts.units;
0998 avhrr_capsed.AVHRR_Y.stored.STD.atts.missing_value = -1;
0999 % avhrr_capsed.AVHRR_Y.processors.CV = @(X)(std(X, 0, 1) ./ mean(X, 1));
1000 % avhrr_capsed.AVHRR_Y.stored.CV.type = 'float';
1001 % avhrr_capsed.AVHRR_Y.stored.CV.atts.long_name = 'Coefficient of variation of AVHRR in MHS';
1002 % avhrr_capsed.AVHRR_Y.stored.CV.atts.missing_value = 0;
1003 % avhrr_capsed.AVHRR_FLAG_3AB.processors.MEAN = mn;
1004 avhrr_capsed.AVHRR_FLAG_3AB.processors.MEAN = @(X, ~)vec2col(nanmean(X, 1));
1005 avhrr_capsed.AVHRR_FLAG_3AB.stored.MEAN.type = 'float';
1006 avhrr_capsed.AVHRR_FLAG_3AB.stored.MEAN.atts.long_name = 'MHS-averaged AVHRR BT';
1007 avhrr_capsed.AVHRR_FLAG_3AB.stored.MEAN.atts.units = 'albedo or BT';
1008 avhrr_capsed.AVHRR_FLAG_3AB.stored.MEAN.atts.missing_value = -1;
1009     
1010 
1011 % -------------------
1012 % COLLAPSED DATASETS
1013 % --------------------
1014 
1015 Collapser(D.associated_CPR_MHS_AMSU_HIRS, appccs, mw_global_vec, ...
1016     'name', 'collapsed_associated_CPR_MHS_AMSU_HIRS', ...
1017     'vectorised', true);
1018 
1019 Collapser(D.associated_CPR_AMSUB_AMSUA_HIRS, appccs, mw_global_vec, ...
1020     'name', 'collapsed_associated_CPR_AMSUB_AMSUA_HIRS', ...
1021     'vectorised', true);
1022 
1023 Collapser(D.dardarsub_modis_IWP,modis,modis_global, ...
1024     'name','dardarsub_modis_collapsedIWP'); % will be depricated by 'dardarsub_modis_closest_ice_clouds' in the future
1025  
1026 
1027 Collapser(D.dardarsub_modis_ice_clouds,modis2,modis_global, ...
1028     'name','dardarsub_modis_closest_ice_clouds');
1029 
1030 Collapser(D.dardarsub_modis_cprCloudLidar,getSelection(modis2,'modis_IWP'),modis_global, ...
1031     'name','dardarsub_modis_cprCloudLidar_closest');
1032 
1033 Collapser(D.cloud_cci_dardarsub_ice_clouds,cloud_cci,cloud_cci_global, ...
1034     'name','cloud_cci_dardarsub_closest_ice_clouds');
1035 
1036 Collapser(D.associated_gras_amsua, capsed_amsua, amsua_global_lim, ...
1037     'name', 'collapsed_gras_amsua');
1038 
1039 Collapser(D.associated_mhs_avhrr, avhrr_capsed, ...
1040     {{{'DIST'}, @(X)(X<7.5)}, ...
1041      {{'INT'}, @(X)(abs(X)<60)}}, ...
1042      'vectorised', true, ...
1043      'name', 'collapsed_mhs_avhrr');
1044 
1045 % this one uses some subfunctions, so is defined in its own file
1046 define_c2dp('mhs');
1047 define_c2dp('amsub');
1048 
1049 %% CollocatedDatasets (and their AssociatedDatasets) depending on Collapsers
1050 
1051 % name 'cacmah' short for collapsed_associated_CPR_MHS_AMSU_HIRS
1052 
1053 CollocatedDataset(...
1054     D.collapsed_associated_CPR_MHS_AMSU_HIRS, ...
1055     D.avhrr, ...
1056     'name', 'Collocated_cacmah_avhrr', ...
1057     'distance', 10, ...
1058     'interval', 30);
1059 
1060 % for fields, I want ROIWP_NO, ROIWP_MEAN, ...
1061 
1062 % fields for fieldcopier cacmah avhrr, defined here because relies on other
1063 % things defined in this namespace
1064 %
1065 % In this fieldcopier, I have:
1066 % - fields from CollocatedDataset_mhs_cpr
1067 % - fields from associated_CPR_MHS_AMSU_HIRS
1068 % - fields from collapser
1069 % total 73 fields!
1070 
1071 fc1 = catstruct(...
1072         struct(...
1073             'MHS_START', D.CollocatedDataset_mhs_cpr.members.START1, ...
1074             'MHS_LINE', D.CollocatedDataset_mhs_cpr.members.LINE1, ...
1075             'MHS_POS', D.CollocatedDataset_mhs_cpr.members.POS1, ...
1076             'MHS_TIME', D.CollocatedDataset_mhs_cpr.members.TIME1, ...
1077             'MHS_LAT', D.CollocatedDataset_mhs_cpr.members.LAT1, ...
1078             'MHS_LON', D.CollocatedDataset_mhs_cpr.members.LON1), ...
1079         getfields(mem2fc(D.associated_CPR_MHS_AMSU_HIRS.members), ...
1080                   'B_LZA', 'B_LAA', 'B_SZA', 'B_SAA', 'B_BT', 'A_LONG', ...
1081                   'A_LAT', 'A_BT', 'A_POS', 'A_LINE', 'H_LONG', 'H_LAT', 'H_BT', 'H_POS', 'H_LINE'), ...
1082         collapsed2fc(appccs));
1083 
1084 fc1.MHS_START.realname = 'START1';
1085 fc1.MHS_LINE.realname = 'LINE1';
1086 fc1.MHS_POS.realname = 'POS1';
1087 fc1.MHS_TIME.realname = 'TIME1';
1088 fc1.MHS_LAT.realname = 'LAT1';
1089 fc1.MHS_LON.realname = 'LON1';
1090 
1091 % FIXME: more from fc2?
1092 fc2 = getfields(fields.avhrr, 'AVHRR_Y', 'AVHRR_FLAG_3AB');
1093 
1094 FieldCopier(...
1095     D.Collocated_cacmah_avhrr, ...
1096     fc1, fc2, 'name', 'associated_cacmah_avhrr');
1097     
1098 Collapser(D.associated_cacmah_avhrr, avhrr_capsed, mw_global_vec, ...
1099     'name', 'collapsed_cacmah_avhrr', ...
1100     'vectorised', true);
1101     
1102 
1103 %%
1104 defined = true;
1105 logtext(atmlab('OUT'), 'Datasets defined. Everything seems fine.\n');
1106 
1107 end
1108 
1109 function fields = listOfDatasetsFields()
1110 %% listOfDatasetsFields
1111 %
1112 % Purpose: List fields belonging to satDatasets in here. This fields are to be
1113 % used in the fieldCopiers
1114 
1115 D = datasets();
1116 
1117 %% helpers for AssociatedDataset definitions
1118 
1119 sza.type = 'float';
1120 sza.realname = 'sza';
1121 sza.atts.long_name = 'Solar zenith angle';
1122 sza.atts.units = 'degrees';
1123 sza.atts.valid_range = [0 180];
1124 
1125 saa.type = 'float';
1126 saa.realname = 'saa';
1127 saa.atts.long_name = 'Solar azimuth angle';
1128 saa.atts.units = 'degrees';
1129 saa.atts.valid_range = [0 360];
1130 
1131 lza.type = 'float';
1132 lza.realname = 'lza';
1133 lza.atts.long_name = 'Local zenith angle';
1134 lza.atts.units = 'degrees';
1135 lza.atts.valid_range = [0 180];
1136 lza.atts.missing_value = -9999;
1137 
1138 laa.type = 'float';
1139 laa.realname = 'laa';
1140 laa.atts.long_name = 'Local azimuth angle';
1141 laa.atts.units = 'degrees';
1142 laa.atts.valid_range = [0 360];
1143 laa.atts.missing_value = -9999;
1144 
1145 %% Fields for datasets
1146 
1147 %% AMSU-A
1148 fields.amsua.A_LONG.type = 'float';
1149 fields.amsua.A_LONG.realname = 'lon';
1150 fields.amsua.A_LONG.atts.long_name = 'AMSU-A Longitude';
1151 fields.amsua.A_LONG.atts.units = 'degrees_east';
1152 fields.amsua.A_LONG.atts.valid_range = [-180 180];
1153 fields.amsua.A_LAT.type = 'float';
1154 fields.amsua.A_LAT.realname = 'lat';
1155 fields.amsua.A_LAT.atts.long_name = 'AMSU-A Latitude';
1156 fields.amsua.A_LAT.atts.units = 'degrees_north';
1157 fields.amsua.A_LAT.atts.valid_range = [-90 90];
1158 fields.amsua.A_TIME.type = 'int';
1159 fields.amsua.A_TIME.realname = 'time';
1160 fields.amsua.A_TIME.atts.long_name = 'AMSU-A measurement time';
1161 fields.amsua.A_TIME.atts.units = 'seconds since 1970-01-01 00:00:00';
1162 fields.amsua.A_LZA = lza;
1163 fields.amsua.A_LAA = laa;
1164 fields.amsua.A_SAA = saa;
1165 fields.amsua.A_SZA = sza;
1166 fields.amsua.A_BT.type = 'float';
1167 fields.amsua.A_BT.realname = 'tb';
1168 fields.amsua.A_BT.dims = {'AMSUA_CHANS', 15};
1169 fields.amsua.A_BT.atts.long_name = 'AMSU-A Brightness Temperature';
1170 fields.amsua.A_BT.atts.units = 'Kelvin';
1171 fields.amsua.A_BT.atts.missing_value = -9999;
1172 fields.amsua.A_LINE.type = 'int';
1173 fields.amsua.A_LINE.realname = 'scanline_number';
1174 fields.amsua.A_LINE.atts.long_name = 'AMSU-A scanline number';
1175 fields.amsua.A_LINE.atts.valid_min = 1;
1176 fields.amsua.A_POS.type = 'byte';
1177 fields.amsua.A_POS.realname = 'scanline_position';
1178 fields.amsua.A_POS.atts.long_name = 'AMSU-A scanline position';
1179 fields.amsua.A_POS.atts.valid_range = [1 30];
1180 fields.amsua.A_ELEV.type = 'int';
1181 fields.amsua.A_ELEV.realname = 'elev';
1182 fields.amsua.A_ELEV.atts.long_name = 'AMSU-A satellite elevation';
1183 fields.amsua.A_ELEV.atts.units = 'km';
1184 fields.amsua.A_ELEV.atts.valid_min = 0;
1185 fields.amsua.A_SATLAT.type = 'float';
1186 fields.amsua.A_SATLAT.realname = 'satlat';
1187 fields.amsua.A_SATLAT.atts.long_name = 'AMSU-A satellite latitude';
1188 fields.amusa.A_SATLAT.atts.units = 'degrees_north';
1189 fields.amsua.A_SATLAT.atts.valid_range = [-90, 90];
1190 fields.amsua.A_SATLON.type = 'float';
1191 fields.amsua.A_SATLON.realname = 'satlon';
1192 fields.amsua.A_SATLON.atts.long_name = 'AMSU-A satellite longitude';
1193 fields.amusa.A_SATLON.atts.units = 'degrees_east';
1194 fields.amsua.A_SATLON.atts.valid_range = [-180, 180];
1195 
1196 %% AMSU-B
1197 fields.amsub.B_LZA = lza;
1198 fields.amsub.B_LAA = laa;
1199 fields.amsub.B_SZA = sza;
1200 fields.amsub.B_SAA = saa;
1201 fields.amsub.B_BT.type = 'float';
1202 fields.amsub.B_BT.realname = 'tb';
1203 fields.amsub.B_BT.dims = {'AMSUB_CHANS', 5};
1204 fields.amsub.B_BT.atts.long_name = 'AMSU-B Brightness Temperature';
1205 fields.amsub.B_BT.atts.units = 'Kelvin';
1206 
1207 fields.amsub1.LZA1 = lza;
1208 fields.amsub1.LAA1 = laa;
1209 fields.amsub1.SZA1 = sza;
1210 fields.amsub1.SAA1 = saa;
1211 fields.amsub1.BT1.type = 'float';
1212 fields.amsub1.BT1.realname = 'tb';
1213 fields.amsub1.BT1.dims = {'AMSUB_CHANS', 5};
1214 fields.amsub1.BT1.atts.long_name = 'AMSU-B Brightness Temperature, primary';
1215 fields.amsub1.BT1.atts.units = 'Kelvin';
1216 
1217 fields.amsub2.LZA2 = lza;
1218 fields.amsub2.LAA2 = laa;
1219 fields.amsub2.SZA2 = sza;
1220 fields.amsub2.SAA2 = saa;
1221 fields.amsub2.BT2.type = 'float';
1222 fields.amsub2.BT2.realname = 'tb';
1223 fields.amsub2.BT2.dims = {'AMSUB_CHANS', 5};
1224 fields.amsub2.BT2.atts.long_name = 'AMSU-B Brightness Temperature, primary';
1225 fields.amsub2.BT2.atts.units = 'Kelvin';
1226 
1227 %% AVHRR
1228 
1229 fields.avhrr.AVHRR_Y.type = 'float';
1230 fields.avhrr.AVHRR_Y.realname = 'y';
1231 fields.avhrr.AVHRR_Y.dims = {'AVHRR_CHANS', 5};
1232 fields.avhrr.AVHRR_Y.atts.long_name = 'AMSU-B measurement';
1233 fields.avhrr.AVHRR_Y.atts.units = 'Albedo or Kelvin';
1234 fields.avhrr.AVHRR_FLAG_3AB.type = 'byte';
1235 fields.avhrr.AVHRR_FLAG_3AB.realname = 'flag_3_is_3A';
1236 fields.avhrr.AVHRR_FLAG_3AB.atts.long_name = 'Channel 3 flag; 1=3A, 0=3B';
1237 
1238 %% cloud_cci
1239 fields.cloud_cci.cwp.type               = 'short'; % int16
1240 fields.cloud_cci.cwp.atts.long_name     = 'cloud liquid water path';
1241 fields.cloud_cci.cwp.atts.units         = 'g/m2';
1242 fields.cloud_cci.cwp.atts.missing_value = -32767;
1243 fields.cloud_cci.cwp.atts.valid_range   = [0 20000];
1244 fields.cloud_cci.cwp.atts.description   = ...
1245     'Atmosphere mass content of cloud liquid water';
1246 fields.cloud_cci.cwp_uncertainty.type               = 'short'; % int16
1247 fields.cloud_cci.cwp_uncertainty.atts.long_name     = 'CWP uncertainty';
1248 fields.cloud_cci.cwp_uncertainty.atts.units         = 'g/m2';
1249 fields.cloud_cci.cwp_uncertainty.atts.missing_value = -32767;
1250 fields.cloud_cci.cwp_uncertainty.atts.valid_range   = [0 40000];
1251 fields.cloud_cci.cwp_uncertainty.atts.description   = ...
1252     ['Uncertainty of atmospheric mass content of cloud liquid water. '...
1253      'If iwp>0 then cwp_uncertainty = iwp_uncertianty'];
1254 fields.cloud_cci.phase.type                 = 'byte'; %int8
1255 fields.cloud_cci.phase.atts.long_name       = 'cloud phase flag';
1256 fields.cloud_cci.phase.atts.units           = '';
1257 fields.cloud_cci.phase.atts.missing_value   = -127;
1258 fields.cloud_cci.phase.atts.valid_range     = [0 2];
1259 fields.cloud_cci.phase.atts.description     = ...
1260     ['thermodynamic_phase_ofields.cloud_water_particles_at_cloud_top'...
1261     '[0 1 2] means clear/unknown liquid ice. (use cc_total for cloud masking)'];
1262 fields.cloud_cci.cc_total.type              = 'byte';
1263 fields.cloud_cci.cc_total.atts.long_name    = 'cloud fraction';
1264 fields.cloud_cci.cc_total.atts.units        = '-';
1265 fields.cloud_cci.cc_total.atts.missing_value= -128;
1266 fields.cloud_cci.cc_total.atts.valid_range  = [0 1];
1267 fields.cloud_cci.cc_total.atts.description  = ...
1268     ['Essentially a cloud flag. 0= cloud free, 1= cloudy. '...
1269     'This field name is used in the level products and then means total cloud cover'];
1270 fields.cloud_cci.iwp.type                = 'short';
1271 fields.cloud_cci.iwp.atts.long_name      = 'ice water path';
1272 fields.cloud_cci.iwp.atts.units          = 'g/m^2';
1273 fields.cloud_cci.iwp.atts.missing_value  = -32767;
1274 fields.cloud_cci.iwp.atts.valid_range    = [0 20000];
1275 fields.cloud_cci.iwp.dependencies_struct = getSelection(fields.cloud_cci,{'cwp','phase','cc_total'});
1276 fields.cloud_cci.iwp.atts.description    = ...
1277     'cloud ice water path from AVHRR solar reflectance channels';
1278 
1279 fields.cloud_cci.iwp_error.type               = 'short'; % int16
1280 fields.cloud_cci.iwp_error.atts.long_name     = 'IWP uncertainty';
1281 fields.cloud_cci.iwp_error.atts.units         = 'g/m^2';
1282 fields.cloud_cci.iwp_error.atts.missing_value = -32767;
1283 fields.cloud_cci.iwp_error.atts.valid_range   = [0 40000];
1284 fields.cloud_cci.iwp_error.dependencies_struct = getSelection(fields.cloud_cci,{'cwp_uncertainty','phase','cc_total'});
1285 fields.cloud_cci.iwp_error.atts.description   = ...
1286     'Uncertainty of atmospheric mass content of cloud ice';
1287  
1288 fields.cloud_cci.ref.type                = 'short';
1289 fields.cloud_cci.ref.atts.long_name      = 'effective radius';
1290 fields.cloud_cci.ref.atts.units          = 'micron';
1291 fields.cloud_cci.ref.atts.missing_value  = -32767;
1292 fields.cloud_cci.ref.atts.valid_range    = [0 200];
1293 fields.cloud_cci.ref.atts.description    = ...
1294     'effective radius of cloud condensed water particles at cloud top';
1295 fields.cloud_cci.ref_uncertainty.type                = 'short';
1296 fields.cloud_cci.ref_uncertainty.atts.long_name      = 'uncertainty in effective radius retrieval';
1297 fields.cloud_cci.ref_uncertainty.atts.units          = 'micron';
1298 fields.cloud_cci.ref_uncertainty.atts.missing_value  = -32767;
1299 fields.cloud_cci.ref_uncertainty.atts.valid_range    = [0 200];
1300 fields.cloud_cci.ref_uncertainty.atts.description    = ...
1301     'uncertainty in effective radius of cloud condensed water particles at cloud top';
1302 fields.cloud_cci.ref_ice.type                = 'short';
1303 fields.cloud_cci.ref_ice.atts.long_name      = 'effective radius';
1304 fields.cloud_cci.ref_ice.atts.units          = 'micron';
1305 fields.cloud_cci.ref_ice.atts.missing_value  = -32767;
1306 fields.cloud_cci.ref_ice.atts.valid_range    = [0 200];
1307 fields.cloud_cci.ref_ice.dependencies_struct = getSelection(fields.cloud_cci,{'ref','phase','cc_total'});
1308 fields.cloud_cci.ref_ice.atts.description    = ...
1309     'ice particle effective radius at cloud top';
1310 
1311 fields.cloud_cci.cot.type               = 'short';
1312 fields.cloud_cci.cot.atts.long_name     = 'cloud optical thickness';
1313 fields.cloud_cci.cot.atts.units         = '-';
1314 fields.cloud_cci.cot.atts.missing_value = -32767;
1315 fields.cloud_cci.cot.atts.valid_range   = [0 3200];
1316 fields.cloud_cci.cot.atts.description   = ...
1317     'atmosphere optical thickness due to cloud';
1318 fields.cloud_cci.cot_uncertainty.type               = 'short';
1319 fields.cloud_cci.cot_uncertainty.atts.long_name     = 'Uncertainty in tau_c';
1320 fields.cloud_cci.cot_uncertainty.atts.units         = '-';
1321 fields.cloud_cci.cot_uncertainty.atts.missing_value = -32767;
1322 fields.cloud_cci.cot_uncertainty.atts.valid_range   = [0 3200];
1323 fields.cloud_cci.cot_uncertainty.atts.description   = ...
1324     'Uncertainty in atmosphere optical thickness due to cloud';
1325 fields.cloud_cci.cot_ice.type                = 'short';
1326 fields.cloud_cci.cot_ice.atts.long_name      = 'cloud optical thickness of ice cloud';
1327 fields.cloud_cci.cot_ice.atts.units          = '-';
1328 fields.cloud_cci.cot_ice.atts.missing_value  = -32767;
1329 fields.cloud_cci.cot_ice.atts.valid_range    = [0 3200];
1330 fields.cloud_cci.cot_ice.dependencies_struct   = getSelection(fields.cloud_cci,{'cot','phase','cc_total'});
1331 fields.cloud_cci.cot_ice.atts.description    = ...
1332     'atmosphere optical thickness due to ice cloud';
1333 
1334 %% CLOUDSAT DATASETS
1335 % ---------
1336 
1337 % CLD-CLASS-LIDAR
1338 fields.cpr.CloudFraction.type                = 'float';
1339 fields.cpr.CloudFraction.dataset             = D.cprCloudLidar;
1340 fields.cpr.CloudFraction.atts.long_name      = 'Cloud Fraction';
1341 fields.cpr.CloudFraction.atts.units          = 'none';
1342 fields.cpr.CloudFraction.atts.missing_value  = -99;
1343 fields.cpr.CloudFraction.atts.valid_range    = [0 1];
1344 fields.cpr.CloudFraction.atts.description    = ...
1345     'Cloud fraction within CloudSat foot print determined from CALIPSO lidar measurements';
1346 fields.cpr.CloudPhase.type               = 'byte';
1347 fields.cpr.CloudPhase.dataset            = D.cprCloudLidar;
1348 fields.cpr.CloudPhase.atts.long_name     = 'Cloud Phase';
1349 fields.cpr.CloudPhase.atts.units         = 'none';
1350 fields.cpr.CloudPhase.atts.missing_value = -9;
1351 fields.cpr.CloudPhase.atts.valid_range   = [0 3];
1352 fields.cpr.CloudPhase.atts.description   = ...
1353     'Cloud phase identified by using CALIPSO feature, temperature, and radar reflectivity 1-ice, 2-mixed, 3-water';
1354 fields.cpr.CloudPhaseConfidenceLevel.type                = 'byte';
1355 fields.cpr.CloudPhaseConfidenceLevel.dataset             = D.cprCloudLidar;
1356 fields.cpr.CloudPhaseConfidenceLevel.atts.long_name      = 'Cloud phase confidence level';
1357 fields.cpr.CloudPhaseConfidenceLevel.atts.units          = 'none';
1358 fields.cpr.CloudPhaseConfidenceLevel.atts.missing_value  = -9;
1359 fields.cpr.CloudPhaseConfidenceLevel.atts.valid_range    = [0 10];
1360 fields.cpr.CloudPhaseConfidenceLevel.atts.description    = ...
1361     ['Confidence level assigned to the cloud phase for '...
1362     'each layer. It has a value ranging from 0 to 10. '...
1363     '10 indicates the highest confidence level. If confidence '...
1364     'level is below 5, use the cloud phase with a caution. '];
1365 fields.cpr.CloudLayerType.type               = 'byte';
1366 fields.cpr.CloudLayerType.dataset            = D.cprCloudLidar;
1367 fields.cpr.CloudLayerType.atts.long_name     = 'Cloud layer type';
1368 fields.cpr.CloudLayerType.atts.units         = 'none';
1369 fields.cpr.CloudLayerType.atts.missing_value = -9;
1370 fields.cpr.CloudLayerType.atts.valid_range   = [0 8];
1371 fields.cpr.CloudLayerType.atts.description   = ...
1372     ['Cloud type for each layer. 0 = Not determined 1 = cirrus, 2 = Altostratus, '...
1373     '3 = Altocumulus 4 = Stratus, 5 = Stratocumulus, 6= Cumulus 7 = Deep Convection, 8 = Nimbostratus Cloud'];
1374 fields.cpr.CloudTypeQuality.type                = 'float';
1375 fields.cpr.CloudTypeQuality.dataset             = D.cprCloudLidar;
1376 fields.cpr.CloudTypeQuality.atts.long_name      = 'Cloud type quality';
1377 fields.cpr.CloudTypeQuality.atts.units          = 'none';
1378 fields.cpr.CloudTypeQuality.atts.missing_value  = -99;
1379 fields.cpr.CloudTypeQuality.atts.valid_range    = [0 1];
1380 fields.cpr.CloudTypeQuality.atts.description    = ...
1381     'Cloud Type Quality decided based on fuzzy-logic classification';
1382 fields.cpr.Cloud_Types_Lidar.type               = 'byte';
1383 fields.cpr.Cloud_Types_Lidar.dataset            = D.cprCloudLidar;
1384 fields.cpr.Cloud_Types_Lidar.atts.long_name     = 'Cloud types derived using radar and lidar';
1385 fields.cpr.Cloud_Types_Lidar.atts.units         = 'none';
1386 fields.cpr.Cloud_Types_Lidar.atts.missing_value = -9;
1387 fields.cpr.Cloud_Types_Lidar.atts.valid_range   = [0 10];
1388 fields.cpr.Cloud_Types_Lidar.dependencies_struct= getSelection(fields.cpr,{'CloudFraction','CloudLayerType','CloudTypeQuality'});
1389 fields.cpr.Cloud_Types_Lidar.atts.description   = ...
1390     ['Single cloud class for entire column. 0 = Cloud free (CloudFraction=0 throughout profile),'...
1391     '1 = cirrus, 2 = Altostratus, 3 = Altocumulus, 4 = Stratus, 5 = Stratocumulus, 6= Cumulus,'...
1392     '7 = Deep Convection, 8 = Nimbostratus Cloud, 9 = Mixed (all profiles with more than one cloudtype),'...
1393     '10 = Not determined (equivalent to CloudLayerType = 0) '...
1394     'Note: if any CloudTypeQuality < 0.5 in the column the cloud type '...
1395     'is assinged to missing_value, as are all clouds that have a cloud fraction between 0<cf<1'];
1396 fields.cpr.Cloud_Types_Lidar_multiLayer.type               = 'byte';
1397 fields.cpr.Cloud_Types_Lidar_multiLayer.dataset            = D.cprCloudLidar;
1398 fields.cpr.Cloud_Types_Lidar_multiLayer.atts.long_name     = 'Cloud types derived using radar and lidar';
1399 fields.cpr.Cloud_Types_Lidar_multiLayer.atts.units         = 'none';
1400 fields.cpr.Cloud_Types_Lidar_multiLayer.atts.missing_value = -9;
1401 fields.cpr.Cloud_Types_Lidar_multiLayer.atts.valid_range   = [0 10];
1402 fields.cpr.Cloud_Types_Lidar_multiLayer.dependencies_struct= getSelection(fields.cpr,{'CloudFraction','CloudLayerType','CloudTypeQuality'});
1403 fields.cpr.Cloud_Types_Lidar_multiLayer.atts.description   = ...
1404     sprintf(['0 = Cloud free\n1 = cirrus\n2 = Altostratus\n3 = Altocumulus\n4 = Stratus\n5 = Stratocumulus\n6= Cumulus\n'...
1405     '8 = Deep Convection\n7 = Nimbostratus Cloud\n10 = Not determined (equivalent to CloudLayerType = 0)\n'...
1406     'Note:\n1) If the CloudTypeQuality < 0.5 the clouds is assinged a missing_value.\n'...
1407     '2) All clouds that have a cloud fraction between 0<cf<1 are assigned missing values.\n'...
1408     '3) A cloud covering more than one verticle bin in the original data is regarded as one '...
1409     'cloud here e.g., [6 5 5 1 1] -> [6 5 1]. This is because of a strangity in the original '...
1410     'data were if e.g., deep convection or Nimbotratus exist in the profile, they only fills the first bin\n'...
1411     '4) If there are several clouds in a profile, the lowest cloud is listed first\n'...
1412     'I''ve switched the Deep convective index with the NimboStratus index since it \n'...
1413     'is obviously wrong (judged by looking at 4 years of data)']); %
1414 
1415 % CLD-CLASS
1416 fields.cpr.cloud_scenario.type               = 'short';
1417 fields.cpr.cloud_scenario.dataset            = D.cprCloud;
1418 fields.cpr.cloud_scenario.atts.long_name     = 'Cloud Scenario';
1419 fields.cpr.cloud_scenario.atts.units         = 'none';
1420 fields.cpr.cloud_scenario.atts.missing_value = 0;
1421 fields.cpr.cloud_scenario.atts.description   = ...
1422     'See table 5 (page 42) in 2B_CLDCLASS_PDICD_5.0.pdf on this dataset';
1423 
1424 fields.cpr.Cloud_Types.type                 = 'byte';
1425 fields.cpr.Cloud_Types.dataset              = D.cprCloud;
1426 fields.cpr.Cloud_Types.atts.long_name       = 'Cloud Types';
1427 fields.cpr.Cloud_Types.atts.units           = 'none';
1428 fields.cpr.Cloud_Types.atts.missing_value   = 127;
1429 fields.cpr.Cloud_Types.dependencies_struct  = getSelection(fields.cpr,{'cloud_scenario'});
1430 fields.cpr.Cloud_Types.atts.description     = ...
1431     ['A condensed version of cloud scenario, where the only single '...
1432      'cloud types per profile are retrieved, i.e. if there are multiple '...
1433      'cloudtypes in the same column, the cloudtype is called mixedCloud Types = '...
1434      'No cloud (0), Ci (1), As (2), Ac (3), St (4), Sc (5), Cu (6), Ns (7), DC (8), mixed (9)'];
1435 
1436 fields.cpr.Cloud_Types_multiLayer.type                 = 'byte';
1437 fields.cpr.Cloud_Types_multiLayer.dataset              = D.cprCloud;
1438 fields.cpr.Cloud_Types_multiLayer.atts.long_name       = 'Cloud Types derived using RADAR only';
1439 fields.cpr.Cloud_Types_multiLayer.atts.units           = 'none';
1440 fields.cpr.Cloud_Types_multiLayer.atts.missing_value   = -9;
1441 fields.cpr.Cloud_Types_multiLayer.dependencies_struct  = getSelection(fields.cpr,{'cloud_scenario'});
1442 fields.cpr.Cloud_Types_multiLayer.atts.description     = ...
1443     sprintf(['A condensed version of cloud scenario. Several cloud types per profile are possible'...
1444           'No cloud (0), Ci (1), As (2), Ac (3), St (4), Sc (5), Cu (6), Ns (7), DC (8)']);
1445  
1446 % 2C-ICE
1447 fields.cpr.IWP_2C.realname           = 'ice_water_path';
1448 fields.cpr.IWP_2C.dataset            = D.CPR_2C_ICE;
1449 fields.cpr.IWP_2C.type               = 'float';
1450 fields.cpr.IWP_2C.atts.long_name     = 'retrieved IWP';
1451 fields.cpr.IWP_2C.atts.units         = 'g/m^2';
1452 fields.cpr.IWP_2C.atts.missing_value = -7777;
1453 % fields.cpr.IWP_2C_error.realname       = 'ice_water_path_uncertainty'; % Appears to always be 0
1454 % fields.cpr.IWP_2C_error.dataset        = D.CPR_2C_ICE;
1455 % fields.cpr.IWP_2C_error.type           = 'float';
1456 % fields.cpr.IWP_2C_error.atts.long_name = 'IWP uncertainty';
1457 % fields.cpr.IWP_2C_error.atts.units     = '%';
1458 fields.cpr.IWC_2C.realname       = 'IWC';
1459 fields.cpr.IWC_2C.dataset        = D.CPR_2C_ICE;
1460 fields.cpr.IWC_2C.type           = 'float';
1461 fields.cpr.IWC_2C.atts.long_name = 'retrieved IWC';
1462 fields.cpr.IWC_2C.atts.units     = 'mg/m^3';
1463 fields.cpr.IWC_2C_error.realname       = 'IWC_uncertainty';
1464 fields.cpr.IWC_2C_error.dataset        = D.CPR_2C_ICE;
1465 fields.cpr.IWC_2C_error.type           = 'float';
1466 fields.cpr.IWC_2C_error.atts.long_name = 'IWC uncertainty';
1467 fields.cpr.IWC_2C_error.atts.units     = '%';
1468 % 2B-CWC-RO
1469 fields.cpr.Data_quality.type                = 'short';
1470 fields.cpr.Data_quality.atts.long_name      = 'data quality';
1471 fields.cpr.Data_quality.atts.units          = 'none';
1472 fields.cpr.Data_quality.atts.missing_value  = 127;
1473 fields.cpr.Data_quality.atts.description    = ...
1474     'If 0, then data is of good quality, otherwise treat as bitfield with 8 flags';
1475 fields.cpr.dROIWP.type           = 'float';
1476 fields.cpr.dROIWP.realname       = 'RO_ice_water_path_uncertainty';
1477 fields.cpr.dROIWP.atts.long_name = 'CloudSat Radar-Only CPR IWP uncertainty';
1478 fields.cpr.dROIWP.atts.units     = 'g/m^2';
1479 fields.cpr.dIOROIWP.type             = 'float';
1480 fields.cpr.dIOROIWP.realname         = 'IO_RO_ice_water_path_uncertainty';
1481 fields.cpr.dIOROIWP.atts.long_name   = 'CloudSat Radar-Only Ice-Only CPR IWP uncertainty';
1482 fields.cpr.dIOROIWP.atts.units       = 'g/m^2';
1483 fields.cpr.Height.type           = 'short';
1484 fields.cpr.Height.atts.long_name = 'Height of range bin in Reflectivity/Cloud Mask above reference surface (~ mean sea level)';
1485 fields.cpr.Height.atts.units     = 'm';
1486 fields.cpr.IOROIWP.type              = 'float';
1487 fields.cpr.IOROIWP.realname          = 'IO_RO_ice_water_path';
1488 fields.cpr.IOROIWP.atts.long_name    = 'CloudSat Radar-Only Ice-Only CPR IWP';
1489 fields.cpr.IOROIWP.atts.units        = 'g/m^2';
1490 fields.cpr.IO_RO_ice_water_path      = fields.cpr.IOROIWP;
1491 fields.cpr.IO_RO_ice_water_path.type = 'short';
1492 fields.cpr.RO_ice_water_content.type             = 'short';
1493 fields.cpr.RO_ice_water_content.atts.long_name   = 'ice water content';
1494 fields.cpr.RO_ice_water_content.atts.units       = 'g/m^3';
1495 fields.cpr.RO_ice_water_content_uncertainty.type             = 'short';
1496 fields.cpr.RO_ice_water_content_uncertainty.atts.long_name   = 'ice water content uncertainty';
1497 fields.cpr.RO_ice_water_content_uncertainty.atts.units       = '%';
1498 fields.cpr.RO_ice_water_content_uncertainty.atts.description = ...
1499     ['Fractional uncertainty in the RO retrieved IWC (from the ice-only retrieval), expressed in percent '...
1500      'and rounded to the nearest integer. A value of 250 indicates an uncertainty >= 250%.'];
1501 fields.cpr.RO_liq_water_content.type             = 'short';
1502 fields.cpr.RO_liq_water_content.atts.long_name   = 'liquid water content';
1503 fields.cpr.RO_liq_water_content.atts.units       = 'g/m^3';
1504 fields.cpr.RO_liq_water_content.atts.missing_value = -9;
1505 fields.cpr.RO_liq_water_content_uncertainty.type             = 'short';
1506 fields.cpr.RO_liq_water_content_uncertainty.atts.long_name   = 'liquid water content uncertainty';
1507 fields.cpr.RO_liq_water_content_uncertainty.atts.units       = '%';
1508 fields.cpr.RO_liq_water_content_uncertainty.atts.missing_value = -9;
1509 fields.cpr.RO_liq_water_content_uncertainty.atts.description = ...
1510     ['Fractional uncertainty in the RO retrieved LWC (from the liquid-only retrieval), expressed in percent '...
1511      'and rounded to the nearest integer. A value of 250 indicates an uncertainty >= 250%.'];
1512 fields.cpr.ROIWP.type                = 'float';
1513 fields.cpr.ROIWP.realname            = 'RO_ice_water_path';
1514 fields.cpr.ROIWP.atts.long_name      = 'CloudSat Radar-Only CPR IWP';
1515 fields.cpr.ROIWP.atts.units          = 'g/m^2';
1516 fields.cpr.RO_ice_water_path         = fields.cpr.ROIWP;
1517 fields.cpr.RO_ice_water_path.type    = 'short'; %int16
1518 fields.cpr.RO_liq_water_path.type    = 'short';
1519 fields.cpr.RO_liq_water_path.atts.long_name = 'Radar-only liquid water path';
1520 fields.cpr.RO_liq_water_path.atts.units = 'g/m^2';
1521 fields.cpr.RO_liq_water_path.atts.missing_value = -9;
1522 fields.cpr.LO_RO_liquid_water_path.type = 'short';
1523 fields.cpr.LO_RO_liquid_water_path.atts.long_name = 'Radar-only liquid-only liquid water path';
1524 fields.cpr.LO_RO_liquid_water_path.atts.units = 'g/m^2';
1525 
1526 % 2B-CWC-RVOD
1527 fields.cpr.RVOD_ice_water_path.type              = 'int';
1528 fields.cpr.RVOD_ice_water_path.dataset           = D.CPR_RVOD;
1529 fields.cpr.RVOD_ice_water_path.atts.long_name    = 'RVOD ice water path';
1530 fields.cpr.RVOD_ice_water_path.atts.units        = 'g/m^2';
1531 fields.cpr.RVOD_ice_water_path.atts.missing_value = -3333;
1532 fields.cpr.RVOD_liq_water_path.type              = 'int';
1533 fields.cpr.RVOD_liq_water_path.dataset           = D.CPR_RVOD;
1534 fields.cpr.RVOD_liq_water_path.atts.long_name    = 'Radar Visible Opticle Depth liquid water path';
1535 fields.cpr.RVOD_liq_water_path.atts.units        = 'g/m^2';
1536 fields.cpr.RVOD_liq_water_path.atts.missing_value = -3333;
1537 
1538 % ECMWF_AUX
1539 fields.cpr.ECMWF_Temperature.type = 'float';
1540 fields.cpr.ECMWF_Temperature.dataset = D.CPR_ECMWF;
1541 fields.cpr.ECMWF_Temperature.realname = 'Temperature';
1542 fields.cpr.ECMWF_Temperature.atts.long_name = 'ECMWF temperature';
1543 fields.cpr.ECMWF_Temperature.atts.units = 'K';
1544 fields.cpr.ECMWF_Temperature.atts.missing_value = -999;
1545 %fields.cpr.ECMWF_Temperature.atts
1546 fields.cpr.ECMWF_Pressure.type = 'float';
1547 fields.cpr.ECMWF_Pressure.dataset = D.CPR_ECMWF;
1548 fields.cpr.ECMWF_Pressure.realname = 'Pressure';
1549 fields.cpr.ECMWF_Pressure.atts.long_name = 'ECMWF pressure';
1550 fields.cpr.ECMWF_Pressure.atts.units = 'Pa';
1551 fields.cpr.ECMWF_Pressure.atts.missing_value = -999;
1552 %fields.cpr.ECMWF_Pressure.atts
1553 fields.cpr.ECMWF_Specific_humidity.type = 'float';
1554 fields.cpr.ECMWF_Specific_humidity.dataset = D.CPR_ECMWF;
1555 fields.cpr.ECMWF_Specific_humidity.realname = 'Specific_humidity';
1556 fields.cpr.ECMWF_Specific_humidity.atts.long_name = 'ECMWF Specific humidity';
1557 fields.cpr.ECMWF_Specific_humidity.atts.units = 'kg/kg';
1558 fields.cpr.ECMWF_Specific_humidity.atts.missing_value = -999;
1559 %fields.cpr.ECMWF_Specific_humidity.atts
1560 fields.cpr.ECMWF_Surface_pressure.type = 'float';
1561 fields.cpr.ECMWF_Surface_pressure.dataset = D.CPR_ECMWF;
1562 fields.cpr.ECMWF_Surface_pressure.realname = 'Surface_pressure';
1563 fields.cpr.ECMWF_Surface_pressure.atts.long_name = 'ECMWF surface pressure';
1564 fields.cpr.ECMWF_Surface_pressure.atts.units = 'Pa';
1565 fields.cpr.ECMWF_Surface_pressure.atts.missing_value = -999;
1566 %fields.cpr.ECMWF_Surface_pressure.atts
1567 fields.cpr.ECMWF_Skin_temperature.type = 'float';
1568 fields.cpr.ECMWF_Skin_temperature.dataset = D.CPR_ECMWF;
1569 fields.cpr.ECMWF_Skin_temperature.realname = 'Skin_temperature';
1570 fields.cpr.ECMWF_Skin_temperature.atts.long_name = 'ECMWF skin temperature';
1571 fields.cpr.ECMWF_Skin_temperature.atts.units = 'K';
1572 fields.cpr.ECMWF_Skin_temperature.atts.missing_value = -999;
1573 %fields.cpr.ECMWF_Skin_temperature.atts
1574 fields.cpr.ECMWF_Temperature_2m.type = 'float';
1575 fields.cpr.ECMWF_Temperature_2m.dataset = D.CPR_ECMWF;
1576 fields.cpr.ECMWF_Temperature_2m.realname = 'Temperature_2m';
1577 fields.cpr.ECMWF_Temperature_2m.atts.long_name = 'ECMWF 2m temperature';
1578 fields.cpr.ECMWF_Temperature_2m.atts.units = 'K';
1579 fields.cpr.ECMWF_Temperature_2m.atts.missing_value = -999;
1580 %fields.cpr.ECMWF_Temperature_2m.atts
1581 fields.cpr.ECMWF_elevation.type = 'short';
1582 fields.cpr.ECMWF_elevation.dataset = D.CPR_ECMWF;
1583 fields.cpr.ECMWF_elevation.realname = 'DEM_elevation';
1584 fields.cpr.ECMWF_elevation.atts.long_name = 'ECMWF DEM surface elevation';
1585 fields.cpr.ECMWF_elevation.atts.units = 'm';
1586 fields.cpr.ECMWF_elevation.atts.missing_value = 9999;
1587 %fields.cpr.ECMWF_elevation.atts
1588 
1589 % dardarsub as sibling for cpr defined AFTER dardar_sub
1590 
1591 %% DARDAR_SUB
1592 fields.dardarsub.HEIGHT.realname         = 'height';
1593 fields.dardarsub.HEIGHT.type             = 'float';
1594 fields.dardarsub.HEIGHT.atts.long_name   = 'Height';
1595 fields.dardarsub.HEIGHT.atts.units       = 'm';
1596 fields.dardarsub.HEIGHT.atts.description = 'This field is only available as meta data';
1597 fields.dardarsub.iwc.type            = 'float';
1598 fields.dardarsub.iwc.atts.long_name  = 'Retrieved Ice Water Content, the mass of ice per unit';
1599 fields.dardarsub.iwc.atts.units       = 'kg m-3';
1600 fields.dardarsub.ln_iwc_error.realname      = 'ln_iwc_error';
1601 fields.dardarsub.ln_iwc_error.type          = 'float';
1602 fields.dardarsub.ln_iwc_error.atts.long_name= '1-sigma random error in natural logarithm of IWC';
1603 fields.dardarsub.ln_iwc_error.atts.units     = 'ln(kg m-3)';
1604 fields.dardarsub.dardar_IWP.type                = 'float'; % is enough since max IWP ca. 14000 g/m^2
1605 fields.dardarsub.dardar_IWP.atts.long_name      = 'DARDAR Ice Water Path';
1606 fields.dardarsub.dardar_IWP.atts.units          = 'kg/m^2';
1607 fields.dardarsub.dardar_IWP.atts.missing_value  = -999;
1608 fields.dardarsub.dardar_IWP.dependencies_struct = getSelection(fields.dardarsub,{'iwc','HEIGHT'});
1609 fields.dardarsub.dardar_IWP.atts.description    = ...
1610     'Column integrated ''iwc''';
1611 fields.dardarsub.dardar_ln_IWP_error.type                = 'float';
1612 fields.dardarsub.dardar_ln_IWP_error.atts.long_name      = 'DARDAR ln_IWP_error';
1613 fields.dardarsub.dardar_ln_IWP_error.atts.units          = 'fractional error';%'ln(kg/m^2)';
1614 fields.dardarsub.dardar_ln_IWP_error.atts.missing_value  = -999;
1615 fields.dardarsub.dardar_ln_IWP_error.dependencies_struct = getSelection(fields.dardarsub,{'iwc','HEIGHT','ln_iwc_error'});
1616 fields.dardarsub.dardar_ln_IWP_error.atts.description    = ...
1617     'Column integrated ''ln_iwc_error''';
1618 fields.dardarsub.INSTR_FLAG.realname         = 'instrument_flag';
1619 fields.dardarsub.INSTR_FLAG.type             = 'short';
1620 fields.dardarsub.INSTR_FLAG.atts.long_name   = 'Instrument flag (0==nothing/1==lidar/2==radar/3==radar+lidar)';
1621 fields.dardarsub.INSTR_FLAG.atts.units       = '-';
1622 fields.dardarsub.VOD.realname        = 'vis_optical_depth';
1623 fields.dardarsub.VOD.type            = 'float';
1624 fields.dardarsub.VOD.atts.long_name  = 'visible optical depth';
1625 fields.dardarsub.VOD.atts.unit       = 'dimless';
1626 fields.dardarsub.VOD.atts.description= ['Visible optical depth, defined as the (dimensionless) line ',...
1627                                     'integral of the ice cloud visible extinction along a vertical path ',...
1628                                     'through the entire atmosphere.'];
1629 fields.dardarsub.VOD_ERROR.realname         = 'vis_optical_depth_error';
1630 fields.dardarsub.VOD_ERROR.type             = 'float';
1631 fields.dardarsub.VOD_ERROR.atts.long_name   = 'visible optical depth error';
1632 fields.dardarsub.VOD_ERROR.atts.units       = '-';
1633 fields.dardarsub.VOD_ERROR.atts.description = 'Visible optical depth error';
1634 fields.dardarsub.dardar_Re.realname             = 'effective_radius';
1635 fields.dardarsub.dardar_Re.type                 = 'float';
1636 fields.dardarsub.dardar_Re.atts.long_name       = 'Retrieved effective radius';
1637 fields.dardarsub.dardar_Re.atts.units           = 'm';
1638 fields.dardarsub.dardar_Re.atts.missing_value   = -999;
1639 fields.dardarsub.dardar_Re_error.realname           = 'ln_effective_radius_error';
1640 fields.dardarsub.dardar_Re_error.type               = 'float';
1641 fields.dardarsub.dardar_Re_error.atts.long_name     = 'Fractional error in effective radius';
1642 fields.dardarsub.dardar_Re_error.atts.units         = 'ln(m)';
1643 fields.dardarsub.dardar_Re_error.atts.missing_value = -999;
1644 
1645 %% CPR siblingfields from dardarsub
1646 
1647 ddfields = fieldnames(fields.dardarsub);
1648 for ddfield = vec2row(ddfields)
1649     if strncmpi(ddfield{1}, 'dardar', 6)
1650         fname = ddfield{1};
1651     else
1652         fname = ['dardar_' ddfield{1}];
1653     end
1654     fields.cpr.(fname) = fields.dardarsub.(ddfield{1});
1655     fields.cpr.(fname).dataset = D.dardarsub;
1656 end
1657 
1658 %% GRAS
1659 %  We will need (at least) the following parameters from the netCDF file:
1660 % - temp
1661 % - temp_sigma
1662 % - shum  (specific humidity)
1663 % - geop (geopotential height)
1664 
1665 fields.gras.G_TEMP.type = 'float';
1666 fields.gras.G_TEMP.realname = 'temp';
1667 fields.gras.G_TEMP.atts.long_name = 'GRAS Temperature';
1668 fields.gras.G_TEMP.atts.units = 'Kelvin';
1669 fields.gras.G_TEMP.atts.valid_range = [150, 350];
1670 fields.gras.G_TEMP.atts.note = 'Attributes copied from original';
1671 fields.gras.G_TEMP_SIGMA.type = 'float';
1672 fields.gras.G_TEMP_SIGMA.realname = 'temp_sigma';
1673 fields.gras.G_TEMP_SIGMA.atts.long_name = 'GRAS Estimated error (1-sigma) for temperature';
1674 fields.gras.G_TEMP_SIGMA.atts.units = 'kelvin';
1675 fields.gras.G_TEMP_SIGMA.atts.valid_range = [0, 5];
1676 fields.gras.G_TEMP_SIGMA.atts.note = 'Attributes copied from original';
1677 fields.gras.G_SHUM.type = 'float';
1678 fields.gras.G_SHUM.realname = 'shum';
1679 fields.gras.G_SHUM.atts.long_name = 'GRAS Specific humidity';
1680 fields.gras.G_SHUM.atts.units = 'gram / kilogram';
1681 fields.gras.G_SHUM.atts.valid_range = [0, 50];
1682 fields.gras.G_SHUM.atts.note = 'Attributes copied from original';
1683 fields.gras.G_SHUM_SIGMA.type = 'float';
1684 fields.gras.G_SHUM_SIGMA.realname = 'shum_sigma';
1685 fields.gras.G_SHUM_SIGMA.atts.long_name = 'GRAS Estimated  error (1-sigma) in specific humidity';
1686 fields.gras.G_SHUM_SIGMA.atts.units = 'gram / kilogram';
1687 fields.gras.G_SHUM_SIGMA.atts.valid_range = [0, 5];
1688 fields.gras.G_SHUM_SIGMA.atts.note = 'Attributes copied from original'; 
1689 fields.gras.G_GEOP.type = 'float';
1690 fields.gras.G_GEOP.realname = 'geop';
1691 fields.gras.G_GEOP.atts.long_name = 'GRAS Geopotential height above geoid for P,T,H';
1692 fields.gras.G_GEOP.atts.units = 'geopotential metres';
1693 fields.gras.G_GEOP.atts.valid_range = [-1000, 100000];
1694 fields.gras.G_GEOP.atts.note = 'Attributes copied from original';
1695 fields.gras.G_GEOP_SIGMA.type = 'float';
1696 fields.gras.G_GEOP_SIGMA.realname = 'geop_sigma';
1697 fields.gras.G_GEOP_SIGMA.atts.long_name = 'GRAS Estimated error (1-sigma) for geopotential height';
1698 fields.gras.G_GEOP_SIGMA.atts.units = 'geopotential metres';
1699 fields.gras.G_GEOP_SIGMA.atts.valid_range = [0, 500];
1700 fields.gras.G_GEOP_SIGMA.atts.note = 'Attributes copied from original';
1701 fields.gras.G_PRESSURE.type = 'float';
1702 fields.gras.G_PRESSURE.realname ='press';
1703 fields.gras.G_PRESSURE.atts.long_name ='Pressure';
1704 fields.gras.G_PRESSURE.atts.units = 'hPa';
1705 fields.gras.G_PRESSURE.atts.valid_range =[1.0e-4, 1100.0];
1706 fields.gras.G_PRESSURE.atts.note = 'Attributes copied from original';
1707 fields.gras.G_PRESSURE_SIGMA.type = 'float';
1708 fields.gras.G_PRESSURE_SIGMA.realname ='press_sigma';
1709 fields.gras.G_PRESSURE_SIGMA.atts.long_name ='Estimated error (1-sigma) for pressure';
1710 fields.gras.G_PRESSURE_SIGMA.atts.units = 'hPa';
1711 fields.gras.G_PRESSURE_SIGMA.atts.valid_range =[0.0, 5.0];
1712 fields.gras.G_PRESSURE_SIGMA.atts.note = 'Attributes copied from original';
1713 
1714 %% HIRS
1715 fields.hirs.H_LONG.type = 'float';
1716 fields.hirs.H_LONG.realname = 'lon';
1717 fields.hirs.H_LONG.atts.long_name = 'HIRS Longitude';
1718 fields.hirs.H_LONG.atts.units = 'degrees_east';
1719 fields.hirs.H_LONG.atts.valid_range = [-180 180];
1720 fields.hirs.H_LONG.atts.missing_value = -9999;
1721 fields.hirs.H_LAT.type = 'float';
1722 fields.hirs.H_LAT.realname = 'lat';
1723 fields.hirs.H_LAT.atts.long_name = 'HIRS Latitude';
1724 fields.hirs.H_LAT.atts.units = 'degrees_north';
1725 fields.hirs.H_LAT.atts.valid_range = [-90 90];
1726 fields.hirs.H_LAT.atts.missing_value = -9999;
1727 fields.hirs.H_TIME.type = 'int';
1728 fields.hirs.H_TIME.realname = 'time';
1729 fields.hirs.H_TIME.atts.long_name = 'HIRS measurement time';
1730 fields.hirs.H_TIME.atts.units = 'seconds since 1970-01-01 00:00:00';
1731 fields.hirs.H_TIME.atts.missing_value = 0;
1732 fields.hirs.H_TIME.atts.valid_min = 0;
1733 fields.hirs.H_LZA = lza;
1734 fields.hirs.H_LAA = laa;
1735 fields.hirs.H_BT.type = 'float';
1736 fields.hirs.H_BT.realname = 'tb';
1737 fields.hirs.H_BT.dims = {'HIRS_CHANS', 20};
1738 fields.hirs.H_BT.atts.long_name = 'HIRS Brightness Temperature';
1739 fields.hirs.H_BT.atts.units = 'Kelvin';
1740 fields.hirs.H_BT.atts.missing_value = -9999;
1741 %fields.hirs.H_BT.atts.valid_min = 0; % asking for trouble i.e. exact flag
1742 fields.hirs.H_LINE.type = 'int';
1743 fields.hirs.H_LINE.realname = 'scanline_number';
1744 fields.hirs.H_LINE.atts.long_name = 'HIRS scanline number';
1745 fields.hirs.H_LINE.atts.missing_value = 0;
1746 fields.hirs.H_LINE.atts.valid_min = 1;
1747 fields.hirs.H_POS.type = 'byte';
1748 fields.hirs.H_POS.realname = 'scanline_position';
1749 fields.hirs.H_POS.atts.long_name = 'HIRS scanline position';
1750 fields.hirs.H_POS.atts.missing_value = 0;
1751 fields.hirs.H_POS.atts.valid_range = [1 56];
1752 
1753 %% MHS
1754 % very similar to AMSU-B
1755 fields.mhs = fields.amsub;
1756 fields.mhs.B_BT.dims = {'MHS_CHANS', 5};
1757 fields.mhs.B_BT.atts.long_name = 'MHS Brightness Temperature';
1758 
1759 fields.mhs1 = fields.amsub1;
1760 fields.mhs1.BT1.dims = {'MHS_CHANS', 5};
1761 fields.mhs1.BT1.atts.long_name = 'MHS Brightness Temperature, primary';
1762 
1763 fields.mhs2 = fields.amsub2;
1764 fields.mhs2.BT2.dims = {'MHS_CHANS', 5};
1765 fields.mhs2.BT2.atts.long_name = 'MHS Brightness Temperature, secondary';
1766 
1767 %% MODIS
1768 fields.modis.Cloud_Water_Path.type                = 'short';
1769 fields.modis.Cloud_Water_Path.atts.long_name      = 'Column Cloud Water Path two-band retrieval using band 7 and either band 1, 2, or 5 .';
1770 fields.modis.Cloud_Water_Path.atts.units          = 'g/m^2';
1771 fields.modis.Cloud_Water_Path.atts.valid_range    = [0 10000];
1772 fields.modis.Cloud_Water_Path.atts.missing_value  = -9999;
1773 fields.modis.Cloud_Water_Path.atts.description    = ...
1774     ['Daytime only: Source data at 1-km is subsampled at 5-km. Note that all cloud phases '...
1775     '(liquid water, ice, and undetermined phase) are represented in the parameter;'...
1776     'users must read the Cloud Phase (Retrieval Processing Path) Flag in the '...
1777     'Cloud_Quality_Assurance SDS to determine the cloud phase represented by each pixel.'];
1778 fields.modis.Cloud_Water_Path_Uncertainty.type                = 'short';
1779 fields.modis.Cloud_Water_Path_Uncertainty.atts.long_name      = 'Cloud Water Path Relative Uncertainty (Percent)';
1780 fields.modis.Cloud_Water_Path_Uncertainty.atts.units          = '%';
1781 fields.modis.Cloud_Water_Path_Uncertainty.atts.valid_range    = [0 20000];
1782 fields.modis.Cloud_Water_Path_Uncertainty.atts.missing_value  = -9999;
1783 fields.modis.Cloud_Water_Path_Uncertainty.atts.description    = 'Relative uncertainty of Cloud_Water_Path';
1784 fields.modis.Cloud_Effective_Radius.type                = 'short'; % this field needs to be scaled by 0.01
1785 fields.modis.Cloud_Effective_Radius.atts.long_name      = ['Cloud particle effective radius (??m) derived from a two-channel '...
1786                                        'retrieval using MODIS band 7 and either band 1, 2, or 5'];
1787 fields.modis.Cloud_Effective_Radius.atts.units          = 'micron';
1788 fields.modis.Cloud_Effective_Radius.atts.valid_range    = [0 10000];
1789 fields.modis.Cloud_Effective_Radius.atts.missing_value  = -9999;
1790 fields.modis.Cloud_Effective_Radius.atts.scale_factor   = 0.01;
1791 fields.modis.Cloud_Effective_Radius.atts.description    = ...
1792     ['Source data at 1-km is subsampled at 5-km. Note that all cloud phases'...
1793     '(liquid water, ice, and undetermined phase) are represented in the parameter;'...
1794     'users must read the Cloud Phase (Retrieval Processing Path) Flag '...
1795     'in the Cloud_Quality_Assurance SDS to determine the cloud phase represented '...
1796     'by each pixel. SDS name changed to clarify application.'];
1797 
1798 fields.modis.Cloud_Effective_Radius_Uncertainty.type                = 'short';
1799 fields.modis.Cloud_Effective_Radius_Uncertainty.atts.long_name      = 'Relative uncertainty in Cloud Effective Radius (Percent)';
1800 fields.modis.Cloud_Effective_Radius_Uncertainty.atts.units          = '%';
1801 fields.modis.Cloud_Effective_Radius_Uncertainty.atts.valid_range    = [0 20000];
1802 fields.modis.Cloud_Effective_Radius_Uncertainty.atts.missing_value ...
1803     = -9999;
1804 fields.modis.Cloud_Effective_Radius_Uncertainty.atts.scale_factor ...
1805     = 0.01;
1806 fields.modis.Cloud_Effective_Radius_Uncertainty.atts.description    = ...
1807     'Relative uncertainty of Cloud Effective Radius';
1808 
1809 fields.modis.Cloud_Multi_Layer_Flag.type              = 'byte';
1810 fields.modis.Cloud_Multi_Layer_Flag.atts.long_name    = 'Cloud Multi Layer Identification From MODIS Shortwave Observations';
1811 fields.modis.Cloud_Multi_Layer_Flag.atts.units        = 'none';
1812 fields.modis.Cloud_Multi_Layer_Flag.atts.valid_range  = [0 9];
1813 fields.modis.Cloud_Multi_Layer_Flag.atts.missing_value=0;
1814 fields.modis.Cloud_Multi_Layer_Flag.atts.description  = ...
1815     [' Flag for multi-layer multi-phase cloud situations. Values 2 through 8',...
1816  'indicate the success of various multi-layer cloud tests. Value of 0',...                
1817  'indicates no retrieval, value of 1 indicates single layer cloud. The',...
1818  'other values are of increasing confidence level. The value of 2 is',...
1819  'of absolute lowest confidence and often can be ignored as it  is a result',...          
1820  'of cloud phase comparison test, which is not always trustworthy.'];
1821 
1822 fields.modis.Cloud_Optical_Thickness.type                = 'short'; % this field needs to be scaled by 0.01
1823 fields.modis.Cloud_Optical_Thickness.atts.long_name      = ['Cloud optical thickness at 0.66 ??m derived from a two-channel retrieval'...
1824                                        'using MODIS band 7 and either band 1, 2, or 5.'];
1825 fields.modis.Cloud_Optical_Thickness.atts.units          = '-';
1826 fields.modis.Cloud_Optical_Thickness.atts.valid_range    = [0 10000];
1827 fields.modis.Cloud_Optical_Thickness.atts.missing_value  = -9999;
1828 fields.modis.Cloud_Optical_Thickness.atts.scale_factor   = 0.01;
1829 fields.modis.Cloud_Optical_Thickness.atts.description    = ...
1830     ['Source data at 1-km is subsampled at 5-km. Note that all cloud phases '...
1831     '(liquid water, ice, and undetermined phase) are represented in the parameter;'...
1832     'users must read the Cloud Phase (Retrieval Processing Path) Flag in the '...
1833     'Cloud_Quality_Assurance SDS to determine the cloud phase represented by each pixel.'];
1834 
1835 fields.modis.Cloud_Optical_Thickness_Uncertainty.type                = 'short';
1836 fields.modis.Cloud_Optical_Thickness_Uncertainty.atts.long_name      = 'Relative uncertainty in Cloud Optical Thickness (Percent)';
1837 fields.modis.Cloud_Optical_Thickness_Uncertainty.atts.units          = '%';
1838 fields.modis.Cloud_Optical_Thickness_Uncertainty.atts.valid_range    = [0 20000];
1839 fields.modis.Cloud_Optical_Thickness_Uncertainty.atts.missing_value  = -9999;
1840 fields.modis.Cloud_Optical_Thickness_Uncertainty.atts.scale_factor ...
1841     = 0.01;
1842 fields.modis.Cloud_Optical_Thickness_Uncertainty.atts.description    = ...
1843     'Relative uncertainty of Cloud Optical Thickness';
1844 
1845 fields.modis.Cloud_Phase_Optical_Properties.type                = 'byte';
1846 fields.modis.Cloud_Phase_Optical_Properties.atts.long_name      = 'Cloud Phase Determination Used in Optical Thickness/Effective Radius Retrieval';
1847 fields.modis.Cloud_Phase_Optical_Properties.atts.units          = '-';
1848 fields.modis.Cloud_Phase_Optical_Properties.atts.valid_range    = [0 4];
1849 fields.modis.Cloud_Phase_Optical_Properties.atts.missing_value  = 0;
1850 fields.modis.Cloud_Phase_Optical_Properties.atts.description = ...
1851     ['Daytime only. Cloud Phase as determined by the '...
1852      'Cloud Optical Property algorithm. Note that this phase flag is '...
1853      'identical for both the primary retrieval and the 1.6/2.1 ??m retrieval.'...
1854      '[(0=fill, 1=clear, 2=liquid water cloud, 3=ice cloud,4=undetermined phase cloud)'];
1855                             
1856 fields.modis.Quality_Assurance_1km.type             = 'byte';
1857 fields.modis.Quality_Assurance_1km.atts.long_name   = 'QA Flags at 1x1 km resolution';
1858 fields.modis.Quality_Assurance_1km.description      = 'For details see http://modis-atmos.gsfc.nasa.gov/reference_atbd.html';
1859      
1860 fields.modis.modis_IWP.type                 = 'short';
1861 fields.modis.modis_IWP.atts.long_name       = 'MODIS IWP';
1862 fields.modis.modis_IWP.atts.units           = 'g/m^2';
1863 fields.modis.modis_IWP.atts.valid_range     = [0 10000];
1864 fields.modis.modis_IWP.atts.missing_value   = -9999;
1865 fields.modis.modis_IWP.dependencies_struct  = getSelection(fields.modis,{'Cloud_Water_Path','Quality_Assurance_1km','Cloud_Phase_Optical_Properties'});
1866 fields.modis.modis_IWP.atts.description     = ...
1867     ['''Cloud_Water_Path'' where the ''Cloud_Phase_Optical_Properties'''...
1868     'have the value ''3'' (ice clouds) and the ''Quality_Assurance_1km'' flag is set to good'];
1869 fields.modis.modis_IWP_uncertainty.type                = 'short';
1870 fields.modis.modis_IWP_uncertainty.atts.long_name      = 'modis_IWP Relative Uncertainty (Percent)';
1871 fields.modis.modis_IWP_uncertainty.atts.units          = '%';
1872 fields.modis.modis_IWP_uncertainty.atts.valid_range    = [0 20000];
1873 fields.modis.modis_IWP_uncertainty.atts.missing_value  = -9999;
1874 fields.modis.modis_IWP_uncertainty.dependencies_struct = getSelection(fields.modis,{'Cloud_Water_Path_Uncertainty','Quality_Assurance_1km','Cloud_Phase_Optical_Properties'});
1875 fields.modis.modis_IWP_uncertainty.atts.description    = ...
1876     'Relative uncertainty of Cloud_Water_Path';
1877 
1878 fields.modis.Re_ice.type                 = 'short';
1879 fields.modis.Re_ice.atts.long_name       = 'modis_Effective_Radius_ice';
1880 fields.modis.Re_ice.atts.units           = 'micron';
1881 fields.modis.Re_ice.atts.valid_range     = [0 10000];
1882 fields.modis.Re_ice.atts.missing_value   = -9999;
1883 fields.modis.Re_ice.atts.scale_factor    = 0.01;
1884 fields.modis.Re_ice.dependencies_struct  = getSelection(fields.modis,{'Cloud_Effective_Radius','Quality_Assurance_1km','Cloud_Phase_Optical_Properties'});
1885 fields.modis.Re_ice.atts.description     = ...
1886     ['''Cloud_Effective_Radius'' where the ''Cloud_Phase_Optical_Properties'' '...
1887     'have the value ''3'' (ice clouds) and the ''Quality_Assurance_1km'' flag is set to good'];
1888 fields.modis.Re_ice_uncertainty.type                = 'short';
1889 fields.modis.Re_ice_uncertainty.atts.long_name      = 'Re_ice Relative Uncertainty (Percent)';
1890 fields.modis.Re_ice_uncertainty.atts.units          = '%';
1891 fields.modis.Re_ice_uncertainty.atts.valid_range    = [0 20000];
1892 fields.modis.Re_ice_uncertainty.atts.missing_value  = -9999;
1893 fields.modis.Re_ice_uncertainty.atts.scale_factor   = 0.01;
1894 fields.modis.Re_ice_uncertainty.dependencies_struct = getSelection(fields.modis,{'Cloud_Effective_Radius_Uncertainty','Quality_Assurance_1km','Cloud_Phase_Optical_Properties'});
1895 fields.modis.Re_ice_uncertainty.atts.description    = ...
1896     'Relative uncertainty of Re_ice';
1897 
1898 fields.modis.Tau_ice.type                = 'short';
1899 fields.modis.Tau_ice.atts.long_name      = 'modis Cloud Optical Depth';
1900 fields.modis.Tau_ice.atts.units          = 'none';
1901 fields.modis.Tau_ice.atts.valid_range    = [0 10000];
1902 fields.modis.Tau_ice.atts.missing_value  = -9999;
1903 fields.modis.Tau_ice.atts.scale_factor   = 0.01;
1904 fields.modis.Tau_ice.dependencies_struct = getSelection(fields.modis,{'Cloud_Optical_Thickness','Quality_Assurance_1km','Cloud_Phase_Optical_Properties'});
1905 fields.modis.Tau_ice.atts.description    = ...
1906     ['''Cloud_Optical_Depth'' where the ''Cloud_Phase_Optical_Properties'' have the value '...
1907     '''3'' (ice clouds) and the ''Quality_Assurance_1km'' flag is set to good'];
1908 
1909 fields.modis.Tau_ice_uncertainty.type                = 'short';
1910 fields.modis.Tau_ice_uncertainty.atts.long_name      = 'Relative uncertainty in Tau_ice (Percent)';
1911 fields.modis.Tau_ice_uncertainty.atts.units          = '%';
1912 fields.modis.Tau_ice_uncertainty.atts.valid_range    = [0 20000];
1913 fields.modis.Tau_ice_uncertainty.atts.missing_value  = -9999;
1914 fields.modis.Tau_ice_uncertainty.atts.scale_factor   = 0.01;
1915 fields.modis.Tau_ice_uncertainty.dependencies_struct = getSelection(fields.modis,{'Cloud_Optical_Thickness_Uncertainty','Quality_Assurance_1km','Cloud_Phase_Optical_Properties'});
1916 fields.modis.Tau_ice_uncertainty.atts.description    = ...
1917     'Relative uncertainty of Tau_ice';
1918 
1919 %% SAPHIR
1920 for i = 1:6
1921     fn = sprintf('TB%d', i);
1922     fields.saphir.(fn).type = 'float';
1923     fields.saphir.(fn).realname = sprintf('TbCh%d', i);
1924     fields.saphir.(fn).atts.long_name = sprintf('Saphir Brightness Temperature, channel %d', i);
1925     fields.saphir.(fn).atts.units = 'Kelvin';
1926     fields.saphir.(fn).atts.missing_value = -9999;
1927 end
1928 
1929 fields.saphir.IncidencAngle.type = 'float';
1930 fields.saphir.IncidencAngle.atts.long_name = sprintf('SAPHIR incidence angle');
1931 
1932 % ---------
1933 
1934 %% SSM/T-2
1935 % (vs. others)
1936 
1937 fields.ssmt2.SSMT2_BT.type = 'float';
1938 fields.ssmt2.SSMT2_BT.dims = {'SSMT2_CHANS', 5};
1939 fields.ssmt2.SSMT2_BT.realname = 'tb';
1940 fields.ssmt2.SSMT2_BT.atts.long_name = 'SSM T/2 Brightness Temperature';
1941 fields.ssmt2.SSMT2_BT.atts.units = 'Kelvin';
1942 fields.ssmt2.SSMT2_channel_quality_flag.type = 'float';
1943 fields.ssmt2.SSMT2_channel_quality_flag.dims = fields.ssmt2.SSMT2_BT.dims;
1944 fields.ssmt2.SSMT2_channel_quality_flag.realname = 'channel_quality_flag';
1945 fields.ssmt2.SSMT2_channel_quality_flag.atts.long_name = 'SSM T/2 channel quality flag';
1946 
1947 % (vs. self)
1948 
1949 % use same field-names but with _1, _2 added
1950 
1951 fn = fieldnames(fields.ssmt2);
1952 for i = 1:length(fn)
1953     fields.ssmt2_1.([fn{i} '_1']) = fields.ssmt2.(fn{i});
1954     fields.ssmt2_2.([fn{i} '_2']) = fields.ssmt2.(fn{i});
1955 end
1956 
1957 %% Collocated datasets
1958 
1959 % CACMEH = collapsed_associated_CPR_MHS_AMSU_HIRS, its parent, and the
1960 % other fieldcopiers belonging to its parent
1961 %
1962 % Note that fieldnames here belong to the fields as returned by
1963 %
1964 
1965 fields.cacmeh.MHS_LAT = CollocatedDataset.members_const.LAT1;
1966 fields.cacmeh.MHS_LAT.realname = 'LAT1';
1967 fields.cacmeh.MHS_LAT.atts.long_name = 'MHS Latitude';
1968 fields.cacmeh.MHS_LON = CollocatedDataset.members_const.LON1;
1969 fields.cacmeh.MHS_LON.realname = 'LON1';
1970 fields.cacmeh.MHS_LON.atts.long_name = 'MHS Latitude';
1971 fields.cacmeh.MHS_START = CollocatedDataset.members_const.START1;
1972 fields.cacmeh.MHS_START.realname = 'START1';
1973 fields.cacmeh.MHS_START.atts.long_name = 'MHS starting time';
1974 fields.cacmeh.MHS_BT = fields.mhs.B_BT;
1975 fields.cacmeh.MHS_BT.realname = 'B_BT';
1976 
1977 % NOTE: unfinished.
1978 
1979 end
1980 
1981 function S = getSelection(S,desired)
1982 %% getSelection
1983 %
1984 % PURPOSE
1985 % function to extract some fields from a structure that contains more fields than
1986 % is needed (since only the fields used are should be in the fieldCopier)
1987 %
1988 % IN
1989 %    S = structure containing the names of data variables that can be read by
1990 %       the fieldCopier, such that fieldnames(S) are the names of the datafields
1991 %       you can read from a data file.
1992 %
1993 %    desired = {'fields','to','extract'};
1994 %
1995 % USAGE
1996 % e.g., S = getSelection(fields.cloud_cci,fieldnames(fields.cloud_cci),{'iwp','iwp_error'})
1997 %
1998 % Salomon Eliasson
1999 
2000 if ~iscell(desired)
2001     desired = {desired};
2002 end
2003 
2004 S = getfields(S, desired{:});
2005 
2006 end
2007 
2008 function S = collapsed2fc(S)
2009 % convert a structure prepared for a collapser back to one for fieldcopier
2010 %
2011 % useful if fields from a collapser are to be fieldcopied when the
2012 % collapser is used as a base for a new collocated dataset
2013 
2014 C = cellfun(...
2015     @(fn) ...
2016             cellfun(@(procn) {[procn '_' fn], S.(fn).stored.(procn)}, ...
2017                     fieldnames(S.(fn).stored), ...
2018                     'UniformOutput', false), ...
2019             fieldnames(S), ...
2020             'UniformOutput', false);
2021 % convert nested cell to flat input for struct
2022 C = vertcat(C{:});
2023 C = vertcat(C{:});
2024 C = flat(C.');
2025 S = struct(C{:});
2026 end
2027 
2028 function S = mem2fc(S)
2029 % prepare a fc members-field for another fc's input-field
2030 %
2031 % In practice, this means removing 'realname' and 'dataset'
2032 %
2033 % IN
2034 %
2035 %   S   input structure
2036 
2037 S = structfun(...
2038     @(X) rmfield(X, intersect({'realname', 'dataset'}, fieldnames(X))), ...
2039     S, ...
2040     'UniformOutput', false);
2041 
2042 end
2043 
2044 function stat = ignoreNeG(M, func, dim)
2045 % like ignoreNaN, but ignores where data are negative
2046 M(M<0) = nan;
2047 stat = ignoreNaN(M, func, dim);
2048 end
2049 
2050 function C = flagneg(C)
2051 % flag negative data
2052 C(C<0) = nan;
2053 end

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