Skip to main content

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 sdss-pymangle 0.9.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sdss-pymangle 0.9.3
File Size Uploaded
sdss_pymangle-0.9.3.tar.gz 31.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sdss-pymangle 0.9.3
File Interpreter ABI Platform
sdss_pymangle-0.9.3-cp312-cp312-macosx_14_0_x86_64.whl CPython 3.12 CPython 3.12 macOS 14.0+ x86-64 Details

Total release size: 92.0 kB

Release files / sdss_pymangle-0.9.3.tar.gz

Download URL sdss_pymangle-0.9.3.tar.gz
Size 31.8 kB
Tags Source
SHA-256 checksum
How to use checksums
1b25e4b776a0a4b8f44891b7915346be8c946fadbf8d01463db3c7557d056cb8
BLAKE2b-256 checksum
How to use checksums
819acac79dc155540f174d7ca38c207096c81146a39798293d1f328b4a99e848
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.3

Release files / sdss_pymangle-0.9.3-cp312-cp312-macosx_14_0_x86_64.whl

Download URL sdss_pymangle-0.9.3-cp312-cp312-macosx_14_0_x86_64.whl
Size 60.1 kB
Tags CPython 3.12 macOS 14.0+ x86-64
SHA-256 checksum
How to use checksums
2c971db43da74a188b7cfe58cb90f836baa962428a1950ada0f8bcbaadeb6a89
BLAKE2b-256 checksum
How to use checksums
0f8965ea23511d7eeffa3af95a81248110009086dabe75446368f847043e45ea
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.9.3 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page