grasp_parameters.c File Reference
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "grasp_parameters.h"
#include "../settings/grasp_settings_data_types.h"

Functions

void grasp_parameters_initialize (float iguess[_KIMAGE][_KPARS])
 Initialize a matrix structure of parameters. More...
 
int grasp_parameters_get_characteristic_index_by_parameter_number (par_number_NDIM *dimensions, int parameter_number)
 Get the index of the characteristic in NDIM.N1 array. More...
 
int grasp_parameters_get_characteristic_code_by_parameter_number (par_number_NDIM *dimensions, int parameter_number)
 
int grasp_parameters_get_mode_by_parameter_number (par_number_NDIM *dimensions, int parameter_number)
 
int grasp_parameters_get_position_by_parameter_number (par_number_NDIM *dimensions, int parameter_number)
 
int grasp_parameters_get_position_of_characteristic (par_number_NDIM *dimensions, int parameter_number)
 
void grasp_parameters_get_characteristic_type_longname_by_parameter_number (par_number_NDIM *dimensions, int parameter_number, char *characteristic_name, int size_characteristic_name)
 Retrieve the name (long) of a characteristic knowing its position. More...
 
void grasp_parameters_get_characteristic_type_shortname_by_parameter_number (par_number_NDIM *dimensions, int parameter_number, char *characteristic_name, int size_characteristic_name)
 Retrieve the name (short) of a characteristic knowing its position. More...
 
void grasp_parameters_get_characteric_type_pretty_name_by_parameter_number (par_number_NDIM *dimensions, int parameter_number, bool longname, float wavelenghts[_KW], int wavelenghts_involved[_KPARS], char *characteristic_name, int size_characteristic_name)
 Retrieve the name of the characteristic of a parameter like a unique string take into account the wavelength (or the position of the parameter) and the mode. More...
 
int grasp_parameters_index_of_parameter_type (par_number_NDIM *dimensions, int characteristic_type)
 Look for the index of a characteristic type. More...
 
int grasp_parameters_index_of_parameter_type_by_kind_of_parameter (par_number_NDIM *dimensions, int begin_characteristic_type, int end_characteristic_type)
 
int grasp_parameters_characteristic_code_present_of_kind_of_parameter (par_number_NDIM *dimensions, int begin_characteristic_type, int end_characteristic_type)
 
bool grasp_parameters_has_parameter_type (par_number_NDIM *dimensions, int characteristic_type)
 Checks if a characteristic was set in settings. More...
 
int grasp_parameters_set_value (par_number_NDIM *dimensions, float iguess[_KPARS], int characteristic_type, int mode, int pos, float value)
 Set in initial guess array a value. More...
 
int grasp_parameters_number_of_modes_of_parameter (par_number_NDIM *dimensions, int characteristic_type)
 
int grasp_parameters_number_of_elements_of_parameter (par_number_NDIM *dimensions, int characteristic_type, int mode)
 
float grasp_parameters_output_get_value (par_number_NDIM *dimensions, const float parameters[_KPARS], int characteristic_type, int mode, int pos)
 
int grasp_parameters_get_position (par_number_NDIM *dimensions, int characteristic_type, int mode, int pos)
 
float grasp_parameters_iguess_get_value (par_number_NDIM *dimensions, float APSING[_KPARS], float iguess[_KPARS], float APSMIN[_KPARS], float APSMAX[_KPARS], int characteristic_type, int mode, int pos)
 

Function Documentation

◆ grasp_parameters_characteristic_code_present_of_kind_of_parameter()

int grasp_parameters_characteristic_code_present_of_kind_of_parameter ( par_number_NDIM dimensions,
int  begin_characteristic_type,
int  end_characteristic_type 
)

Look for the type of characteristics of the group. For example, if you want to know what kind of size distribution is defined you'll do a call with begin=par_type_SD_beg and end=par_type_SD_end and it will return the code of present size distribution otherwise, if it is not present, -1

