pymangle
A python code to read and work with Mangle masks.
The underlying code is in C for speed, and is based on some C++ code written by Martin White. Martin has posted his C++ code at https://github.com/martinjameswhite/litemangle
Currently supports ascii mangle polygon files, with and without pixelization. The code works in python2 and python3
Authors: Erin Sheldon. Long double support added by Eli Rykoff.
examples
import pymangle
# read a mangle polygon file
m=pymangle.Mangle("mask.ply")
# test an ra,dec point against the mask
good = m.contains(200.0, 0.0)
# test arrays of ra,dec points against the mask
ra=numpy.array([200.0, 152.7])
dec=numpy.array([0.0, -15.0])
good = m.contains(ra, dec)
# get the polygon ids
ids = m.polyid(ra,dec)
# get the weights
weights = m.weight(ra,dec)
# get poth polyids and weights
ids, weights = m.polyid_and_weight(ra, dec)
# generate random points
ra_rand, dec_rand = m.genrand(1000)
# generate randoms from the mask and with the additional constraint that they
# are within the specified rectangle. This speeds things up if your mask is
# relatively small compared to the full sphere; choose the box just big enough
# to contain the mask.
ra_min=200.0
ra_max=210.0
dec_min=0.0
dec_max=10.0
ra_rand, dec_rand = m.genrand_range(1000,ra_min,ra_max,dec_min,dec_max)
# get the polygon weights
weights = m.weights
# read in a new set of weights
m.read_weightfile(weightfile)
# set the weights
m.weights = weight_array
build and install python library
# using pip
pip install pymangle
# from source
python setup.py install --prefix=/some/path
tests
python -c 'import pymangle; pymangle.test.test()
Metadata
Release files for pymangle 0.9.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pymangle-0.9.4.tar.gz | 32.7 kB | Without provenance | Details |
Release files / pymangle-0.9.4.tar.gz
| Download URL | pymangle-0.9.4.tar.gz |
|---|---|
| Size | 32.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8c5ce10a6bf32dcfa3106ae4a2de5e382ded0c4b3215243b495c782a5991e182
|
|
BLAKE2b-256 checksum How to use checksums |
24755a0560ae137552b433a19650952080fc23e88a790e0d9085a92631e3fbb9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.10.13
|
Security for pymangle 0.9.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.