dirac-institute / sorcha

An open-source community LSST Solar System Simulator
Other
18 stars 17 forks source link

Updating FOV filters to use #538

Open mschwamb opened 1 year ago

mschwamb commented 1 year ago

From @mjuric

My high-level note (maybe for future upgrade): it looks like this implements point-in-polygon to test whether an object falls within the camera footprint? I'd advocate against implementing this manually -- use an existing (optimized) library. I did a bit of googling and Shapely seems promising (https://www.matecdev.com/posts/point-in-polygon.html, https://pypi.org/project/shapely/).

Alternatively, I have code from LSD that wraps a C implementation (it's fast): https://github.com/EUPSForge/polygon. Hasn't been updated since Python 2.7, but the math hasn't changed :). That said, think of this as a last resort; (much) better to use a strong 3rd-party library.

It would be good to explore these possibilities and see whether these are faster/better optimized than what we currently have implemented in the FOV filter and the FOV edge case filter

bernardinelli commented 1 year ago

Matplotlib's patches.Patch can do this: https://matplotlib.org/stable/api/_as_gen/matplotlib.patches.Patch.html (contains_points), but my experience is that it's not particularly fast. Is this for the general camera footprint or for each CCD? (In the CCD case, if we can live with the assumption that it's a rectangle in a tangent plane, this can be done very efficiency with, eg, kD trees)