zooc.run.model_z_offset

Z-offset model based on measurements.

class zooc.run.model_z_offset.ModelZOffset

Bases: ABC

Base class for the Z-offset model based on measurements.

static log_data(filter_model)

Convert to TOML formatted string.

Format:

z_samples=[[x0,y0],
           [x1,y1],
           [...]]
Parameters:

filter_model (FilterMath | None) – Filter model.

Returns:

Input data in TOML format.

Return type:

str

calc_offset(sample, max_delta)

Calculate the final Z-offset based on the previous and the latest measurements.

Parameters:
  • sample (tuple[float, float]) – Z-offset measurement.

  • max_delta (float) – Maximum allowed deviation between successful forecasted value.

Returns:

True if valid measurement was acquired.

Return type:

bool

abstractmethod create_filter(data)

Create a filter model based on the collected data.

Parameters:

data (dict[float, float]) – <time>: <value> dictionary.

Returns:

Filter model if converged, None if not converged.

Return type:

FilterMath

describe()

Describe the internal state of the model.

Returns:

Dictionary with the model state.

Return type:

dict[str, object]

dict_time_z: dict[float, float]

Time and Z-offset data points.

filter_model: FilterMath | None = None

Filter model based on the latest valid measurement.

t_0: float | None = None

1st sample time.

z_prev: float | None = None

Latest valid Z-offset value [mm].

class zooc.run.model_z_offset.ModelZOffsetExp(*, require_success=2, tau_min_th=30.0, tau_max_th=600.0, noise_rel_range_th=0.02, noise_abs_range_th=0.01)

Bases: ModelZOffset

Modeling the settling of Z-offset due to heat expansion over time.

The model provides the estimated Z-offset value based on the data collected.

Parameters:
  • require_success (int) – How many consecutive measurements should yield valid offset.

  • tau_min_th (float) – Minimum time constant for the exp filter. Time constant should be reasonable, at least some seconds [s].

  • tau_max_th (float) – Maximum time constant for the exp filter. Large printers may have time constant of many minutes [s].

  • noise_rel_range_th (float) – Allowed relative noise range for the monotonicity. Allow 2% full range noise (or noise_abs_range_th which ever is larger) [%].

  • noise_abs_range_th (float) – Allowed absolute noise range for the monotonicity.

static log_data(filter_model)

Convert to TOML formatted string.

Format:

z_samples=[[x0,y0],
           [x1,y1],
           [...]]
Parameters:

filter_model (FilterMath | None) – Filter model.

Returns:

Input data in TOML format.

Return type:

str

calc_offset(sample, max_delta)

Calculate the final Z-offset based on the previous and the latest measurements.

Parameters:
  • sample (tuple[float, float]) – Z-offset measurement.

  • max_delta (float) – Maximum allowed deviation between successful forecasted value.

Returns:

True if valid measurement was acquired.

Return type:

bool

create_filter(data)

Create a filter model based on the collected data.

Parameters:

data (dict[float, float]) – <time>: <value> dictionary.

Returns:

Filter model if converged, None if not converged.

Return type:

FilterExpDecayZ

describe()

Describe the internal state of the model.

Returns:

Dictionary with the model state.

Return type:

dict[str, object]

dict_time_z: dict[float, float]

Time and Z-offset data points.

filter_model: FilterMath | None = None

Filter model based on the latest valid measurement.

success: int = 0

Consecutive, valid measurement counter

t_0: float | None = None

1st sample time.

z_prev: float | None = None

Latest valid Z-offset value [mm].

class zooc.run.model_z_offset.ModelZOffsetStable(*, t_end, t_forecast, mean_samples=7, max_abs_input_range=0.1)

Bases: ModelZOffset

Z-offset model for stable state where the offset is not changing.

Parameters:
  • t_end (float) – Time to stop the estimation [s].

  • t_forecast (float) – Time in the future to forecast the Z-offset starting from the last sample [s].

  • mean_samples (int) – Number of samples used for the measurement.

  • max_abs_input_range (float) – Allowed absolute noise threshold over the input range.

static log_data(filter_model)

Convert to TOML formatted string.

Format:

z_samples=[[x0,y0],
           [x1,y1],
           [...]]
Parameters:

filter_model (FilterMath | None) – Filter model.

Returns:

Input data in TOML format.

Return type:

str

calc_offset(sample, max_delta)

Calculate the final Z-offset based on the previous and the latest measurements.

Parameters:
  • sample (tuple[float, float]) – Z-offset measurement.

  • max_delta (float) – Maximum allowed deviation between successful forecasted value.

Returns:

True if valid measurement was acquired.

Return type:

bool

create_filter(data)

Create a filter model based on the collected data.

Parameters:

data (dict[float, float]) – <time>: <value> dictionary.

Returns:

Filter model if converged, None if not converged.

Return type:

FilterStable

describe()

Describe the internal state of the model.

Returns:

Dictionary with the model state.

Return type:

dict[str, object]

completed: bool = False

When no more data is needed.

dict_time_z: dict[float, float]

Time and Z-offset data points.

filter_model: FilterMath | None = None

Filter model based on the latest valid measurement.

t_0: float | None = None

1st sample time.

z_prev: float | None = None

Latest valid Z-offset value [mm].