Parameters
dimensionsNDIM block from settings
begin_characteristic_typeBegin of block of characteristic (grasp_retrieval_characteristic_type.h) that you want to look for
end_characteristic_typeEnd of block of characteristic (grasp_retrieval_characteristic_type.h) that you want to look for
Returns
Index of position of characteristic type in the array of characteristics. If the characteristic is not present it will return -1

◆ grasp_parameters_get_characteric_type_pretty_name_by_parameter_number()

void grasp_parameters_get_characteric_type_pretty_name_by_parameter_number ( par_number_NDIM dimensions,
int  parameter_number,
bool  longname,
float  wavelenghts[_KW],
int  wavelenghts_involved[_KPARS],
char *  characteristic_name,
int  size_characteristic_name 
)

Retrieve the name of the characteristic of a parameter like a unique string take into account the wavelength (or the position of the parameter) and the mode.

Parameters
dimensionsDefinition of parameter structure
parameter_numberNumber of the parameter which the user want to retrieve the name
longnameIf you want to get a long name or not. If you don't want a long name you'll obtain a short one
wavelenghtsArray of wavelengths from settings (settings->retrieval.WAVE)
wavelenghts_involvedArray of wavelengths involved from settings (settings->retrieval.IWW_SINGL)
characteristic_nameReturned value. This string will be set with a pretty name which describe the parameter
size_characteristic_nameSize of characteristic_name to check the string in in the limits.

◆ grasp_parameters_get_characteristic_code_by_parameter_number()

int grasp_parameters_get_characteristic_code_by_parameter_number ( par_number_NDIM dimensions,
int  parameter_number 
)

Get the code of characteristic (example, if characteristic is SizeDistribBin it returns par_type_SD_TB=10101) of a specific parameter knowing its position

Parameters
dimensionsDefinition of parameter structure
parameter_numberNumber of the parameter which the user want to retrieve the name
Returns
The code of characteristic (a valid constant defined in grasp_retrieval_characteristic_type.h) or -1 if there was an error

◆ grasp_parameters_get_characteristic_index_by_parameter_number()

int grasp_parameters_get_characteristic_index_by_parameter_number ( par_number_NDIM dimensions,
int  parameter_number 
)

Get the index of the characteristic in NDIM.N1 array.

Parameters
dimensionsDefinition of parameter structure
parameter_numberNumber of the parameter which the user want to retrieve the name
Returns
Number of the characteristic or -1 if there was an error

◆ grasp_parameters_get_characteristic_type_longname_by_parameter_number()

void grasp_parameters_get_characteristic_type_longname_by_parameter_number ( par_number_NDIM dimensions,
int  parameter_number,
char *  characteristic_name,
int  size_characteristic_name 
)

Retrieve the name (long) of a characteristic knowing its position.

Parameters
dimensionsDefinition of parameter structure
parameter_numberNumber of the parameter which the user want to retrieve the name
characteristic_nameReturned name of the characteristic
size_characteristic_nameSize of allocated characteristic_name argument in order to check that no memory leak is produced

Given a parameter number and the dimensions of the parameter array this funtion will get the characteristic name in characteristic_name string where size_characteristic_name is the maximum size of the string and should be bigger than the characteristic name returned

◆ grasp_parameters_get_characteristic_type_shortname_by_parameter_number()

void grasp_parameters_get_characteristic_type_shortname_by_parameter_number ( par_number_NDIM dimensions,
int  parameter_number,
char *  characteristic_name,
int  size_characteristic_name 
)

Retrieve the name (short) of a characteristic knowing its position.

Parameters
dimensionsDefinition of parameter structure
parameter_numberNumber of the parameter which the user want to retrieve the name
characteristic_nameReturned name of the characteristic
size_characteristic_nameSize of allocated characteristic_name argument in order to check that no memory leak is produced

