#ifndef _H_I3_MODEL #define _H_I3_MODEL #include "i3_image.h" #include "i3_global.h" #include "i3_data_set.h" #include #include "models/i3_sersics.h" #include "models/i3_logsersics.h" #include "models/i3_quadratic_test.h" #include "models/i3_multisersics.h" #include "models/i3_multixray.h" #include "i3_options.h" #include "i3_math.h" #ifdef I3_USE_DOUBLE #define i3_options_parse_flt_array i3_options_parse_double_array #else #define i3_options_parse_flt_array i3_options_parse_float_array #endif #ifdef _H_I3_SERSICS #define NO_SERSICS 0 #else #define NO_SERSICS 1 #endif #ifdef _H_I3_LOGSERSICS #define NO_LOGSERSICS 0 #else #define NO_LOGSERSICS 1 #endif typedef i3_flt (*likelihood_function)(i3_image*,i3_parameter_set*,i3_data_set*); typedef i3_flt (*prior_function)(i3_parameter_set *); typedef i3_parameter_set* (*proposal_function)(i3_mcmc_ptr,i3_parameter_set*,i3_parameter_set*); typedef void (*print_function)(i3_parameter_set*,char*,int) ; typedef void (*derivative_function)(i3_image*,i3_flt,i3_data_set*,i3_parameter_set*,i3_parameter_set*); typedef void (*start_position_function)(i3_parameter_set * start, i3_data_set * data_set, i3_options * options); typedef void (*map_physical_function)(i3_parameter_set * input, i3_parameter_set * output, i3_options * options); typedef enum {i3_parameter_type_flt, i3_parameter_type_int, i3_parameter_type_bool, i3_parameter_type_array} i3_parameter_type; /* * A structure representing the model being fit to the image. * This is generated by looking up the model name to determine the * number and type of parameters, and then getting the ranges of them too. * The model is generated from an i3_options struct. */ typedef struct i3_model{ char name[i3_max_string_length]; int nparam; bool * param_fixed; likelihood_function likelihood; prior_function prior; derivative_function posterior_derivative; proposal_function propose; start_position_function start; map_physical_function map_physical; int nbytes; // i3_prior_type * param_prior_types; i3_parameter_type * param_type; int * byte_offsets; void ** param_prior; void ** param_proposal; i3_parameter_set * min; i3_parameter_set * max; } i3_model; int i3_model_number_varied_params_nonzero_width(i3_model * model, i3_parameter_set * width); int i3_model_number_varied_params(i3_model * model); i3_model * i3_model_create(char * name, i3_options * options); void i3_model_destroy(i3_model * model); void i3_model_copy_parameters(i3_model * model, i3_parameter_set * dest, i3_parameter_set * source); void i3_model_pretty_fprintf_parameters(i3_model * model, FILE * f, i3_parameter_set * p); void i3_model_fprintf_parameters(i3_model * model, FILE * f, i3_parameter_set * p); void i3_model_pretty_printf_parameters(i3_model * model, i3_parameter_set * p); void i3_model_printf_parameters(i3_model * model, i3_parameter_set * p); i3_parameter_set * i3_model_option_widths(i3_model * model, i3_options * options); void i3_model_option_fixes(i3_model * model, i3_options * options); i3_parameter_set * i3_model_option_starts(i3_model * mode, i3_options * options); void i3_model_map_physical(i3_model * model, i3_parameter_set * input, i3_parameter_set * output, i3_options * options); int i3_model_parameter_string(i3_model * model, i3_parameter_set * p, char * parameter_string, int string_length); int i3_model_parameter_pretty_string(i3_model * model, i3_parameter_set * p, char * parameter_string, int string_length); i3_parameter_set * i3_model_option_min(i3_model * model, i3_options * options); i3_parameter_set * i3_model_option_max(i3_model * model, i3_options * options); i3_parameter_set * i3_model_option_range(i3_model * model, i3_options * options); i3_flt i3_model_posterior(i3_model * model,i3_image * image, i3_parameter_set * p, i3_data_set * data); i3_flt i3_model_likelihood(i3_model * model,i3_image * image, i3_parameter_set * p, i3_data_set * data); i3_flt i3_model_prior(i3_model * model, i3_parameter_set * p); i3_flt i3_model_prior_limits(i3_model * model, i3_parameter_set * p); bool i3_model_prior_violations(i3_model * model, i3_parameter_set * p, FILE * output); void i3_model_starting_position(i3_model * model, i3_parameter_set * p, i3_data_set * data_set, i3_options * options); void i3_model_extract_ellipticity(i3_model * mode, i3_parameter_set * parameter_set, i3_flt * e1, i3_flt * e2); void i3_model_get_image_into(i3_model * model, i3_parameter_set * params, i3_data_set * dataset,i3_image * image); void i3_model_read_params_from_str_into(i3_model * model, char *parameter_strings[], i3_parameter_set * params); void i3_model_perturb(i3_model * model, i3_parameter_set * p, i3_flt scale); void i3_model_scale_parameters(i3_model * model, i3_parameter_set * p, i3_flt scale); const char * i3_model_header_line(i3_model * model); void i3_model_posterior_derivative_approximation(i3_model * model, i3_parameter_set * p, i3_image * model_image, i3_data_set * data_set, i3_parameter_set * pprime, i3_flt * like, i3_flt epsilon); bool i3_model_any_nan(i3_model * model, i3_parameter_set * p); void i3_model_extract_varied_parameters(i3_model * model, i3_parameter_set * x, i3_flt * output); void i3_model_input_varied_parameters(i3_model * model, i3_flt * input, i3_parameter_set * x, i3_parameter_set * base_x); void i3_model_extract_varied_nonzero_width_parameters(i3_model * model, i3_parameter_set * x, i3_parameter_set * width, i3_flt * output); void i3_model_input_varied_nonzero_width_parameters(i3_model * model, i3_flt * input, i3_parameter_set * x, i3_parameter_set * width, i3_parameter_set * base_x); int i3_model_set_parameter_by_name(i3_model * model, i3_parameter_set * p, char * name, double value); #endif