# objscale
Object-based analysis functions for fractal dimensions and size distributions in atmospheric sciences and beyond. Optimized for large datasets.
## Description
`objscale` provides computational tools for analyzing the scaling properties of objects in 2D binary arrays. The package consolidates methods for calculating size distributions and fractal dimensions that account for finite domain effects and complex boundary conditions. Originally developed for atmospheric science applications, these methods apply broadly to any field where object scaling properties matter.
The package implements methods from two main papers:
- [DeWitt & Garrett (2024)](https://acp.copernicus.org/articles/24/8457/2024/) - finite domain effects in size distributions
- DeWitt et al. (in prep) - fractal dimensions for cloud field characterization
## Key Functions
### `finite_array_powerlaw_exponent`
Calculate power-law exponents for size distributions while accounting for finite domain truncation effects. Essential for accurate scaling analysis in bounded domains.
### `individual_fractal_dimension`
Fractal dimension of individual objects using the perimeter-area relationship, with proper handling of interior holes and resolution effects.
### `ensemble_correlation_dimension`
Correlation dimension for characterizing the collective scaling properties of object ensembles. Uses point-pair correlation analysis across multiple length scales.
### `ensemble_box_dimension`
Box-counting dimension for object ensembles. New analyses should prefer `ensemble_correlation_dimension`. Counts boxes containing object boundaries at varying spatial scales.
### `ensemble_coarsening_dimension`
Novel fractal dimension based on how total object perimeter changes under spatial coarsening operations. New analyses should prefer `ensemble_correlation_dimension`. Used in [Rees et. al., 2024](https://npg.copernicus.org/articles/31/497/2024/)
## Installation
```bash
pip install objscale
```
## Documentation
📖 **[Full Documentation](https://objscale.readthedocs.io)**
Complete API reference, detailed examples, and usage guides are available at [objscale.readthedocs.io](https://objscale.readthedocs.io).
## Quick Example
```python
import objscale
import numpy as np
# Create binary array (e.g., cloud mask, percolation lattice)
arrays = [(np.random.random((1000, 1000)) < 0.3).astype(int) for _ in range(4)]
# Size distribution with finite domain corrections
(exponent, error), (log10_sizes, log10_counts) = objscale.finite_array_powerlaw_exponent(
arrays, 'area', return_counts=True
)
# Ensemble fractal dimensions
corr_dim, corr_error = objscale.ensemble_correlation_dimension(arrays)
box_dim, box_error = objscale.ensemble_box_dimension(arrays)
# Individual object analysis
ind_dim, ind_error = objscale.individual_fractal_dimension(arrays)
```
## Features
- **Finite domain corrections**: Proper handling of truncation effects at domain boundaries as recommended by [DeWitt & Garrett (2024)]([ACP - Finite domains cause bias in measured and modeled distributions of cloud sizes](https://acp.copernicus.org/articles/24/8457/2024/))
- **Multiple size metrics**: Area, perimeter, width, height, nested perimeter
- **Arbitrary boundaries**: Support for NaN-demarcated non-rectangular domains
- **Individual and Ensemble methods**: Characterize both individual and collective properties of object fields
- **Performance optimized**: Numba acceleration for computational efficiency. Can handle billions of individual objects on a mid-range laptop.
## Requirements
- Python ≥ 3.8
- NumPy ≥ 1.20.0
- SciPy ≥ 1.7.0
- scikit-image ≥ 0.18.0
- Numba ≥ 0.56.0
## Available Functions
### Fractal Dimensions
- `individual_fractal_dimension` - Fractal dimension of individual objects
- `ensemble_correlation_dimension` - Correlation dimension for object ensembles
- `ensemble_box_dimension` - Box-counting dimension for object ensembles
- `ensemble_coarsening_dimension` - Coarsening-based fractal dimension
### Size Distributions
- `finite_array_powerlaw_exponent` - Power-law exponents with finite domain corrections
- `finite_array_size_distribution` - Size distributions with truncation analysis
- `array_size_distribution` - Basic size distribution for single arrays
### Object Analysis
- `get_structure_props` - Calculate perimeter, area, width, height of structures
- `total_perimeter` - Total perimeter of all objects
- `total_number` - Count number of structures
- `isolate_largest_structure` - Extract the largest connected structure
- `remove_structures_touching_border_nan` - Remove border-touching structures
- `remove_structure_holes` - Fill holes in structures
- `clear_border_adjacent` - Clear structures touching array edges
### Utilities
- `coarsen_array` - Coarsen array resolution by averaging
- `linear_regression` - Linear regression with error estimates
- `encase_in_value` - Add border of specified value around array
For detailed parameter descriptions and usage examples, see the [full documentation](https://objscale.readthedocs.io) or use `help(objscale.function_name)` or `objscale.function_name?` in IPython/Jupyter.
## Support Statement
This package consolidates research code developed over several years. While functional and tested, it should be considered research software with limited ongoing support. Users are encouraged to understand the underlying methods through the referenced papers before applying to their data.
## References
If you use this package, please cite:
DeWitt, T. D. and Garrett, T. J.: Finite domains cause bias in measured and modeled
distributions of cloud sizes, Atmos. Chem. Phys., 24, 8457–8472,
https://doi.org/10.5194/acp-24-8457-2024, 2024.
## Author
Thomas D. DeWitt
University of Utah Department of Atmospheric Sciences
Sonnet 4 with Claude Code
Anthropic
## License
MIT License
Raw data
{
"_id": null,
"home_page": null,
"name": "objscale",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "fractal, dimensions, size-distributions, object-analysis, perimeter, area",
"author": null,
"author_email": "Thomas DeWitt <thomas.dewitt@utah.edu>",
"download_url": "https://files.pythonhosted.org/packages/e4/ea/1625c60c97858256b2c9410b4561fb04b8d9344606e3dbf7b9c3a86d3ae5/objscale-0.1.2.tar.gz",
"platform": null,
"description": "# objscale\n\nObject-based analysis functions for fractal dimensions and size distributions in atmospheric sciences and beyond. Optimized for large datasets.\n\n## Description\n\n`objscale` provides computational tools for analyzing the scaling properties of objects in 2D binary arrays. The package consolidates methods for calculating size distributions and fractal dimensions that account for finite domain effects and complex boundary conditions. Originally developed for atmospheric science applications, these methods apply broadly to any field where object scaling properties matter.\n\nThe package implements methods from two main papers:\n\n- [DeWitt & Garrett (2024)](https://acp.copernicus.org/articles/24/8457/2024/) - finite domain effects in size distributions \n- DeWitt et al. (in prep) - fractal dimensions for cloud field characterization\n\n## Key Functions\n\n### `finite_array_powerlaw_exponent`\n\nCalculate power-law exponents for size distributions while accounting for finite domain truncation effects. Essential for accurate scaling analysis in bounded domains.\n\n### `individual_fractal_dimension`\n\nFractal dimension of individual objects using the perimeter-area relationship, with proper handling of interior holes and resolution effects.\n\n### `ensemble_correlation_dimension`\n\nCorrelation dimension for characterizing the collective scaling properties of object ensembles. Uses point-pair correlation analysis across multiple length scales.\n\n### `ensemble_box_dimension`\n\nBox-counting dimension for object ensembles. New analyses should prefer `ensemble_correlation_dimension`. Counts boxes containing object boundaries at varying spatial scales.\n\n### `ensemble_coarsening_dimension`\n\nNovel fractal dimension based on how total object perimeter changes under spatial coarsening operations. New analyses should prefer `ensemble_correlation_dimension`. Used in [Rees et. al., 2024](https://npg.copernicus.org/articles/31/497/2024/)\n\n## Installation\n\n```bash\npip install objscale\n```\n\n## Documentation\n\n\ud83d\udcd6 **[Full Documentation](https://objscale.readthedocs.io)**\n\nComplete API reference, detailed examples, and usage guides are available at [objscale.readthedocs.io](https://objscale.readthedocs.io).\n\n## Quick Example\n\n```python\nimport objscale\nimport numpy as np\n\n# Create binary array (e.g., cloud mask, percolation lattice)\narrays = [(np.random.random((1000, 1000)) < 0.3).astype(int) for _ in range(4)]\n\n# Size distribution with finite domain corrections\n(exponent, error), (log10_sizes, log10_counts) = objscale.finite_array_powerlaw_exponent(\n arrays, 'area', return_counts=True\n)\n\n# Ensemble fractal dimensions\ncorr_dim, corr_error = objscale.ensemble_correlation_dimension(arrays)\nbox_dim, box_error = objscale.ensemble_box_dimension(arrays)\n\n# Individual object analysis \nind_dim, ind_error = objscale.individual_fractal_dimension(arrays)\n```\n\n## Features\n\n- **Finite domain corrections**: Proper handling of truncation effects at domain boundaries as recommended by [DeWitt & Garrett (2024)]([ACP - Finite domains cause bias in measured and modeled distributions of cloud sizes](https://acp.copernicus.org/articles/24/8457/2024/))\n- **Multiple size metrics**: Area, perimeter, width, height, nested perimeter\n- **Arbitrary boundaries**: Support for NaN-demarcated non-rectangular domains \n- **Individual and Ensemble methods**: Characterize both individual and collective properties of object fields\n- **Performance optimized**: Numba acceleration for computational efficiency. Can handle billions of individual objects on a mid-range laptop.\n\n## Requirements\n\n- Python \u2265 3.8\n- NumPy \u2265 1.20.0\n- SciPy \u2265 1.7.0 \n- scikit-image \u2265 0.18.0\n- Numba \u2265 0.56.0\n\n## Available Functions\n\n### Fractal Dimensions\n- `individual_fractal_dimension` - Fractal dimension of individual objects\n- `ensemble_correlation_dimension` - Correlation dimension for object ensembles\n- `ensemble_box_dimension` - Box-counting dimension for object ensembles\n- `ensemble_coarsening_dimension` - Coarsening-based fractal dimension\n\n### Size Distributions\n- `finite_array_powerlaw_exponent` - Power-law exponents with finite domain corrections\n- `finite_array_size_distribution` - Size distributions with truncation analysis\n- `array_size_distribution` - Basic size distribution for single arrays\n\n### Object Analysis\n- `get_structure_props` - Calculate perimeter, area, width, height of structures\n- `total_perimeter` - Total perimeter of all objects\n- `total_number` - Count number of structures\n- `isolate_largest_structure` - Extract the largest connected structure\n- `remove_structures_touching_border_nan` - Remove border-touching structures\n- `remove_structure_holes` - Fill holes in structures\n- `clear_border_adjacent` - Clear structures touching array edges\n\n### Utilities\n- `coarsen_array` - Coarsen array resolution by averaging\n- `linear_regression` - Linear regression with error estimates\n- `encase_in_value` - Add border of specified value around array\n\nFor detailed parameter descriptions and usage examples, see the [full documentation](https://objscale.readthedocs.io) or use `help(objscale.function_name)` or `objscale.function_name?` in IPython/Jupyter.\n\n## Support Statement\n\nThis package consolidates research code developed over several years. While functional and tested, it should be considered research software with limited ongoing support. Users are encouraged to understand the underlying methods through the referenced papers before applying to their data.\n\n## References\n\nIf you use this package, please cite:\n\nDeWitt, T. D. and Garrett, T. J.: Finite domains cause bias in measured and modeled \ndistributions of cloud sizes, Atmos. Chem. Phys., 24, 8457\u20138472, \nhttps://doi.org/10.5194/acp-24-8457-2024, 2024.\n\n## Author\n\nThomas D. DeWitt\nUniversity of Utah Department of Atmospheric Sciences\n\n\nSonnet 4 with Claude Code\nAnthropic\n\n## License\n\nMIT License\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Object-based analysis functions for fractal dimensions and size distributions",
"version": "0.1.2",
"project_urls": {
"Documentation": "https://objscale.readthedocs.io",
"Homepage": "https://github.com/thomasdewitt/objscale",
"Issues": "https://github.com/thomasdewitt/objscale/issues",
"Repository": "https://github.com/thomasdewitt/objscale"
},
"split_keywords": [
"fractal",
" dimensions",
" size-distributions",
" object-analysis",
" perimeter",
" area"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "96cf3c9eeb11bb5a18be447c2c8b9656e0357a7248497660232ff4e10a03665f",
"md5": "0546f2bd293a3b304b4332acfdec1dcb",
"sha256": "b0900bbb86340aa6c00f73d54c45b2120e71046efbf02f3b11d3540b1443a6b3"
},
"downloads": -1,
"filename": "objscale-0.1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0546f2bd293a3b304b4332acfdec1dcb",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 22441,
"upload_time": "2025-07-09T15:18:56",
"upload_time_iso_8601": "2025-07-09T15:18:56.365022Z",
"url": "https://files.pythonhosted.org/packages/96/cf/3c9eeb11bb5a18be447c2c8b9656e0357a7248497660232ff4e10a03665f/objscale-0.1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "e4ea1625c60c97858256b2c9410b4561fb04b8d9344606e3dbf7b9c3a86d3ae5",
"md5": "cdb24f2bf6383d76f9c28e54d06ec2ef",
"sha256": "72dfdd829890d089aba32e766c76064ed11eefb93c93ccd30f93f769316a699a"
},
"downloads": -1,
"filename": "objscale-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "cdb24f2bf6383d76f9c28e54d06ec2ef",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 24557,
"upload_time": "2025-07-09T15:18:57",
"upload_time_iso_8601": "2025-07-09T15:18:57.206808Z",
"url": "https://files.pythonhosted.org/packages/e4/ea/1625c60c97858256b2c9410b4561fb04b8d9344606e3dbf7b9c3a86d3ae5/objscale-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-09 15:18:57",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "thomasdewitt",
"github_project": "objscale",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "objscale"
}