Skip to content

Commit 97590e8

Browse files
M3nin0OldLipe
andcommitted
docs: review documentation using dragoman
Co-authored-by: Felipe Carvalho <lipecaso@gmail.com>
1 parent 74e5ae2 commit 97590e8

91 files changed

Lines changed: 1205 additions & 1020 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

pysits/docs/content/impute_linear.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ Replace NA values by linear interpolation
33
Remove NA by linear interpolation
44

55
Args:
6-
data (list | pandas.DataFrame): A time series vector or matrix.
6+
data (list): A time series vector or matrix.
77

88
Returns:
99
R: A set of filtered time series using the imputation function.
10+

pysits/docs/content/impute_mean.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Remove NA using mean
33
Remove NA using mean
44

55
Args:
6-
data (list[float] | pandas.DataFrame): A time series or matrix.
6+
data (list[float] | SITSMatrix): A time series vector or matrix.
77

88
Returns:
99
R: A set of filtered time series using the imputation function.

pysits/docs/content/impute_mean_window.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ Remove NA using weighted moving average
33
Remove NA using weighted moving average
44

55
Args:
6-
data (list): A time series vector or matrix.
6+
data (list[float]): A time series vector or matrix.
77
k (int): Width of the moving average window. Expands to both sides
88
of the center element e.g. k = 2 means 4 observations (2 left,
99
2 right) are taken into account. If all observations in the
1010
current window are NA, the window size is automatically
1111
increased until there are at least 2 non-NA values present.
12-
weighting (str): The weighting strategy to be used. More details
13-
below (default is "simple").
12+
weighting (str): Weighting strategy to be used. More details below
13+
(default is "simple").
1414

1515
Returns:
1616
R: A set of filtered time series using the imputation function.

pysits/docs/content/impute_median.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Remove NA using median
33
Remove NA using median
44

55
Args:
6-
data (list[float] | SITSMatrix): A time series vector or matrix.
6+
data (list | SITSMatrix): A time series vector or matrix.
77

88
Returns:
99
R: A set of filtered time series using the imputation function.

pysits/docs/content/plot.md

Lines changed: 95 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,112 +1,117 @@
11
Plot sits objects.
22

3-
Unified plotting function that dispatches on the type of the object passed
4-
as `x`. It mirrors the many `plot` methods of the R `sits` package,
5-
covering data cubes (raster, SAR, DEM, vector, RGB), probability and
6-
uncertainty cubes, variance cubes, classified images, time series patterns
7-
and predictions, machine learning / deep learning models, clustering and
8-
self-organizing map (SOM) results, accuracy tables, and t-SNE / embedding
9-
visualizations. The set of accepted keyword arguments depends on the type
10-
of object being plotted.
3+
A single dispatching function that produces a plot appropriate to the type
4+
of the object passed as `x`. It covers data cubes (raster, SAR, DEM,
5+
vector), probability and uncertainty products, variance cubes, patterns,
6+
time-series predictions, embeddings, clustering and SOM outputs, accuracy
7+
tables, and trained models. Depending on the object type, the plot is
8+
rendered as a map, a chart, or a raster image.
9+
10+
The accepted keyword arguments depend on the type of `x`. The sections
11+
below group the parameters by the kind of object being plotted.
1112

