spacetelescope / PASTIS

Algorithm for analytical contrast predictions of coronagraphs on segmented telescopes
BSD 3-Clause "New" or "Revised" License
8 stars 4 forks source link

Speed up creation of segmented mirror in simulators #160

Open ivalaginja opened 1 year ago

ivalaginja commented 1 year ago

Theh create_segmented_mirror() method in the SegmentedTelescope class takes an awful lot of time and scales with the number of segments: https://github.com/spacetelescope/PASTIS/blob/df1c8110b132a4f29f0dde5ba7b57e6a127c0949/pastis/simulators/generic_segmented_telescopes.py#L647

The current bottleneck is the extention of the mode basis by each new segment. Scipy interprets the transformation matrices in my bases as non-sparse matrices, which makes extend() use a concatenation, which takes an awful lot of time.

My initial idea is to make sure the transformation matrices in the basis is a sparse matrix object by scipy, and then check whether this helps.

In any case, building my mirrors is a one-time operation so it’s not that awful if it takes a long time, but it’s annoying and it would be nice to improve that.

Script that can be used to test that can be found in #159