vipr_reflectometry.reflectorch.preprocess package

Submodules

vipr_reflectometry.reflectorch.preprocess.error_bar_filter module

Error bar filtering for experimental reflectometry data.

This module provides filtering based on relative uncertainties to remove or truncate data points with high errors before model inference.

class vipr_reflectometry.reflectorch.preprocess.error_bar_filter.ErrorBarFilter(app: VIPR)

Bases: object

Filter experimental data based on error bars using Reflectorch’s filtering logic.

This filter removes or truncates data points with high relative errors (dR/R) before interpolation, matching the behavior of Reflectorch’s preprocess_and_predict.

preprocess_error_bar_filter(data: DataSet, **kwargs) DataSet

Filter experimental data based on error bars.

Runs with weight=-10 to execute BEFORE interpolation (weight=0).

Parameters:
  • data – DataSet with experimental data

  • **kwargs – Filter parameters

Returns:

Filtered DataSet

class vipr_reflectometry.reflectorch.preprocess.error_bar_filter.ErrorBarFilterParams(*, filter_threshold: float = 0.3, filter_remove_singles: bool = True, filter_remove_consecutives: bool = True, filter_consecutive: int = 3, filter_q_start_trunc: float = 0.1)

Bases: BaseModel

Configuration for error-bar filtering.

filter_consecutive: int
filter_q_start_trunc: float
filter_remove_consecutives: bool
filter_remove_singles: bool
filter_threshold: float
model_config: ClassVar[ConfigDict] = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

vipr_reflectometry.reflectorch.preprocess.error_bar_filter.get_filtering_mask(Q, R, dR, threshold=0.3, consecutive=3, remove_singles=True, remove_consecutives=True, q_start_trunc=0.1)

vipr_reflectometry.reflectorch.preprocess.interpolation_filter module

Interpolation filter for Reflectorch models.

This module provides interpolation of experimental data to the model’s Q-grid, handling both cases with and without pointwise Q-resolution.

class vipr_reflectometry.reflectorch.preprocess.interpolation_filter.InterpolationFilter(app: VIPR)

Bases: object

Interpolate experimental data to the model’s Q-grid.

This filter uses Reflectorch’s interpolation functionality to map experimental data onto the Q-points expected by the model.

preprocess_interpolate(data: DataSet, **kwargs) DataSet

Row-by-row DataSet preprocessing filter for reflectorch interpolation.

Handles both cases: with and without pointwise q-resolution (dx values).

Parameters:
  • data – DataSet with experimental data

  • **kwargs – Additional parameters (expects ‘model’)

Returns:

DataSet with data interpolated to model Q-grid

Module contents

Preprocessing filters for Reflectorch.

This package contains preprocessing filters that prepare experimental data for Reflectorch model inference.

class vipr_reflectometry.reflectorch.preprocess.ErrorBarFilter(app: VIPR)

Bases: object

Filter experimental data based on error bars using Reflectorch’s filtering logic.

This filter removes or truncates data points with high relative errors (dR/R) before interpolation, matching the behavior of Reflectorch’s preprocess_and_predict.

preprocess_error_bar_filter(data: DataSet, **kwargs) DataSet

Filter experimental data based on error bars.

Runs with weight=-10 to execute BEFORE interpolation (weight=0).

Parameters:
  • data – DataSet with experimental data

  • **kwargs – Filter parameters

Returns:

Filtered DataSet

class vipr_reflectometry.reflectorch.preprocess.InterpolationFilter(app: VIPR)

Bases: object

Interpolate experimental data to the model’s Q-grid.

This filter uses Reflectorch’s interpolation functionality to map experimental data onto the Q-points expected by the model.

preprocess_interpolate(data: DataSet, **kwargs) DataSet

Row-by-row DataSet preprocessing filter for reflectorch interpolation.

Handles both cases: with and without pointwise q-resolution (dx values).

Parameters:
  • data – DataSet with experimental data

  • **kwargs – Additional parameters (expects ‘model’)

Returns:

DataSet with data interpolated to model Q-grid