chi_squared_sampler

chi_squared_sampler#

class chi_squared_sampler#

Bases: SamplerModel

The Chi-squared sampler implements a bounded minimization of a chi-squared curve.

This metric is defined in the RV_step worker. After finding the optimal value, fit a parabola to estimate the true minimum value and the RV that would be associated with it. It also uses the curvature of the chi squared curve to estimate the RV uncertainty.

__init__(rv_step, rv_prior, user_configs=None)#
Parameters:
  • rv_step (RV_measurement) – Step to use when computing the numerical derivatives of the metric function (for the parabolic fit)

  • rv_prior – Specifies the “effective” RV window that the sampler can use. More details in here.

optimize_orderwise(target, target_kwargs)#

Compute the RV for an entire order, followed by a parabolic fit to estimate uncertainty and better adjust chosen RV

Parameters:
  • target ([type]) – [description]

  • target_kwargs ([type]) –

    Input arguments of the target function. Must contain the following:
    • dataClassProxy,

    • frameID

    • order

Returns:

[description]

Return type:

[type]

property N_model_params: int#

returns: Number of free-parameters that are currently enabled in our model :rtype: number_params

property RV_keyword: str#
Return type:

str

add_extra_param(parameter)#
add_relative_path(path_name, relative_structure)#
add_to_status(new_flag)#
Return type:

NoReturn

apply_epochwise(optimizer_estimate, config_dict)#

Application of the model’s parameters to all spectral orders at the same time. The children classes must implement this on their own, as the application stratagies will end up being different for each

Parameters:
  • config_dict – Dictionary that will be passed to the target function

  • model_parameters – List with the model parameters in the correct order

apply_orderwise(optimizer_estimate, target, target_kwargs)#

Minimize the target function for the data of a single order. As the models might have multiple free-parameters, we ensure that the target always receives a list of elements.

Parameters:
  • optimizer_estimate (Union[float, list]) – Value at which the target function will be evaluated.

  • target (func) – Target function, which will be one the worker of the selected RV routine

  • target_kwargs ([type]) –

    Input arguments of the target function. Must contain the following:
    • dataClassProxy,

    • frameID

    • order

Returns:

Evaluation of

Return type:

func_output

compute_epochwise_combination(outputs)#

Each children class must implement this to combine the order-wise metrics into a “global” value for the optimization process :param outputs:

classmethod config_help()#

Prints a message to terminal, showing all possible configurations and their constraints

classmethod control_parameters()#
disable_disk_savings()#
Return type:

NoReturn

disable_memory_savings()#
enable_disk_savings()#

Save, as much as possible, disk space when saving the worker outputs. Each target function will decide on the details of such “savings”

Return type:

NoReturn

enable_memory_savings()#
enable_param(param_name)#

External activation of the parameters of the model

Parameters:
  • param_name (str) – One of the available parameters

  • bounds – Bounds for the parameter

  • guess – Initial guess for the parameter

Return type:

NoReturn

generate_prior_of_model(dataClassProxy)#
generate_root_path(storage_path, no_logs=True)#
Return type:

NoReturn

is_object_type(type_to_check)#

Check if this object is of a given type

Parameters:

type_to_check (str) –

Return type:

bool

is_sampler(sampler_type)#

Check if the sampler is of a given type

Parameters:

sampler_type (str) –

Return type:

bool

property is_valid: bool#
Return type:

bool

json_ready()#

Concerts the current class into a json entry that can be easily saved/loaded to/from disk

Return type:

Dict[str, Any]

load_from_file(root_path, loading_path)#
Return type:

None

lock_model_param(param_name)#
Return type:

NoReturn

manage_RV_calculation(dataClass, subInst, valid_orders, target_specific_configs, target_function, package_queue, output_pool)#

” This function has the goal of dispatching/managing the handling of the spectral data. Depending on the “mode”, it will either launch the order- or epoch-wise managers. Those managers control the data that is currently in memory, the “work packages” that are available to the pool of workers and the communication between the main “process” and the workers.

There is no “base” implementation of the epoch-wise manager, but there is base implementation of the order-wise manager:

  • Sequential iteration over all frames. For each frame:

    • Trigger the opening of the S2D arrays

    • Populate the package_queue with “work packages” for all valid orders

    • Wait for the responses

    • If the memory saving mode is enabled, close the S2D arrays

Parameters:
  • dataClass

  • subInst (str) – subInst for which we want to compute RVs

  • valid_orders (tuple) – List of the valid orders for the RV calculation

  • target_specific_configs (dict) –

  • target_function

  • package_queue – Communication queue between the main core (this one) and the workers

  • output_pool – Communication queue on which the workers place their outputs

Returns:

List of products that was collected from the workers TODO: confirm/update this type hint

Return type:

worker_products

Raises:

InvalidConfiguration – If there are no valid orders for the calculation of RVs

property name: str#
Return type:

str

process_epochwise_metrics(outputs)#

Each children class must implement this, as it will be used to parse the outputs when the optimal RV is provided to the target!

Parameters:

outputs

set_mode(mode)#

Set the sampler to one of its two working modes:

  • order-wise

  • epoch-wise

Parameters:

mode (str) – The mode for the sampler

Raises:

InvalidConfiguration – If the mode is not one of the valid options

Return type:

None

property storage_name: str#
Return type:

str

store_shared_buffer(buffer)#
Return type:

None

trigger_data_storage(*args, **kwargs)#
Return type:

NoReturn