Compositing¶
Per-pixel composites over co-registered frame stacks and matched multi-source tuples.
- Temporal composites:
MedianComposite,MaxNDVIComposite(NDVI viageoops.indices.ndvi),CloudFreeComposite,MinCloudComposite,BAPComposite - Multi-source fusion:
StackMatched,BlendMatched - Calling convention: every composite is an N-ary reducer — frames as positional arguments
(
MedianComposite()(f1, f2, f3), soop(Input("a"), Input("b"))works in aGraph) or one sequence;MedianComposite/MaxNDVICompositealso take one(T, C, H, W)stack, the cloud-aware composites take(frame, mask_or_metadata)pairs,StackMatched/BlendMatchedalso take oneMapping, andBlendMatched(method="ivw")takes(tensor, variance)pairs - Tier-A primitives (plain
(T, ..., H, W)numpy stacks, NaN = missing):median_composite,mean_composite,take_by_spatial_index,mask_frames,blend_weighted,bap_scoresand the per-criterion BAP scoresdoy_distance,doy_score,view_angle_score,cloud_distance_score,opacity_score - Nodata-aware reductions:
reduce,argreduce(aGeoArray,GeoPointsorGeoSwath, any dim)
Reductions that leave nodata out¶
reduce(x, fn, dim) and argreduce(x, fn, dim) are pipekit-array's
reduce / argreduce with the carrier's nodata read first, by the
stack's rule (GeoArray.valid_mask): a value that is non-finite or equals
the fill, every band of a pixel where any band is, and on GeoPoints a
sample that is not valid, never count. They agree with
MedianComposite on a (time, band, y, x) stack. A named reduction runs as its
NaN-skipping form, a position with no valid entry is NaN, and the result's
fill is NaN. pipekit_array.reduce reduces the raw values, so on a scene
with fill 0 a time mean averages the zeros in. geoarray does not re-export
either (GA-B6). They run on NumPy and under jax.jit.
import numpy as np
import pipekit_array as pa
from geoarray import GeoArray
from geoops.compositing import argreduce, reduce
stack: GeoArray = GeoArray(
np.array([[[1.0]], [[0.0]], [[3.0]]]), # (T, H, W) float64, 0 = nodata
(20.0, 0.0, 600000.0, 0.0, -20.0, 3550000.0),
"EPSG:32613",
fill_value=0.0,
dims=("time", "y", "x"),
)
mean: GeoArray = reduce(stack, "mean", "time") # (H, W) float64: 2.0
raw: GeoArray = pa.reduce(stack, "mean", "time") # (H, W) float64: 1.33, fill counted
best = argreduce(stack, "argmax", "time") # (H, W) int: 2, never the fill
picked = pa.take_along(stack, best, "time") # (H, W) float64: 3.0
geoops.compositing
¶
Compositing operators for co-registered GeoArray stacks, and the
nodata-aware reductions they are built from (reduce, argreduce).
BAPComposite
¶
Bases: Operator
Best Available Pixel compositing from quality-score metadata.
Each frame-pixel gets a weighted sum of per-criterion scores in
[0, 1] and the highest-scoring valid frame wins (Griffiths et al.,
2013; White et al., 2014):
S = w_view · S_view + w_recency · S_doy
+ w_cloud · S_cloud + w_opacity · S_opacity
Metadata may give precomputed view_angle_score, recency_score,
cloud_distance_score and opacity_score values, or the raw
values the scores are built from:
-
doy/day_of_year→ Gaussian of the circular DOY distance (Griffiths et al.), so late December is close to early January::Δ = |doy − target_doy| mod 365, d = min(Δ, 365 − Δ) S_doy = exp(−½ · (d / σ_doy)²)
-
view_angle(view zenith angle, degrees; sign ignored)::S_view = exp(−½ · (θ / σ_θ)²)
-
cloud_distance(distance to the nearest cloud / shadow, in the unit ofcloud_distance_req, e.g. pixels) → Griffiths et al. eq. 2 sigmoid::S_cloud = 1 / (1 + exp(−k · (min(D, D_req) − (D_req − D_min) / 2)))
-
opacity(unitless atmospheric opacity τ, e.g. LEDAPSatmos_opacity) → White et al. (2014) ramp::S_opacity = clip((τ_high − τ) / (τ_high − τ_low), 0, 1)
Missing raw values default to the best case (doy = target_doy,
view_angle = 0, opacity = 0), except cloud_distance, which
defaults to 0 (next to a cloud). Every score lies in [0, 1], so
raw and precomputed values may be mixed across frames. Each value may
be a scalar or a per-pixel array. Frames may be GeoArrays or plain
np.ndarray maps (the scores live in the metadata dicts, not in
geo-metadata). A nodata frame-pixel (non-finite or the frame's fill)
or a NaN score is never selected; pixels with no valid frame hold the
output fill value (also in the score output). Griffiths et al. also
score acquisition year and sensor; those have no raw input here.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target_doy
|
int
|
Day of year (1-366) the DOY score is centred on. |
required |
w_view_angle
|
float
|
Weight of the view-angle score. |
0.3
|
w_recency
|
float
|
Weight of the DOY score. |
0.4
|
w_cloud_distance
|
float
|
Weight of the cloud-distance score. |
0.2
|
w_opacity
|
float
|
Weight of the opacity score. |
0.1
|
doy_sigma
|
float
|
|
30.0
|
view_angle_sigma
|
float
|
|
15.0
|
cloud_distance_req
|
float
|
|
50.0
|
cloud_distance_min
|
float
|
|
0.0
|
cloud_distance_slope
|
float
|
Sigmoid slope |
0.2
|
opacity_low
|
float
|
|
0.2
|
opacity_high
|
float
|
|
0.3
|
return_score
|
bool
|
When true, also return a carrier holding the
winning per-pixel score ( |
False
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
References
Griffiths, P., van der Linden, S., Kuemmerle, T. & Hostert, P. (2013). A pixel-based Landsat compositing algorithm for large area land cover mapping. IEEE JSTARS 6(5), 2088-2101.
White, J. C., Wulder, M. A., Hobart, G. W., et al. (2014). Pixel-based image compositing for large-area dense time series applications and science. Canadian Journal of Remote Sensing 40(3), 192-212.
Source code in packages/geotoolz-ops/src/geoops/compositing/_src/operators.py
469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 | |
BlendMatched
¶
Bases: Operator
Weighted mean across N aligned tensors.
Three blending modes:
"mean"— equal-weight average across all inputs. Best for ensemble-style fusion where every source is equally trustworthy."weighted_mean"— per-source scalar weights fromself.weights. Useful when one source is known to be higher-quality (e.g. ground-truth vs satellite)."ivw"— inverse-variance weighting. Each input is weighted by1 / variance, so noisier sources contribute less. Each input is then a(tensor, variance)pair, the variance an array of the tensor's full or spatial shape:BlendMatched(method="ivw")((a, var_a), (b, var_b)).
Inputs are positional, op(a, b, ...) -- so the operator wires into
a pipekit_ops.Graph as BlendMatched()(Input("a"), Input("b")) --
or one sequence or mapping of them, or one (T, C, H, W) stack whose
frames are the inputs.
nan_policy controls per-pixel NaN handling:
"ignore"— exclude NaN samples from the blend; the surviving weights renormalise. If every input is NaN at a pixel, the output is NaN."propagate"— any NaN at a pixel poisons the output pixel.
Nodata pixels of each input (non-finite, or that input's
fill_value, in any band) are treated as NaN; pixels that
are nodata in every input hold the output fill: the first input's
fill_value, or NaN when it has none or is an integer
input blended into float (see :func:geoops._src.valid.carried_fill).
All inputs must share spatial shape, transform, and CRS. The
band axis must also be uniform (use StackMatched if you want
cross-source band concatenation; BlendMatched is the per-pixel
averaging counterpart). Plain np.ndarray inputs are also
accepted (the blend is metadata-free per-pixel math); grid
verification then degrades to shape equality and the output
carrier follows the first input.
When the input is a Mapping, the per-source order used by
weighted_mean follows the mapping's iteration order (insertion
order on dicts), and weights are zipped positionally against it
— pass an OrderedDict or positional inputs if you need a stable,
explicit pairing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method
|
BlendMethod
|
One of |
'mean'
|
weights
|
list[float] | None
|
Per-source scalar weights. Required when
|
None
|
nan_policy
|
NanPolicy
|
|
'ignore'
|
Source code in packages/geotoolz-ops/src/geoops/compositing/_src/operators.py
934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 | |
CloudFreeComposite
¶
Bases: Operator
Per-pixel mean over frames where the cloud mask is false.
Consumes (frame, cloud_mask) pairs as positional arguments,
op((f1, m1), (f2, m2)), or one sequence of them; masks may have
spatial shape (H, W), (1, H, W), or match the frame shape
exactly, and a georeferenced mask must share the frames' grid. Pixels
with fewer than min_valid clear contributors come out as NaN.
Nodata frame-pixels (non-finite or the frame's fill) never contribute;
pixels invalid in every frame hold the output fill value.
Metadata-independent: plain np.ndarray frames are accepted and
yield plain-array outputs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nan_policy
|
NanPolicy
|
|
'ignore'
|
min_valid
|
int
|
Minimum number of clear contributors per pixel; pixels below the threshold are NaN. Must be at least 1. |
1
|
return_count
|
bool
|
When true, also return a carrier with the number
of clear contributors per pixel ( |
False
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in packages/geotoolz-ops/src/geoops/compositing/_src/operators.py
MaxNDVIComposite
¶
Bases: Operator
Pick the frame with maximum NDVI per pixel and return its band values.
Called like :class:MedianComposite (frames as arguments, one
sequence, or a (T, C, H, W) stack). Inputs must be multi-band
((C, H, W)); 2-D GeoArrays raise because NDVI needs distinct red
and NIR bands. Nodata frame-pixels (non-finite or the frame's fill in
any band) never win the selection. Pixels with
no valid NDVI in any frame hold the first frame's
fill_value (NaN for float inputs without one), so the
output dtype is the input dtype.
The per-pixel math is metadata-independent, so plain np.ndarray
frames are accepted when red / nir are integer indices; named
band references need GeoArray attrs and raise TypeError for
plain arrays.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
red
|
BandRef
|
Red band reference — integer band index or a band name resolved against the first frame's attrs. |
required |
nir
|
BandRef
|
NIR band reference, same conventions as |
required |
return_index
|
bool
|
When true, also return a carrier holding the
selected frame index per pixel ( |
False
|
eps
|
float
|
Stabiliser added to the NDVI denominator. |
1e-10
|
Source code in packages/geotoolz-ops/src/geoops/compositing/_src/operators.py
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 | |
MedianComposite
¶
Bases: Operator
Per-pixel median across a stack of co-registered GeoArrays.
Called as op(f1, f2, ...), op([f1, f2, ...]) or op(stack)
with a (T, C, H, W) time stack; every frame must share the first
frame's grid and full shape (ValueError otherwise).
Metadata-independent: frames may also be plain np.ndarray maps, in
which case the outputs are plain arrays and the grid check reduces to
shape equality. Nodata frame-pixels (non-finite or the frame's fill)
are treated like NaN; pixels invalid in every frame hold the output fill.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nan_policy
|
NanPolicy
|
|
'ignore'
|
return_count
|
bool
|
When true, also return a carrier with the number
of valid contributors per output pixel.
The output is then a tuple, so the operator is terminal
(last step only) in a |
False
|
Source code in packages/geotoolz-ops/src/geoops/compositing/_src/operators.py
MinCloudComposite
¶
Bases: Operator
Pick each pixel from the scene with the lowest global cloud coverage.
For every pixel, the selected frame is the one with the smallest scene-wide cloud fraction among those where the pixel is clear. Pixels cloudy in every frame fall back to the globally least-cloudy frame so the output is a complete composite. Nodata frame-pixels (non-finite or the frame's fill) are never picked and do not count towards a scene's cloud fraction; pixels invalid in every frame hold the output fill.
This is a coarse cloud-aware composite, not a per-pixel
cloud-distance composite — frames are ranked by their overall cloud
coverage rather than by distance-to-nearest-cloud at each pixel. Use
:class:BAPComposite with per-pixel cloud_distance metadata when
that finer granularity is needed.
Metadata-independent: plain np.ndarray frames are accepted and
yield plain-array outputs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
return_count
|
bool
|
When true, also return a carrier with the number
of clear contributors per pixel ( |
False
|
Source code in packages/geotoolz-ops/src/geoops/compositing/_src/operators.py
StackMatched
¶
Bases: Operator
Concatenate aligned tensors along the band axis.
Inputs are positional, op(a, b, ...) -- so the operator wires into
a pipekit_ops.Graph as StackMatched()(Input("a"), Input("b")) --
or one Sequence[GeoArray] or Mapping[str, GeoArray] --
typical when called on MatchedPatch.members -- or one (T, C, H, W)
stack whose frames are the inputs. All inputs must share spatial shape,
transform, and CRS; the per-tensor band count may differ. Plain
np.ndarray inputs are also accepted (the concatenation itself is
metadata-free); grid verification then degrades to spatial-shape
equality and the output carrier follows the first input.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
order
|
list[str] | None
|
When the input is a Mapping, this list fixes the stacking order. Must cover every key of the input mapping exactly — extra or missing names raise. (If you want a subset, slice the input dict before passing it in; this avoids silently dropping a key the user forgot to update.) Ignored for Sequence inputs. |
None
|
Examples:
>>> import geoops as gz
>>> stack = gz.compositing.StackMatched(order=["modis", "s2"])
>>> fused = stack({"modis": modis_chip, "s2": s2_chip_aligned})
>>> fused.shape # (modis_bands + s2_bands, H, W)
(5, 256, 256)
Notes
Per-band attrs (band_names, descriptions, wavelengths,
...) are concatenated in stacking order when every input carries
them; a key missing from any input is dropped. Other attrs follow
the first input. NaN-fill padding on grid mismatch is not
implemented; the operator requires strict grid
equality. Pre-coregister with
geoops.geom.coregister.RasterToRasterLike if the
inputs aren't already on the same grid. Nodata pixels of each
input (non-finite or that input's fill) are rewritten to the
output's fill (the first input's fill_value) in that
input's bands, when the output dtype can represent it.
Where :func:geoarray.concatenate applies (3-D GeoArray inputs
with equal fills and no nodata pixels) the output matches it. The
operator does not delegate to it because concatenate refuses
2-D inputs and plain arrays, and leaves each input's nodata
pixels as they are.
Source code in packages/geotoolz-ops/src/geoops/compositing/_src/operators.py
841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 | |
argreduce(x, fn, dim)
¶
pipekit_array.argreduce that never picks an invalid entry.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Any
|
A |
required |
fn
|
str
|
|
required |
dim
|
str
|
The dim to pick an index along. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The integer index carrier |
Any
|
every entry along |
``take_along`` there gathers an invalid entry
|
the nodata survives. |
Raises:
| Type | Description |
|---|---|
TypeError
|
|
ValueError
|
|
Example
import numpy as np from geoarray import GeoArray from geoops.compositing import argreduce t = (20.0, 0.0, 0.0, 0.0, -20.0, 0.0) ndvi = GeoArray( ... np.array([[[0.4]], [[9.0]], [[0.7]]]), t, None, fill_value=9.0, ... dims="time y x", ... ) argreduce(ndvi, "argmax", "time").data.tolist() # 9.0 is the fill [[2]]
Source code in packages/geotoolz-ops/src/geoops/compositing/_src/reduce.py
bap_scores(scores, weights)
¶
Weighted Best-Available-Pixel score per frame-pixel.
S_t(y, x) = Σ_k w_k · s_{t,k}(y, x)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scores
|
Float[ndarray, 't k h w']
|
|
required |
weights
|
Float[ndarray, ' k']
|
|
required |
Returns:
| Type | Description |
|---|---|
Float[ndarray, 't h w']
|
The |
Examples:
>>> scores = np.ones((2, 4, 1, 1))
>>> bap_scores(scores, np.array([0.3, 0.4, 0.2, 0.1]))[:, 0, 0]
array([1., 1.], dtype=float32)
Source code in packages/geotoolz-ops/src/geoops/compositing/_src/array.py
blend_weighted(stack, weights, *, nan_policy='ignore')
¶
Weighted mean over the leading source axis of a NaN-masked stack.
x̄ = Σ_n w_n · x_n / Σ_n w_n
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stack
|
Float[ndarray, 'n *dims h w']
|
|
required |
weights
|
Float[ndarray, 'n *dims h w']
|
Weights broadcastable to |
required |
nan_policy
|
NanPolicy
|
|
'ignore'
|
Returns:
| Type | Description |
|---|---|
Float[ndarray, '*dims']
|
The blended |
Examples:
>>> stack = np.array([[1.0, np.nan], [3.0, 5.0]])
>>> blend_weighted(stack, np.ones((2, 1)))
array([2., 5.])
>>> blend_weighted(stack, np.ones((2, 1)), nan_policy="propagate")
array([ 2., nan])
Source code in packages/geotoolz-ops/src/geoops/compositing/_src/array.py
cloud_distance_score(distance, *, d_req, d_min, slope)
¶
Sigmoid distance-to-cloud score (Griffiths et al., 2013, eq. 2).
S_cloud = 1 / (1 + exp(−k · (min(D, D_req) − (D_req − D_min) / 2)))
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
distance
|
Float[ndarray, '*dims']
|
|
required |
d_req
|
float
|
|
required |
d_min
|
float
|
|
required |
slope
|
float
|
|
required |
Returns:
| Type | Description |
|---|---|
Float[ndarray, '*dims']
|
The score in |
Examples:
Source code in packages/geotoolz-ops/src/geoops/compositing/_src/array.py
doy_distance(doy, target_doy)
¶
Circular day-of-year distance to target_doy, in days.
Δ = |doy − target_doy| mod 365, d = min(Δ, 365 − Δ)
so DOY 360 and target DOY 5 are 10 days apart, not 355. A 365-day year is assumed (DOY 366 coincides with DOY 1).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
doy
|
Float[ndarray, '*dims']
|
Day(s) of year. |
required |
target_doy
|
float
|
Reference day of year. |
required |
Returns:
| Type | Description |
|---|---|
Float[ndarray, '*dims']
|
The circular distance, |
Examples:
Source code in packages/geotoolz-ops/src/geoops/compositing/_src/array.py
doy_score(doy, target_doy, sigma)
¶
Gaussian day-of-year score (Griffiths et al., 2013), peak-normalised.
S_doy = exp(−½ · (d / σ_doy)²), d = circular DOY distance
Griffiths et al. score DOY with a Gaussian centred on the target DOY;
the 1/(σ√(2π)) density factor is dropped so S_doy ∈ (0, 1]
shares a scale with the other scores (S_doy = e^(−½) ≈ 0.61 at
d = σ_doy).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
doy
|
Float[ndarray, '*dims']
|
Day(s) of year. |
required |
target_doy
|
float
|
Day of year the Gaussian is centred on. |
required |
sigma
|
float
|
|
required |
Returns:
| Type | Description |
|---|---|
Float[ndarray, '*dims']
|
The score in |
Examples:
Source code in packages/geotoolz-ops/src/geoops/compositing/_src/array.py
mask_frames(stack, valid)
¶
Float copy of stack with every invalid frame-pixel set to NaN.
Float stacks keep their dtype; integer stacks become float64 --
the dtype np.median / integer division already produced for them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stack
|
Num[ndarray, 't *dims h w']
|
|
required |
valid
|
Bool[ndarray, 't h w']
|
|
required |
Returns:
| Type | Description |
|---|---|
Float[ndarray, 't *dims h w']
|
The masked float copy. |
Examples:
>>> stack = np.ones((2, 1, 2), dtype=np.int16)
>>> mask_frames(stack, np.array([[[True, False]], [[True, True]]]))[0]
array([[ 1., nan]])
Source code in packages/geotoolz-ops/src/geoops/compositing/_src/array.py
mean_composite(stack, clear, *, min_valid=1, nan_policy='ignore')
¶
Per-pixel mean over the clear samples of a frame stack.
μ(y, x) = Σ_t [clear_t] · x_t / Σ_t [clear_t]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stack
|
Float[ndarray, 't *dims h w']
|
|
required |
clear
|
Bool[ndarray, 't *dims h w']
|
Same-shape mask of samples allowed to contribute. |
required |
min_valid
|
int
|
Minimum contributors per pixel; pixels with fewer come out NaN. |
1
|
nan_policy
|
NanPolicy
|
|
'ignore'
|
Returns:
| Type | Description |
|---|---|
Float[ndarray, '*dims h w']
|
|
Int[ndarray, '*dims h w']
|
the per-pixel contributor count. |
Examples:
>>> stack = np.array([[[1.0]], [[3.0]], [[np.nan]]])
>>> mean, count = mean_composite(stack, np.ones_like(stack, bool))
>>> mean, count
(array([[2.]]), array([[2]]))
Source code in packages/geotoolz-ops/src/geoops/compositing/_src/array.py
median_composite(stack, *, nan_policy='ignore')
¶
Per-pixel median over the frame axis of a NaN-masked stack.
m(y, x) = median_t stack[t, ..., y, x]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stack
|
Float[ndarray, 't *dims h w']
|
|
required |
nan_policy
|
NanPolicy
|
|
'ignore'
|
Returns:
| Type | Description |
|---|---|
Float[ndarray, '*dims h w']
|
The |
Examples:
>>> stack = np.array([[[1.0]], [[np.nan]], [[3.0]]])
>>> median_composite(stack)
array([[2.]])
>>> median_composite(stack, nan_policy="propagate")
array([[nan]])
Source code in packages/geotoolz-ops/src/geoops/compositing/_src/array.py
opacity_score(opacity, *, low, high)
¶
Piecewise-linear atmospheric-opacity score (White et al., 2014).
S_opacity = clip((τ_high − τ) / (τ_high − τ_low), 0, 1)
i.e. 1 for τ ≤ τ_low, 0 for τ ≥ τ_high, linear between.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
opacity
|
Float[ndarray, '*dims']
|
Unitless atmospheric opacity |
required |
low
|
float
|
|
required |
high
|
float
|
|
required |
Returns:
| Type | Description |
|---|---|
Float[ndarray, '*dims']
|
The score in |
Examples:
Source code in packages/geotoolz-ops/src/geoops/compositing/_src/array.py
reduce(x, fn, dim)
¶
pipekit_array.reduce over the valid entries of a geoarray carrier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Any
|
A |
required |
fn
|
str | Callable[..., Any]
|
A named reduction ( |
required |
dim
|
str | Sequence[str]
|
The dim to reduce over, or several. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The reduced carrier, as |
Any
|
|
NaN fill
|
NaN where no entry along |
Raises:
| Type | Description |
|---|---|
TypeError
|
|
ValueError
|
|
Example
import numpy as np from geoarray import GeoArray from geoops.compositing import reduce t = (20.0, 0.0, 0.0, 0.0, -20.0, 0.0) stack = GeoArray( ... np.array([[[1.0]], [[0.0]], [[3.0]]]), t, None, fill_value=0.0, ... dims="time y x", ... ) reduce(stack, "mean", "time").data.tolist() # the 0 is nodata [[2.0]]
Source code in packages/geotoolz-ops/src/geoops/compositing/_src/reduce.py
take_by_spatial_index(stack, index)
¶
Select one frame per sample from a (T, ..., H, W) stack.
out[..., y, x] = stack[index[..., y, x], ..., y, x]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stack
|
Shaped[ndarray, 't *dims h w']
|
Frame stack, frame axis first. |
required |
index
|
Int[ndarray, 'h w'] | Int[ndarray, '*dims h w']
|
Frame index in |
required |
Returns:
| Type | Description |
|---|---|
Shaped[ndarray, '*dims h w']
|
A new |
Examples:
>>> stack = np.arange(8).reshape(2, 2, 2)
>>> take_by_spatial_index(stack, np.array([[0, 1], [1, 0]]))
array([[0, 5],
[6, 3]])
Source code in packages/geotoolz-ops/src/geoops/compositing/_src/array.py
view_angle_score(view_angle, sigma)
¶
Gaussian view-zenith-angle score, best at nadir.
S_view = exp(−½ · (θ / σ_θ)²)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
view_angle
|
Float[ndarray, '*dims']
|
View zenith angle |
required |
sigma
|
float
|
|
required |
Returns:
| Type | Description |
|---|---|
Float[ndarray, '*dims']
|
The score in |
Examples: