<html><body>
<p>10 new commits in yt:</p>
<p><a href="https://bitbucket.org/yt_analysis/yt/commits/0bbd1eab3681/">https://bitbucket.org/yt_analysis/yt/commits/0bbd1eab3681/</a> Changeset:   0bbd1eab3681 Branch:      yt User:        chummels Date:        2016-05-05 01:32:12+00:00 Summary:     Making it so LightRay will accept a dataset instead of just the filename of a dataset. Affected #:  1 file</p>
<p>diff -r 2f2c9e84c335e5d4be9c4eac86b1f67aed7e752f -r 0bbd1eab36818b307d83fb0bd9fc1829efdf9942 yt/analysis_modules/cosmological_observation/light_ray/light_ray.py --- a/yt/analysis_modules/cosmological_observation/light_ray/light_ray.py +++ b/yt/analysis_modules/cosmological_observation/light_ray/light_ray.py @@ -31,6 +31,7 @@</p>
<pre>    parallel_objects, \
    parallel_root_only
from yt.utilities.physical_constants import speed_of_light_cgs</pre>
<p>+from yt.data_objects.static_output import Dataset</p>
<pre>class LightRay(CosmologySplice):
    """</pre>
<p>@@ -130,24 +131,34 @@</p>
<pre>        self.light_ray_solution = []
        self._data = {}
</pre>
<ul><li><p># Make a light ray from a single, given dataset.</p></li>
<li><p>if simulation_type is None:</p></li></ul>
<p>+        # The options here are: +        # 1) User passed us a dataset: use it to make a simple ray +        # 2) User passed us a dataset filename: use it to make a simple ray +        # 3) User passed us a simulation filename: use it to make a compound ray + +        # Make a light ray from a single, given dataset: #1, #2 +        if simulation_type is None:</p>
<pre>self.simulation_type = simulation_type</pre>
<ul><li><p>ds = load(parameter_filename, **self.load_kwargs)</p></li>
<li><p>if ds.cosmological_simulation:</p></li>
<li><p>redshift = ds.current_redshift</p></li></ul>
<p>+            if isinstance(parameter_filename, Dataset): +                self.ds = parameter_filename +                self.parameter_filename = self.ds.basename +            elif isinstance(parameter_filename, str): +                self.ds = load(parameter_filename, **self.load_kwargs) +            if self.ds.cosmological_simulation: +                redshift = self.ds.current_redshift</p>
<pre>self.cosmology = Cosmology(</pre>
<ul><li><p>hubble_constant=ds.hubble_constant,</p></li>
<li><p>omega_matter=ds.omega_matter,</p></li>
<li><p>omega_lambda=ds.omega_lambda,</p></li>
<li><p>unit_registry=ds.unit_registry)</p></li></ul>
<p>+                    hubble_constant=self.ds.hubble_constant, +                    omega_matter=self.ds.omega_matter, +                    omega_lambda=self.ds.omega_lambda, +                    unit_registry=self.ds.unit_registry)</p>
<pre>            else:
                redshift = 0.
            self.light_ray_solution.append({"filename": parameter_filename,
                                            "redshift": redshift})
</pre>
<ul><li><p># Make a light ray from a simulation time-series.</p></li></ul>
<p>+        # Make a light ray from a simulation time-series. #3</p>
<pre>else:</pre>
<p>+            self.ds = None</p>
<pre># Get list of datasets for light ray solution.
CosmologySplice.__init__(self, parameter_filename, simulation_type,
                         find_outputs=find_outputs)</pre>
<p>@@ -383,8 +394,12 @@</p>
<pre>                                                       storage=all_ray_storage,
                                                       njobs=njobs):
</pre>
<ul><li><p># Load dataset for segment.</p></li>
<li><p>ds = load(my_segment['filename'], **self.load_kwargs)</p></li></ul>
<p>+            # In case of simple rays, use the already loaded dataset: self.ds, +            # otherwise, load dataset for segment. +            if self.ds is None: +                ds = load(my_segment['filename'], **self.load_kwargs) +            else: +                ds = self.ds</p>
<pre>my_segment['unique_identifier'] = ds.unique_identifier
if redshift is not None:</pre>
<p>@@ -555,7 +570,7 @@</p>
<pre>Write light ray data to hdf5 file.
"""
if self.simulation_type is None:</pre>
<ul><li><p>ds = load(self.parameter_filename, **self.load_kwargs)</p></li></ul>
<p>+            ds = self.ds</p>
<pre>         else:
ds = {}
ds["dimensionality"] = self.simulation.dimensionality</pre>
<p><a href="https://bitbucket.org/yt_analysis/yt/commits/3d126df4b1b6/">https://bitbucket.org/yt_analysis/yt/commits/3d126df4b1b6/</a> Changeset:   3d126df4b1b6 Branch:      yt User:        chummels Date:        2016-05-05 01:48:51+00:00 Summary:     Updating docstrings for LightRay to reflect changes. Affected #:  1 file</p>
<p>diff -r 0bbd1eab36818b307d83fb0bd9fc1829efdf9942 -r 3d126df4b1b6d832cf447863c983e2ee80b6b562 yt/analysis_modules/cosmological_observation/light_ray/light_ray.py --- a/yt/analysis_modules/cosmological_observation/light_ray/light_ray.py +++ b/yt/analysis_modules/cosmological_observation/light_ray/light_ray.py @@ -35,21 +35,22 @@</p>
<pre>class LightRay(CosmologySplice):
    """</pre>
<ul><li><p>LightRay(parameter_filename, simulation_type=None,</p></li></ul>
<p>+    LightRay(dataset/filename, simulation_type=None,</p>
<pre>             near_redshift=None, far_redshift=None,
             use_minimum_datasets=True, deltaz_min=0.0,
             minimum_coherent_box_fraction=0.0,
             time_data=True, redshift_data=True,
             find_outputs=False, load_kwargs=None):
</pre>
<ul><li><p>Create a LightRay object.  A light ray is much like a light cone,</p></li>
<li><p>in that it stacks together multiple datasets in order to extend a</p></li>
<li><p>redshift interval.  Unlike a light cone, which does randomly</p></li>
<li><p>oriented projections for each dataset, a light ray consists of</p></li>
<li><p>randomly oriented single rays.  The purpose of these is to create</p></li>
<li><p>synthetic QSO lines of sight.</p></li></ul>
<p>–</p>
<ul><li><p>Light rays can also be made from single datasets.</p></li></ul>
<p>+    A LightRay object is a one-dimensional object representing the trajectory +    of a ray of light as it passes through one or more datasets (simple and +    compound rays respectively).  One can sample any of the fields intersected +    by the LightRay object as it passed through the dataset(s). + +    For compound rays, the LightRay stacks together multiple datasets in a time +    series in order to approximate a LightRay's path through a volume +    and redshift interval larger than a single simulation data output. +    The outcome is something akin to a synthetic QSO line of sight.</p>
<pre>Once the LightRay object is set up, use LightRay.make_light_ray to
begin making rays.  Different randomizations can be created with a</pre>
<p>@@ -57,31 +58,32 @@</p>
<pre>Parameters
----------</pre>
<ul><li><p>parameter_filename : string</p></li>
<li><p>The path to the simulation parameter file or dataset.</p></li></ul>
<p>+    dataset/filename : string or dataset +        For simple rays, one must pass either a loaded dataset object or +        the path and filename of a dataset. +        For compound rays, one must pass the path and filename of the simulation +        parameter file.</p>
<pre>simulation_type : optional, string</pre>
<ul><li><p>The simulation type.  If None, the first argument is assumed to</p></li>
<li><p>refer to a single dataset.</p></li></ul>
<p>+        This refers to the simulation frontend type.  Do not use for simple +        rays.</p>
<pre>    Default: None
near_redshift : optional, float
    The near (lowest) redshift for a light ray containing multiple</pre>
<ul><li><p>datasets.  Do not use if making a light ray from a single</p></li>
<li><p>dataset.</p></li></ul>
<p>+        datasets.  Do not use for simple rays.</p>
<pre>    Default: None
far_redshift : optional, float
    The far (highest) redshift for a light ray containing multiple</pre>
<ul><li><p>datasets.  Do not use if making a light ray from a single</p></li>
<li><p>dataset.</p></li></ul>
<p>+        datasets.  Do not use for simple rays.</p>
<pre>    Default: None
use_minimum_datasets : optional, bool
    If True, the minimum number of datasets is used to connect the
    initial and final redshift.  If false, the light ray solution
    will contain as many entries as possible within the redshift</pre>
<ul><li><p>interval.</p></li></ul>
<p>+        interval.  Do not use for simple rays.</p>
<pre>    Default: True.
deltaz_min : optional, float
    Specifies the minimum :math:`\Delta z` between consecutive</pre>
<ul><li><p>datasets in the returned list.</p></li></ul>
<p>+        datasets in the returned list.  Do not use for simple rays.</p>
<pre>    Default: 0.0.
minimum_coherent_box_fraction : optional, float
    Used with use_minimum_datasets set to False, this parameter</pre>
<p>@@ -89,23 +91,26 @@</p>
<pre>before rerandomizing the projection axis and center.  This
was invented to allow light rays with thin slices to sample
coherent large scale structure, but in practice does not work</pre>
<ul><li><p>so well.  Try setting this parameter to 1 and see what happens.</p></li></ul>
<p>+        so well.  Try setting this parameter to 1 and see what happens. +        Do not use for simple rays.</p>
<pre>    Default: 0.0.
time_data : optional, bool
    Whether or not to include time outputs when gathering</pre>
<ul><li><p>datasets for time series.</p></li></ul>
<p>+        datasets for time series.  Do not use for simple rays.</p>
<pre>    Default: True.
redshift_data : optional, bool
    Whether or not to include redshift outputs when gathering</pre>
<ul><li><p>datasets for time series.</p></li></ul>
<p>+        datasets for time series.  Do not use for simple rays.</p>
<pre>    Default: True.
find_outputs : optional, bool
    Whether or not to search for datasets in the current</pre>
<ul><li><p>directory.</p></li></ul>
<p>+        directory.  Do not use for simple rays.</p>
<pre>    Default: False.
load_kwargs : optional, dict</pre>
<ul><li><p>Optional dictionary of kwargs to be passed to the “load”</p></li>
<li><p>function, appropriate for use of certain frontends.  E.g.</p></li></ul>
<p>+        If you are passing a filename of a dataset to LightRay rather than an +        already loaded dataset, then you can optionally provide this dictionary +        as keywords when the dataset is loaded by yt with the “load” function. +        Necessary for use with certain frontends.  E.g.</p>
<pre>Tipsy using "bounding_box"
Gadget using "unit_base", etc.
Default : None</pre>
<p>@@ -281,7 +286,7 @@</p>
<pre>Create a light ray and get field values for each lixel.  A light
ray consists of a list of field values for cells intersected by
the ray and the path length of the ray through those cells.</pre>
<ul><li><p>Light ray data can be written out to an hdf5 file.</p></li></ul>
<p>+        Light ray data must be written out to an hdf5 file.</p>
<pre>Parameters
----------</pre>
<p><a href="https://bitbucket.org/yt_analysis/yt/commits/50dba45ad90f/">https://bitbucket.org/yt_analysis/yt/commits/50dba45ad90f/</a> Changeset:   50dba45ad90f Branch:      yt User:        chummels Date:        2016-05-05 02:33:16+00:00 Summary:     Adding tests for light_ray analysis module. Affected #:  2 files</p>
<p>diff -r 3d126df4b1b6d832cf447863c983e2ee80b6b562 -r 50dba45ad90f881fbf8d0cdb5097e65614fcdbf1 yt/analysis_modules/cosmological_observation/light_ray/tests/test_light_ray.py --- /dev/null +++ b/yt/analysis_modules/cosmological_observation/light_ray/tests/test_light_ray.py @@ -0,0 +1,104 @@ +""" +Unit test for the light_ray analysis module +""" + +#----------------------------------------------------------------------------- +# Copyright © 2016, yt Development Team. +# +# Distributed under the terms of the Modified BSD License. +# +# The full license is in the file COPYING.txt, distributed with this software. +#----------------------------------------------------------------------------- + +import numpy as np +from yt.testing import \ +    assert_allclose_units, requires_file, requires_module, \ +    assert_almost_equal +from yt.analysis_modules.absorption_spectrum.absorption_line import \ +    voigt_old, voigt_scipy +from yt.analysis_modules.absorption_spectrum.api import AbsorptionSpectrum +from yt.analysis_modules.cosmological_observation.api import LightRay +from yt.utilities.answer_testing.framework import \ +    GenericArrayTest, \ +    requires_answer_testing +import tempfile +import os +import shutil +from yt.utilities.on_demand_imports import \ +    _h5py as h5 +from yt import load + + +COSMO_PLUS = “enzo_cosmology_plus/AMRCosmology.enzo” +COSMO_PLUS_SINGLE = “enzo_cosmology_plus/RD0009/RD0009” + + +@requires_file(COSMO_PLUS) +def test_light_ray_cosmo(): +    """ +    This test generates a cosmological light ray +    """ +    # Set up in a temp dir +    tmpdir = tempfile.mkdtemp() +    curdir = os.getcwd() +    os.chdir(tmpdir) + +    lr = LightRay(COSMO_PLUS, ‘Enzo’, 0.0, 0.03) + +    lr.make_light_ray(seed=1234567, +                      fields=['temperature', ‘density’, ‘H_number_density'], +                      data_filename='lightray.h5’) + +    # clean up +    os.chdir(curdir) +    shutil.rmtree(tmpdir) + + +@requires_file(COSMO_PLUS_SINGLE) +def test_light_ray_non_cosmo(): +    """ +    This test generates a non-cosmological light ray +    """ + +    # Set up in a temp dir +    tmpdir = tempfile.mkdtemp() +    curdir = os.getcwd() +    os.chdir(tmpdir) + +    lr = LightRay(COSMO_PLUS_SINGLE) + +    ray_start = [0,0,0] +    ray_end = [1,1,1] +    lr.make_light_ray(start_position=ray_start, end_position=ray_end, +                      fields=['temperature', ‘density’, ‘H_number_density'], +                      data_filename='lightray.h5’) + +    # clean up +    os.chdir(curdir) +    shutil.rmtree(tmpdir) + +@requires_file(COSMO_PLUS_SINGLE) +def test_light_ray_non_cosmo_from_dataset(): +    """ +    This test generates a non-cosmological light ray created from an already +    loaded dataset +    """ + +    # Set up in a temp dir +    tmpdir = tempfile.mkdtemp() +    curdir = os.getcwd() +    os.chdir(tmpdir) + +    ds = load(COSMO_PLUS_SINGLE) +    lr = LightRay(ds) + +    ray_start = [0,0,0] +    ray_end = [1,1,1] +    lr.make_light_ray(start_position=ray_start, end_position=ray_end, +                      fields=['temperature', ‘density’, ‘H_number_density'], +                      data_filename='lightray.h5’) + +    # clean up +    os.chdir(curdir) +    shutil.rmtree(tmpdir) +</p>
<p><a href="https://bitbucket.org/yt_analysis/yt/commits/bfa7b16eb9e0/">https://bitbucket.org/yt_analysis/yt/commits/bfa7b16eb9e0/</a> Changeset:   bfa7b16eb9e0 Branch:      yt User:        chummels Date:        2016-05-05 02:36:39+00:00 Summary:     Updating cookbook recipe to reflect new way to generate LightRays Affected #:  1 file</p>
<p>diff -r 50dba45ad90f881fbf8d0cdb5097e65614fcdbf1 -r bfa7b16eb9e0532758d2acc2e933c992731fc4e0 doc/source/cookbook/single_dataset_light_ray.py --- a/doc/source/cookbook/single_dataset_light_ray.py +++ b/doc/source/cookbook/single_dataset_light_ray.py @@ -3,8 +3,8 @@</p>
<pre>from yt.analysis_modules.cosmological_observation.api import \
    LightRay
</pre>
<p>-fn = “IsolatedGalaxy/galaxy0030/galaxy0030” -lr = LightRay(fn) +ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030") +lr = LightRay(ds)</p>
<pre># With a single dataset, a start_position and
# end_position or trajectory must be given.</pre>
<p><a href="https://bitbucket.org/yt_analysis/yt/commits/4afcca78a729/">https://bitbucket.org/yt_analysis/yt/commits/4afcca78a729/</a> Changeset:   4afcca78a729 Branch:      yt User:        chummels Date:        2016-05-05 05:01:55+00:00 Summary:     Correcting typo in light_ray cookbook recipe. Affected #:  1 file</p>
<p>diff -r bfa7b16eb9e0532758d2acc2e933c992731fc4e0 -r 4afcca78a7295accb48d89ac746d37028c6af85b doc/source/cookbook/single_dataset_light_ray.py --- a/doc/source/cookbook/single_dataset_light_ray.py +++ b/doc/source/cookbook/single_dataset_light_ray.py @@ -17,7 +17,6 @@</p>
<pre># Optionally, we can now overplot this ray on a projection of the source
# dataset</pre>
<p>-ds = yt.load(fn)</p>
<pre>p = yt.ProjectionPlot(ds, 'z', 'density')
p.annotate_ray(lr)
p.save()</pre>
<p><a href="https://bitbucket.org/yt_analysis/yt/commits/fad103b9515d/">https://bitbucket.org/yt_analysis/yt/commits/fad103b9515d/</a> Changeset:   fad103b9515d Branch:      yt User:        chummels Date:        2016-05-05 05:04:38+00:00 Summary:     Getting rid of extra unused imports in test_light_ray test. Affected #:  1 file</p>
<p>diff -r 4afcca78a7295accb48d89ac746d37028c6af85b -r fad103b9515d94e3523bbf8785e3a98242d84d6e yt/analysis_modules/cosmological_observation/light_ray/tests/test_light_ray.py --- a/yt/analysis_modules/cosmological_observation/light_ray/tests/test_light_ray.py +++ b/yt/analysis_modules/cosmological_observation/light_ray/tests/test_light_ray.py @@ -10,29 +10,17 @@</p>
<pre># The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
</pre>
<p>-import numpy as np</p>
<pre>from yt.testing import \</pre>
<ul><li><p>assert_allclose_units, requires_file, requires_module, \</p></li>
<li><p>assert_almost_equal</p></li></ul>
<p>-from yt.analysis_modules.absorption_spectrum.absorption_line import \</p>
<ul><li><p>voigt_old, voigt_scipy</p></li></ul>
<p>-from yt.analysis_modules.absorption_spectrum.api import AbsorptionSpectrum +    requires_file</p>
<pre>from yt.analysis_modules.cosmological_observation.api import LightRay</pre>
<p>-from yt.utilities.answer_testing.framework import \</p>
<ul><li><p>GenericArrayTest, \</p></li>
<li><p>requires_answer_testing</p></li></ul>
<p>-import tempfile</p>
<pre>import os
import shutil</pre>
<p>-from yt.utilities.on_demand_imports import \</p>
<ul><li><p>_h5py as h5</p></li></ul>
<pre>from yt import load</pre>
<p>– +import tempfile</p>
<pre>COSMO_PLUS = "enzo_cosmology_plus/AMRCosmology.enzo"
COSMO_PLUS_SINGLE = "enzo_cosmology_plus/RD0009/RD0009"
</pre>
<p>–</p>
<pre>@requires_file(COSMO_PLUS)
def test_light_ray_cosmo():
    """</pre>
<p><a href="https://bitbucket.org/yt_analysis/yt/commits/c390d655f2ff/">https://bitbucket.org/yt_analysis/yt/commits/c390d655f2ff/</a> Changeset:   c390d655f2ff Branch:      yt User:        chummels Date:        2016-05-06 00:16:24+00:00 Summary:     Correcting problems pointed out in PR comments. Affected #:  1 file</p>
<p>diff -r fad103b9515d94e3523bbf8785e3a98242d84d6e -r c390d655f2ffd8dce3e49bba11ad7cae2ffb68d3 yt/analysis_modules/cosmological_observation/light_ray/light_ray.py --- a/yt/analysis_modules/cosmological_observation/light_ray/light_ray.py +++ b/yt/analysis_modules/cosmological_observation/light_ray/light_ray.py @@ -35,13 +35,6 @@</p>
<pre>class LightRay(CosmologySplice):
    """</pre>
<ul><li><p>LightRay(dataset/filename, simulation_type=None,</p></li>
<li><p>near_redshift=None, far_redshift=None,</p></li>
<li><p>use_minimum_datasets=True, deltaz_min=0.0,</p></li>
<li><p>minimum_coherent_box_fraction=0.0,</p></li>
<li><p>time_data=True, redshift_data=True,</p></li>
<li><p>find_outputs=False, load_kwargs=None):</p></li></ul>
<p>–</p>
<pre>A LightRay object is a one-dimensional object representing the trajectory
of a ray of light as it passes through one or more datasets (simple and
compound rays respectively).  One can sample any of the fields intersected</pre>
<p>@@ -58,10 +51,10 @@</p>
<pre>Parameters
----------</pre>
<ul><li><p>dataset/filename : string or dataset</p></li>
<li><p>For simple rays, one must pass either a loaded dataset object or</p></li>
<li><p>the path and filename of a dataset.</p></li>
<li><p>For compound rays, one must pass the path and filename of the simulation</p></li></ul>
<p>+    parameter_filename : string or :class:`yt.data_objects.static_output.Dataset` +        For simple rays, one may pass either a loaded dataset object or +        the filename of a dataset. +        For compound rays, one must pass the filename of the simulation</p>
<pre>    parameter file.
simulation_type : optional, string
    This refers to the simulation frontend type.  Do not use for simple</pre>
<p>@@ -144,11 +137,11 @@</p>
<pre>         # Make a light ray from a single, given dataset: #1, #2
         if simulation_type is None:
self.simulation_type = simulation_type</pre>
<ul><li><p>if isinstance(parameter_filename, Dataset):</p></li>
<li><p>self.ds = parameter_filename</p></li></ul>
<p>+            if isinstance(self.parameter_filename, Dataset): +                self.ds = self.parameter_filename</p>
<pre>self.parameter_filename = self.ds.basename</pre>
<ul><li><p>elif isinstance(parameter_filename, str):</p></li>
<li><p>self.ds = load(parameter_filename, **self.load_kwargs)</p></li></ul>
<p>+            elif isinstance(self.parameter_filename, str): +                self.ds = load(self.parameter_filename, **self.load_kwargs)</p>
<pre>if self.ds.cosmological_simulation:
    redshift = self.ds.current_redshift
    self.cosmology = Cosmology(</pre>
<p>@@ -158,14 +151,15 @@</p>
<pre>        unit_registry=self.ds.unit_registry)
else:
    redshift = 0.</pre>
<ul><li><p>self.light_ray_solution.append({"filename": parameter_filename,</p></li></ul>
<p>+            self.light_ray_solution.append({"filename": self.parameter_filename,</p>
<pre>                                            "redshift": redshift})

        # Make a light ray from a simulation time-series. #3
        else:
            self.ds = None</pre>
<p>+            assert isinstance(self.parameter_filename, str)</p>
<pre># Get list of datasets for light ray solution.</pre>
<ul><li><p>CosmologySplice.__init__(self, parameter_filename, simulation_type,</p></li></ul>
<p>+            CosmologySplice.__init__(self, self.parameter_filename, simulation_type,</p>
<pre>                         find_outputs=find_outputs)
self.light_ray_solution = \
  self.create_cosmology_splice(self.near_redshift, self.far_redshift,</pre>
<p><a href="https://bitbucket.org/yt_analysis/yt/commits/75ae4d87e5bf/">https://bitbucket.org/yt_analysis/yt/commits/75ae4d87e5bf/</a> Changeset:   75ae4d87e5bf Branch:      yt User:        chummels Date:        2016-05-06 00:18:09+00:00 Summary:     Updating LightRay tests to not have a global yt import. Affected #:  1 file</p>
<p>diff -r c390d655f2ffd8dce3e49bba11ad7cae2ffb68d3 -r 75ae4d87e5bfdbaf28159be0ce89af021121c4bd yt/analysis_modules/cosmological_observation/light_ray/tests/test_light_ray.py --- a/yt/analysis_modules/cosmological_observation/light_ray/tests/test_light_ray.py +++ b/yt/analysis_modules/cosmological_observation/light_ray/tests/test_light_ray.py @@ -15,7 +15,7 @@</p>
<pre>from yt.analysis_modules.cosmological_observation.api import LightRay
import os
import shutil</pre>
<p>-from yt import load +from yt.utilities.answer_testing.framework import data_dir_load</p>
<pre>import tempfile

COSMO_PLUS = "enzo_cosmology_plus/AMRCosmology.enzo"</pre>
<p>@@ -77,7 +77,7 @@</p>
<pre>    curdir = os.getcwd()
    os.chdir(tmpdir)
</pre>
<ul><li><p>ds = load(COSMO_PLUS_SINGLE)</p></li></ul>
<p>+    ds = data_dir_load(COSMO_PLUS_SINGLE)</p>
<pre>    lr = LightRay(ds)

    ray_start = [0,0,0]</pre>
<p><a href="https://bitbucket.org/yt_analysis/yt/commits/3941e80752c7/">https://bitbucket.org/yt_analysis/yt/commits/3941e80752c7/</a> Changeset:   3941e80752c7 Branch:      yt User:        chummels Date:        2016-05-06 00:18:45+00:00 Summary:     Merging with tip. Affected #:  2 files</p>
<p>diff -r 75ae4d87e5bfdbaf28159be0ce89af021121c4bd -r 3941e80752c732b9f0a58148610131764632a5a3 yt/geometry/oct_container.pyx --- a/yt/geometry/oct_container.pyx +++ b/yt/geometry/oct_container.pyx @@ -317,6 +317,41 @@</p>
<pre>        oinfo.level = level
        return cur
</pre>
<p>+    def locate_positions(self, np.float64_t[:,:] positions): +        """ +        This routine, meant to be called by other internal routines, returns a +        list of oct IDs and a dictionary of Oct info for all the positions +        supplied.  Positions must be in code_length. +        """ +        cdef np.float64_t factor = (1 << self.oref) +        cdef dict all_octs = {} +        cdef OctInfo oi +        cdef Oct* o = NULL +        cdef np.float64_t pos[3] +        cdef np.ndarray[np.uint8_t, ndim=1] recorded +        cdef np.ndarray[np.int64_t, ndim=1] oct_id +        oct_id = np.ones(positions.shape[0], dtype="int64") * -1 +        recorded = np.zeros(self.nocts, dtype="uint8") +        cdef np.int64_t i, j, k +        for i in range(positions.shape[0]): +            for j in range(3): +                pos[j] = positions[i,j] +            o = self.get(pos, &oi) +            if o == NULL: +                raise RuntimeError +            if recorded[o.domain_ind] == 0: +                left_edge = np.asarray(<np.float64_t[:3]>oi.left_edge).copy() +                dds = np.asarray(<np.float64_t[:3]>oi.dds).copy() +                right_edge = left_edge + dds*factor +                all_octs[o.domain_ind] = dict( +                    left_edge = left_edge, +                    right_edge = right_edge, +                    level = oi.level +                ) +                recorded[o.domain_ind] = 1 +            oct_id[i] = o.domain_ind +        return oct_id, all_octs +</p>
<pre>def domain_identify(self, SelectorObject selector):
    cdef np.ndarray[np.uint8_t, ndim=1] domain_mask
    domain_mask = np.zeros(self.num_domains, dtype="uint8")</pre>
<p>diff -r 75ae4d87e5bfdbaf28159be0ce89af021121c4bd -r 3941e80752c732b9f0a58148610131764632a5a3 yt/geometry/tests/test_particle_octree.py --- a/yt/geometry/tests/test_particle_octree.py +++ b/yt/geometry/tests/test_particle_octree.py @@ -209,6 +209,24 @@</p>
<pre>        i[0](*i[1:])
    time.sleep(1)
</pre>
<p>+def test_position_location(): +    np.random.seed(int(0x4d3d3d3)) +    pos = np.random.normal(0.5, scale=0.05, size=(NPART,3)) * (DRE-DLE) + DLE +    # Now convert to integers +    data = {} +    bbox = [] +    for i, ax in enumerate('xyz'): +        np.clip(pos[:,i], DLE[i], DRE[i], pos[:,i]) +        bbox.append([DLE[i], DRE[i]]) +        data["particle_position_%s" % ax] = pos[:,i] +    bbox = np.array(bbox) +    ds = load_particles(data, 1.0, bbox = bbox, over_refine_factor = 2) +    oct_id, all_octs = ds.index.oct_handler.locate_positions(pos) +    for oi in sorted(all_octs): +        this_oct = pos[oct_id == oi] +        assert(np.all(this_oct >= all_octs[oi]["left_edge"])) +        assert(np.all(this_oct <= all_octs[oi]["right_edge"])) +</p>
<pre>os33 = "snapshot_033/snap_033.0.hdf5"
@requires_file(os33)
def test_get_smallest_dx():</pre>
<p><a href="https://bitbucket.org/yt_analysis/yt/commits/5ffd0fbe9057/">https://bitbucket.org/yt_analysis/yt/commits/5ffd0fbe9057/</a> Changeset:   5ffd0fbe9057 Branch:      yt User:        ngoldbaum Date:        2016-05-11 19:26:20+00:00 Summary:     Merged in chummels/yt (pull request #2158)</p>
<p>Enabling LightRay to accept loaded datasets instead of just filenames Affected #:  4 files</p>
<p>diff -r de456d1efc0ecd2faa73ec9a309a40c5ee1ce393 -r 5ffd0fbe9057407dbb37fa2225906315695d569a doc/source/cookbook/single_dataset_light_ray.py --- a/doc/source/cookbook/single_dataset_light_ray.py +++ b/doc/source/cookbook/single_dataset_light_ray.py @@ -3,8 +3,8 @@</p>
<pre>from yt.analysis_modules.cosmological_observation.api import \
    LightRay
</pre>
<p>-fn = “IsolatedGalaxy/galaxy0030/galaxy0030” -lr = LightRay(fn) +ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030") +lr = LightRay(ds)</p>
<pre># With a single dataset, a start_position and
# end_position or trajectory must be given.</pre>
<p>@@ -17,7 +17,6 @@</p>
<pre># Optionally, we can now overplot this ray on a projection of the source
# dataset</pre>
<p>-ds = yt.load(fn)</p>
<pre>p = yt.ProjectionPlot(ds, 'z', 'density')
p.annotate_ray(lr)
p.save()</pre>
<p>diff -r de456d1efc0ecd2faa73ec9a309a40c5ee1ce393 -r 5ffd0fbe9057407dbb37fa2225906315695d569a yt/analysis_modules/cosmological_observation/light_ray/light_ray.py --- a/yt/analysis_modules/cosmological_observation/light_ray/light_ray.py +++ b/yt/analysis_modules/cosmological_observation/light_ray/light_ray.py @@ -31,24 +31,19 @@</p>
<pre>    parallel_objects, \
    parallel_root_only
from yt.utilities.physical_constants import speed_of_light_cgs</pre>
<p>+from yt.data_objects.static_output import Dataset</p>
<pre>class LightRay(CosmologySplice):
    """</pre>
