%------------------------------------------------------------------------ % NAME: qp_x2arts % % Maps a state vector to ARTS variables or to a correction term % for the measured spectrum. % % The function can be used for iterative retrievals to apply the % present state. % % Atmospheric variables are maped to ARTS, while sensor variables % are maped to a correction term for the spectrum. The correction % term can include for example fit of baseline ripple. This term % shall be subtracted from the measurement spectrum. % % If the RECALC_ABS=0, the absorption is scaled to match the % retrieved species profiles. If RECALC_ABS=1, only the species % profiles are stored and the absorption must be recalculed in % next iteration. % % The function is developed for qpcls but can maybe be useful % for other purposes. % % FORMAT: yc = map_x( x, basename, Kx, kx_names, kx_index, kx_aux, % recalc_abs, logspecies, p_abs, vmrs, Abs, Absp, za ) % % OUT: yc Correction term for measurement spectrum. % IN: basename Basename for the ARTS calculations. % Kx Weighting function matrix. % kx_names As the corresponding ARTS variable. % kx_index Start and stop index for each retrieval identity. % A 2 column matrix. % kx_aux As the corresponding ARTS variable. % recalc_abs Flag to determine if absorption will be recalculated % logspecies Flag for retrieval of the log. of species. % p_abs As ARTS variable p_abs. % vmrs As ARTS variable vmrs. % Abs As ARTS variable abs. % Absp As ARTS variable abs_per_tg. % za As ARTS variable za_pencil. %------------------------------------------------------------------------ % HISTORY: 2001.01.04 Started by by Patrick Eriksson. function yc = map_x( x, basename, Kx, kx_names, kx_index, kx_aux, recalc_abs, logspecies, p_abs, vmrs, Abs, Absp, za ) yc = 0; ispecies = 0; nf = size( Abs, 1 ); for i = 1:size(kx_names,1) [group,name,par1] = qp_kinfo( kx_names{i} ); ind = kx_index(i,1):kx_index(i,2); %=== Species % if strcmp( group, 'Species' ) % ispecies = ispecies + 1; % xp = interpp( kx_aux(ind,1), x(ind), p_abs ); % if logspecies xp = exp( xp ); end % vmrs(ispecies,:) = vmrs(ispecies,:) .* xp'; % if ~recalc_abs % dAbs = Absp{ispecies} .* ( ones(nf,1) * (xp-1)' ); Absp{ispecies} = Absp{ispecies} + dAbs; Abs = Abs + dAbs; % end %=== Temperature % elseif strcmp( group, 'Temperature' ) % t_abs = interpp( kx_aux(ind,1), x(ind), p_abs ); write_artsvar( basename, 't_abs', t_abs, 'b' ); %=== Pointing off-set % elseif strcmp( name, 'Pointing: off-set' ) % za = za + x(ind); write_artsvar( basename, 'za_pencil', za, 'b' ); %=== Polynomial baseline fits % elseif strncmp( group, 'Baseline', 8 ) % yc = yc + Kx(:,ind) * x(ind); else error(sprintf( 'Unknown retrieval identity: %s', name )); end end %=== Save profile/absorption data % write_artsvar( basename, 'vmrs', vmrs, 'b' ); % if ~recalc_abs write_artsvar( basename, 'abs', Abs, 'b' ); write_artsvar( basename, 'abs_per_tg', Absp, 'b' ); end