Metadata-Version: 2.2
Name: smoother-py
Version: 0.1.0
Summary: Spatial smoothing methods for probability maps.
Keywords: land use and land cover,lulc,satellite,time-series,metrics,remote-sensing
Author-Email: Felipe Carlos <efelipecarlos@gmail.com>
License: MIT License
         
         Copyright (c) 2024 Felipe Carlos
         
         Permission is hereby granted, free of charge, to any person obtaining a copy
         of this software and associated documentation files (the "Software"), to deal
         in the Software without restriction, including without limitation the rights
         to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         copies of the Software, and to permit persons to whom the Software is
         furnished to do so, subject to the following conditions:
         
         The above copyright notice and this permission notice shall be included in all
         copies or substantial portions of the Software.
         
         THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
         SOFTWARE.
         
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering
Project-URL: homepage, https://github.com/m3nin0-labs/smoother.py
Project-URL: repository, https://github.com/m3nin0-labs/smoother.py
Requires-Python: >=3.11
Requires-Dist: numpy>=1.26.4
Provides-Extra: xarray
Requires-Dist: xarray>=2024.1; extra == "xarray"
Provides-Extra: examples
Requires-Dist: rasterio>=1.3; extra == "examples"
Requires-Dist: rioxarray>=0.15; extra == "examples"
Requires-Dist: matplotlib>=3.8; extra == "examples"
Description-Content-Type: text/markdown

## smoother.py 🧹

Spatial smoothing methods for probability maps.

### Installation

To install the package, you can use pip:

```bash
pip install git+https://github.com/m3nin0-labs/smoother.py
```

### Methods available

Currently, the `smoother` implements the [Bayes smoothing method](https://e-sensing.github.io/sitsbook/cl_smoothing.html), adapting the code from the [sits](https://github.com/e-sensing/sits) R package.

### Usage

First, import the package:

```python
import smoother
```

Then, use the `smooth` function on the `numpy` data of your map. The smoothing method is selected with `method` (defaults to `"bayes"`), and any method-specific options are passed as keyword arguments:

```python
smoothed = smoother.smooth(your_numpy_array)

# selecting the method explicitly and tuning it
smoothed = smoother.smooth(your_numpy_array, method="bayes", window_size=5)
```

You can use [rasterio](https://rasterio.readthedocs.io/en/latest/index.html) or other library to load the numpy array.

#### xarray

`smooth` also accepts `xarray` objects. To use it, first install the `xarray` dependencies:

```bash
pip install "smoother-py[xarray]"
```

Then, using your `xarray` data, you can call the `smooth` function:

```python
# DataArray with class, y and x dimensions
smoothed = smoother.smooth(your_data_array)

# dimension names are inferred (e.g. band/class, y/latitude, x/longitude)
# you can also name them explicitly
smoothed = smoother.smooth(your_data_array, class_dim="band")
```

Extra dimensions (e.g. `time`) are smoothed per layer automatically.

#### Discovering the options

`smoother.smooth` documents every option, the smoothing parameters and the xarray-only dimension names:

```python
help(smoother.smooth)
```

### Development

The project uses [uv](https://docs.astral.sh/uv/) to manage the development environment:

```bash
# create the environment and build/install the package
uv sync

# run the tests
uv run pytest
```

### Learn more

The smoothing methods implemented in this package uses the approach described in the [sits documentation](https://e-sensing.github.io/sitsbook/bayesian-smoothing-for-post-processing.html). This method helps in refining the probability maps by considering the spatial context of each pixel.

### Acknowledgments

We would like to thank the developers and contributors of the `sits` R package for their work on spatial smoothing methods for Earth observation data. Their comprehensive [documentation](https://e-sensing.github.io/sitsbook/) and methodologies have been invaluable in the development of `smoother.py`.

### Contributing

We welcome contributions! If you have suggestions for improvements or bug fixes, please feel free to fork the repository and submit a pull request.

### License

`smoother.py` is distributed under the MIT license. See [LICENSE](./LICENSE) for more details.