<ul><li><p>LightRay(parameter_filename, simulation_type=None,</p></li>
<li><p>near_redshift=None, far_redshift=None,</p></li>
<li><p>use_minimum_datasets=True, deltaz_min=0.0,</p></li>
<li><p>minimum_coherent_box_fraction=0.0,</p></li>
<li><p>time_data=True, redshift_data=True,</p></li>
<li><p>find_outputs=False, load_kwargs=None):</p></li></ul>
<p>–</p>
<ul><li><p>Create a LightRay object.  A light ray is much like a light cone,</p></li>
<li><p>in that it stacks together multiple datasets in order to extend a</p></li>
<li><p>redshift interval.  Unlike a light cone, which does randomly</p></li>
<li><p>oriented projections for each dataset, a light ray consists of</p></li>
<li><p>randomly oriented single rays.  The purpose of these is to create</p></li>
<li><p>synthetic QSO lines of sight.</p></li></ul>
<p>–</p>
<ul><li><p>Light rays can also be made from single datasets.</p></li></ul>
<p>+    A LightRay object is a one-dimensional object representing the trajectory +    of a ray of light as it passes through one or more datasets (simple and +    compound rays respectively).  One can sample any of the fields intersected +    by the LightRay object as it passed through the dataset(s). + +    For compound rays, the LightRay stacks together multiple datasets in a time +    series in order to approximate a LightRay's path through a volume +    and redshift interval larger than a single simulation data output. +    The outcome is something akin to a synthetic QSO line of sight.</p>
<pre>Once the LightRay object is set up, use LightRay.make_light_ray to
begin making rays.  Different randomizations can be created with a</pre>
<p>@@ -56,31 +51,32 @@</p>
<pre>Parameters
----------</pre>
<ul><li><p>parameter_filename : string</p></li>
<li><p>The path to the simulation parameter file or dataset.</p></li></ul>
<p>+    parameter_filename : string or :class:`yt.data_objects.static_output.Dataset` +        For simple rays, one may pass either a loaded dataset object or +        the filename of a dataset. +        For compound rays, one must pass the filename of the simulation +        parameter file.</p>
<pre>simulation_type : optional, string</pre>
<ul><li><p>The simulation type.  If None, the first argument is assumed to</p></li>
<li><p>refer to a single dataset.</p></li></ul>
<p>+        This refers to the simulation frontend type.  Do not use for simple +        rays.</p>
<pre>    Default: None
near_redshift : optional, float
    The near (lowest) redshift for a light ray containing multiple</pre>
