Textory package¶
textory.textures module¶
-
textory.textures.
cross_variogram
(x, y, lag=1, win_size=5, win_geom='square', **kwargs)[source]¶ Calculate moveing window pseudo-variogram with specified lag for the two arrays.
Parameters: Returns: array like – Array where each element is the pseudo-variogram between the two arrays of the window around the element.
-
textory.textures.
madogram
(x, lag=1, win_size=5, win_geom='square', **kwargs)[source]¶ Calculate moveing window madogram with specified lag for array.
Parameters: Returns: array like – Array where each element is the madogram of the window around the element
-
textory.textures.
pseudo_cross_variogram
(x, y, lag=1, win_size=5, win_geom='square', **kwargs)[source]¶ Calculate moveing window pseudo-variogram with specified lag for the two arrays.
Parameters: Returns: array like – Array where each element is the pseudo-variogram between the two arrays of the window around the element.
-
textory.textures.
rodogram
(x, lag=1, win_size=5, win_geom='square', **kwargs)[source]¶ Calculate moveing window rodogram with specified lag for array.
Parameters: Returns: array like – Array where each element is the madogram of the window around the element
-
textory.textures.
tpi
(x, win_size=5, win_geom='square', **kwargs)[source]¶ Calculate topographic position index for a given window size.
Parameters: - x (array like) – Input array
- win_size (int, optional) – Length of one side of window. Window will be of size window*window. Defaults to 5.
- win_geom ({"square", "round"}) – Geometry of the kernel. Defaults to square.
Returns: array like – Array with tpi
-
textory.textures.
variogram
(x, lag=1, win_size=5, win_geom='square', **kwargs)[source]¶ Calculate moveing window variogram with specified lag for array.
Parameters: Returns: array like – Array where each element is the variogram of the window around the element
-
textory.textures.
window_statistic
(x, stat='nanmean', win_size=5, **kwargs)[source]¶ Calculate the specified statistic with a moveing window of size win_size.
Parameters: - x (array like) – Input array
- stat ({"nanmean", "nanmax", "nanmin", "nanmedian", "nanstd"}) – Statistical measure to calculate.
- win_size (int, optional) – Length of one side of window. Window will be of size window*window.
- kwargs (optional) – Any parameters a certain stat may need other than the array itself.
Returns: array like
textory.statistics module¶
textory.wrappers module¶
Textory satpy Scene and xarray Dataset wrappers
Calculate textures for Scene¶
With the textures_for_scene()
function it is easy to
calculate one or multiple textures with the same or different parameters for
datasets in a satpy.scene.Scene
. The function will return a new Scene
either with the textures in addition to all input datasets (default) or a Scene only with
the textures, depending on the append
parameter of the function.
The textures
parameter takes a dictionary where the keys are a tuple with the texture
and the parameters which to calculate and the values are a list (or list of tuples in the
case of textures which require two inputs) of the datasets to apply the texture to in the general
form of:
textures_dict = {("texture_name", lag, win_size, win_geom): [list of dataset names]}
The following example would calculate the variogram with lag=2, win_size=7, win_geom=”square” for the datasets with name “IR_039” and “IR_108” as well as the cross variogram with lag=1, win_size=5, and win_geom=”round” between the datasets with name “WV_062” and “IR_108” of the Scene.
import textory as tx
scn = Scene(...)
textures_dict = {("variogram", 2, 7, "square"): ["IR_039", "IR_108"],
("cross_variogram", 1, 5, "round"): [("WV_062", "IR_108")]}
scn_with_textures = tx.textures_for_scene(scn, textures=textures_dict)
Calculate textures for xarray Dataset¶
The textures_for_xr_dataset()
function works similarly to the
textures_for_scene()
function above but takes xarray.Dataset
as input and also returns a xarray.Dataset
.
-
textory.wrappers.
textures_for_scene
(scn, textures, append=True)[source]¶ Wrapper to calculate multiple textures for datasets in a
satpy.scene.Scene
.Parameters: - scn (satpy.scene.Scene) –
- textures (dict) –
Dictionary with textures bands to calulate. The accepted notation is {(“texture name”, lag, win_size, win_geom): [list of dataset names or tuples of dataset names]}
- For example:
- {(“variogram”, 2, 7, “round”), [“IR_039”, “IR_103”]}
- append (boolean, optional) – If False returns a new
satpy.scene.Scene
with all calculated textures, By default returns a newsatpy.scene.Scene
with all input datasets and all calculated textures.
Returns: satpy.scene.Scene
-
textory.wrappers.
textures_for_xr_dataset
(xrds, textures, append=True)[source]¶ Wrapper to calculate multiple textures for dataarrays in a
xarray.Dataset
.Parameters: - xrds (xarray.Dataset) –
- textures (dict) –
Dictionary with textures bands to calulate. The accepted notation is {(“texture name”, lag, win_size, win_geom): [list of dataset names or tuples of dataset names]}
- For example:
- {(“variogram”, 2, 7, “round”), [“IR_039”, “IR_103”]}
- append (boolean, optional) – If False returns a new
xarray.Dataset
with all calculated textures, By default returns a newxarray.Dataset
with all input datasets and all calculated textures.
Returns: xarray.Dataset – Dataset