A python code to read and work with mangle masks
Project description
pymangle
Simple 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()
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
pymangle-0.9.2.tar.gz
(30.8 kB
view details)
File details
Details for the file pymangle-0.9.2.tar.gz
.
File metadata
- Download URL: pymangle-0.9.2.tar.gz
- Upload date:
- Size: 30.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.22.0 setuptools/42.0.2.post20191203 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f46677e54393f1b55d3e0691454b3b78e369931498fefdb12da5fc71ec32e28a |
|
MD5 | 905de736542add2794006f4399dfef31 |
|
BLAKE2b-256 | af20a10d397705e1474e7dc379bef717119b8b19b1fe58943a0019e678d01df5 |