from mocpy import MOC
import astropy.units as u
# Create a MOC from a cone
field_of_view = MOC.from_cone(lon=0*u.deg, lat=0*u.deg, radius=10*u.deg, max_depth=7)
# Check if a position is covered
field_of_view.contains_lonlat(0*u.deg, 0*u.deg) # True
# Combine MOCs with set operations
field_of_view2 = MOC.from_cone(lon=8*u.deg, lat=8*u.deg, radius=5*u.deg, max_depth=7)
coverage = field_of_view | field_of_view2
# Quick preview of the combined field of views
coverage.display_preview()
The example notebooks require additional dependencies. They can be installed with
pip install mocpy[notebooks]
Development installation
Contributions are very welcome. To build and test the library, clone this repository,
make sure that you've got Rust on your machine (https://www.rust-lang.org/tools/install).
Check that the Rust version you have is more recent than the minimal version declared in
Cargo.toml under rust-version and do:
And the library is ready to be edited. After a change on the Rust side, you'll have to
do maturin develop --release again. If you only edit the python side, then a
pip install . at the root of the repository will suffice.
We use pre-commit to keep consistent style conventions between all of us. This means
that your commits will not pass if they require modifications. If this happens, do the
required changes, git add the files again and attempt to commit again as usual.
To run the tests, do:
pip install .[dev]
python -m pytest
The tests that require to download remote data from external servers don't run by
default. To execute them, do: