Home > atmlab > sensors > ssmi_read_1tbfile.m

ssmi_read_1tbfile

PURPOSE ^

SSMI_READ_1TBFILE Loads Tb data from one file.

SYNOPSIS ^

function C = ssmi_read_1tbfile(infolder,satnr,year,filedoy,passnr,varargin)

DESCRIPTION ^

 SSMI_READ_1TBFILE   Loads Tb data from one file.

    This is the core file to read SSM/I brightness temperatures.

    The function reads data from files with names:
       fxx_Tb_yyddd_ppZ.hdf
    and corresponding geolocation files (_ln_ and _hn_, instead of _Tb_),
    where 
       xx    is the satellite id number
       yyddd is the date; year(yy) and day (ddd)
       pp    is the pass number (01-29)
       Z     is direction (A-ascending or D-descending)

     Files can be obtained from ghrc.msfc.nasa.gov by anonymous access.
     The files are found in folders:
       cd pub/data/ssmi-fXX/current-tb/hdf-swath/YY.DDD

     See further the document SSMI-TBs.pdf found on the web, or at the
     ftp given above.

     The function reads all data in the file that match given limits, set
     by the optional arguments. For example, to limit the latitude range
     considered, set e.g. *lats* = [-30 30]. Default values give all
     data flagged to be OK.

 FORMAT   C = ssmi_read_1tbfile(infolder,satnr,year,filedoy,passnr,
                                          [channels,doys,tods,lats,lons,sfts])
        
 OUT   C   Structure with fields:
              TB    Brightness temperature
              LAT   Latitude
              LON   Longitude
              SFT   Surface type
              PSD   Pass direction ('a'=ascending, 'd'=descending)
           All fields, except PSD, are vectors.
 IN    infolder   Path to folder with HDf files.
       satnr      Satellite id number (e.g. 15).
       filedoy    File day of year .
       passnr     Pass number.
 OPT   channels   Channels to read:
                     1 : 19 GHz V
                     2 : 19 GHz H
                     3 : 22 GHz V
                     4 : 37 GHz V
                     5 : 37 GHz H
                     6 : 85 GHz V
                     7 : 85 GHz H
                  Default is 1:7.
        doys      Day of year to keep. Default is *fildoy* + [-1 1].
        tods      Time of day to keep [s]. Default is 0 to 25 h (in seconds).
        lats      Latitudes to keep. Default is [-90 90].
        lons      Longitudes to keep. Default is [-180 180].
        sfts      Surface types to keep:
                     <0 : Missing or questionable data.
                      0 : Land.
                      1 : Vegetation/land.
                      2 : Near-coast.
                      3 : Ice.
                      4 : Possible ice.
                      5 : Water.
                      6 : Coast.
                      7 : Not used.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

ssmi_read_1tbfile.m

SOURCE CODE ^