1213
Args:
13-
x (SITSCubeModel | SITSTimeSeriesModel | SITSTimeSeriesPatternsModel | SITSMachineLearningMethod | SITSConfusionMatrix): Object to be
14-
plotted. Supported objects include classified raster images,
15-
classified segments, digital elevation model cubes, multi-year
16-
land use/cover embedding predictions, sample distances, class
17-
temporal patterns, probability cubes, raster, SAR, and vector
18-
data cubes, confusion matrices / accuracy metrics, dendrograms,
19-
trained models, time series predictions, t-SNE projections, SOM
20-
results, uncertainty cubes, and variance cubes.
14+
x (SITSCubeModel | SITSTimeSeriesModel | SITSTimeSeriesPatternsModel | SITSMachineLearningMethod | SITSConfusionMatrix):
15+
Object to be plotted. Supported kinds include raster, SAR, DEM,
16+
and vector cubes; classified, probability, uncertainty, and
17+
variance cubes; patterns; time-series and embedding predictions;
18+
geographic distances; clustering and SOM outputs; accuracy
19+
tables; t-SNE projections; and trained models.
2120
y: Ignored. Present for compatibility with the generic `plot`.
22-
band (str): Band used for plotting a single-band (grey scale) image.
23-
Applies to raster, SAR, DEM, and vector cubes, and to SOM maps.
24-
red (str): Band assigned to the red channel of an RGB composite
25-
(raster, SAR, and vector cubes).
26-
green (str): Band assigned to the green channel of an RGB composite.
27-
blue (str): Band assigned to the blue channel of an RGB composite.
28-
tile (str): Tile to be plotted (data cubes, probability, uncertainty,
29-
and variance cubes).
21+
band (str): For raster, SAR, DEM, and vector cubes, the band used to
22+
plot a grey (B/W) image. For SOM maps, the band to be plotted.
23+
red (str): Band assigned to the red channel for RGB plots of raster,
24+
SAR, and vector cubes.
25+
green (str): Band assigned to the green channel for RGB plots.
26+
blue (str): Band assigned to the blue channel for RGB plots.
27+
tile (str): Tile to be plotted (for cube objects).
3028
dates (list[str]): Dates to be plotted (raster, SAR, and vector
3129
cubes).
32-
roi (dict | geopandas.GeoDataFrame): Spatial extent (region of
33-
interest) to plot, in WGS 84.
34-
labels (list[str]): Labels to plot (probability and variance cubes).
35-
bands (list[str]): Bands to be viewed (patterns and time series
36-
predictions).
37-
legend (dict): Associates labels to colors, or a legend specification
38-
for SOM plots.
39-
legend_position (str): Where to place the legend (typically "inside"
40-
or "outside", with defaults varying by plot type).
41-
legend_title (str): Title of the legend (probability and variance
30+
roi (dict): Spatial extent (region of interest) to plot, in WGS 84.
31+
See notes.
32+
labels (list[str]): Labels to plot (probability, variance, and vector
4233
cubes).
43-
palette (str): An RColorBrewer or "cols4all" (or HCL) palette used
44-
for color mapping.
34+
bands (list[str]): Bands to be viewed (for patterns and time-series
35+
predictions).
36+
legend (dict): Maps labels to colors (class cubes, SOM maps, and
37+
cluster confusion plots).
38+
legend_position (str): Where to place the legend. Typical default is
39+
`"inside"` for RGB/grey plots and `"outside"` for classified and
40+
probability maps.
41+
legend_title (str): Title of the legend for probability and variance
42+
cubes (for example `"probs"` or `"logvar"`).
43+
palette (str): An `RColorBrewer` or `cols4all` palette. For
44+
chart-based plots (predictions, embeddings, clusters, t-SNE), an
45+
HCL palette name.
4546
rev (bool): Whether to reverse the color order in the palette.
46-
scale (float): Relative scale of plot text and map (typically 0.4 to
47-
1.0).
47+
scale (float): Relative scale (roughly 0.4 to 1.0) of the plot text
48+
and map.
4849
quantile (float): Minimum quantile to plot (probability and variance
4950
cubes).
50-
first_quantile (float): First quantile for stretching images.
51-
last_quantile (float): Last quantile for stretching images.
51+
first_quantile (float): First quantile used for stretching images.
52+
last_quantile (float): Last quantile used for stretching images.
5253
max_cog_size (int): Maximum size of COG (Cloud Optimized GeoTIFF)
53-
overviews, in lines/columns or pixels.
54-
seg_color (str): Color used to draw segment boundaries (vector cubes).
55-
line_width (float): Line width used to draw segment boundaries
56-
(vector cubes).
57-
type (str): Type of plot; meaning depends on the object. For accuracy
58-
objects it is "confusion_matrix" or "metrics"; for variance cubes
59-
it is "map" or "hist"; for SOM maps it is "codes" or "mapping".
60-
cluster: Cluster object produced by `sits_cluster_dendro`, used when
61-
plotting a dendrogram.
62-
cutree_height (float): Height at which to draw a dashed horizontal
63-
line indicating where the dendrogram is cut.
64-
name_cluster (str): Cluster to plot (SOM cluster evaluation).
65-
title (str): Title of the plot (SOM cluster evaluation).
66-
year_grid (bool): Whether to plot patterns as a grid of panels with
67-
labels as columns and years as rows. Defaults to False.
68-
tree_idx (int): Index of the tree to be plotted for an XGBoost model.
69-
plot_embedding (str): For embedding predictions, either "none" (plot
70-
only predicted class intervals) or "area" (overlay a smoothed
71-
vertical embedding profile per year).
72-
stretch (tuple[float, float]): For embedding plots, lower/upper
73-
quantiles used to stretch embedding values before plotting.
74-
class_alpha (float): Transparency of class polygons in embedding plots
75-
(0-1).
76-
area_alpha (float): Transparency of the embedding area in embedding
77-
plots (0-1).
78-
area_width (float): Horizontal width fraction of the embedding area.
79-
area_spar (float): Smoothing parameter for the embedding area spline.
80-
**kwargs (dict): Further specifications passed to the underlying plot.
54+
overviews, in lines/columns (pixels).
55+
seg_color (str): Color used for segment borders in vector cubes.
56+
line_width (float): Line width used for segment borders in vector
57+
cubes.
58+
type (str): Type of plot. For accuracy objects, either
59+
`"confusion_matrix"` or `"metrics"`. For variance cubes, `"map"`
60+
or `"hist"`. For SOM maps, `"codes"` (neuron weight time series)
61+
or `"mapping"` (number of samples per neuron).
62+
year_grid (bool): For patterns, whether to plot a grid of panels
63+
using labels as columns and years as rows (default `False`).
64+
cluster: For clustering plots, the cluster object produced by
65+
`sits_cluster_dendro`.
66+
cutree_height (float): For clustering plots, the height at which to
67+
draw a dashed horizontal line indicating where the dendrogram is
68+
cut.
69+
name_cluster (str): For SOM cluster evaluation, the cluster to plot.
70+
title (str): For SOM cluster evaluation, the title of the plot.
71+
tree_idx (int): For XGBoost models, the index of the tree to be
72+
plotted.
73+
plot_embedding (str): For embedding predictions, either `"none"` (plot
74+
only the predicted class intervals) or `"area"` (overlay a
75+
smoothed vertical embedding profile per year).
76+
stretch (list[float]): For embedding predictions, the lower and upper
77+
quantiles used to stretch embedding values before plotting
78+
(default `[0.02, 0.98]`).
79+
class_alpha (float): For embedding predictions, transparency of the
80+
class polygons in `[0, 1]` (default `0.7`).
81+
area_alpha (float): For embedding predictions, transparency of the
82+
embedding area in `[0, 1]` (default `0.25`).
83+
area_width (float): For embedding predictions, the horizontal width
84+
fraction of the embedding area along the time axis.
85+
area_spar (float): For embedding predictions, the smoothing parameter
86+
passed to the spline fit (default `0.6`); higher values produce
87+
smoother profiles.
88+
**kwargs (dict): Further specifications for the plot. The keywords
89+
understood depend on the type of `x` (see below).
8190

8291
Returns:
83-
None: A plot is produced. Depending on the input type this may be a
84-
color map of classified pixels, an RGB or grey-scale image, a
85-
probability or uncertainty map, a variance map (optionally with
86-
segment overlays), a dendrogram, a confusion matrix, a SOM map, a
87-
model diagnostic plot, or a plot for patterns, predictions,
88-
embeddings, and t-SNE projections. Some methods are called only for
89-
their side effect of drawing the plot.
92+
None: A plot appropriate to the type of `x` is drawn. Maps of cubes
93+
yield color or B/W raster images (optionally overlaid with segment
94+
boundaries for vector cubes); probability, uncertainty, and
95+
variance cubes yield per-class or per-pixel maps; classified cubes
96+
yield color maps where each pixel is colored by its label.
97+
Chart-based plots (patterns, predictions, embeddings, clusters,
98+
t-SNE, model diagnostics) render the corresponding plot. Some
99+
methods (accuracy tables, SOM diagnostics, model summaries) are
100+
called only for their side effect of drawing the plot.
90101

91102
Notes:
92-
The `roi` argument can be defined as a `dict` giving the spatial
93-
extent (for example with `lon_min`, `lon_max`, `lat_min`, `lat_max`),
94-
a `geopandas.GeoDataFrame`, or another spatial specification accepted
95-
by `sits`. Vector cube plots overlay the segments produced by
96-
`sits_segment` on top of the raster image; their appearance is
97-
controlled by `seg_color` and `line_width`.
103+
The set of valid keyword arguments depends on the type of `x`;
104+
passing arguments that do not apply to a given object type has no
105+
effect. When a region of interest (`roi`) is supported, it defines
106+
the spatial extent to plot in WGS 84.
98107

99108
Examples:
100109
from pysits import *
101110

102-
# Plot a set of time series patterns
103-
patterns = sits_patterns(cerrado_2classes)
111+
# Plot a set of time-series patterns (one average pattern per label)
112+
patterns = sits_patterns(samples_modis_ndvi)
104113
plot(patterns)
105114

106-
# Train a random forest model and plot variable importance
107-
rfor_model = sits_train(samples_modis_ndvi, ml_method=sits_rfor())
108-
plot(rfor_model)
109-
110-
# Plot a SOM map produced from a set of samples
111-
som_map = sits_som_map(samples_modis_ndvi)
112-
plot(som_map)
115+
# Train a random forest model and plot its important variables
116+
rf_model = sits_train(samples_modis_ndvi, ml_method=sits_rfor())
117+
plot(rf_model)

pysits/docs/content/sits_accuracy.md

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
Assess classification accuracy
22

3-
This function calculates the accuracy of the classification result. The input
4-
is either a set of classified time series or a classified data cube. Classified
5-
time series are produced by `sits_classify`. Classified images are generated
6-
using `sits_classify` followed by `sits_label_classification`.
3+
This function calculates the accuracy of the classification result. The
4+
input is either a set of classified time series or a classified data cube.
5+
Classified time series are produced by `sits_classify`. Classified images
6+
are generated using `sits_classify` followed by
7+
`sits_label_classification`.
78
For a set of time series, `sits_accuracy` creates a confusion matrix and
8-
calculates the resulting statistics using package `caret`. For a classified
9-
image, the function uses an area-weighted technique proposed by Olofsson et al.
10-
according to references [1-3] to produce reliable accuracy estimates at 95%
11-
confidence level. In both cases, it provides an accuracy assessment of the
9+
calculates the resulting statistics. For a classified image, the function
10+
uses an area-weighted technique proposed by Olofsson et al. according to
11+
references [1-3] to produce reliable accuracy estimates at 95% confidence
12+
level. In both cases, it provides an accuracy assessment of the
1213
classified, including Overall Accuracy, Kappa, User's Accuracy, Producer's
1314
Accuracy and error matrix (confusion matrix).
1415

1516
Args:
1617
data (SITSCubeModel | SITSTimeSeriesModel): Either a data cube with
1718
classified images or a set of time series.
18-
prediction_attr (str): Name of the column of the segments object that
19-
contains the predicted values (only for vector class cubes).
20-
reference_attr (str): Name of the column of the segments object that
21-
contains the reference values (only for vector class cubes).
19+
prediction_attr (str): Name of the column of the segments that contains
20+
the predicted values (only for vector class cubes).
21+
reference_attr (str): Name of the column of the segments that contains
22+
the reference values (only for vector class cubes).
2223
validation (str | pathlib.Path | pandas.DataFrame | geopandas.GeoDataFrame | SITSTimeSeriesModel):
2324
Samples for validation (see below). Only required when data is a
2425
raster class cube.
@@ -28,22 +29,23 @@ Args:
2829

2930
Returns:
3031
SITSData: The error_matrix, the class_areas, the unbiased estimated
31-
areas, the standard error areas, confidence interval 95 and the accuracy
32-
(user, producer, and overall), or `None` if the data is empty. The result
33-
can be visualized directly on the screen.
32+
areas, the standard error areas, confidence interval 95 and the
33+
accuracy (user, producer, and overall), or `None` if the data is
34+
empty. The result can be visualized directly on the screen.
3435

3536
Notes:
36-
The `validation` data needs to contain the following columns: "latitude",
37-
"longitude", "start_date", "end_date", and "label". It can be either a path
38-
to a CSV file, a `SITSTimeSeriesModel`, a `pandas.DataFrame`, or a
39-
`geopandas.GeoDataFrame`.
37+
The `validation` data needs to contain the following columns:
38+
"latitude", "longitude", "start_date", "end_date", and "label". It can
39+
be either a path to a CSV file, a `SITSTimeSeriesModel`, a
40+
`pandas.DataFrame`, or a `geopandas.GeoDataFrame`.
4041
When `validation` is a `geopandas.GeoDataFrame`, the columns "latitude"
4142
and "longitude" are not required as the locations are extracted from the
4243
geometry column. The `centroid` is calculated before extracting the
4344
location values for any geometry type.
4445

4546
Examples:
4647
from pysits import *
48+
import tempfile
4749

4850
# show accuracy for a set of samples
4951
train_data = sits_sample(samples_modis_ndvi, frac=0.5)
@@ -65,7 +67,6 @@ Examples:
6567
data_dir=data_dir
6668
)
6769
# classify a data cube
68-
import tempfile
6970
probs_cube = sits_classify(
7071
data=cube, ml_model=rfor_model, output_dir=tempfile.gettempdir()
7172
)
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
Print accuracy summary
22

3-
Adaptation of the caret::print.confusionMatrix method for the more common
4-
usage in Earth Observation.
3+
Adaptation of the caret::print.confusionMatrix method for the more
4+
common usage in Earth Observation.
55

66
Args:
7-
x (SITSConfusionMatrix): accuracy object to summarize.
8-
digits (int): number of significant digits when printed.
7+
x (SITSConfusionMatrix): Accuracy assessment object.
8+
digits (int): Number of significant digits when printed.
99

1010
Returns:
11-
SITSData: called for side effects.
11+
SITSData: Called for side effects.

pysits/docs/content/sits_add_base_cube.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ sensor, resolution, bounding box, timeline, and have different bands.
88

99
Args:
1010
cube1 (SITSCubeModel): Data cube.
11-
cube2 (SITSCubeModel): Data cube with base information.
11+
cube2 (SITSCubeModel): Base data cube (e.g., DEM).
1212

1313
Returns:
1414
SITSCubeModel: a merged data cube with the inclusion of base

0 commit comments

Comments
 (0)