Given a parameter number and the dimensions of the parameter array this funtion will get the characteristic name in characteristic_name string where size_characteristic_name is the maximum size of the string and should be bigger than the characteristic name returned

◆ grasp_parameters_get_mode_by_parameter_number()

int grasp_parameters_get_mode_by_parameter_number ( par_number_NDIM dimensions,
int  parameter_number 
)

Get the mode in which a specific parameter is (starting in 1)

Parameters
dimensionsDefinition of parameter structure
parameter_numberNumber of the parameter which the user want to retrieve the name
Returns
The mode in which a specific parameter is (starting in 1)

◆ grasp_parameters_get_position()

int grasp_parameters_get_position ( par_number_NDIM dimensions,
int  characteristic_type,
int  mode,
int  pos 
)

This function return a the position of a specific characteristic from an array of output parameters

Parameters
dimensionsNDIM block from settings
parametersArray of output parameters
characteristic_typeCharacteristic index (base on grasp_retrieval_characteristic_type.h) where the value will be set
modeMode which will be set (starting in 1 like in yml settings file)
posIndex of the value inside the characteristic and mode which will be set (starting in 0 like C array)
Returns
Value from output requested. -1 if Characteristic type does not exist and -2 if characteristic exist but it does not have specific mode

◆ grasp_parameters_get_position_by_parameter_number()

int grasp_parameters_get_position_by_parameter_number ( par_number_NDIM dimensions,
int  parameter_number 
)

Get the position inside the block of a specific parameter. This is the position of the parameter in its mode and characteristic type

Parameters
dimensionsDefinition of parameter structure
parameter_numberNumber of the parameter which the user want to retrieve the name
Returns
The position of the parameter starting to count in its characteristic type and mode

◆ grasp_parameters_get_position_of_characteristic()

int grasp_parameters_get_position_of_characteristic ( par_number_NDIM dimensions,
int  parameter_number 
)

Return the position in the parameters array of the first element of a characteristic type

Parameters
dimensionsDefinition of parameter structure
parameter_numberNumber of the parameter which the user want to retrieve the name

◆ grasp_parameters_has_parameter_type()

bool grasp_parameters_has_parameter_type ( par_number_NDIM dimensions,
int  characteristic_type 
)

Checks if a characteristic was set in settings.

Parameters
dimensionsNDIM block from settings
characteristic_typeNumber of the characteristic (grasp_retrieval_characteristic_type.h) that you want to look for
Returns
true if the characteristic is present in current settings definition

◆ grasp_parameters_iguess_get_value()

float grasp_parameters_iguess_get_value ( par_number_NDIM dimensions,
float  APSING[_KPARS],
float  iguess[_KPARS],
float  APSMIN[_KPARS],
float  APSMAX[_KPARS],
int  characteristic_type,
int  mode,
int  pos 
)

This function return a value which will be used like initial guess. It is the value of apsing expect if iguess if different from -999.0. If iguess is different of -999 it will be returned except if it is outside of range, in this case min or max will be returned (depending which limit is overflowed)

Parameters
dimensionsNDIM block from settings
APSINGInitial guess array
iguessInitial guess array for a specific pixel
APSMINMinimum value of initial guess
APSMAXMaximum value of initial guess
characteristic_typeCharacteristic index (base on grasp_retrieval_characteristic_type.h) where the value will be set
modeMode which will be set (starting in 1 like in yml settings file)
posIndex of the value inside the characteristic and mode which will be set (starting in 0 like C array)
Returns
Value from output requested. -1 if Characteristic type does not exist and -2 if characteristic exist but it does not have specific mode

◆ grasp_parameters_index_of_parameter_type()

int grasp_parameters_index_of_parameter_type ( par_number_NDIM dimensions,
int  characteristic_type 
)

Look for the index of a characteristic type.

Parameters
dimensionsNDIM block from settings
characteristic_typeNumber of the characteristic (grasp_retrieval_characteristic_type.h) that you want to look for
Returns
Index of position of characteristic type in the array of characteristics. If the characteristic is not present it will return -1

◆ grasp_parameters_index_of_parameter_type_by_kind_of_parameter()

int grasp_parameters_index_of_parameter_type_by_kind_of_parameter ( par_number_NDIM dimensions,
int  begin_characteristic_type,
int  end_characteristic_type 
)

Look for the index of a kind of characteristic. For example, if you want to know where is defined size distribution but it does not matter with kind of size distribution you can call this function with par_type_SD_beg and par_type_SD_end as arguments and you'll get the index of the sd characteristic

Parameters
dimensionsNDIM block from settings
begin_characteristic_typeBegin of block of characteristic (grasp_retrieval_characteristic_type.h) that you want to look for
end_characteristic_typeEnd of block of characteristic (grasp_retrieval_characteristic_type.h) that you want to look for
Returns
Index of position of characteristic type in the array of characteristics. If the characteristic is not present it will return -1

◆ grasp_parameters_initialize()

void grasp_parameters_initialize ( float  iguess[_KIMAGE][_KPARS])

Initialize a matrix structure of parameters.

Parameters
iguessMatrix of parameters

This function will set -999 for all values of iguess matrix. This function is useful for working with input parameters (initial guess) because if you don't want to define initial guess for each pixel you have to set everything to -999. Then, you can replace (overwrite) the positions that you want to change if you want to specify a specific initial guess for each pixel.

◆ grasp_parameters_number_of_elements_of_parameter()

int grasp_parameters_number_of_elements_of_parameter ( par_number_NDIM dimensions,
int  characteristic_type,
int  mode 
)

Return number of elements of specific mode (mode starts in 1 like in setting file) of a characteristic.

Parameters
dimensionsNDIM block from settings
characteristic_typeCharacteristic index (base on grasp_retrieval_characteristic_type.h) where the value will be set
modeMode which will be set (starting in 1 like in yml settings file)
Returns

◆ grasp_parameters_number_of_modes_of_parameter()

int grasp_parameters_number_of_modes_of_parameter ( par_number_NDIM dimensions,
int  characteristic_type 
)

This function return number of modes of specific parameter

Parameters
dimensionsNDIM block from settings
characteristic_typeNumber of the characteristic (grasp_retrieval_characteristic_type.h) that you want to look for
Returns
It has to return a number bigger than 0 because when a characteristic type is defined at least has to be one mode. If characteristic type is not defined it will return -1

◆ grasp_parameters_output_get_value()

float grasp_parameters_output_get_value ( par_number_NDIM dimensions,
const float  parameters[_KPARS],
int  characteristic_type,
int  mode,
int  pos 
)

This function return a output value of a specific characteristic from an array of output parameters

Parameters
dimensionsNDIM block from settings
parametersArray of output parameters
characteristic_typeCharacteristic index (base on grasp_retrieval_characteristic_type.h) where the value will be set
modeMode which will be set (starting in 1 like in yml settings file)
posIndex of the value inside the characteristic and mode which will be set (starting in 0 like C array)
Returns
Value from output requested. -1 if Characteristic type does not exist and -2 if characteristic exist but it does not have specific mode

◆ grasp_parameters_set_value()

int grasp_parameters_set_value ( par_number_NDIM dimensions,
float  iguess[_KPARS],
int  characteristic_type,
int  mode,
int  pos,
float  value 
)

Set in initial guess array a value.

Parameters
dimensionsDefinition of initial guess (NDIM Block)
iguessInitial guess values array of the pixel
characteristic_typeCharacteristic index (base on grasp_retrieval_characteristic_type.h) where the value will be set
modeMode which will be set (starting in 1 like in yml settings file)
posIndex of the value inside the characteristic and mode which will be set (starting in 0 like C array)
valueValue to be set
Returns
index set if the value is well set, -1 if value can not be set because is not strictly positive or -2 if index obtained is outside the valid range [0,_KPARS)