Deterministic atmospheric phase screens  #173
Thanks for your outstanding works. I have read the #169 and #173 When using the `layer.reset()` , I cannot get the initial state（Expectation: the InfiniteAtmosphericLayer hould return the same phase screen every time.）. or maybe `print(layer.phase_for(1))` should be same?.
the code follows:
```
from hcipy import *
import numpy as np
wavelength = 0.5e-6
D_tel = 1
fried_parameter = 0.1
outer_scale = 10
propagate_phase_screen = False
velocity = 10.0  # meters/sec
num_modes = 1000
pupil_grid = make_pupil_grid(64, D_tel)
aperture = make_circular_aperture(D_tel)(pupil_grid)
Cn_squared = Cn_squared_from_fried_parameter(fried_parameter, wavelength)
## add the seed
layer = InfiniteAtmosphericLayer(pupil_grid, Cn_squared, outer_scale, [velocity / np.sqrt(2), velocity / np.sqrt(2)],
                                 use_interpolation=False,seed=1)
layer.reset()
print(layer.phase_for(1))
layer.reset()
print(layer.phase_for(1))
layer.reset(make_independent_realization=True)
print(layer.phase_for(1))
```
and the outputs vary every time 
```
[-2.57236972e-06 -2.70448871e-06 -2.75221671e-06 ...  4.62491109e-06
  4.63627301e-06  4.81470425e-06]
[ 2.06733563e-06  2.08069233e-06  2.17932777e-06 ... -1.82349645e-07
 -2.99504848e-07 -6.31952191e-08]
[ 6.92540580e-07  4.12439742e-07  2.36030268e-07 ... -4.45835357e-07
 -2.77815848e-07 -3.59797936e-07]
```
Is there anything wrong?

diff --git a/hcipy/atmosphere/finite_atmospheric_layer.py b/hcipy/atmosphere/finite_atmospheric_layer.py
index 473c4fb..1409165 100644
--- a/hcipy/atmosphere/finite_atmospheric_layer.py
+++ b/hcipy/atmosphere/finite_atmospheric_layer.py
@@ -80,7 +80,7 @@ class FiniteAtmosphericLayer(AtmosphericLayer):
 		self.psd = power_spectral_density_von_karman(fried_parameter_from_Cn_squared(self.Cn_squared, 1), self.L0)
 
 		self.noise_factory = SpectralNoiseFactoryMultiscale(self.psd, self.input_grid, self.oversampling)
-		self._noise = self.noise_factory.make_random()
+		self._noise = self.noise_factory.make_random(self.rng)
 
 		self._achromatic_screen = None
 
diff --git a/hcipy/atmosphere/infinite_atmospheric_layer.py b/hcipy/atmosphere/infinite_atmospheric_layer.py
index 962b920..1319322 100644
--- a/hcipy/atmosphere/infinite_atmospheric_layer.py
+++ b/hcipy/atmosphere/infinite_atmospheric_layer.py
@@ -205,6 +205,10 @@ class InfiniteAtmosphericLayer(AtmosphericLayer):
 		self._achromatic_screen = layer.phase_for(1)
 		self._shifted_achromatic_screen = self._achromatic_screen
 
+		# Reuse the rng from the temporary layer, since it "forwarded" the randomness.
+		# This avoids reusing the same randomness every call to reset().
+		self.rng = layer.rng
+
 	def _extrude(self, where=None):
 		flipped = (where == 'top') or (where == 'right')
 		horizontal = (where == 'left') or (where == 'right')
diff --git a/tests/test_atmosphere.py b/tests/test_atmosphere.py
index 5580626..020125a 100644
--- a/tests/test_atmosphere.py
+++ b/tests/test_atmosphere.py
@@ -160,6 +160,41 @@ def test_infinite_atmosphere_zernike_variances_in_depth():
 	check_zernike_variances(0.5e-6, 1, 0.3, 10, True)
 	check_zernike_variances(0.5e-6, 1, 0.1, 40, True)
 
+@pytest.mark.parametrize('layer_cls', [InfiniteAtmosphericLayer, FiniteAtmosphericLayer])
+def test_atmospheric_layer_reset(layer_cls):
+	fried_parameter = 0.3  # meter
+	wavelength = 1e-6  # meter
+	velocity = 10.0  # meter / sec
+	pupil_diameter = 8  # meter
+	outer_scale = 20  # meter
+
+	pupil_grid = make_pupil_grid(32, pupil_diameter)
+
+	Cn_squared = Cn_squared_from_fried_parameter(fried_parameter, wavelength)
+	layer = layer_cls(pupil_grid, Cn_squared, outer_scale, [velocity / np.sqrt(2), velocity / np.sqrt(2)])
+
+	phase_1 = layer.phase_for(wavelength)
+	layer.reset(make_independent_realization=False)
+	phase_2 = layer.phase_for(wavelength)
+	layer.reset(make_independent_realization=False)
+	phase_3 = layer.phase_for(wavelength)
+	layer.reset(make_independent_realization=True)
+	phase_4 = layer.phase_for(wavelength)
+	layer.reset(make_independent_realization=False)
+	phase_5 = layer.phase_for(wavelength)
+	layer.evolve_until(1)
+	phase_6 = layer.phase_for(wavelength)
+	layer.reset(make_independent_realization=False)
+	layer.evolve_until(1)
+	phase_7 = layer.phase_for(wavelength)
+
+	assert np.allclose(phase_1, phase_2)
+	assert np.allclose(phase_2, phase_3)
+	assert not np.allclose(phase_3, phase_4)
+	assert np.allclose(phase_4, phase_5)
+	assert not np.allclose(phase_5, phase_6)
+	assert np.allclose(phase_6, phase_7)
+
 def test_multi_layer_atmosphere():
 	r0 = 0.1
 	wavelength = 500e-9
['tests/test_atmosphere.py', 'hcipy/atmosphere/infinite_atmospheric_layer.py', 'hcipy/atmosphere/finite_atmospheric_layer.py']