Skip to content

Commit

Permalink
Merge pull request #93 from brittonsmith/pr92pick
Browse files Browse the repository at this point in the history
backport PR 92 to master
  • Loading branch information
brittonsmith committed Sep 19, 2019
2 parents c5ab106 + 51c67dd commit fc9fd5d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
18 changes: 13 additions & 5 deletions trident/light_ray.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,13 @@ def make_light_ray(self, seed=None, periodic=True,
the dataset redshift for a cosmological dataset.
Default: None.
:field_parameters: optional, dict
Used to set field parameters in light rays. For example,
if the 'bulk_velocity' field parameter is set, the relative
velocities used to calculate peculiar velocity will be adjusted
accordingly.
Default: None.
:njobs: optional, int
The number of parallel jobs over which the segments will
Expand Down Expand Up @@ -514,10 +521,11 @@ def make_light_ray(self, seed=None, periodic=True,
all_fields.extend(['x', 'y', 'z', 'dx', 'dy', 'dz'])
data_fields.extend(['x', 'y', 'z', 'dx', 'dy', 'dz'])
if use_peculiar_velocity:
all_fields.extend(['velocity_x', 'velocity_y', 'velocity_z',
all_fields.extend(['relative_velocity_x', 'relative_velocity_y',
'relative_velocity_z',
'velocity_los', 'redshift_eff',
'redshift_dopp'])
data_fields.extend(['velocity_x', 'velocity_y', 'velocity_z'])
data_fields.extend(['relative_velocity_x', 'relative_velocity_y', 'relative_velocity_z'])

all_ray_storage = {}
for my_storage, my_segment in parallel_objects(self.light_ray_solution,
Expand Down Expand Up @@ -604,9 +612,9 @@ def make_light_ray(self, seed=None, periodic=True,
if use_peculiar_velocity:
line_of_sight = sub_segment[0] - sub_segment[1]
line_of_sight /= ((line_of_sight**2).sum())**0.5
sub_vel = ds.arr([sub_ray['velocity_x'],
sub_ray['velocity_y'],
sub_ray['velocity_z']])
sub_vel = ds.arr([sub_ray['relative_velocity_x'],
sub_ray['relative_velocity_y'],
sub_ray['relative_velocity_z']])
# Line of sight velocity = vel_los
sub_vel_los = (np.rollaxis(sub_vel, 1) * \
line_of_sight).sum(axis=1)
Expand Down
23 changes: 20 additions & 3 deletions trident/ray_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
def make_simple_ray(dataset_file, start_position, end_position,
lines=None, ftype="gas", fields=None,
solution_filename=None, data_filename=None,
trajectory=None, redshift=None,
trajectory=None, redshift=None, field_parameters=None,
setup_function=None, load_kwargs=None,
line_database=None, ionization_table=None):
"""
Expand Down Expand Up @@ -157,6 +157,13 @@ def make_simple_ray(dataset_file, start_position, end_position,
it will use a redshift of 0.
Default: None
:field_parameters: optional, dict
Used to set field parameters in light rays. For example,
if the 'bulk_velocity' field parameter is set, the relative
velocities used to calculate peculiar velocity will be adjusted
accordingly.
Default: None.
:setup_function: function, optional
A function that will be called on the dataset as it is loaded but
Expand Down Expand Up @@ -263,6 +270,7 @@ def make_simple_ray(dataset_file, start_position, end_position,
setup_function=setup_function,
solution_filename=solution_filename,
data_filename=data_filename,
field_parameters=field_parameters,
redshift=redshift)

def make_compound_ray(parameter_filename, simulation_type,
Expand All @@ -272,7 +280,8 @@ def make_compound_ray(parameter_filename, simulation_type,
use_minimum_datasets=True, max_box_fraction=1.0,
deltaz_min=0.0, minimum_coherent_box_fraction=0.0,
seed=None, setup_function=None, load_kwargs=None,
line_database=None, ionization_table=None):
line_database=None, ionization_table=None,
field_parameters = None):
"""
Create a yt LightRay object for multiple consecutive datasets (eg IGM).
This is a wrapper function around yt's LightRay interface to reduce some
Expand Down Expand Up @@ -473,6 +482,13 @@ def make_compound_ray(parameter_filename, simulation_type,
it uses the table specified in ~/.trident/config
Default: None
:field_parameters: optional, dict
Used to set field parameters in light rays. For example,
if the 'bulk_velocity' field parameter is set, the relative
velocities used to calculate peculiar velocity will be adjusted
accordingly.
Default: None.
**Example**
Generate a compound ray passing from the redshift 0 to redshift 0.05
Expand Down Expand Up @@ -581,7 +597,8 @@ def setup_ds(ds):
setup_function=setup_ds,
solution_filename=solution_filename,
data_filename=data_filename,
redshift=None, njobs=-1)
redshift=None, njobs=-1,
field_parameters = field_parameters)

def _determine_ions_from_lines(line_database, lines):
"""
Expand Down

0 comments on commit fc9fd5d

Please sign in to comment.