revanalyzer.metrics.cf.BasicCFMetric
- class revanalyzer.metrics.cf.BasicCFMetric(vectorizer, n_threads, show_time, normalize)
Bases:
BasicMetric
Base class of CF-based metrics. (Don’t use it directly but derive from it).
Input:
vectorizer (CFVectorizer): vectorizer to be used for CF metric;
n_threads (int): number of threads used for data generation;
show_time (bool): flag to monitor time cost for large images;
normalize (bool): flag to control normalization of CF. If True, CF are normalized to satisfy the condition CF(0) = 1. See the details in Karsanina et al. (2021). Compressing soil structural information into parameterized correlation functions. European Journal of Soil Science, 72(2), 561-577.
Methods
Generates CF metric for a specific subsample.
Read the metric data generated for a specific subsample.
Vizualize CF for a specific subsample.
Vectorize the vector metric values for a given pair of subsamples.
- generate(cut, cut_name, outputdir, method, gendatadir=None)
Generates CF metric for a specific subsample.
Input:
cut (numpy.ndarray): 3D array representing a subsample;
cut_name (str): name of subsample;
outputdir (str): output folder;
method (str): method for generation of cpecific CF. Different in differenent CF-based metrics.
- read(inputdir, step, cut_id)
Read the metric data generated for a specific subsample.
Input:
inputdir (str): path to the folder containing image;
step (int): subsamples selection step;
cut_id (int: 0,..8): cut index.
Output:
metric value (float or np.array(dtype=’float’)).
- show(inputdir, step, cut_id, title, cf_type)
Vizualize CF for a specific subsample.
Input:
inputdir (str): path to the folder containing generated metric data for subsamples;
step (int): subsamples selection step;
cut_id (int: 0,..8): cut index;
title (str): image title;
cf_type (str): type of CF (directional or probability density).
- vectorize(v1, v2)
Vectorize the vector metric values for a given pair of subsamples.
Input:
v1 (list(dtype = float)): data for the first subsample;
v2 (list(dtype = float)): data for the second subsample;
Output:
Depends on the chosen mode in CFVectorizer.
If mode = ‘all’:
(list(dtype = float), list(dtype = float), float) - a tuple, in which the first two elements are vectorized metric values for a given pair of subsamples, and the last one is the normalized distance between these vectors.
If mode = ‘max:
(list(list(dtype = float)), list(list(dtype = float)), list(float)) - a tuple, in which in which the first two elements are vectorized metric values in ‘x’, ‘y’ and ‘z’ directions for a given pair of subsamples, and the last one is a list of normalized distances between these vectors.