WindowSampler

WindowSampler#

class WindowSampler#

Bases: SamplerModel

__init__(rv_step, rv_window, fixed_window=True)#
generate_prior_of_model(dataClassProxy)#
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]

optimize_epochwise(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]

compute_epochwise_combination(outputs)#

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

Parameters:

outputs

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

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

classmethod config_help()#

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

classmethod control_parameters()#
disable_memory_savings()#
property disk_save_enabled: bool#

True if there is any sort of disk savings active.

Return type:

bool

property disk_save_level: DISK_SAVE_MODE#

Return the current disk save level for this object.

Return type:

DISK_SAVE_MODE

enable_memory_savings(nobs)#
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_root_path(storage_path, no_logs=True)#
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

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)#
update_disk_saving_level(level)#

Update the work level of the current object.

Return type:

None

update_work_mode_level(level)#

Update the disk save level.

Return type:

None

property work_mode: WORKING_MODE#

Return the current working mode for this object.

Return type:

WORKING_MODE