Upgrade parameters (spectra to spectra) using minimize function (here based on L-BFGS-B optimization module)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
real(kind=xp), | intent(in), | dimension(:,:,:), allocatable | :: | cube | cube |
|
real(kind=xp), | intent(inout), | dimension(:,:,:), allocatable | :: | params | cube parameters to update |
|
integer, | intent(in) | :: | power | nside of the cube |
||
integer, | intent(in) | :: | n_gauss | number of Gaussian |
||
integer, | intent(in) | :: | dim_v | dimension along v axis |
||
integer, | intent(in) | :: | maxiter | max number of iteration |
||
integer, | intent(in) | :: | m | number of corrections used in the limited memory matrix by LBFGS-B |
||
integer, | intent(in) | :: | iprint | print option |
subroutine upgrade(cube, params, power, n_gauss, dim_v, maxiter, m, iprint)
!! Upgrade parameters (spectra to spectra) using minimize function (here based on L-BFGS-B optimization module)
implicit none
real(xp), intent(in), dimension(:,:,:), allocatable :: cube !! cube
integer, intent(in) :: power !! nside of the cube
integer, intent(in) :: n_gauss !! number of Gaussian
integer, intent(in) :: dim_v !! dimension along v axis
integer, intent(in) :: maxiter !! max number of iteration
integer, intent(in) :: m !! number of corrections used in the limited memory matrix by LBFGS-B
integer, intent(in) :: iprint !! print option
real(xp), intent(inout), dimension(:,:,:), allocatable :: params !! cube parameters to update
integer :: i,j
real(xp), dimension(:), allocatable :: line
real(xp), dimension(:), allocatable :: x
real(xp), dimension(:), allocatable :: lb, ub
do i=1, power
do j=1, power
! print*, (i-1)*power+j, " / ", power*power
allocate(line(dim_v))
allocate(x(3*n_gauss), lb(3*n_gauss), ub(3*n_gauss))
line = cube(:,i,j)
x = params(:,i,j)
call init_bounds(line, n_gauss, dim_v, lb, ub)
call minimize_spec(3*n_gauss, m, x, lb, ub, line, dim_v, n_gauss, maxiter, iprint)
params(:,i,j) = x
deallocate(line)
deallocate(x, lb, ub)
end do
end do
end subroutine upgrade