yaw.config.ResamplingConfig#
- class yaw.config.ResamplingConfig(method: str = 'jackknife', crosspatch: bool = True, n_boot: int = 500, global_norm: bool = False, seed: int = 12345)[source]#
Bases:
BaseConfigConfiguration for error estimation from spatial resampling.
Used for all functions and methods that use spatial patches for error estimation. Use the
get_samples()method to generate samples from the spatial patches, which can be reused to ensure consistent error estimates for different data products that use the same patches.- Parameters:
method (
str) – Resampling method to use, seemethod.crosspath (
str) – Whether to use cross-patch pair count measurements.n_boot (
int) – Number of samples to generate for thebootstrapmethod.global_norm (
bool) – Whether to normalise paircounts globally or for each sample. Usually not recommended.seed (
int) – Random seed to use.
Methods
__init__([method, crosspatch, n_boot, ...])create(**kwargs)Create a new configuration object.
from_dict(the_dict, **kwargs)Create a class instance from a dictionary representation of the minimally required data.
get_samples(n_patches)Generate a list of patch indices that produces samples for the selected resampling method.
modify([method, crosspatch, n_boot, ...])Create a copy of the current configuration with updated parameter values.
reset()Reset the internally stored patch indices generated by
get_samples().to_dict()Serialise the class instance to a dictionary containing a minimal set of required data.
Attributes
Whether to use cross-patch pair count measurements.
Whether to normalise paircounts globally or for each sample.
Resampling method to use, see
method.Number of samples to generate for the
bootstrapmethod.The number of spatial patches for which this configuratin is valid.
Random seed to use.
- classmethod create(**kwargs: Any) T#
Create a new configuration object.
By default this is an alias for
__init__(). Configuration classes that are hierarchical (i.e. contain configuration objects as attributes) implement this method to provide a single constructer for its own and its subclasses parameters.
- crosspatch: bool = True#
Whether to use cross-patch pair count measurements.
- classmethod from_dict(the_dict: dict[str, Any], **kwargs: dict[str, Any]) T#
Create a class instance from a dictionary representation of the minimally required data.
- Parameters:
the_dict (
dict) – Dictionary containing the data.**kwargs – Additional data needed to construct the class instance.
- get_samples(n_patches: int) NDArray[np.int64][source]#
Generate a list of patch indices that produces samples for the selected resampling method.
- Parameters:
n_patches (
int) – Total number of patches for which the samples are generated.
Note
Samples are generated only once for each instance. Later calls to this method will only check if the number of patches agree with the first call and return the initially generated index list. Raises a
ValueErrorotherwise.The reason is, that the
bootstrapmethod produces random samples, which must be consistent if the resampling is applied to different pair count measurements.
- global_norm: bool = False#
Whether to normalise paircounts globally or for each sample.
- modify(method: str = NotSet, crosspatch: bool = NotSet, n_boot: int = NotSet, global_norm: bool = NotSet, seed: int = NotSet) ResamplingConfig[source]#
Create a copy of the current configuration with updated parameter values.
The method arguments are identical to
create(). Values that should not be modified are by default represented by the special valueNotSet.
- n_boot: int = 500#
Number of samples to generate for the
bootstrapmethod.
- property n_patches: int | None#
The number of spatial patches for which this configuratin is valid.
Available only after generating samples with
get_samples().- Returns:
int if samples have been generated, else None.
- reset() None[source]#
Reset the internally stored patch indices generated by
get_samples().
- seed: int = 12345#
Random seed to use.