cds-astro / mocpy

Python library to easily create and manipulate MOCs (Multi-Order Coverage maps)
https://cds-astro.github.io/mocpy/
BSD 3-Clause "New" or "Revised" License
60 stars 33 forks source link

Max, min, median, average Distance in a region #144

Closed santier14 closed 4 months ago

santier14 commented 4 months ago

Hello simiar to probabilities_in_multiordermap(moc,skymap), is it possible to have a function distance_in_multiordermap(moc2,skymap) for GW alerts, because the map is 3D with a distance per pixel in it. Thanks

fxpineau commented 4 months ago

When computing the min/max, if a cell of the multi-order map is partially covered by a MOC, would you ignore or take into account the value (the distance in your case) it contains? For the mean/median, would you consider each value with a weight of 1 or would you like to apply a weight which depends on the surface area of the part of multi-order map cells covered by the MOC? Also, we just made a new MOCPy release, would you have other requirements?

MPillas commented 4 months ago

Hello @fxpineau, I am working with @santier14. If possible, I would consider the value if it is partially covered. For the weights, I think the best in our case would be to return both the associated distance and the weight that depends on the surface area of the part of multi-order map cells covered by the MOC. Is that possible? Thanks!

fxpineau commented 4 months ago

Hi @MPillas,

If I understand correctly, from an API point-of-view, you would like a method MOC.multiordermap_values_and_weigths(self, multiordermap: Table, column: str) returning a numpy table made of 2 columns:

Then, you will be able to compute the min/max/mean/weithed mean/median/... on your side. Does that sound good?

MPillas commented 4 months ago

That would be great, thanks !

fxpineau commented 4 months ago

First implementation (to be tested) made in the Rust part of the code:

MPillas commented 4 months ago

@fxpineau Does this commit have been merged so we can use it?

ManonMarchand commented 4 months ago

Hello, only the rust part is merged for now. We'll do the python port soon

fxpineau commented 4 months ago

@ManonMarchand I just added a method multiorder_filter_mask_in_smoc on the Rust part of the code, see this commit. (Since I added a method in the master of moc-lib-rust, be careful with the cargo cache ;) )

ManonMarchand commented 4 months ago

@MPillas , @santier14 : can you can try the new method (MOC.mask_uniq) in the master branch and tell us if it works for you?

There are two options for the cells that are not entirely in the MOC:

ManonMarchand commented 4 months ago

Implemented in https://github.com/cds-astro/mocpy/pull/151 It will be in the next release