Skip to main content

Weighted overlap coefficient for 2D and 3D data comparison

Project description

WOC - Weighted Overlap Coefficient

Python code to calculate the weighted overlap coefficient between 2 fields (2D or 3D) while considering masking.

Please cite J. Yoo et.al., (ApJS, Vol 261, Issue 2, 2022) arXiv:2205.08161

Install

Base (runtime only):

pip install pywoc

Optional extras:

  • Plotting support: pip install pywoc[plot]
  • Examples/tutorial deps (Astropy/Scipy/Matplotlib): pip install pywoc[examples]

From source:

python -m pip install git+https://github.com/csabiu/WOC.git

Running

from pywoc import woc

woc(map1, map2, radii, mask=None, centre=None, pixelsize=1, plot=False, savefig=None, rbins=20, maxr=None):

  • map1 -- 2‑D or 3-D numpy.ndarray representing the reference map/volume. The array shape defines the pixel/voxel grid and all values should be finite and non‑negative.

  • map2 -- second map/volume with the same shape as map1. Its units should match those of map1. Any NaN entries are ignored when the coefficient is calculated.

  • radii -- sequence of radius values used to define contours in map1. The values are interpreted in units of pixelsize (pixels if pixelsize is 1). For example [100, 200, 300] means 100, 200 and 300 pixels or, when pixelsize gives the physical pixel size, distances in those physical units.

  • optional parameters

    • mask -- boolean array with the same shape as the maps. 1 marks valid pixels/voxels and 0 masks them.
    • pixelsize -- conversion factor from pixel/voxel units to physical units.
    • rbins -- number of radial bins for the radial profile.
    • maxr -- maximum radius of the profile in pixel/voxel units.
    • centre -- profile centre. None uses the brightest pixel of map1; "mid" uses the geometric centre; [x, y] for 2D or [x, y, z] for 3D specifies explicit coordinates.
    • plot -- if True show diagnostic plots (only supported for 2D data).
    • savefig -- filename for plots when plot is True.

The call returns a single floating point value containing the weighted overlap coefficient between map1 and map2.

revision history

0.0.1 initial code release

0.1.0 added python notebook tutorial under /nb improved documentation

0.2.0 added a dynamic calculation of radial profile fixed some installation problems

0.3.0 added extra parameters to control the radial profile calculation

0.4.0 added some numba support

0.4.1 added radial profile vectorization and regression tests

0.4.2 bug fixes and performance improvements

0.5.0 extended to support 3D analysis

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pywoc-0.5.0.tar.gz (21.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pywoc-0.5.0-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file pywoc-0.5.0.tar.gz.

File metadata

  • Download URL: pywoc-0.5.0.tar.gz
  • Upload date:
  • Size: 21.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for pywoc-0.5.0.tar.gz
Algorithm Hash digest
SHA256 fbccb5694325c3e8a52d24155cbf5722ead1d7c711b514a2a125ef18a5b304da
MD5 a37bc747981ec161fc2c23be05fad1b2
BLAKE2b-256 1c71b697e45ffcde33fc117e9d300fbf9507181c683ffcdab48060b7ebe37a43

See more details on using hashes here.

File details

Details for the file pywoc-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: pywoc-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for pywoc-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8fa3b6fb62ccf5d839ca85092f5d7b039efc60fedd2e1e33a0c9b4badef621cf
MD5 3c62fec1eaa7b331c4a48e0249ccd7ec
BLAKE2b-256 e40c067b592c6d44e9c4c10fb4656cbc1689d895bd37ace219c9b508852bbb20

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page