[yt-svn] commit/yt: ngoldbaum: Merged in xarthisius/yt (pull request #1345)
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Mon Dec 8 12:44:06 PST 2014
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/commits/0aed1d0679fc/
Changeset: 0aed1d0679fc
Branch: yt
User: ngoldbaum
Date: 2014-12-08 20:43:55+00:00
Summary: Merged in xarthisius/yt (pull request #1345)
Simple doc syntax fixes
Affected #: 5 files
diff -r 04e36ac413d7bea0dd18e90a3a944f9844e12848 -r 0aed1d0679fc0d9a0813616f9e044574ab5b2ef5 doc/source/developing/testing.rst
--- a/doc/source/developing/testing.rst
+++ b/doc/source/developing/testing.rst
@@ -157,8 +157,6 @@
More data will be added over time. To run the tests, you can import the yt
module and invoke ``yt.run_nose()`` with a new keyword argument:
-__ run_answer_testing_
-
.. code-block:: python
import yt
diff -r 04e36ac413d7bea0dd18e90a3a944f9844e12848 -r 0aed1d0679fc0d9a0813616f9e044574ab5b2ef5 doc/source/examining/loading_data.rst
--- a/doc/source/examining/loading_data.rst
+++ b/doc/source/examining/loading_data.rst
@@ -16,10 +16,10 @@
interested in using yt for ART data, or if you are interested in assisting with
development of yt to work with ART data.
-To load an ART dataset you can use the ``yt.load`` command and provide it
- the gas mesh file. It will search for and attempt
-to find the complementary dark matter and stellar particle header and data
-files. However, your simulations may not follow the same naming convention.
+To load an ART dataset you can use the ``yt.load`` command and provide it the
+gas mesh file. It will search for and attempt to find the complementary dark
+matter and stellar particle header and data files. However, your simulations may
+not follow the same naming convention.
So for example, a single snapshot might have a series of files looking like
this:
diff -r 04e36ac413d7bea0dd18e90a3a944f9844e12848 -r 0aed1d0679fc0d9a0813616f9e044574ab5b2ef5 yt/analysis_modules/halo_analysis/halo_catalog.py
--- a/yt/analysis_modules/halo_analysis/halo_catalog.py
+++ b/yt/analysis_modules/halo_analysis/halo_catalog.py
@@ -18,40 +18,40 @@
import os
from yt.funcs import \
- ensure_dir, \
- mylog
+ ensure_dir, \
+ mylog
from yt.utilities.parallel_tools.parallel_analysis_interface import \
- ParallelAnalysisInterface, \
- parallel_blocking_call, \
- parallel_objects
-
+ ParallelAnalysisInterface, \
+ parallel_blocking_call, \
+ parallel_objects
+
from .halo_object import \
- Halo
+ Halo
from .halo_callbacks import \
- callback_registry
+ callback_registry
from .halo_filters import \
- filter_registry
+ filter_registry
from .halo_finding_methods import \
- finding_method_registry
+ finding_method_registry
from .halo_quantities import \
- quantity_registry
+ quantity_registry
class HaloCatalog(ParallelAnalysisInterface):
r"""Create a HaloCatalog: an object that allows for the creation and association
of data with a set of halo objects.
- A HaloCatalog object pairs a simulation dataset and the output from a halo finder,
+ A HaloCatalog object pairs a simulation dataset and the output from a halo finder,
allowing the user to perform analysis on each of the halos found by the halo finder.
- Analysis is performed by providing callbacks: functions that accept a Halo object
- and perform independent analysis, return a quantity to be associated with the halo,
- or return True or False whether a halo meets various criteria. The resulting set of
+ Analysis is performed by providing callbacks: functions that accept a Halo object
+ and perform independent analysis, return a quantity to be associated with the halo,
+ or return True or False whether a halo meets various criteria. The resulting set of
quantities associated with each halo is then written out to disk at a "halo catalog."
This halo catalog can then be loaded in with yt as any other simulation dataset.
-
+
Parameters
----------
halos_ds : str
- Dataset created by a halo finder. If None, a halo finder should be
+ Dataset created by a halo finder. If None, a halo finder should be
provided with the finder_method keyword.
data_ds : str
Dataset created by a simulation.
@@ -68,27 +68,26 @@
Examples
--------
- # create profiles or overdensity vs. radius for each halo and save to disk
+ >>> # create profiles or overdensity vs. radius for each halo and save to disk
>>> from yt.mods import *
>>> from yt.analysis_modules.halo_analysis.api import *
>>> data_ds = load("DD0064/DD0064")
>>> halos_ds = load("rockstar_halos/halos_64.0.bin",
... output_dir="halo_catalogs/catalog_0064")
>>> hc = HaloCatalog(data_ds=data_ds, halos_ds=halos_ds)
- # filter out halos with mass < 1e13 Msun
+ >>> # filter out halos with mass < 1e13 Msun
>>> hc.add_filter("quantity_value", "particle_mass", ">", 1e13, "Msun")
- # create a sphere object with radius of 2 times the virial_radius field
+ >>> # create a sphere object with radius of 2 times the virial_radius field
>>> hc.add_callback("sphere", factor=2.0, radius_field="virial_radius")
- # make radial profiles
+ >>> # make radial profiles
>>> hc.add_callback("profile", "radius", [("gas", "overdensity")],
... weight_field="cell_volume", accumulation=True)
- # save the profiles to disk
+ >>> # save the profiles to disk
>>> hc.add_callback("save_profiles", output_dir="profiles")
- # create the catalog
+ >>> # create the catalog
>>> hc.create()
-
- # load in the saved halo catalog and all the profile data
+ >>> # load in the saved halo catalog and all the profile data
>>> halos_ds = load("halo_catalogs/catalog_0064/catalog_0064.0.h5")
>>> hc = HaloCatalog(halos_ds=halos_ds,
output_dir="halo_catalogs/catalog_0064")
@@ -98,11 +97,11 @@
See Also
--------
add_callback, add_filter, add_finding_method, add_quantity
-
+
"""
-
- def __init__(self, halos_ds=None, data_ds=None,
- data_source=None, finder_method=None,
+
+ def __init__(self, halos_ds=None, data_ds=None,
+ data_source=None, finder_method=None,
finder_kwargs=None,
output_dir="halo_catalogs/catalog"):
ParallelAnalysisInterface.__init__(self)
@@ -133,8 +132,8 @@
if finder_method is not None:
finder_method = finding_method_registry.find(finder_method,
**finder_kwargs)
- self.finder_method = finder_method
-
+ self.finder_method = finder_method
+
# all of the analysis actions to be performed: callbacks, filters, and quantities
self.actions = []
# fields to be written to the halo catalog
@@ -146,8 +145,8 @@
r"""
Add a callback to the halo catalog action list.
- A callback is a function that accepts and operates on a Halo object and
- does not return anything. Callbacks must exist within the callback_registry.
+ A callback is a function that accepts and operates on a Halo object and
+ does not return anything. Callbacks must exist within the callback_registry.
Give additional args and kwargs to be passed to the callback here.
Parameters
@@ -158,15 +157,15 @@
Examples
--------
- # Here, a callback is defined and added to the registry.
- def _say_something(halo, message):
- my_id = halo.quantities['particle_identifier']
- print "Halo %d: here is a message - %s." % (my_id, message)
- add_callback("hello_world", _say_something)
+ >>> # Here, a callback is defined and added to the registry.
+ >>> def _say_something(halo, message):
+ ... my_id = halo.quantities['particle_identifier']
+ ... print "Halo %d: here is a message - %s." % (my_id, message)
+ >>> add_callback("hello_world", _say_something)
- # Now this callback is accessible to the HaloCatalog object
+ >>> # Now this callback is accessible to the HaloCatalog object
>>> hc.add_callback("hello_world", "this is my message")
-
+
"""
callback = callback_registry.find(callback, *args, **kwargs)
if "output_dir" in kwargs is not None:
@@ -177,9 +176,9 @@
r"""
Add a quantity to the halo catalog action list.
- A quantity is a function that accepts a Halo object and return a value or
- values. These values are stored in a "quantities" dictionary associated
- with the Halo object. Quantities must exist within the quantity_registry.
+ A quantity is a function that accepts a Halo object and return a value or
+ values. These values are stored in a "quantities" dictionary associated
+ with the Halo object. Quantities must exist within the quantity_registry.
Give additional args and kwargs to be passed to the quantity function here.
Parameters
@@ -187,26 +186,26 @@
key : string
The name of the callback.
field_type : string
- If not None, the quantity is the value of the field provided by the
- key parameter, taken from the halo finder dataset. This is the way
+ If not None, the quantity is the value of the field provided by the
+ key parameter, taken from the halo finder dataset. This is the way
one pulls values for the halo from the halo dataset.
Default : None
Examples
--------
- # pull the virial radius from the halo finder dataset
- hc.add_quantity("virial_radius", field_type="halos")
+ >>> # pull the virial radius from the halo finder dataset
+ >>> hc.add_quantity("virial_radius", field_type="halos")
- # define a custom quantity and add it to the register
- def _mass_squared(halo):
- # assume some entry "particle_mass" exists in the quantities dict
- return halo.quantities["particle_mass"]**2
- add_quantity("mass_squared", _mass_squared)
+ >>> # define a custom quantity and add it to the register
+ >>> def _mass_squared(halo):
+ ... # assume some entry "particle_mass" exists in the quantities dict
+ ... return halo.quantities["particle_mass"]**2
+ >>> add_quantity("mass_squared", _mass_squared)
- # add it to the halo catalog action list
+ >>> # add it to the halo catalog action list
>>> hc.add_quantity("mass_squared")
-
+
"""
if "field_type" in kwargs:
field_type = kwargs.pop("field_type")
@@ -229,11 +228,11 @@
r"""
Add a filter to the halo catalog action list.
- A filter is a function that accepts a Halo object and returns either True
- or False. If True, any additional actions added to the list are carried out
- and the results are added to the final halo catalog. If False, any further
+ A filter is a function that accepts a Halo object and returns either True
+ or False. If True, any additional actions added to the list are carried out
+ and the results are added to the final halo catalog. If False, any further
actions are skipped and the halo will be omitted from the final catalog.
- Filters must exist within the filter_registry. Give additional args and kwargs
+ Filters must exist within the filter_registry. Give additional args and kwargs
to be passed to the filter function here.
Parameters
@@ -244,44 +243,41 @@
Examples
--------
- # define a filter and add it to the register.
- def _my_filter(halo, mass_value):
- if halo.quantities["particle_mass"] > YTQuantity(mass_value, "Msun"):
- return True
- else:
- return False
- # add it to the register
- add_filter("mass_filter", _my_filter)
+ >>> # define a filter and add it to the register.
+ >>> def _my_filter(halo, mass_value):
+ ... return halo.quantities["particle_mass"] > YTQuantity(mass_value, "Msun")
+ >>> # add it to the register
+ >>> add_filter("mass_filter", _my_filter)
- # add the filter to the halo catalog actions
+ >>> # add the filter to the halo catalog actions
>>> hc.add_filter("mass_value", 1e12)
-
+
"""
-
+
halo_filter = filter_registry.find(halo_filter, *args, **kwargs)
self.actions.append(("filter", halo_filter))
def create(self, save_halos=False, save_catalog=True, njobs=-1, dynamic=False):
r"""
- Create the halo catalog given the callbacks, quantities, and filters that
+ Create the halo catalog given the callbacks, quantities, and filters that
have been provided.
- This is a wrapper around the main _run function with default arguments tuned
- for halo catalog creation. By default, halo objects are not saved but the
+ This is a wrapper around the main _run function with default arguments tuned
+ for halo catalog creation. By default, halo objects are not saved but the
halo catalog is written, opposite to the behavior of the load function.
Parameters
----------
save_halos : bool
If True, a list of all Halo objects is retained under the "halo_list"
- attribute. If False, only the compiles quantities are saved under the
+ attribute. If False, only the compiles quantities are saved under the
"catalog" attribute.
Default: False
save_catalog : bool
If True, save the final catalog to disk.
Default: True
njobs : int
- The number of jobs over which to divide halo analysis. Choose -1
+ The number of jobs over which to divide halo analysis. Choose -1
to allocate one processor per halo.
Default: -1
dynamic : int
@@ -292,7 +288,7 @@
See Also
--------
load
-
+
"""
self._run(save_halos, save_catalog, njobs=njobs, dynamic=dynamic)
@@ -300,23 +296,23 @@
r"""
Load a previously created halo catalog.
- This is a wrapper around the main _run function with default arguments tuned
- for reloading halo catalogs and associated data. By default, halo objects are
- saved and the halo catalog is not written, opposite to the behavior of the
+ This is a wrapper around the main _run function with default arguments tuned
+ for reloading halo catalogs and associated data. By default, halo objects are
+ saved and the halo catalog is not written, opposite to the behavior of the
create function.
-
+
Parameters
----------
save_halos : bool
If True, a list of all Halo objects is retained under the "halo_list"
- attribute. If False, only the compiles quantities are saved under the
+ attribute. If False, only the compiles quantities are saved under the
"catalog" attribute.
Default: True
save_catalog : bool
If True, save the final catalog to disk.
Default: False
njobs : int
- The number of jobs over which to divide halo analysis. Choose -1
+ The number of jobs over which to divide halo analysis. Choose -1
to allocate one processor per halo.
Default: -1
dynamic : int
@@ -327,10 +323,10 @@
See Also
--------
create
-
+
"""
self._run(save_halos, save_catalog, njobs=njobs, dynamic=dynamic)
-
+
@parallel_blocking_call
def _run(self, save_halos, save_catalog, njobs=-1, dynamic=False):
r"""
@@ -340,12 +336,12 @@
----------
save_halos : bool
If True, a list of all Halo objects is retained under the "halo_list"
- attribute. If False, only the compiles quantities are saved under the
+ attribute. If False, only the compiles quantities are saved under the
"catalog" attribute.
save_catalog : bool
If True, save the final catalog to disk.
njobs : int
- The number of jobs over which to divide halo analysis. Choose -1
+ The number of jobs over which to divide halo analysis. Choose -1
to allocate one processor per halo.
Default: -1
dynamic : int
@@ -356,7 +352,7 @@
See Also
--------
create, load
-
+
"""
self.catalog = []
if save_halos: self.halo_list = []
@@ -419,7 +415,7 @@
(self.output_prefix, self.comm.rank))
n_halos = len(self.catalog)
mylog.info("Saving halo catalog (%d halos) to %s." %
- (n_halos, os.path.join(self.output_dir,
+ (n_halos, os.path.join(self.output_dir,
self.output_prefix)))
out_file = h5py.File(filename, 'w')
for attr in ["current_redshift", "current_time",
diff -r 04e36ac413d7bea0dd18e90a3a944f9844e12848 -r 0aed1d0679fc0d9a0813616f9e044574ab5b2ef5 yt/data_objects/derived_quantities.py
--- a/yt/data_objects/derived_quantities.py
+++ b/yt/data_objects/derived_quantities.py
@@ -94,8 +94,8 @@
r"""
Calculates the weight average of a field or fields.
- Where f is the field and w is the weight, the weighted average is
- Sum_i(f_i * w_i) / Sum_i(w_i).
+ Where f is the field and w is the weight, the weighted average is
+ Sum_i(f_i \* w_i) / Sum_i(w_i).
Parameters
----------
@@ -112,7 +112,7 @@
>>> print ad.quantities.weighted_average_quantity([("gas", "density"),
... ("gas", "temperature")],
... ("gas", "cell_mass"))
-
+
"""
def count_values(self, fields, weight):
# This is a list now
@@ -149,7 +149,7 @@
>>> ds = load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> ad = ds.all_data()
>>> print ad.quantities.total_quantity([("gas", "cell_mass")])
-
+
"""
def count_values(self, fields):
# This is a list now
@@ -180,7 +180,7 @@
>>> ds = load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> ad = ds.all_data()
>>> print ad.quantities.total_mass()
-
+
"""
def __call__(self):
self.data_source.ds.index
@@ -202,11 +202,11 @@
Parameters
----------
use_gas : bool
- Flag to include gas in the calculation. Gas is ignored if not
+ Flag to include gas in the calculation. Gas is ignored if not
present.
Default: True
use_particles : bool
- Flag to include particles in the calculation. Particles are ignored
+ Flag to include particles in the calculation. Particles are ignored
if not present.
Default: False
@@ -216,7 +216,7 @@
>>> ds = load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> ad = ds.all_data()
>>> print ad.quantities.center_of_mass()
-
+
"""
def count_values(self, use_gas = True, use_particles = False):
use_gas &= \
@@ -271,11 +271,11 @@
Parameters
----------
use_gas : bool
- Flag to include gas in the calculation. Gas is ignored if not
+ Flag to include gas in the calculation. Gas is ignored if not
present.
Default: True
use_particles : bool
- Flag to include particles in the calculation. Particles are ignored
+ Flag to include particles in the calculation. Particles are ignored
if not present.
Default: True
@@ -285,7 +285,7 @@
>>> ds = load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> ad = ds.all_data()
>>> print ad.quantities.bulk_velocity()
-
+
"""
def count_values(self, use_gas = True, use_particles = False):
# This is a list now
@@ -298,7 +298,7 @@
def process_chunk(self, data, use_gas = True, use_particles = False):
vals = []
if use_gas:
- vals += [(data["gas", "velocity_%s" % ax] *
+ vals += [(data["gas", "velocity_%s" % ax] *
data["gas", "cell_mass"]).sum(dtype=np.float64)
for ax in 'xyz']
vals.append(data["gas", "cell_mass"].sum(dtype=np.float64))
@@ -327,17 +327,17 @@
class WeightedVariance(DerivedQuantity):
r"""
- Calculates the weighted variance and weighted mean for a field
+ Calculates the weighted variance and weighted mean for a field
or list of fields.
- Where f is the field, w is the weight, and <f_w> is the weighted mean,
- the weighted variance is
- Sum_i( (f_i - <f_w>)^2 * w_i ) / Sum_i(w_i).
+ Where f is the field, w is the weight, and <f_w> is the weighted mean,
+ the weighted variance is
+ Sum_i( (f_i - <f_w>)^2 \* w_i ) / Sum_i(w_i).
Parameters
----------
fields : field or list of fields
- The field or fields of which the variance and mean values are
+ The field or fields of which the variance and mean values are
to be calculated.
weight : field
The weight field.
@@ -350,7 +350,7 @@
>>> print ad.quantities.weighted_variance([("gas", "density"),
... ("gas", "temperature")],
... ("gas", "cell_mass"))
-
+
"""
def count_values(self, fields, weight):
# This is a list now
@@ -382,12 +382,12 @@
my_mean = values[i]
my_var2 = values[i + len(values) / 2]
all_mean = (my_weight * my_mean).sum(dtype=np.float64) / all_weight
- rvals.append(np.sqrt((my_weight * (my_var2 +
- (my_mean - all_mean)**2)).sum(dtype=np.float64) /
+ rvals.append(np.sqrt((my_weight * (my_var2 +
+ (my_mean - all_mean)**2)).sum(dtype=np.float64) /
all_weight))
rvals.append(all_mean)
return rvals
-
+
class AngularMomentumVector(DerivedQuantity):
r"""
Calculates the angular momentum vector, using gas and/or particles.
@@ -397,11 +397,11 @@
Parameters
----------
use_gas : bool
- Flag to include gas in the calculation. Gas is ignored if not
+ Flag to include gas in the calculation. Gas is ignored if not
present.
Default: True
use_particles : bool
- Flag to include particles in the calculation. Particles are ignored
+ Flag to include particles in the calculation. Particles are ignored
if not present.
Default: True
@@ -411,7 +411,7 @@
>>> ds = load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> ad = ds.all_data()
>>> print ad.quantities.angular_momentum_vector()
-
+
"""
def count_values(self, use_gas=True, use_particles=True):
use_gas &= \
@@ -449,7 +449,7 @@
if values:
jx += values.pop(0).sum(dtype=np.float64)
jy += values.pop(0).sum(dtype=np.float64)
- jz += values.pop(0).sum(dtype=np.float64)
+ jz += values.pop(0).sum(dtype=np.float64)
m += values.pop(0).sum(dtype=np.float64)
return (jx / m, jy / m, jz / m)
@@ -472,7 +472,7 @@
>>> ad = ds.all_data()
>>> print ad.quantities.extrema([("gas", "density"),
... ("gas", "temperature")])
-
+
"""
def count_values(self, fields, non_zero):
self.num_vals = len(fields) * 2
@@ -503,7 +503,7 @@
class MaxLocation(DerivedQuantity):
r"""
- Calculates the maximum value plus the index, x, y, and z position
+ Calculates the maximum value plus the index, x, y, and z position
of the maximum.
Parameters
@@ -517,7 +517,7 @@
>>> ds = load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> ad = ds.all_data()
>>> print ad.quantities.max_location(("gas", "density"))
-
+
"""
def count_values(self, *args, **kwargs):
self.num_vals = 5
@@ -546,7 +546,7 @@
class MinLocation(DerivedQuantity):
r"""
- Calculates the minimum value plus the index, x, y, and z position
+ Calculates the minimum value plus the index, x, y, and z position
of the minimum.
Parameters
@@ -560,7 +560,7 @@
>>> ds = load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> ad = ds.all_data()
>>> print ad.quantities.min_location(("gas", "density"))
-
+
"""
def count_values(self, *args, **kwargs):
self.num_vals = 5
@@ -591,22 +591,22 @@
r"""
Calculates the dimensionless spin parameter.
- Given by Equation 3 of Peebles (1971, A&A, 11, 377), the spin parameter
+ Given by Equation 3 of Peebles (1971, A&A, 11, 377), the spin parameter
is defined as
-
- lambda = (L * |E|^(1/2)) / (G * M^5/2),
-
- where L is the total angular momentum, E is the total energy (kinetic and
+
+ lambda = (L \* |E|^(1/2)) / (G \* M^5/2),
+
+ where L is the total angular momentum, E is the total energy (kinetic and
potential), G is the gravitational constant, and M is the total mass.
Parameters
----------
use_gas : bool
- Flag to include gas in the calculation. Gas is ignored if not
+ Flag to include gas in the calculation. Gas is ignored if not
present.
Default: True
use_particles : bool
- Flag to include particles in the calculation. Particles are ignored
+ Flag to include particles in the calculation. Particles are ignored
if not present.
Default: True
@@ -616,7 +616,7 @@
>>> ds = load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> ad = ds.all_data()
>>> print ad.quantities.center_of_mass()
-
+
"""
def count_values(self, **kwargs):
self.num_vals = 3
diff -r 04e36ac413d7bea0dd18e90a3a944f9844e12848 -r 0aed1d0679fc0d9a0813616f9e044574ab5b2ef5 yt/units/yt_array.py
--- a/yt/units/yt_array.py
+++ b/yt/units/yt_array.py
@@ -472,7 +472,7 @@
The unit that you wish to convert to.
equiv : string
The equivalence you wish to use. To see which equivalencies are
- supported for this unitful quantity, try the :method:`list_equivalencies`
+ supported for this unitful quantity, try the :meth:`list_equivalencies`
method.
Examples
Repository URL: https://bitbucket.org/yt_analysis/yt/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the yt-svn
mailing list