Skip to content

Commit

Permalink
add option for backwards compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
adrn committed Feb 14, 2024
1 parent dc9b6bd commit 6ae9ff1
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions gala/dynamics/mockstream/df.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -326,13 +326,22 @@ cdef class FardalStreamDF(BaseStreamDF):
Parameters
----------
gala_modified : bool (optional)
If True, use the modified version of the Fardal method parameters used in Gala. If you would like to use the exact parameters from Fardal+2015, set this to False. Default: True.
lead : bool (optional)
Generate a leading tail. Default: True.
trail : bool (optional)
Generate a trailing tail. Default: True.
random_state : `~numpy.random.RandomState` (optional)
To control random number generation.
"""
def __init__(
self, gala_modified=True, lead=True, trail=True, random_state=None
):
super().__init__(lead=lead, trail=trail, random_state=random_state)
self._gala_modified = bool(gala_modified)


cpdef _sample(self, potential,
double[:, ::1] prog_x, double[:, ::1] prog_v,
double[::1] prog_t, double[::1] prog_m, int[::1] nparticles):
Expand Down Expand Up @@ -360,14 +369,19 @@ cdef class FardalStreamDF(BaseStreamDF):
CPotential cpotential = (<CPotentialWrapper>(potential.c_instance)).cpotential
double G = potential.G

# TODO: support computing this, which requires knowing the peri/apo and values
# of Om**2 - d2Phi/dr2 at those points...
# kvt_fardal = min(0.15 * self.f_t**2 * Racc**(2/3), 0.4)
kvt_fardal = 0.4

k_mean[0] = 2. # R
k_disp[0] = 0.4
k_disp[0] = 0.5 if self._gala_modified else 0.4

k_mean[2] = 0. # z
k_disp[2] = 0.5

k_mean[4] = 0.3 # vt
k_disp[4] = 0.4
k_disp[4] = 0.5 if self._gala_modified else kvt_fardal

k_mean[5] = 0. # vz
k_disp[5] = 0.5
Expand All @@ -388,6 +402,8 @@ cdef class FardalStreamDF(BaseStreamDF):
tmp_x[0] = kx * rj
tmp_x[2] = self.random_state.normal(k_mean[2], k_disp[2]) * rj
tmp_v[1] = self.random_state.normal(k_mean[4], k_disp[4]) * vj
if self._gala_modified: # for backwards compatibility
tmp_v[1] *= kx
tmp_v[2] = self.random_state.normal(k_mean[5], k_disp[5]) * vj
particle_t1[j+k] = prog_t[i]

Expand All @@ -406,6 +422,8 @@ cdef class FardalStreamDF(BaseStreamDF):
tmp_x[0] = kx * -rj
tmp_x[2] = self.random_state.normal(k_mean[2], k_disp[2]) * -rj
tmp_v[1] = self.random_state.normal(k_mean[4], k_disp[4]) * -vj
if self._gala_modified: # for backwards compatibility
tmp_v[1] *= kx
tmp_v[2] = self.random_state.normal(k_mean[5], k_disp[5]) * -vj
particle_t1[j+k] = prog_t[i]

Expand Down

0 comments on commit 6ae9ff1

Please sign in to comment.