Inverse Model and Error Analysis Routines Brian Connor 21 November 2003 Subroutine perform_retrieval Iteratively retrieves the state vector, from which XCO2 is calculated. For each iteration, computes radiances and Jacobian, using do_forwardmodel and compute_pd. Also computes retrieved radiances, the spectral goodness-of-fit, error estimates for the state vector and XCO2, and averaging kernels. Current version uses optimal estimation, which best reproduces the measured radiances while maintaining consistency with an a priori estimate of the state vector. The result of each retrieval will be described by a parameter “outcome”, which is an integer with values 0-4, corresponding to the following: 0. Not yet determined 1. Convergence is reached and there is a good fit of measured and calculated spectra 2. Convergence is reached but the spectral fit is unacceptable 3. No convergence after a maximum number of iterations, max_iter 4. Continuing divergence for max_div iterations For development and test purposes, all products will be calculated for all retrievals attempted. However in production we may wish not to calculate all products for some outcomes. So tests on the outcome parameter will control what is done. One possibility: vectors of flags can be input parameters, with the index equal to the outcome parameter. Two vectors will be sufficient, one to determine if the retrieved radiances and the spectral goodness-of-fit should be calculated, and a corresponding one for error estimates for the state vector and XCO2 and the averaging kernels. E.g. logical array final_rad(0:4) could be initialized with values true, true, true, false, false. Then radiances would be calculated for outcome = 0, 1 or 2, not for outcome = 3 or 4. Meanwhile do_error(4) could be initialized true, true, false, false. Code Outline: Subroutine perform_retrieval Do while (iter_flag==true) iter = iter + 1 call do_forwardmodel call compute_pd[optional] call do_inversion call test_convergence do while(div_flag .eq. true .and. n_div .le. max_div) call do_inversion call test_convergence enddo if (final_rad(outcome)) call update_statestructure EndDo If (final_rad(outcome)) call do_forwardmodel call test_goodness if(do_error(outcome)) call compute_pd call error_analysis call compute_cwvmr endif endif End Subroutine do_inversion Solves the equation for the state vector update dxi+1 ( (1 + )Sa-1 + KiT Sε-1 Ki ) dxi+1 = [KiT Sε-1 (y - f(xi)) + Sa-1(xi - xa)] also computes di2 = dxi+1T Ŝ-1 dxi+1 using the relation Ŝ-1 dxi+1 [KiT Sε-1 (y - f(xi)) + Sa-1(xi - xa)] di2 is effectively the square of the state vector update in units of the solution variance, and is used by test_convergence. Subroutine test_convergence Tests for convergence, divergence, and maximum iterations. First, test for divergence: is di2 > di-12 ? If so, check for max_div iterations through the divergence loop. If max_div, set outcome = 4 and exit. If not, increase and exit with flags set to not update state vector and to loop to do_inversion. Then test for convergence. If di2 << n (the number of state vector elements), convergence is reached. Set flags and output values to exit, updating state vector and computing final radiances and spectral goodness-of-fit. If convergence is not reached, has max_iter been reached? If so, set outcome = 3 and exit. If not, exit with flags set to update state vector and iterate. Subroutine test_goodness Computes chi-squared, i.e. the ratio of the mean square of measured minus calculated spectra to the mean square of the spectral errors, Χ2i, for each spectral band i. Χ2i = mean(yi - fi( x̂ ))2/mean(2i) If Χ2i < max_chi2 i, then the fit is acceptable, and set good = true. Subroutine error_analysis Given the Jacobian from the retrieved state vector, and the measurement and a priori covariance matrices, this routine computes the retrieval uncertainties and averaging kernels. From these it computes the quantities ACO2, ac, ŜCO2, Ŝii, and ~s 1, defined below, which will be archived. First computes the retrieval covariance matrix, Ŝ, and the averaging kernel matrix A. Ŝ is given by Ŝ = (KT S-1 K + Sa-1)-1 The averaging kernel matrix A is given by A = Ŝ KT S-1 K ACO2 and ŜCO2 are simply the square sub-matrices of A and Ŝ which correspond to the CO2 profile. Ŝii is the diagonal of Ŝ. ~s 1 gives the covariance of XCO2 with the non-CO2 elements of the state vector. ac is the column averaging kernel, giving the sensitivity of XCO2 to the state vector. They are defines as follows. The CO2 dry air mole fraction, XCO2, is obtained by averaging the CO2 profile, weighted by the pressure weighting function, h, such that XCO2 = hT x̂ . The formal error variance in the retrieved XCO2 is therefore given by σ2XCO2 = hTŜ h. Further, the sensitivity of XCO2 to the state vector is given by the column averaging kernel ac = XCO2/x = hT A An extension of this procedure can be used to calculate the covariance of XCO2 with the non-CO2 elements of the state vector. Assume the CO2 profile occupies the first p elements of the state vector, and define a matrix H with dimension n (n p 1) such that Hij = hi , j 1 1, i j ( p 1), j 1 0, else XCO 2 xp 1 xp 2 and the covariance of H x̂ is given by HTŜ H. Denote the first row of Thus H x̂ = xn ~ T H Ŝ H by s 1 , where ~s 1 = ( σ2XCO2 ρXCO2,jσXCO2σj …) for j = p+1, n ~s 1 gives the covariance of XCO2 with the n – p non-CO2 elements of the state vector. Subroutine compute_xco2 Calculates XCO2 and its uncertainty σXCO2. The CO2 dry air mole fraction, XCO2, is obtained by averaging the CO2 profile, weighted by the pressure weighting function, h, such that XCO2 = hT x̂ . The formal error variance in the retrieved XCO2 is therefore given by σ2XCO2 = hTŜ h.