From 44facf4d4dc5f9abdc7f1266835323d9ab0ee3d3 Mon Sep 17 00:00:00 2001 From: Thomas Pugnat Date: Fri, 20 Jan 2023 11:32:53 +0100 Subject: [PATCH 1/2] Angle interval is now an argument of generate_initial_random + change function name for consistency --- xdyna/da.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/xdyna/da.py b/xdyna/da.py index 8ae4b32..8d430d7 100644 --- a/xdyna/da.py +++ b/xdyna/da.py @@ -428,8 +428,8 @@ def generate_initial_radial(self, *, angles, r_min, r_max, r_step=None, r_num=No # Not allowed on parallel process - def generate_random_initial(self, *, num_part=1000, r_max=25, px_norm=0, py_norm=0, zeta=0, delta=0.00027, - normalised_emittance=None, nseeds=None, pairs_shift=0, pairs_shift_var=None): + def generate_initial_random(self, *, num_part=1000, r_max=25, px_norm=0, py_norm=0, zeta=0, delta=0.00027, ang_min=None, + ang_max=None, normalised_emittance=None, nseeds=None, pairs_shift=0, pairs_shift_var=None): """Generate the initial conditions in a 2D random grid. """ @@ -437,19 +437,18 @@ def generate_random_initial(self, *, num_part=1000, r_max=25, px_norm=0, py_norm # Make the data rng = default_rng() + ang_min = 0 if ang_min is None else ang_min + ang_max = 90 if ang_max is None else ang_max if self.meta.nseeds > 0: r = rng.uniform(low=0, high=r_max**2, size=num_part*self.meta.nseeds) - r = np.sqrt(r) - th = rng.uniform(low=0, high=2*np.pi, size=num_part*self.meta.nseeds) - x = r*np.cos(th) - y = r*np.sin(th) + th = rng.uniform(low=ang_min, high=ang_max*np.pi/180, size=num_part*self.meta.nseeds) seeds = np.repeat(np.arange(1,self.meta.nseeds+1), num_part) else: r = rng.uniform(low=0, high=r_max**2, size=num_part) - r = np.sqrt(r) - th = rng.uniform(low=0, high=2*np.pi, size=num_part) - x = r*np.cos(th) - y = r*np.sin(th) + th = rng.uniform(low=ang_min, high=ang_max*np.pi/180, size=num_part) + r = np.sqrt(r) + x = r*np.cos(th) + y = r*np.sin(th) # Make dataframe self._surv = pd.DataFrame() From 408317306991d71403f9ce25ee49095d34145d9a Mon Sep 17 00:00:00 2001 From: tpugnat Date: Mon, 23 Jan 2023 11:06:51 +0100 Subject: [PATCH 2/2] generate_initial_random -> generate_random_initial --- xdyna/da.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xdyna/da.py b/xdyna/da.py index 8d430d7..9badddd 100644 --- a/xdyna/da.py +++ b/xdyna/da.py @@ -428,7 +428,7 @@ def generate_initial_radial(self, *, angles, r_min, r_max, r_step=None, r_num=No # Not allowed on parallel process - def generate_initial_random(self, *, num_part=1000, r_max=25, px_norm=0, py_norm=0, zeta=0, delta=0.00027, ang_min=None, + def generate_random_initial(self, *, num_part=1000, r_max=25, px_norm=0, py_norm=0, zeta=0, delta=0.00027, ang_min=None, ang_max=None, normalised_emittance=None, nseeds=None, pairs_shift=0, pairs_shift_var=None): """Generate the initial conditions in a 2D random grid. """