Object-based analysis functions for fractal dimensions and size distributions
Project description
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) - 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
Installation
pip install objscale
Documentation
Complete API reference, detailed examples, and usage guides are available at objscale.readthedocs.io.
Quick Example
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)
- 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 objectsensemble_correlation_dimension- Correlation dimension for object ensemblesensemble_box_dimension- Box-counting dimension for object ensemblesensemble_coarsening_dimension- Coarsening-based fractal dimension
Size Distributions
finite_array_powerlaw_exponent- Power-law exponents with finite domain correctionsfinite_array_size_distribution- Size distributions with truncation analysisarray_size_distribution- Basic size distribution for single arrays
Object Analysis
get_structure_props- Calculate perimeter, area, width, height of structurestotal_perimeter- Total perimeter of all objectstotal_number- Count number of structuresisolate_largest_structure- Extract the largest connected structureremove_structures_touching_border_nan- Remove border-touching structuresremove_structure_holes- Fill holes in structuresclear_border_adjacent- Clear structures touching array edges
Utilities
coarsen_array- Coarsen array resolution by averaginglinear_regression- Linear regression with error estimatesencase_in_value- Add border of specified value around array
For detailed parameter descriptions and usage examples, see the full documentation 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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file objscale-0.1.4.tar.gz.
File metadata
- Download URL: objscale-0.1.4.tar.gz
- Upload date:
- Size: 25.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c9de5dcfcd7b902e6eff974f7331b50673594e80d3a4c447232e9498bd09b9c9
|
|
| MD5 |
454ef00df930b5c686e9e38b22783435
|
|
| BLAKE2b-256 |
0b1c60348cdb6e0332580c5eb020af878ddaf8d7bd246d43c9d2136e4fbfee92
|
File details
Details for the file objscale-0.1.4-py3-none-any.whl.
File metadata
- Download URL: objscale-0.1.4-py3-none-any.whl
- Upload date:
- Size: 23.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d039ca2d6a24b2d4d8bf0e6ee876debdf6ceb2b579354c14ce9a652322d70ea
|
|
| MD5 |
4e45db441eeed11d91bf6e02a24b5882
|
|
| BLAKE2b-256 |
5667df66d5a05ff23cc3f3fa36a906002b9654e01fd7932facc9b10c9f614a70
|