Home > atmlab > datasets > modis_postprocessor.m

modis_postprocessor

PURPOSE ^

% modis_postprocessor

SYNOPSIS ^

function S = modis_postprocessor(self,S,fields)

DESCRIPTION ^

% modis_postprocessor

 PURPOSE: To create "pseudo" fields that are not in the original modis data by 
          post-processing fields that are in the original data


 IN
     self = dataset
     S = Data structure to add pseudo field to (from self.reader)
     fields = {'names','of','pseudo','fields'}

 OUT
     S = Data structure + pseudo field/s

 NOTE: See also help Satdataset/pseudo_fields

 $Id: modis_postprocessor.m 8286 2013-03-11 20:27:31Z seliasson $
 Salomon Eliasson

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

modis_postprocessor.m

SOURCE CODE ^

0001 function S = modis_postprocessor(self,S,fields)
0002 %% modis_postprocessor
0003 %
0004 % PURPOSE: To create "pseudo" fields that are not in the original modis data by
0005 %          post-processing fields that are in the original data
0006 %
0007 %
0008 % IN
0009 %     self = dataset
0010 %     S = Data structure to add pseudo field to (from self.reader)
0011 %     fields = {'names','of','pseudo','fields'}
0012 %
0013 % OUT
0014 %     S = Data structure + pseudo field/s
0015 %
0016 % NOTE: See also help Satdataset/pseudo_fields
0017 %
0018 % $Id: modis_postprocessor.m 8286 2013-03-11 20:27:31Z seliasson $
0019 % Salomon Eliasson
0020 
0021 
0022 % READ dependent fields
0023 % So far this function assumesa you always need cloud phase and quality
0024 % flag
0025 % common_fields = {'Quality_Assurance_1km','Cloud_Phase_Optical_Properties'};
0026 % associatedFields = {'Cloud_Water_Path','Cloud_Effective_Radius','Cloud_Optical_Thickness'};
0027 % pseudo_fields = {'modis_IWP','Tau_ice','Re_ice'};
0028 % dependent_fields = [common_fields,associatedFields(ismember(pseudo_fields,fields))];
0029 
0030 if any(ismember(fields,{'modis_IWP','modis_IWP_uncertainty','Tau_ice','Re_ice','Tau_ice_uncertainty','Re_ice_uncertainty'}))
0031     
0032     % Keeping record of the pixels that are deemed to be cloud free
0033     clearPixel = S.Cloud_Phase_Optical_Properties==1;
0034 
0035     % Removing all points that are not flagged as ice clouds
0036     icePhase = S.Cloud_Phase_Optical_Properties==3;
0037 
0038     % only KEEP retrievals that are USEFUL and CONFIDENT
0039 
0040     % this corresponds to the 1st and 2nd bit in the 2nd byte in
0041     % Quality_Assurance_1km (regarding cloud_water_path. I assume the
0042     % same apply to Re and Tau that CWP is based on anyway). By doing this
0043     % I'm also disregarding values with marginal confidence
0044     usefull=uint8(sum(2.^[0,1]));
0045 
0046     % bitand only works on vectors
0047     S.Quality_Assurance_1km = permute(S.Quality_Assurance_1km,[3,1,2]);
0048 
0049     flaggedAsGood = bitand(typecast(S.Quality_Assurance_1km(2,:),'uint8'),usefull)==usefull;
0050     flaggedAsGood = reshape(flaggedAsGood,size(icePhase,1),size(icePhase,2));
0051 
0052 end
0053 
0054 D = datasets;
0055 for F = fields
0056     mv = D.modis_aqua_L2.pseudo_fields.(F{1}).atts.missing_value;
0057     switch F{1}
0058         case 'modis_IWP'
0059             S.modis_IWP = S.Cloud_Water_Path;
0060             S.modis_IWP(~(clearPixel | (icePhase & flaggedAsGood))) = mv;
0061             S.modis_IWP(clearPixel)=0;
0062         case 'modis_IWP_uncertainty'
0063             logtext(atmlab('OUT'),'scaling Cloud_Water_Path_Uncertainty by 0.01\n')
0064             S.modis_IWP_uncertainty = S.Cloud_Water_Path_Uncertainty*0.01;
0065             S.modis_IWP_uncertainty(~(clearPixel | (icePhase & flaggedAsGood))) = mv;
0066         case 'Re_ice'
0067             S.Re_ice = S.Cloud_Effective_Radius; %scale by *0.01;
0068             S.Re_ice(~(clearPixel | (icePhase & flaggedAsGood)))=mv;
0069             S.Re_ice(clearPixel)=0;
0070         case 'Re_ice_uncertainty'
0071             logtext(atmlab('OUT'),'scaling Cloud_Effective_Radius_Uncertainty by 0.01\n')
0072             S.Re_ice_uncertainty = S.Cloud_Effective_Radius_Uncertainty*0.01;
0073             S.Re_ice_uncertainty(~(clearPixel | (icePhase & flaggedAsGood))) = mv;
0074         case 'Tau_ice'
0075             logtext(atmlab('OUT'),'scaling Cloud_Optical_Thickness by 0.01\n')
0076             S.Tau_ice = S.Cloud_Optical_Thickness*0.01;
0077             S.Tau_ice(~(clearPixel | (icePhase & flaggedAsGood))) = mv;
0078             S.Tau_ice(clearPixel)=0;
0079         case 'Tau_ice_uncertainty'
0080             logtext(atmlab('OUT'),'scaling Cloud_Optical_Thickness_Uncertainty by 0.01\n')
0081             S.Tau_ice_uncertainty = S.Cloud_Optical_Thickness_Uncertainty*0.01;
0082             S.Tau_ice_uncertainty(~(clearPixel | (icePhase & flaggedAsGood))) = mv;
0083     end
0084     S.(F{1})(S.(F{1})<0) = mv; % since none of these quantities are negative
0085 end
0086 
0087 end

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