# Settings example to retrieve aerosol and surface parameters from synthetic POLDER (I, Q and U) observations (multi-pixel)
# Authors: Pavel Litvinov, Xin Huang, Anton Lopatin
# date of last modification: 2016-09-11 (Anton Lopatin)

# Other comments:
#   fast settings
#   monomodal triangular bins
#   monomodal spectral dependent refractive index
#   exponential aerosol vertical profile with retrieved scale altitude
#   both land and ocean surface
#   characteristics, optics, refractive index, surface, residual and size distribution bimodal properties provided

input:
    driver: sdata
    file: sim_polder_iteris.sdat


output:
    segment:
        function: classic
        stream: output_polder_inversion_iteris.txt 

retrieval:
    general:
        path_to_internal_files: "../../src/retrieval/internal_files/"

    mode: inversion # forward
    
    inversion: 
        regime: multi_pixel   
        
        convergence:
            minimization_convention: logarithm
            threshold_for_stopping: 1.0e-3
            maximum_iterations_for_stopping: 15
            maximum_iterations_of_Levenberg-Marquardt: 15
            threshold_for_stopping_Q_iterations:  1.0e-12
            scale_for_finite_difference:          1.0e-3 
            shift_for_applying_logarithm_to_negative_values: 1.1

        measurement_fitting:
            polarization: relative_polarization_components

        noises:
            noise[1]:
                standard_deviation_synthetic: 0.0
                error_type:   relative
                standard_deviation:  0.03
                measurement_type[1]:
                    type: I
                    index_of_wavelength_involved: [ 1, 2, 3, 4, 5, 6 ]
            noise[2]:
                standard_deviation_synthetic: 0.0
                error_type:  absolute
                standard_deviation:  0.005
                measurement_type[1]:
                    type: Q
                    index_of_wavelength_involved: [ 2, 4, 5 ]
                measurement_type[2]:
                    type: U
                    index_of_wavelength_involved: [ 2, 4, 5 ]

    forward_model:
        phase_matrix:
            size_binning_method_for_triangle_bins: logarithm
            number_of_elements: 4
            kernels_folder: "KERNELS_BASE/"
            radius:
                mode[1]:
                    min: 0.05
                    max: 15.0
                    
        radiative_transfer:
            number_of_layers: 50
            aerosol_profile_vertical_type:    exponential
            absolute_error_rt_calculations: 0.0005
            reference_plane_for_polarization:   meridian
            simulating_observation:
                order_of_scattering: multiple_scattering
                number_of_gaussian_quadratures_for_expansion_coefficients:  15
                number_of_guassian_quadratures_for_fourier_expansion_coefficients:  5
                number_of_fourier_expansion_coefficients:  4
            simulating_derivatives:
                order_of_scattering: multiple_scattering
                number_of_gaussian_quadratures_for_expansion_coefficients:  15
                number_of_guassian_quadratures_for_fourier_expansion_coefficients:   4
                number_of_fourier_expansion_coefficients:   4


    products: 
        configuration:
            wavelength_indices_for_angstrom: [4, 5]
            wavelength_indices_for_ndvi: [4, 5]
        aerosol:
            chemistry: false
            lidar: false                            
            optical_properties: true                
            phase_matrix: false                      
            refractive_index: true                 
            theoretical_bimodal_extinction: false    
            theoretical_bimodal_parameters: true  
        error_estimation:
            aerosol:
                lidar: false            
                optical_properties: false
            parameters: false               
        forcing:
            broadband_flux: false                    
            forcing: false                           
        retrieval:
            fitting: false                       
            parameters: true                      
            residual: true                        
        surface:
            main_characteristics: true 
            isotropic_bihemispherical_reflectance: false

    debug:
        additional_information: false
        verbose: true

    constraints:
        characteristic[1]: #1
            type: size_distribution_triangle_bins
            retrieved: true
            mode[1]: 
                initial_guess:                         #1         #2        #3        #4        #5        #6        #7        #8        #9        #10       #11       #12       #13       #14       #15       #16       
                      value:                          [0.005,     0.05,     0.05,     0.05,     0.05,     0.05,     0.05,     0.05,     0.05,     0.05,     0.05,     0.05,     0.05,     0.05,     0.05,     0.05      ]
                      min:                            [0.000005,  0.000005, 0.000005, 0.000005, 0.000005, 0.000005, 0.000005, 0.000005, 0.000005, 0.000005, 0.000005, 0.000005, 0.000005, 0.000005, 0.000005, 0.000005  ]
                      max:                            [5.0,       15.0,     15.0,     15.0,     15.0,     15.0,     15.0,     15.0,     15.0,     15.0,     15.0,     15.0,     15.0,     15.0,     15.0,     5.0       ]
                      index_of_wavelength_involved:   [0,         0,        0,        0,        0,        0,        0,        0 ,       0,        0,        0,        0,        0,        0,        0,        0         ]
                single_pixel:
                    smoothness_constraints:
                        difference_order: 0
                        lagrange_multiplier: 0.0
                multi_pixel:
                   smoothness_constraints:
                       derivative_order_of_X_variability:    1
                       lagrange_multiplier_of_X_variability: 1.0e-1                        
                       derivative_order_of_Y_variability:    1
                       lagrange_multiplier_of_Y_variability: 1.0e-1                     
                       derivative_order_of_T_variability:    1
                       lagrange_multiplier_of_T_variability: 5.0e-4
                                                
        characteristic[2]: #2
            type: real_part_of_refractive_index_spectral_dependent
            retrieved: true
            mode[1]:
                initial_guess:                       #1         #2        #3        #4        #5        #6       
                    value:                          [1.5,       1.5,      1.5,      1.5,      1.5,      1.5    ]
                    min:                            [1.33,      1.33,     1.33,     1.33,     1.33,     1.33   ]
                    max:                            [1.6,       1.6,      1.6,      1.6,      1.6,      1.6    ]
                    index_of_wavelength_involved:   [1,         2,        3,        4,        5,        6      ] 
                single_pixel:
                    smoothness_constraints:
                        difference_order: 1
                        lagrange_multiplier: 1.0e+1
                multi_pixel:
                   smoothness_constraints:
                       derivative_order_of_X_variability:    1
                       lagrange_multiplier_of_X_variability: 1.0e-1                        
                       derivative_order_of_Y_variability:    1
                       lagrange_multiplier_of_Y_variability: 1.0e-1                     
                       derivative_order_of_T_variability:    1
                       lagrange_multiplier_of_T_variability: 2.0e-2                                               

        characteristic[3]: #3
            type: imaginary_part_of_refractive_index_spectral_dependent
            retrieved: true
            mode[1]:
                initial_guess:                       #1        #2        #3        #4        #5        #6    
                    value:                          [0.005,    0.005,    0.005,    0.005,    0.005,    0.005     ]
                    min:                            [0.00005,  0.00005,  0.00005,  0.00005,  0.00005,  0.00005   ]
                    max:                            [0.1,      0.1,      0.1,      0.1,      0.1,      0.1       ]
                    index_of_wavelength_involved:   [1,        2,        3,        4,        5,        6         ]
                single_pixel:
                    smoothness_constraints:
                        difference_order: 1
                        lagrange_multiplier: 5.0e-2
                multi_pixel:
                   smoothness_constraints:
                       derivative_order_of_X_variability:    1
                       lagrange_multiplier_of_X_variability: 1.0e-1                        
                       derivative_order_of_Y_variability:    1
                       lagrange_multiplier_of_Y_variability: 1.0e-1                     
                       derivative_order_of_T_variability:    1
                       lagrange_multiplier_of_T_variability: 2.0e-2

        characteristic[4]: #4
            type: sphere_fraction
            retrieved: true
            mode[1]:
                initial_guess:                      #1      
                    value:                          [0.5   ]
                    min:                            [0.005 ]
                    max:                            [0.9999]
                    index_of_wavelength_involved:   [0     ]
                single_pixel:
                    smoothness_constraints:
                        difference_order: 0
                        lagrange_multiplier: 0.0
                multi_pixel:
                   smoothness_constraints:
                       derivative_order_of_X_variability:    1
                       lagrange_multiplier_of_X_variability: 1.0e-1                        
                       derivative_order_of_Y_variability:    1
                       lagrange_multiplier_of_Y_variability: 1.0e-1                     
                       derivative_order_of_T_variability:    1
                       lagrange_multiplier_of_T_variability: 1.0e-2

        characteristic[5]: #5
            type: vertical_profile_parameter_height
            retrieved: true
            mode[1]:
                initial_guess:                      #1          
                    value:                          [2500.0 ]
                    min:                            [10.0   ] 
                    max:                            [5000.0 ]
                    index_of_wavelength_involved:   [0      ]
                single_pixel:
                    smoothness_constraints:
                        difference_order: 0
                        lagrange_multiplier: 0
                multi_pixel:
                   smoothness_constraints:
                       derivative_order_of_X_variability:    1
                       lagrange_multiplier_of_X_variability: 1.0e-1                        
                       derivative_order_of_Y_variability:    1
                       lagrange_multiplier_of_Y_variability: 1.0e-1                     
                       derivative_order_of_T_variability:    1
                       lagrange_multiplier_of_T_variability: 1.0e-2
                         
        characteristic[6]: #7
            type: surface_land_brdf_ross_li
            retrieved: true
            mode[1]:    
                initial_guess:                       #1     #2     #3     #4     #5     #6
                    value:                          [0.1,   0.1,   0.1,   0.1,   0.1,   0.1   ]     
                    min:                            [0.001, 0.001, 0.001, 0.001, 0.001, 0.001 ]
                    max:                            [0.2,   0.3,   0.4,   0.7,   0.8,   0.8   ]
                    index_of_wavelength_involved:   [1,     2,     3,     4,     5,     6     ]
                single_pixel:
                    smoothness_constraints:
                        difference_order: 1
                        lagrange_multiplier: 1.0e-4
                multi_pixel:
                   smoothness_constraints:
                       derivative_order_of_X_variability:    0
                       lagrange_multiplier_of_X_variability: 1.0e-3                        
                       derivative_order_of_Y_variability:    0
                       lagrange_multiplier_of_Y_variability: 1.0e-3
                       derivative_order_of_T_variability:    1
                       lagrange_multiplier_of_T_variability: 1.0e-0                            

            mode[2]:
                initial_guess:                       #1     #2     #3     #4     #5     #6
                    value:                          [0.1,   0.1,   0.1,   0.1,   0.1,   0.1   ]    
                    min:                            [0.01,  0.01,  0.01,  0.01,  0.01,  0.01  ]
                    max:                            [2.0,   2.0,   2.0,   2.0,   2.0,   2.0   ]
                    index_of_wavelength_involved:   [1,     2,     3,     4,     5,     6     ]
                single_pixel:
                    smoothness_constraints:
                        difference_order: 1
                        lagrange_multiplier: 10.0e-0
                multi_pixel:
                   smoothness_constraints:
                       derivative_order_of_X_variability:    0
                       lagrange_multiplier_of_X_variability: 1.0e-3                        
                       derivative_order_of_Y_variability:    0
                       lagrange_multiplier_of_Y_variability: 1.0e-3
                       derivative_order_of_T_variability:    1
                       lagrange_multiplier_of_T_variability: 1.0e-0

            mode[3]:
                initial_guess:                       #1     #2     #3     #4     #5     #6       
                    value:                          [0.1,   0.1,   0.1,   0.1,   0.1,   0.1   ]
                    min:                            [0.01,  0.01,  0.01,  0.01,  0.01,  0.01  ]
                    max:                            [1.0,   1.0,   1.0,   1.0,   1.0,   1.0   ]
                    index_of_wavelength_involved:   [1,     2,     3,     4,     5,     6     ]
                single_pixel:
                    smoothness_constraints:
                        difference_order: 1
                        lagrange_multiplier: 10.0e-0
                multi_pixel:
                   smoothness_constraints:
                       derivative_order_of_X_variability:    0
                       lagrange_multiplier_of_X_variability: 1.0e-3                        
                       derivative_order_of_Y_variability:    0
                       lagrange_multiplier_of_Y_variability: 1.0e-3
                       derivative_order_of_T_variability:    1
                       lagrange_multiplier_of_T_variability: 1.0e-0                            

        characteristic[7]: #8
            type: surface_land_polarized_maignan_breon
            retrieved: true
            mode[1]:
                initial_guess:                       #1        #2        #3        #4        #5        #6        
                    value:                          [2.1,      2.1,      2.1,      2.1,      2.1,      2.1   ]
                    min:                            [0.01,     0.01,     0.01,     0.01,     0.01,     0.01  ]
                    max:                            [10.03,    10.03,    10.03,    10.03,    10.03,    10.03 ]
                    index_of_wavelength_involved:   [1,        2,        3,        4,        5,        6     ]
                single_pixel:
                    smoothness_constraints:
                        difference_order: 1
                        lagrange_multiplier: 10.0e-0
                multi_pixel:
                   smoothness_constraints:
                       derivative_order_of_X_variability:    1
                       lagrange_multiplier_of_X_variability: 0.0e-3                        
                       derivative_order_of_Y_variability:    1
                       lagrange_multiplier_of_Y_variability: 0.0e-3
                       derivative_order_of_T_variability:    1
                       lagrange_multiplier_of_T_variability: 1.0e-0  
             
        characteristic[8]: #9
            type: surface_water_cox_munk_iso
            retrieved: true
            mode[1]:    
                initial_guess:                       #1      #2      #3      #4      #5      #6       
                    value:                          [0.01,   0.01,   0.01,   0.005,  0.005,  0.005  ]
                    min:                            [0.0001, 0.0001, 0.0001, 0.0001, 0.0001, 0.0001 ]
                    max:                            [0.05,   0.05,   0.05,   0.05,   0.05,   0.05   ]
                    index_of_wavelength_involved:   [1,      2,      3,      4,      5,      6      ]
                single_pixel:
                    smoothness_constraints:
                        difference_order: 1
                        lagrange_multiplier: 1.0e-3
                multi_pixel:
                   smoothness_constraints:
                       derivative_order_of_X_variability:    1
                       lagrange_multiplier_of_X_variability: 1.0e-3                        
                       derivative_order_of_Y_variability:    1
                       lagrange_multiplier_of_Y_variability: 1.0e-3
                       derivative_order_of_T_variability:    1
                       lagrange_multiplier_of_T_variability: 1.0e-3

            mode[2]:
                initial_guess:                       #1      #2      #3      #4      #5      #6       
                    value:                          [0.90,   0.90,   0.90,   0.90,   0.90,   0.90   ]
                    min:                            [0.60,   0.60,   0.60,   0.60,   0.60,   0.60   ]
                    max:                            [1.0000, 1.0000, 1.0000, 1.0000, 1.0000, 1.0000 ]
                    index_of_wavelength_involved:   [1,      2,      3,      4,      5,      6      ]
                single_pixel:
                    smoothness_constraints:
                        difference_order: 1
                        lagrange_multiplier: 10.0e-0
                multi_pixel:
                   smoothness_constraints:
                       derivative_order_of_X_variability:    1
                       lagrange_multiplier_of_X_variability: 1.0e-3                        
                       derivative_order_of_Y_variability:    1
                       lagrange_multiplier_of_Y_variability: 1.0e-3
                       derivative_order_of_T_variability:    0
                       lagrange_multiplier_of_T_variability: 1.0e-3

            mode[3]:
                initial_guess:                       #1      #2      #3      #4      #5      #6       
                    value:                          [0.01,    0.01,   0.01,   0.01,   0.01,   0.01  ]
                    min:                            [0.0015, 0.0015, 0.0015, 0.0015, 0.0015, 0.0015 ]
                    max:                            [0.1,    0.1,    0.1,    0.1,    0.1,    0.1    ]
                    index_of_wavelength_involved:   [ 1,      2,      3,      4,      5,      6     ]
                single_pixel:

                    smoothness_constraints:
                        difference_order: 1
                        lagrange_multiplier: 10.0e-0
                multi_pixel:
                   smoothness_constraints:
                       derivative_order_of_X_variability:    1
                       lagrange_multiplier_of_X_variability: 1.0e-3                        
                       derivative_order_of_Y_variability:    1
                       lagrange_multiplier_of_Y_variability: 1.0e-3
                       derivative_order_of_T_variability:    0
                       lagrange_multiplier_of_T_variability: 1.0e-3


