Home > atmlab > gridcreation > optimize_za_grid.m

optimize_za_grid

PURPOSE ^

za_grid_opt.m

SYNOPSIS ^

function [i_approx, za_opt] = optimize_za_grid(i_field, za_grid_fine, acc)

DESCRIPTION ^

 za_grid_opt.m

 OPTIMIZE_ZA_GRID

 Optimitation of the zenith angle grid (scat_za_grid) 
 for an ARTS scattering calculation.

 This script optimizes the zenith angle grid, on which
 the radiation field is stored inside ARTS. Only the intensity
 is optmized (not the other Stokes components). 
 The script works only for one latitude and longitude, so 
 it can be used for 1D calculations or homogeneous 3D 
 calculations. For inhomogeneous 3D clouds one hos to 
 optimize the full intensity field (Tensor6).
 It is sufficient to take the clearsky field for optimization. 
 The optimal grid for all altitudes inside the cloudbox is 
 calculated.

 To represent the radiation field accurately, the grid has 
 to be very find at angles around 90 degress. For limb spectra
 simulations, the sensor look at exactly this regions. It is 
 very important to reduce the number of grid points as far as 
 possible because computation time depends strongly on this 
 number. From my experience, optimization within an accuracy
 of 0.1% leads to sufficiently good results.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

DOWNLOAD ^

optimize_za_grid.m

SOURCE CODE ^

0001 % za_grid_opt.m
0002 %
0003 % OPTIMIZE_ZA_GRID
0004 %
0005 % Optimitation of the zenith angle grid (scat_za_grid)
0006 % for an ARTS scattering calculation.
0007 %
0008 % This script optimizes the zenith angle grid, on which
0009 % the radiation field is stored inside ARTS. Only the intensity
0010 % is optmized (not the other Stokes components).
0011 % The script works only for one latitude and longitude, so
0012 % it can be used for 1D calculations or homogeneous 3D
0013 % calculations. For inhomogeneous 3D clouds one hos to
0014 % optimize the full intensity field (Tensor6).
0015 % It is sufficient to take the clearsky field for optimization.
0016 % The optimal grid for all altitudes inside the cloudbox is
0017 % calculated.
0018 %
0019 % To represent the radiation field accurately, the grid has
0020 % to be very find at angles around 90 degress. For limb spectra
0021 % simulations, the sensor look at exactly this regions. It is
0022 % very important to reduce the number of grid points as far as
0023 % possible because computation time depends strongly on this
0024 % number. From my experience, optimization within an accuracy
0025 % of 0.1% leads to sufficiently good results.
0026 
0027 % FORMAT  [i_approx, za_opt] = optimize_za_grid(i_field, za_grid_fine, acc)
0028 %
0029 % OUT   i_approx Approximated i_field
0030 %       za_opt   Optimized grid.
0031 % IN    i_field  Clearsky radiation field (output from ARTS).
0032 %       za_grid_fine Fine grid used for ARTS calculation.
0033 %       acc      Accuracy limit [%]
0034 
0035 % 24-10-2003 Created by Claudia Emde
0036 
0037 function [i_approx, za_opt] = optimize_za_grid(i_field, za_grid_fine, acc)
0038 
0039 % Number of grid points in the fine grid.
0040 N_za = length(za_grid_fine);
0041 
0042 % Number of pressure levels.
0043 N_p = length(squeeze(i_field(:,1,1,1,1,1)));
0044 
0045 % "Exact" i_field, calculated on fine za_grid
0046 i_exact = squeeze(i_field(:,1,1,:,1,1));
0047 
0048 
0049 % Index vector holds indicees of the optimized grid.
0050 
0051 % Start with the end points of the grid
0052 indx = [1 N_za];
0053 
0054 % The maximum difference between any point of the intensity
0055 % on the very fine grid and the intensity on the optimized
0056 % grid (linearly interpolated) in %. Arbitrary set to 100.
0057 max_diff = 100 
0058 
0059 
0060 % This value gives the accuracy of the optimization.
0061 while max_diff > acc
0062     
0063     % Create reduced grid and approximated intensity vector
0064     N = length(indx);
0065     
0066     % Interpolate reduced intensity field on fine za grid
0067     % for all pressure levels.
0068     for j = 1:N_p
0069         for i = 1:N
0070             za_reduced(i) = za_grid_fine(indx(i));
0071             i_approx(j,i) = i_exact(j, indx(i));
0072         end
0073         i_approx_interp = interp1(za_reduced, i_approx(j,:), za_grid_fine);
0074         
0075         % Plot (just to check, whether the method works correctly)
0076         % plot(za_grid, i_approx_interp);
0077         % hold on;
0078                 
0079         % Calculate the differences between approx. i-vector and
0080         % exact i-vector for one pressure level.
0081         diff_vec = abs(i_exact(j,:)' - i_approx_interp);
0082         
0083         % Pick out maximum value.
0084         [max_diff_za(j), ind_za(j)] = max(diff_vec);
0085     end
0086     % Take the maximum of the maximum differences of all
0087     % pressure levels
0088     [max_diff_p, ind_p] = max(max_diff_za);
0089     
0090     % Take relative difference [%]
0091     max_diff = max_diff_p/i_exact(ind_p, ind_za(ind_p))*100;
0092     
0093     % Put the index of maximum value into index vector and sort.
0094     indx = [indx ind_za(ind_p)];
0095     indx = sort(indx);
0096 end
0097 
0098 % The optimized za grid:
0099 za_opt = sort(za_reduced);
0100 
0101 
0102 
0103

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