0001 % SSMI_READ_1TBFILE   Loads Tb data from one file.
0002 %
0003 %    This is the core file to read SSM/I brightness temperatures.
0004 %
0005 %    The function reads data from files with names:
0006 %       fxx_Tb_yyddd_ppZ.hdf
0007 %    and corresponding geolocation files (_ln_ and _hn_, instead of _Tb_),
0008 %    where
0009 %       xx    is the satellite id number
0010 %       yyddd is the date; year(yy) and day (ddd)
0011 %       pp    is the pass number (01-29)
0012 %       Z     is direction (A-ascending or D-descending)
0013 %
0014 %     Files can be obtained from ghrc.msfc.nasa.gov by anonymous access.
0015 %     The files are found in folders:
0016 %       cd pub/data/ssmi-fXX/current-tb/hdf-swath/YY.DDD
0017 %
0018 %     See further the document SSMI-TBs.pdf found on the web, or at the
0019 %     ftp given above.
0020 %
0021 %     The function reads all data in the file that match given limits, set
0022 %     by the optional arguments. For example, to limit the latitude range
0023 %     considered, set e.g. *lats* = [-30 30]. Default values give all
0024 %     data flagged to be OK.
0025 %
0026 % FORMAT   C = ssmi_read_1tbfile(infolder,satnr,year,filedoy,passnr,
0027 %                                          [channels,doys,tods,lats,lons,sfts])
0028 %
0029 % OUT   C   Structure with fields:
0030 %              TB    Brightness temperature
0031 %              LAT   Latitude
0032 %              LON   Longitude
0033 %              SFT   Surface type
0034 %              PSD   Pass direction ('a'=ascending, 'd'=descending)
0035 %           All fields, except PSD, are vectors.
0036 % IN    infolder   Path to folder with HDf files.
0037 %       satnr      Satellite id number (e.g. 15).
0038 %       filedoy    File day of year .
0039 %       passnr     Pass number.
0040 % OPT   channels   Channels to read:
0041 %                     1 : 19 GHz V
0042 %                     2 : 19 GHz H
0043 %                     3 : 22 GHz V
0044 %                     4 : 37 GHz V
0045 %                     5 : 37 GHz H
0046 %                     6 : 85 GHz V
0047 %                     7 : 85 GHz H
0048 %                  Default is 1:7.
0049 %        doys      Day of year to keep. Default is *fildoy* + [-1 1].
0050 %        tods      Time of day to keep [s]. Default is 0 to 25 h (in seconds).
0051 %        lats      Latitudes to keep. Default is [-90 90].
0052 %        lons      Longitudes to keep. Default is [-180 180].
0053 %        sfts      Surface types to keep:
0054 %                     <0 : Missing or questionable data.
0055 %                      0 : Land.
0056 %                      1 : Vegetation/land.
0057 %                      2 : Near-coast.
0058 %                      3 : Ice.
0059 %                      4 : Possible ice.
0060 %                      5 : Water.
0061 %                      6 : Coast.
0062 %                      7 : Not used.
0063 
0064 % 2004-03-16   Created by Patrick Eriksson.
0065 
0066 
0067 function C = ssmi_read_1tbfile(infolder,satnr,year,filedoy,passnr,varargin)
0068 %
0069 [channels,doys,tods,lats,lons,sfts] = optargs( varargin, ...
0070 { 1:7, filedoy+[-1 1], [0 25*60*60], [-90 90], [-180 180], [-99 99] } );
0071 %
0072 rqre_nargin( 5, nargin );                                               %&%
0073 
0074 
0075 %= Create file names
0076 %
0077 filestart = fullfile( infolder, ['f',int2str(satnr),'_'] );
0078 fileendA  = sprintf( '_%02d%03d_%02dA.hdf', year, filedoy, passnr );
0079 fileendD  = sprintf( '_%02d%03d_%02dD.hdf', year, filedoy, passnr );
0080 
0081 %= Check if it is an ascending or descending passage
0082 %
0083 filetb    = [ filestart, 'Tb', fileendA ];
0084 if exist( filetb, 'file' )
0085   fileend = fileendA;
0086   passdir = 'a';
0087 else
0088   filetb    = [ filestart, 'Tb', fileendD ];
0089   if exist( filetb, 'file' )
0090     fileend = fileendD;
0091     passdir = 'd';
0092   else
0093     error( sprintf('Could not find Tb file matching %s', ...
0094                                              filetb(1:(length(filetb)-5) ) ) );
0095   end
0096 end
0097 
0098 %= Check that geolocation files exist and read data
0099 %
0100 filehn    = [ filestart, 'hn', fileend ];
0101 fileln    = [ filestart, 'ln', fileend ];
0102 %
0103 if any( channels ) <= 5  &  ~exist( fileln, 'file' )
0104   error( sprintf('Could not find file %s', fileln ) );
0105 else
0106   DOY_ln = hdfread( fileln, 'Data-Set-2' );
0107   TOD_ln = hdfread( fileln, 'Data-Set-3' );
0108   LAT_ln = double( hdfread( fileln, 'Data-Set-4' ) ) / 100;
0109   LON_ln = double( hdfread( fileln, 'Data-Set-5' ) ) / 100;
0110   SFT_ln = hdfread( fileln, 'Data-Set-6' );
0111 end
0112 %
0113 if any( channels ) >= 6  &  ~exist( filehn, 'file' )
0114   error( sprintf('Could not find file %s', filehn ) );
0115 else
0116   DOY_hn = double( hdfread( filehn, 'Data-Set-2' ) );
0117   TOD_hn = double( hdfread( filehn, 'Data-Set-3' ) );
0118   LAT_hn = double( hdfread( filehn, 'Data-Set-4' ) ) / 100;
0119   LON_hn = double( hdfread( filehn, 'Data-Set-5' ) ) / 100;
0120   SFT_hn = hdfread( filehn, 'Data-Set-6' );
0121 end
0122 
0123 
0124 %= Loop channels
0125 %
0126 for i = 1 : length(channels)
0127   
0128   %= Read data and convert to K
0129   %
0130   TB = double( hdfread( filetb, ...
0131                               sprintf( 'Data-Set-%d', channels(i)+3) ) ) / 100;
0132 
0133   if channels(i) <= 5
0134     DOY = repmat( DOY_ln, 1, 64 );
0135     TOD = repmat( TOD_ln, 1, 64 );   
0136     LAT = LAT_ln;
0137     LON = LON_ln;
0138     SFT = SFT_ln;
0139   else
0140     DOY = repmat( DOY_hn, 1, 128 );
0141     TOD = repmat( TOD_hn, 1, 128 );   
0142     LAT = LAT_hn;
0143     LON = LON_hn;
0144     SFT = SFT_hn;
0145   end
0146 
0147   ind = find( TB>=1 & DOY>=doys(1) & DOY<=doys(2) & TOD>=tods(1) & ...
0148        TOD<=tods(2) & LAT>=lats(1) & LAT<=lats(2) & LON>=lons(1) & ...
0149        LON<=lons(2) & SFT>=sfts(1) & SFT<=sfts(2) );
0150 
0151   C{i}.TB  = TB(ind);
0152   C{i}.LAT = LAT(ind);
0153   C{i}.LON = LON(ind);
0154   C{i}.SFT = SFT(ind);
0155   C{i}.PSD = passdir;
0156 end
0157 
0158

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