<ul><li><p>datasets.  Do not use if making a light ray from a single</p></li>
<li><p>dataset.</p></li></ul>
<p>+        datasets.  Do not use for simple rays.</p>
<pre>    Default: None
far_redshift : optional, float
    The far (highest) redshift for a light ray containing multiple</pre>
<ul><li><p>datasets.  Do not use if making a light ray from a single</p></li>
<li><p>dataset.</p></li></ul>
<p>+        datasets.  Do not use for simple rays.</p>
<pre>    Default: None
use_minimum_datasets : optional, bool
    If True, the minimum number of datasets is used to connect the
    initial and final redshift.  If false, the light ray solution
    will contain as many entries as possible within the redshift</pre>
<ul><li><p>interval.</p></li></ul>
<p>+        interval.  Do not use for simple rays.</p>
<pre>    Default: True.
deltaz_min : optional, float
    Specifies the minimum :math:`\Delta z` between consecutive</pre>
<ul><li><p>datasets in the returned list.</p></li></ul>
<p>+        datasets in the returned list.  Do not use for simple rays.</p>
<pre>    Default: 0.0.
minimum_coherent_box_fraction : optional, float
    Used with use_minimum_datasets set to False, this parameter</pre>
<p>@@ -88,23 +84,26 @@</p>
<pre>before rerandomizing the projection axis and center.  This
was invented to allow light rays with thin slices to sample
coherent large scale structure, but in practice does not work</pre>
<ul><li><p>so well.  Try setting this parameter to 1 and see what happens.</p></li></ul>
<p>+        so well.  Try setting this parameter to 1 and see what happens. +        Do not use for simple rays.</p>
<pre>    Default: 0.0.
time_data : optional, bool
    Whether or not to include time outputs when gathering</pre>
