Comments (5)
Hi all, came across this issue when trying to lookup if mocpy
supported searching for contained coordinates using astropy regions, something like mocpy.contains_region(CircleSkyRegion(my_region))
.
Looks like y'all might already have some working code over on cds-astro/ipyaladin#88 (comment). Wanted to throw my interest and support onto this issue, as it would be incredibly useful for our work at NASA HEASARC/STScI
from mocpy.
Hi, we meet again!
Just to be clear about your needs, the function you suggest would return True
only if the region is entirely comprised in the MOC?
Cause you can already do a bit of a workaround with the existing code:
# Let's create a CircleSkyRegion
from regions import CircleSkyRegion
from astropy.coordinates import SkyCoord, Angle
center = SkyCoord.from_name("m1")
angle = Angle("2d")
circle = CircleSkyRegion(center, radius)
# Now we convert it into a MOC
from mocpy import MOC
small_circle_moc = MOC.from_cone(circle.center.ra, circle.center.dec, radius=circle.radius, max_depth=13)
# Let's define a bigger MOC that encloses it
big_circle_moc = MOC.from_cone(circle.center.ra, circle.center.dec, radius=Angle("4d"), max_depth=13)
# And one that is disjoint
other_part_of_the_sky = MOC.from_str("5/12")
# Let's define the test to see if the small moc is in the big one
def contains(moc1, moc2):
return moc1.union(moc2) == moc1
# And voilà
print(contains(big_circle_moc, small_circle_moc))
print(contains(other_part_of_the_sky, small_circle_moc))
True
False
It is not entirely precise because of the way the cells in the border of the MOC are chosen with respect to the region delimitation, but you might be able to tweak things in your way with the extended
and contracted
methods?
@fxpineau : What do you think about implementing this? We might need bmocs.
from mocpy.
(and otherwise, the from_regions
methods is very high on our lists of things to add. It should come after we converge in ipyaladin
)
from mocpy.
Thanks @ManonMarchand!
Our particular usecase is more "if the region contains any intersection with the MOC" but I imagine that can be easily tweaked by modifying the contains
method you posted.
I think first-order a True/False return (and thus your above snippet) would be sufficient, many thanks! For second order, a formal method that (1) abstracts the above from the user, and possibly (2) returns a mask over the intersection, like the other contains
methods would be a useful feature to have.
from mocpy.
Hi!
We added the support for astropy-regions and this feature will be in the next mocpy's release.
It is now possible to:
- create a moc from an astropy-regions
- test weather this moc intersects or is contained in an other moc with the existing operations between mocs (ex: union, intersect, difference...)
Could you explain a bit more your second point though because I'm not sure I get it.
from mocpy.
Related Issues (20)
- `new_empty` is not implemented for STMOCs
- rewrite doc of MOC.from_ methods
- (corner case) Ban negative indices HOT 6
- MOC to STC-S HOT 3
- MOC overlap with a MRM: calculation of proba in the intersection HOT 14
- MOCServer Cancells request on HST coverage (MOC too big) HOT 3
- MOC sky area HOT 5
- mocpy probability calculation when using multiprocessing HOT 21
- garbage collector stumbles when a MOC is pickled
- Parallelized (on the Rust side) MOC generation HOT 25
- Remove deprecated plot methods
- Multiple Subplotting Issue/help HOT 4
- PyPI wheels for manylinux2014 x86_64 HOT 3
- from_vizier_table returns empty MOC silently on incorrect table names HOT 4
- Max, min, median, average Distance in a region HOT 10
- Support of numpy 2.0 HOT 1
- JSON serialization of empty space MOC fails HOT 2
- moc.union(moc1, moc2) fails with TypeError HOT 5
- `from_healpix_cells` no longer allows HEALPix cells with index 0 HOT 3
- MOC.from_astropy_regions doesn't work with boxes with height > width HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mocpy.