AOtools / aotools

A useful set of tools for Adaptive Optics in Python
GNU Lesser General Public License v3.0
109 stars 43 forks source link

Random seeds in infinite phase screens do not work #61

Closed ojdf closed 2 years ago

ojdf commented 3 years ago

Currently, setting numpy.random.seed(random_seed) in the infinite phase screens does not do anything. I have managed to get the initial screens to be deterministic by passing random_seed to ft_phase_screen when computing the initial screen. However, when rows are added to the screen these are not deterministic.

It seems like using numpy.random.seed is a bad way of trying to get deterministic behaviour from the infinite phase screens, since the fixed seed seems to only apply within the scope of the function in which numpy.random.seed is used?

rjonnal commented 3 years ago

The accepted answer to this s/o question suggests that @ojdf's kludge is the right thing to do: https://stackoverflow.com/questions/50971213/is-there-a-scope-for-numpy-random-seeds.

ojdf commented 3 years ago

just noticed that @andrewpaulreeves has made a fix to this, so you now definitely get the same initial screen if you provide the same seed. But when you add_row() to the screen you still don't get deterministic behaviour so I don't think we can close this yet...