mod_functions Module

This module contains the main routines of ROHSA


Uses

  • module~~mod_functions~~UsesGraph module~mod_functions mod_functions module~mod_constants mod_constants module~mod_functions->module~mod_constants module~mod_array mod_array module~mod_functions->module~mod_array module~mod_optimize mod_optimize module~mod_functions->module~mod_optimize iso_fortran_env iso_fortran_env module~mod_constants->iso_fortran_env module~mod_array->module~mod_constants module~mod_optimize->module~mod_constants module~mod_optimize->module~mod_array

Used by

  • module~~mod_functions~~UsedByGraph module~mod_functions mod_functions module~mod_rohsa mod_rohsa module~mod_rohsa->module~mod_functions program~rohsa ROHSA program~rohsa->module~mod_rohsa

Contents


Functions

public pure function dim2nside(dim_cube)

Compute nside value from and

Arguments

Type IntentOptional AttributesName
integer, intent(in), dimension(3):: dim_cube

cube dimension

Return Value integer

nside of the cube


Subroutines

public subroutine dim_data2dim_cube(nside, dim_data, dim_cube)

Arguments

Type IntentOptional AttributesName
integer :: nside
integer, intent(in), dimension(3):: dim_data
integer, intent(inout), dimension(3):: dim_cube

public subroutine reshape_up(data, cube, dim_data, dim_cube)

Reshape the data in a grid of

Arguments

Type IntentOptional AttributesName
real(kind=xp), intent(in), dimension(:,:,:), allocatable:: data

original cube

real(kind=xp), intent(inout), dimension(:,:,:), allocatable:: cube

reshape cube

integer, intent(in), dimension(3):: dim_data

original cube dimension

integer, intent(in), dimension(3):: dim_cube

new cube dimension

public subroutine reshape_down(cube, data, dim_cube, dim_data)

Reshape the cube () into a grid with original dimension (opposite of reshape_up)

Arguments

Type IntentOptional AttributesName
real(kind=xp), intent(in), dimension(:,:,:), allocatable:: cube

original cube

real(kind=xp), intent(inout), dimension(:,:,:), allocatable:: data

reshape cube

integer, intent(in), dimension(3):: dim_cube

new cube dimension

integer, intent(in), dimension(3):: dim_data

original cube dimension

public subroutine mean_array(nside, cube, cube_mean)

Average cube along spatial axis depending on level n

Arguments

Type IntentOptional AttributesName
integer, intent(in) :: nside

nside of the cube

real(kind=xp), intent(in), dimension(:,:,:), allocatable:: cube

cube

real(kind=xp), intent(inout), dimension(:,:,:), allocatable:: cube_mean

average cube

public subroutine mean_map(nside, map, map_mean)

Average map depending on level nside

Arguments

Type IntentOptional AttributesName
integer, intent(in) :: nside

nside

real(kind=xp), intent(in), dimension(:,:), allocatable:: map

map

real(kind=xp), intent(inout), dimension(:,:), allocatable:: map_mean

avarage map

public subroutine go_up_level(cube_params)

Projection of the solution at next level (nside += 1)

Arguments

Type IntentOptional AttributesName
real(kind=xp), intent(inout), dimension(:,:,:), allocatable:: cube_params

cube of parameters

public subroutine init_spectrum(n_gauss, params, dim_v, line, amp_fact_init, sig_init, maxiter, m, iprint)

Initialization of the mean sprectrum with N Gaussian

Arguments

Type IntentOptional AttributesName
integer, intent(in) :: n_gauss

number of Gaussian

real(kind=xp), intent(inout), dimension(3*n_gauss):: params

params to optimize

integer, intent(in) :: dim_v

dimension along v axis

real(kind=xp), intent(in), dimension(dim_v):: line

spectrum

real(kind=xp), intent(in) :: amp_fact_init

times max amplitude of additional Gaussian

real(kind=xp), intent(in) :: sig_init

dispersion of additional Gaussian

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

private subroutine init_bounds(line, n_gauss, dim_v, lb, ub)

Initialize parameters bounds for optimization

Arguments

Type IntentOptional AttributesName
real(kind=xp), intent(in), dimension(dim_v):: line

spectrum

integer, intent(in) :: n_gauss

number of Gaussian

integer, intent(in) :: dim_v

dimension along v axis

real(kind=xp), intent(inout), dimension(3*n_gauss):: lb

lower bounds

real(kind=xp), intent(inout), dimension(3*n_gauss):: ub

upper bounds

public 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)

Arguments

Type IntentOptional AttributesName
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

public subroutine update(cube, params, n_gauss, dim_v, dim_y, dim_x, lambda_amp, lambda_mu, lambda_sig, lambda_var_amp, lambda_var_mu, lambda_var_sig, maxiter, m, kernel, iprint, std_map)

Update parameters (entire cube) using minimize function (here based on L-BFGS-B optimization module)

Arguments

Type IntentOptional AttributesName
real(kind=xp), intent(in), dimension(:,:,:), allocatable:: cube

