Home > atmlab > retrieval > qpack2 > qp2_check_f.m

qp2_check_f

PURPOSE ^

QP2_CHECK_F Checks if frequencies of measurement data are correct

SYNOPSIS ^

function [all_ok,df,i_ok,i_bad] = qp2_check_f(Q,Y,max_df)

DESCRIPTION ^

 QP2_CHECK_F   Checks if frequencies of measurement data are correct

   The frequencies of measurement data (Y.f) are compared to
   Q.SENSOR_RESPONSE.F_BACKEND. A first demand is that Y(i).F has the same
   length as Q.F_BACKEND. If not, df is set to NaN. The second step is to
   determine the max (absolute) difference between Y(i).F and
   Q.SENSOR_RESPONSE.F_BACKEND, and check if this difference is below *max_df*.

 FORMAT   [all_ok,df,i_ok,i_bad] = qp2_check_f(Q,Y,max_df)

 IN    Q        Qpack2 setting structure
       Y        Measurement data.
       max_df   Max allowed deviation to Q.F_BACKEND
 OUT   all_ok   1 if all checks OK. 0 otherwise.
       df       The maximum deviation for each spectrum.
       i_ok     Index of spectra where check OK.
       i_bad    Index of spectra where check not OK.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

qp2_check_f.m

SOURCE CODE ^

0001 % QP2_CHECK_F   Checks if frequencies of measurement data are correct
0002 %
0003 %   The frequencies of measurement data (Y.f) are compared to
0004 %   Q.SENSOR_RESPONSE.F_BACKEND. A first demand is that Y(i).F has the same
0005 %   length as Q.F_BACKEND. If not, df is set to NaN. The second step is to
0006 %   determine the max (absolute) difference between Y(i).F and
0007 %   Q.SENSOR_RESPONSE.F_BACKEND, and check if this difference is below *max_df*.
0008 %
0009 % FORMAT   [all_ok,df,i_ok,i_bad] = qp2_check_f(Q,Y,max_df)
0010 %
0011 % IN    Q        Qpack2 setting structure
0012 %       Y        Measurement data.
0013 %       max_df   Max allowed deviation to Q.F_BACKEND
0014 % OUT   all_ok   1 if all checks OK. 0 otherwise.
0015 %       df       The maximum deviation for each spectrum.
0016 %       i_ok     Index of spectra where check OK.
0017 %       i_bad    Index of spectra where check not OK.
0018 
0019 % 2009-08-05   Created by Patrick Eriksson.
0020 
0021 function [all_ok,df,i_ok,i_bad] = qp2_check_f(Q,Y,max_df)
0022 
0023 
0024 %- Check of input
0025 %
0026 qcheck( @qp2_y, Y );  
0027 
0028 
0029 %- Init
0030 %
0031 if ~isstruct( Q.SENSOR_RESPONSE )                                           %&%
0032   error( 'The structure version of Q.SENSOR_RESPONSE must be used.' );      %&%
0033 end                                                                         %&%
0034 %
0035 f0 = qarts_get( Q.SENSOR_RESPONSE.F_BACKEND );
0036 %
0037 ny = length( Y );
0038 nf = length( f0 );
0039 %
0040 all_ok = 1;
0041 df     = zeros( ny, 1 );
0042 i_ok   = ones( ny, 1 );
0043 
0044 
0045 %- Loop spectra and check
0046 %
0047 for i = 1 : ny
0048   
0049   if length( Y(i).F ) ~= nf 
0050     this_df = NaN;
0051   else
0052     this_df = max( abs( f0 - Y(i).F ) );
0053   end
0054   
0055   if isnan(this_df)  |  this_df > df
0056     all_ok  = 0;
0057     i_ok(i) = 0;
0058   end
0059   
0060   df(i) = this_df;
0061     
0062 end
0063 
0064 
0065 %- Convert 0/1 to index data
0066 %
0067 i_bad = find( ~i_ok );
0068 i_ok  = find( i_ok );

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