swectral.create_example_spec_exp#

swectral.create_example_spec_exp(dir_path, sample_n=10, n_bands=4, is_regression=True, use_val_group=False)#

Create a standard test SpecExp instance for spectral experiments.

This function generates a SpecExp data manager pre-populated with: :rtype: SpecExp

  • A test group.

  • A synthetic multispectral image.

  • Synthetic ROIs.

  • Synthetic sample labels and targets.

It can be used for testing spectral processing pipelines, demonstration or development.

Parameters:
dir_pathstr

Directory where the test data (images and ROI XML) will be stored. Will be created if it does not exist.

sample_nint, optional

Number of samples / ROIs to generate. Default is 10.

n_bandsint, optional

Number of bands in the synthetic image. Default is 4.

is_regressionbool, optional

If True, target values are numeric (regression). If False, targets are categorical (classification). Default is True.

use_val_groupbool, optional

Whether validation group is enabled. Default is False.

Returns:
SpecExp

A SpecExp instance populated with synthetic data, ready for spectral analysis.

Notes

  • The synthetic image is a pseudo-random gradient with band-specific variations.

  • ROIs are rectangular and evenly distributed across the raster height.

  • Sample labels and target values are automatically generated based on sample_n.

Examples

Create a default test SpecExp instance:

>>> exp = create_test_spec_exp("test_spec_exp")

Create a test instance with 20 samples and 6 spectral bands:

>>> exp = create_test_spec_exp("test_spec_exp_dir", sample_n=20, n_bands=6)

Create a classification-type SpecExp instance:

>>> exp = create_test_spec_exp("class_spec_exp", is_regression=False)