cube

real(kind=xp), intent(inout), dimension(:,:,:), allocatable:: params

parameters cube to update

integer, intent(in) :: n_gauss

Number of Gaussian

integer, intent(in) :: dim_v

dimension along v axis

integer, intent(in) :: dim_y

dimension along spatial axis y

integer, intent(in) :: dim_x

dimension along spatial axis x

real(kind=xp), intent(in) :: lambda_amp

lambda for amplitude parameter

real(kind=xp), intent(in) :: lambda_mu

lambda for mean position parameter

real(kind=xp), intent(in) :: lambda_sig

lambda for dispersion parameter

real(kind=xp), intent(in) :: lambda_var_amp

lambda for amp dispersion parameter

real(kind=xp), intent(in) :: lambda_var_mu

lambda for mean position dispersion parameter

real(kind=xp), intent(in) :: lambda_var_sig

lambda for variance dispersion parameter

integer, intent(in) :: maxiter

max number of iteration

integer, intent(in) :: m

number of corrections used in the limited memory matrix by LBFGS-B

real(kind=xp), intent(in), dimension(:,:), allocatable:: kernel

convolution kernel

integer, intent(in) :: iprint

print option

real(kind=xp), intent(in), dimension(:,:), allocatable:: std_map

Standard deviation map

public subroutine set_stdmap(std_map, cube, lb, ub)

Compute the STD map of a 3D array

Arguments

Type IntentOptional AttributesName
real(kind=xp), intent(inout), dimension(:,:), allocatable:: std_map

standard deviation map of the cube

real(kind=xp), intent(in), dimension(:,:,:), allocatable:: cube

cube

integer, intent(in) :: lb

lower bound

integer, intent(in) :: ub

upper bound

public subroutine std_spectrum(data, spectrum, dim_v, dim_y, dim_x)

Compute the STD spectrum of a cube along the spatial axis

Arguments

Type IntentOptional AttributesName
real(kind=xp), intent(in), dimension(:,:,:), allocatable:: data

initial fits data

real(kind=xp), intent(inout), dimension(:), allocatable:: spectrum

std_spectrum of the observation

integer, intent(in) :: dim_v

dimension along v axis

integer, intent(in) :: dim_y

dimension along spatial axis y

integer, intent(in) :: dim_x

dimension along spatial axis x

public subroutine max_spectrum(data, spectrum, dim_v, dim_y, dim_x, norm_value)

Compute the MAX spectrum of a cube along the spatial axis

Arguments

Type IntentOptional AttributesName
real(kind=xp), intent(in), dimension(:,:,:), allocatable:: data

initial fits data

real(kind=xp), intent(inout), dimension(:), allocatable:: spectrum

max_spectrum of the observation

integer, intent(in) :: dim_v

dimension along v axis

integer, intent(in) :: dim_y

dimension along spatial axis y

integer, intent(in) :: dim_x

dimension along spatial axis x

real(kind=xp), intent(in), optional :: norm_value

max value of the mean spectrum to normalze the max spectrum if present

public subroutine mean_spectrum(data, spectrum, dim_v, dim_y, dim_x)

Compute the MEAN spectrum of a cube along the spatial axis

Arguments

Type IntentOptional AttributesName
real(kind=xp), intent(in), dimension(:,:,:), allocatable:: data

initial fits data

real(kind=xp), intent(inout), dimension(:), allocatable:: spectrum

std_spectrum of the observation

integer, intent(in) :: dim_v

dimension along v axis

integer, intent(in) :: dim_y

dimension along spatial axis y

integer, intent(in) :: dim_x

dimension along spatial axis x

public subroutine init_grid_params(params, guess_spectrum, dim_y, dim_x)

Set up a grid params array with std spectrum at each spatial position

Arguments

Type IntentOptional AttributesName
real(kind=xp), intent(inout), dimension(:,:,:), allocatable:: params

grid of paramters

real(kind=xp), intent(in), dimension(:), allocatable:: guess_spectrum

std spectrum of the observation

integer, intent(in) :: dim_y

dimension along spatial axis y

integer, intent(in) :: dim_x

dimension along spatial axis x

public subroutine init_new_gauss(cube, params, std_map, n_gauss, dim_v, dim_y, dim_x, amp_fact_init, sig_init)

Arguments

Type IntentOptional AttributesName
real(kind=xp), intent(in), dimension(:,:,:), allocatable:: cube

mean cube over spatial axis

real(kind=xp), intent(inout), dimension(:,:,:), allocatable:: params

parameters to optimize with cube mean at each iteration

real(kind=xp), intent(in), dimension(:,:), allocatable:: std_map

standard deviation map fo the cube computed by ROHSA with lb and ub

integer, intent(inout) :: n_gauss
integer, intent(in) :: dim_v
integer, intent(in) :: dim_y
integer, intent(in) :: dim_x
real(kind=xp), intent(in) :: amp_fact_init

times max amplitude of additional Gaussian

real(kind=xp), intent(in) :: sig_init

dispersion of additional Gaussian