<ul><li><p>datasets for time series.</p></li></ul>
<p>+        datasets for time series.  Do not use for simple rays.</p>
<pre>    Default: True.
redshift_data : optional, bool
    Whether or not to include redshift outputs when gathering</pre>
<ul><li><p>datasets for time series.</p></li></ul>
<p>+        datasets for time series.  Do not use for simple rays.</p>
<pre>    Default: True.
find_outputs : optional, bool
    Whether or not to search for datasets in the current</pre>
<ul><li><p>directory.</p></li></ul>
<p>+        directory.  Do not use for simple rays.</p>
<pre>    Default: False.
load_kwargs : optional, dict</pre>
<ul><li><p>Optional dictionary of kwargs to be passed to the “load”</p></li>
<li><p>function, appropriate for use of certain frontends.  E.g.</p></li></ul>
<p>+        If you are passing a filename of a dataset to LightRay rather than an +        already loaded dataset, then you can optionally provide this dictionary +        as keywords when the dataset is loaded by yt with the “load” function. +        Necessary for use with certain frontends.  E.g.</p>
<pre>Tipsy using "bounding_box"
Gadget using "unit_base", etc.
Default : None</pre>
<p>@@ -130,26 +129,37 @@</p>
<pre>        self.light_ray_solution = []
        self._data = {}
