Home > atmlab > arts > arts_sx.m

arts_sx

PURPOSE ^

ARTS_SX Creation of Sx matrix based on Qarts/ARTS data

SYNOPSIS ^

function Sx = arts_sx( Q, R )

DESCRIPTION ^

 ARTS_SX   Creation of Sx matrix based on Qarts/ARTS data

    This is a standardised function to set up Sx. The function simply includes
    the covariance matrices defined in the SX sub-fields along the diagonal of
    the complete Sx matrix. That is, the function handles only covariances
    inside each retrieval quantity. The result will be a (sparse) matrix with
    non-zero elements in blocks around the diagonal.

 FORMAT   Sx = arts_sx( Q, R )
        
 OUT   Sx   Covariance matrix (sparse).
 IN    Q     Qarts structure. See *qarts*.
       R     Retrieval data structure. See *arts_oem*.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

arts_sx.m

SOURCE CODE ^

0001 % ARTS_SX   Creation of Sx matrix based on Qarts/ARTS data
0002 %
0003 %    This is a standardised function to set up Sx. The function simply includes
0004 %    the covariance matrices defined in the SX sub-fields along the diagonal of
0005 %    the complete Sx matrix. That is, the function handles only covariances
0006 %    inside each retrieval quantity. The result will be a (sparse) matrix with
0007 %    non-zero elements in blocks around the diagonal.
0008 %
0009 % FORMAT   Sx = arts_sx( Q, R )
0010 %
0011 % OUT   Sx   Covariance matrix (sparse).
0012 % IN    Q     Qarts structure. See *qarts*.
0013 %       R     Retrieval data structure. See *arts_oem*.
0014 
0015 % 2006-09-07   Created by Patrick Eriksson.
0016 
0017 
0018 function Sx = arts_sx( Q, R )
0019 
0020 
0021 
0022 %--- Initialization of variables ----------------------------------------------
0023 
0024 %- xa
0025 %
0026 nq = length( R.jq );
0027 nx = R.ji{nq}{2};
0028 %
0029 Sx = sparse( nx, nx );
0030 %
0031 i_asj = find( [ Q.ABS_SPECIES.RETRIEVE ] );
0032 
0033 
0034 
0035 %--- Loop retrieval quantities and fill xa and R fields -----------------------
0036 %------------------------------------------------------------------------------
0037 
0038 for i = 1 : nq
0039 
0040   ind = R.ji{i}{1} : R.ji{i}{2};
0041 
0042   switch R.jq{i}.maintag
0043 
0044    case 'Absorption species'   %-----------------------------------------------
0045     %
0046     ig = i_asj(i);    % Gas species index
0047     %                                                                       %&%
0048     rqre_field( Q.ABS_SPECIES(ig), 'SX', sprintf('Q.ABS_SPECIES(%d)',ig) ); %&%
0049     rqre_datatype( Q.ABS_SPECIES(ig).SX, @istensor2, ...                    %&%
0050                                       sprintf('Q.ABS_SPECIES(%d).SX',ig) ); %&%
0051     if any( size(Q.ABS_SPECIES(ig).SX) ~= length(ind) )                     %&%
0052       error( sprintf('Wrong size of Q.ABS_SPECIES(%d).SX.',ig) );           %&%
0053     end                                                                     %&%
0054     %
0055     Sx(ind,ind) = Q.ABS_SPECIES(ig).SX;
0056    
0057    case 'Atmospheric temperatures'   %-----------------------------------------
0058     %
0059     rqre_field( Q.T, 'SX', 'Q.T' );                                         %&%
0060     rqre_datatype( Q.T.SX, @istensor2, 'Q.T.SX' );                          %&%
0061     if any( size(Q.T.SX) ~= length(ind) )                                   %&%
0062       error( sprintf('Wrong size of Q.T.SX.') );                            %&%
0063     end                                                                     %&%
0064     %
0065     Sx(ind,ind) = Q.T.SX;
0066 
0067    case 'Wind'   %-------------------------------------------------------------
0068     %
0069     if strcmp( R.jq{i}.subtag, 'u' )             
0070       rqre_field( Q.WIND_U, 'SX', 'Q.WIND_U' );                             %&%
0071       rqre_datatype( Q.WIND_U.SX, @istensor2, 'Q.WIND_U.SX' );              %&%
0072       if any( size(Q.WIND_U.SX) ~= length(ind) )                            %&%
0073         error( sprintf('Wrong size of Q.WIND_U.SX.') );                     %&%
0074       end                                                                   %&%
0075       Sx(ind,ind) = Q.WIND_U.SX;
0076     elseif strcmp( R.jq{i}.subtag, 'v' )             
0077       rqre_field( Q.WIND_V, 'SX', 'Q.WIND_V' );                             %&%
0078       rqre_datatype( Q.WIND_V.SX, @istensor2, 'Q.WIND_V.SX' );              %&%
0079       if any( size(Q.WIND_V.SX) ~= length(ind) )                            %&%
0080         error( sprintf('Wrong size of Q.WIND_V.SX.') );                     %&%
0081       end                                                                   %&%
0082       Sx(ind,ind) = Q.WIND_V.SX;
0083     elseif strcmp( R.jq{i}.subtag, 'w' ) 
0084       rqre_field( Q.WIND_W, 'SX', 'Q.WIND_W' );                             %&%
0085       rqre_datatype( Q.WIND_W.SX, @istensor2, 'Q.WIND_W.SX' );              %&%
0086       if any( size(Q.WIND_W.SX) ~= length(ind) )                            %&%
0087         error( sprintf('Wrong size of Q.WIND_W.SX.') );                     %&%
0088       end                                                                   %&%
0089       Sx(ind,ind) = Q.WIND_W.SX;
0090     else                                                                    %&%
0091       error( 'Unknown wind subtag.' );                                      %&%
0092     end
0093     
0094    case 'Sensor pointing'   %--------------------------------------------------
0095     %
0096     if ~strcmp( R.jq{i}.subtag, 'Zenith angle off-set' )                    %&%
0097       error( 'Unknown pointing subtag.' );                                  %&%
0098     end                                                                     %&%
0099     rqre_field( Q.POINTING, 'SX', 'Q.POINTING' );                           %&%
0100     rqre_datatype( Q.POINTING.SX, @istensor2, 'Q.POINTING.SX' );            %&%
0101     if any( size(Q.POINTING.SX) ~= length(ind) )                            %&%
0102       error( sprintf('Wrong size of Q.POINTING.SX.') );                     %&%
0103     end                                                                     %&%
0104     %
0105     Sx(ind,ind) = Q.POINTING.SX;
0106    
0107    case 'Frequency'   %--------------------------------------------------------
0108     %
0109     if strcmp( R.jq{i}.subtag, 'Shift' )
0110       rqre_field( Q.FSHIFTFIT, 'SX', 'Q.FSHIFTFIT' );                       %&%
0111       rqre_datatype( Q.FSHIFTFIT.SX, @istensor2, 'Q.FSHIFTFIT.SX' );        %&%
0112       if any( size(Q.FSHIFTFIT.SX) ~= length(ind) )                         %&%
0113         error( sprintf('Wrong size of Q.FSHIFTFIT.SX.') );                  %&%
0114       end                                                                   %&%
0115       Sx(ind,ind) = Q.FSHIFTFIT.SX;
0116       %
0117     elseif strcmp( R.jq{i}.subtag, 'Stretch' )
0118       rqre_field( Q.FSTRETCHFIT, 'SX', 'Q.FSTRETCHFIT' );                   %&%
0119       rqre_datatype( Q.FSTRETCHFIT.SX, @istensor2, 'Q.FSTRETCHFIT.SX' );    %&%
0120       if any( size(Q.FSTRETCHFIT.SX) ~= length(ind) )                       %&%
0121         error( sprintf('Wrong size of Q.FSTRETCHFIT.SX.') );                %&%
0122       end                                                                   %&%
0123       Sx(ind,ind) = Q.FSTRETCHFIT.SX;
0124       %
0125     else                                                                    %&%
0126       error( 'Unknown frequency subtag' );                                  %&%
0127     end
0128     
0129    case 'Polynomial baseline fit'   %------------------------------------------
0130     %
0131     c      = sscanf( R.jq{i}.subtag(end+[-1:0]), '%d' );
0132     sxname = sprintf( 'SX%d', c );
0133     rqre_field( Q.POLYFIT, sxname, 'Q.POLYFIT' );                           %&%
0134     rqre_datatype( Q.POLYFIT.(sxname), @istensor2, ...                      %&%
0135                                           sprintf('Q.POLYFIT.%s',sxname) ); %&%
0136     if any( size(Q.POLYFIT.(sxname)) ~= length(ind) )                       %&%
0137       error( sprintf('Wrong size of Q.POLYFIT.%s.',sxname) );               %&%
0138     end                                                                     %&%
0139     %
0140     Sx(ind,ind) = Q.POLYFIT.(sxname);
0141  
0142    case 'Sinusoidal baseline fit'   %------------------------------------------
0143     %
0144     c      = sscanf( R.jq{i}.subtag(end+[-1:0]), '%d' ) + 1;
0145     sxname = sprintf( 'SX%d', c );
0146     rqre_field( Q.SINEFIT, sxname, 'Q.SINEFIT' );                           %&%
0147     rqre_datatype( Q.SINEFIT.(sxname), @istensor2, ...                      %&%
0148                                           sprintf('Q.SINEFIT.%s',sxname) ); %&%
0149     if any( size(Q.SINEFIT.(sxname))*2 ~= length(ind) )                     %&%
0150       error( sprintf('Wrong size of Q.SINEFIT.%s.',sxname) );               %&%
0151     end                                                                     %&%
0152     %
0153     Sx(ind(1:2:end),ind(1:2:end)) = Q.SINEFIT.(sxname);
0154     Sx(ind(2:2:end),ind(2:2:end)) = Q.SINEFIT.(sxname);
0155    
0156   otherwise   %----------------------------------------------------------------
0157     error( sprintf('Unknown retrieval quantity (%s).',R.jq{i}.maintag) ); 
0158   end
0159 end

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