</pre>
<ul><li><p># Make a light ray from a single, given dataset.</p></li>
<li><p>if simulation_type is None:</p></li></ul>
<p>+        # The options here are: +        # 1) User passed us a dataset: use it to make a simple ray +        # 2) User passed us a dataset filename: use it to make a simple ray +        # 3) User passed us a simulation filename: use it to make a compound ray + +        # Make a light ray from a single, given dataset: #1, #2 +        if simulation_type is None:</p>
<pre>self.simulation_type = simulation_type</pre>
<ul><li><p>ds = load(parameter_filename, **self.load_kwargs)</p></li>
<li><p>if ds.cosmological_simulation:</p></li>
<li><p>redshift = ds.current_redshift</p></li></ul>
<p>+            if isinstance(self.parameter_filename, Dataset): +                self.ds = self.parameter_filename +                self.parameter_filename = self.ds.basename +            elif isinstance(self.parameter_filename, str): +                self.ds = load(self.parameter_filename, **self.load_kwargs) +            if self.ds.cosmological_simulation: +                redshift = self.ds.current_redshift</p>
<pre>self.cosmology = Cosmology(</pre>
<ul><li><p>hubble_constant=ds.hubble_constant,</p></li>
<li><p>omega_matter=ds.omega_matter,</p></li>
<li><p>omega_lambda=ds.omega_lambda,</p></li>
<li><p>unit_registry=ds.unit_registry)</p></li></ul>
<p>+                    hubble_constant=self.ds.hubble_constant, +                    omega_matter=self.ds.omega_matter, +                    omega_lambda=self.ds.omega_lambda, +                    unit_registry=self.ds.unit_registry)</p>
<pre>else:
    redshift = 0.</pre>
<ul><li><p>self.light_ray_solution.append({"filename": parameter_filename,</p></li></ul>
<p>+            self.light_ray_solution.append({"filename": self.parameter_filename,</p>
<pre>                                            "redshift": redshift})
</pre>
<ul><li><p># Make a light ray from a simulation time-series.</p></li></ul>
<p>+        # Make a light ray from a simulation time-series. #3</p>
<pre>else:</pre>
<p>+            self.ds = None +            assert isinstance(self.parameter_filename, str)</p>
<pre># Get list of datasets for light ray solution.</pre>
<ul><li><p>CosmologySplice.__init__(self, parameter_filename, simulation_type,</p></li></ul>
<p>+            CosmologySplice.__init__(self, self.parameter_filename, simulation_type,</p>
<pre>                         find_outputs=find_outputs)
self.light_ray_solution = \
  self.create_cosmology_splice(self.near_redshift, self.far_redshift,</pre>
<p>@@ -270,7 +280,7 @@</p>
<pre>Create a light ray and get field values for each lixel.  A light
ray consists of a list of field values for cells intersected by
the ray and the path length of the ray through those cells.</pre>
<ul><li><p>Light ray data can be written out to an hdf5 file.</p></li></ul>
<p>+        Light ray data must be written out to an hdf5 file.</p>
<pre>Parameters
----------</pre>
<p>@@ -383,8 +393,12 @@</p>
<pre>                                                       storage=all_ray_storage,
                                                       njobs=njobs):
</pre>
<ul><li><p># Load dataset for segment.</p></li>
<li><p>ds = load(my_segment['filename'], **self.load_kwargs)</p></li></ul>
<p>+            # In case of simple rays, use the already loaded dataset: self.ds, +            # otherwise, load dataset for segment. +            if self.ds is None: +                ds = load(my_segment['filename'], **self.load_kwargs) +            else: +                ds = self.ds</p>
<pre>my_segment['unique_identifier'] = ds.unique_identifier
if redshift is not None:</pre>
<p>@@ -555,7 +569,7 @@</p>
<pre>Write light ray data to hdf5 file.
"""
if self.simulation_type is None:</pre>
<ul><li><p>ds = load(self.parameter_filename, **self.load_kwargs)</p></li></ul>
<p>+            ds = self.ds</p>
<pre>         else:
ds = {}
ds["dimensionality"] = self.simulation.dimensionality</pre>
<p>diff -r de456d1efc0ecd2faa73ec9a309a40c5ee1ce393 -r 5ffd0fbe9057407dbb37fa2225906315695d569a yt/analysis_modules/cosmological_observation/light_ray/tests/test_light_ray.py --- /dev/null +++ b/yt/analysis_modules/cosmological_observation/light_ray/tests/test_light_ray.py @@ -0,0 +1,92 @@ +""" +Unit test for the light_ray analysis module +""" + +#----------------------------------------------------------------------------- +# Copyright © 2016, yt Development Team. +# +# Distributed under the terms of the Modified BSD License. +# +# The full license is in the file COPYING.txt, distributed with this software. +#----------------------------------------------------------------------------- + +from yt.testing import \ +    requires_file +from yt.analysis_modules.cosmological_observation.api import LightRay +import os +import shutil +from yt.utilities.answer_testing.framework import data_dir_load +import tempfile + +COSMO_PLUS = “enzo_cosmology_plus/AMRCosmology.enzo” +COSMO_PLUS_SINGLE = “enzo_cosmology_plus/RD0009/RD0009” + +@requires_file(COSMO_PLUS) +def test_light_ray_cosmo(): +    """ +    This test generates a cosmological light ray +    """ +    # Set up in a temp dir +    tmpdir = tempfile.mkdtemp() +    curdir = os.getcwd() +    os.chdir(tmpdir) + +    lr = LightRay(COSMO_PLUS, ‘Enzo’, 0.0, 0.03) + +    lr.make_light_ray(seed=1234567, +                      fields=['temperature', ‘density’, ‘H_number_density'], +                      data_filename='lightray.h5’) + +    # clean up +    os.chdir(curdir) +    shutil.rmtree(tmpdir) + + +@requires_file(COSMO_PLUS_SINGLE) +def test_light_ray_non_cosmo(): +    """ +    This test generates a non-cosmological light ray +    """ + +    # Set up in a temp dir +    tmpdir = tempfile.mkdtemp() +    curdir = os.getcwd() +    os.chdir(tmpdir) + +    lr = LightRay(COSMO_PLUS_SINGLE) + +    ray_start = [0,0,0] +    ray_end = [1,1,1] +    lr.make_light_ray(start_position=ray_start, end_position=ray_end, +                      fields=['temperature', ‘density’, ‘H_number_density'], +                      data_filename='lightray.h5’) + +    # clean up +    os.chdir(curdir) +    shutil.rmtree(tmpdir) + +@requires_file(COSMO_PLUS_SINGLE) +def test_light_ray_non_cosmo_from_dataset(): +    """ +    This test generates a non-cosmological light ray created from an already +    loaded dataset +    """ + +    # Set up in a temp dir +    tmpdir = tempfile.mkdtemp() +    curdir = os.getcwd() +    os.chdir(tmpdir) + +    ds = data_dir_load(COSMO_PLUS_SINGLE) +    lr = LightRay(ds) + +    ray_start = [0,0,0] +    ray_end = [1,1,1] +    lr.make_light_ray(start_position=ray_start, end_position=ray_end, +                      fields=['temperature', ‘density’, ‘H_number_density'], +                      data_filename='lightray.h5’) + +    # clean up +    os.chdir(curdir) +    shutil.rmtree(tmpdir) +</p>
<p>Repository URL: <a href="https://bitbucket.org/yt_analysis/yt/">https://bitbucket.org/yt_analysis/yt/</a></p>
<p>—</p>
<p>This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.</p>

<img src="http://link.bitbucket.org/wf/open?upn=ll4ctv0L-2ByeRZFC1LslHcg6aJmnQ70VruLbmeLQr27AVAxPeQTXTw4vGYCfim-2BGo9b3DEsmyD7-2BHcjihcKAARgltkBydMelBJvhz6IE3CA6FAvy20Xx0z8JicULtbu9pLzAxV0rLG2ZpvM9CRtlfXrVCXiXNYJf5u7XewQ-2BCYE3ElinBNu3D6KRCF23qN4GxvLEo75lM86EvXicYJh3-2Fo0lDb3aKcQ5VNMG2z-2B28-2BzU-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;"/>
</body></html>