[yt-svn] commit/yt: atmyers: Merged in al007/yt (pull request #2385)
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Tue Sep 27 22:42:58 PDT 2016
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/commits/9b5937af5857/
Changeset: 9b5937af5857
Branch: yt
User: atmyers
Date: 2016-09-28 05:42:30+00:00
Summary: Merged in al007/yt (pull request #2385)
Make sampler_type required for built-in derived fields.
Affected #: 39 files
diff -r 5a08f4cc1af1a18889e0dc93cb3afa908f2d3d2f -r 9b5937af58578d073179329863c7e220f8ec7df6 yt/data_objects/static_output.py
--- a/yt/data_objects/static_output.py
+++ b/yt/data_objects/static_output.py
@@ -20,6 +20,7 @@
import os
import time
import weakref
+import warnings
from collections import defaultdict
from yt.extern.six import add_metaclass, string_types
@@ -214,7 +215,7 @@
obj = _cached_datasets[apath]
return obj
- def __init__(self, filename, dataset_type=None, file_style=None,
+ def __init__(self, filename, dataset_type=None, file_style=None,
units_override=None, unit_system="cgs"):
"""
Base class for generating new output types. Principally consists of
@@ -338,7 +339,7 @@
in that directory, and a list of subdirectories. It should return a
list of filenames (defined relative to the supplied directory) and a
boolean as to whether or not further directories should be recursed.
-
+
This function doesn't need to catch all possibilities, nor does it need
to filter possibilities.
"""
@@ -938,7 +939,7 @@
"dangerous option that may yield inconsistent results, and must be "
"used very carefully, and only if you know what you want from it.")
for unit, cgs in [("length", "cm"), ("time", "s"), ("mass", "g"),
- ("velocity","cm/s"), ("magnetic","gauss"),
+ ("velocity","cm/s"), ("magnetic","gauss"),
("temperature","K")]:
val = self.units_override.get("%s_unit" % unit, None)
if val is not None:
@@ -1043,7 +1044,7 @@
self._quan = functools.partial(YTQuantity, registry=self.unit_registry)
return self._quan
- def add_field(self, name, function=None, **kwargs):
+ def add_field(self, name, function=None, sampling_type=None, **kwargs):
"""
Dataset-specific call to add_field
@@ -1081,7 +1082,18 @@
if not override and name in self.field_info:
mylog.warning("Field %s already exists. To override use " +
"force_override=True.", name)
- self.field_info.add_field(name, function=function, **kwargs)
+ if kwargs.setdefault('particle_type', False):
+ if sampling_type is not None and sampling_type != "particle":
+ raise RuntimeError("Clashing definition of 'sampling_type' and "
+ "'particle_type'. Note that 'particle_type' is "
+ "deprecated. Please just use 'sampling_type'.")
+ else:
+ sampling_type = "particle"
+ if sampling_type is None:
+ warnings.warn("Because 'sampling_type' not specified, yt will "
+ "assume a cell 'sampling_type'")
+ sampling_type = "cell"
+ self.field_info.add_field(name, sampling_type, function=function, **kwargs)
self.field_info._show_field_errors.append(name)
deps, _ = self.field_info.check_derived_fields([name])
self.field_dependencies.update(deps)
diff -r 5a08f4cc1af1a18889e0dc93cb3afa908f2d3d2f -r 9b5937af58578d073179329863c7e220f8ec7df6 yt/fields/angular_momentum.py
--- a/yt/fields/angular_momentum.py
+++ b/yt/fields/angular_momentum.py
@@ -59,15 +59,15 @@
rv = data.ds.arr(rv, input_units = data["index", "x"].units)
return xv * rv[...,1] - yv * rv[...,0]
- registry.add_field((ftype, "specific_angular_momentum_x"),
+ registry.add_field((ftype, "specific_angular_momentum_x"), sampling_type="cell",
function=_specific_angular_momentum_x,
units=unit_system["specific_angular_momentum"],
validators=[ValidateParameter("center")])
- registry.add_field((ftype, "specific_angular_momentum_y"),
+ registry.add_field((ftype, "specific_angular_momentum_y"), sampling_type="cell",
function=_specific_angular_momentum_y,
units=unit_system["specific_angular_momentum"],
validators=[ValidateParameter("center")])
- registry.add_field((ftype, "specific_angular_momentum_z"),
+ registry.add_field((ftype, "specific_angular_momentum_z"), sampling_type="cell",
function=_specific_angular_momentum_z,
units=unit_system["specific_angular_momentum"],
validators=[ValidateParameter("center")])
@@ -78,7 +78,7 @@
def _angular_momentum_x(field, data):
return data[ftype, "cell_mass"] \
* data[ftype, "specific_angular_momentum_x"]
- registry.add_field((ftype, "angular_momentum_x"),
+ registry.add_field((ftype, "angular_momentum_x"), sampling_type="cell",
function=_angular_momentum_x,
units=unit_system["angular_momentum"],
validators=[ValidateParameter('center')])
@@ -86,7 +86,7 @@
def _angular_momentum_y(field, data):
return data[ftype, "cell_mass"] \
* data[ftype, "specific_angular_momentum_y"]
- registry.add_field((ftype, "angular_momentum_y"),
+ registry.add_field((ftype, "angular_momentum_y"), sampling_type="cell",
function=_angular_momentum_y,
units=unit_system["angular_momentum"],
validators=[ValidateParameter('center')])
@@ -94,7 +94,7 @@
def _angular_momentum_z(field, data):
return data[ftype, "cell_mass"] \
* data[ftype, "specific_angular_momentum_z"]
- registry.add_field((ftype, "angular_momentum_z"),
+ registry.add_field((ftype, "angular_momentum_z"), sampling_type="cell",
function=_angular_momentum_z,
units=unit_system["angular_momentum"],
validators=[ValidateParameter('center')])
diff -r 5a08f4cc1af1a18889e0dc93cb3afa908f2d3d2f -r 9b5937af58578d073179329863c7e220f8ec7df6 yt/fields/astro_fields.py
--- a/yt/fields/astro_fields.py
+++ b/yt/fields/astro_fields.py
@@ -52,7 +52,7 @@
"""
return np.sqrt(3.0 * np.pi / (16.0 * G * data[ftype, "density"]))
- registry.add_field((ftype, "dynamical_time"),
+ registry.add_field((ftype, "dynamical_time"), sampling_type="cell",
function=_dynamical_time,
units=unit_system["time"])
@@ -65,7 +65,7 @@
(data[ftype, "density"]**(-0.5)))
return u
- registry.add_field((ftype, "jeans_mass"),
+ registry.add_field((ftype, "jeans_mass"), sampling_type="cell",
function=_jeans_mass,
units=unit_system["mass"])
@@ -88,7 +88,7 @@
- 1.6667 * logT0**1 - 0.2193 * logT0)),
"") # add correct units here
- registry.add_field((ftype, "chandra_emissivity"),
+ registry.add_field((ftype, "chandra_emissivity"), sampling_type="cell",
function=_chandra_emissivity,
units="") # add correct units here
@@ -102,7 +102,7 @@
nenh *= 0.5*(1.+X_H)*X_H*data["cell_volume"]
return nenh
- registry.add_field((ftype, "emission_measure"),
+ registry.add_field((ftype, "emission_measure"), sampling_type="cell",
function=_emission_measure,
units=unit_system["number_density"])
@@ -112,7 +112,7 @@
* data[ftype, "temperature"].to_ndarray()**0.5,
"") # add correct units here
- registry.add_field((ftype, "xray_emissivity"),
+ registry.add_field((ftype, "xray_emissivity"), sampling_type="cell",
function=_xray_emissivity,
units="") # add correct units here
@@ -121,7 +121,7 @@
# Only useful as a weight_field for temperature, metallicity, velocity
return data["density"]*data["density"]*data["kT"]**-0.25/mh/mh
- registry.add_field((ftype,"mazzotta_weighting"),
+ registry.add_field((ftype,"mazzotta_weighting"), sampling_type="cell",
function=_mazzotta_weighting,
units="keV**-0.25*cm**-6")
@@ -135,7 +135,7 @@
# See issue #1225
return -scale * vel * data[ftype, "density"]
- registry.add_field((ftype, "sz_kinetic"),
+ registry.add_field((ftype, "sz_kinetic"), sampling_type="cell",
function=_sz_kinetic,
units=unit_system["length"]**-1,
validators=[
@@ -145,6 +145,6 @@
scale = 0.88 / mh * kboltz / (me * clight*clight) * sigma_thompson
return scale * data[ftype, "density"] * data[ftype, "temperature"]
- registry.add_field((ftype, "szy"),
+ registry.add_field((ftype, "szy"), sampling_type="cell",
function=_szy,
units=unit_system["length"]**-1)
diff -r 5a08f4cc1af1a18889e0dc93cb3afa908f2d3d2f -r 9b5937af58578d073179329863c7e220f8ec7df6 yt/fields/cosmology_fields.py
--- a/yt/fields/cosmology_fields.py
+++ b/yt/fields/cosmology_fields.py
@@ -45,14 +45,14 @@
return data[ftype, "density"] + \
data[ftype, "dark_matter_density"]
- registry.add_field((ftype, "matter_density"),
+ registry.add_field((ftype, "matter_density"), sampling_type="cell",
function=_matter_density,
units=unit_system["density"])
def _matter_mass(field, data):
return data[ftype, "matter_density"] * data["index", "cell_volume"]
- registry.add_field((ftype, "matter_mass"),
+ registry.add_field((ftype, "matter_mass"), sampling_type="cell",
function=_matter_mass,
units=unit_system["mass"])
@@ -65,7 +65,7 @@
return data[ftype, "matter_density"] / \
co.critical_density(data.ds.current_redshift)
- registry.add_field((ftype, "overdensity"),
+ registry.add_field((ftype, "overdensity"), sampling_type="cell",
function=_overdensity,
units="")
@@ -83,7 +83,7 @@
return data[ftype, "density"] / omega_baryon / co.critical_density(0.0) / \
(1.0 + data.ds.current_redshift)**3
- registry.add_field((ftype, "baryon_overdensity"),
+ registry.add_field((ftype, "baryon_overdensity"), sampling_type="cell",
function=_baryon_overdensity,
units="",
validators=[ValidateParameter("omega_baryon")])
@@ -100,7 +100,7 @@
co.critical_density(0.0) / \
(1.0 + data.ds.current_redshift)**3
- registry.add_field((ftype, "matter_overdensity"),
+ registry.add_field((ftype, "matter_overdensity"), sampling_type="cell",
function=_matter_overdensity,
units="")
@@ -109,7 +109,7 @@
virial_radius = data.get_field_parameter("virial_radius")
return data["radius"] / virial_radius
- registry.add_field(("index", "virial_radius_fraction"),
+ registry.add_field(("index", "virial_radius_fraction"), sampling_type="cell",
function=_virial_radius_fraction,
validators=[ValidateParameter("virial_radius")],
units="")
@@ -137,7 +137,7 @@
return (1.5 * (co.hubble_constant / speed_of_light_cgs)**2 * (dl * dls / ds) * \
data[ftype, "matter_overdensity"]).in_units("1/cm")
- registry.add_field((ftype, "weak_lensing_convergence"),
+ registry.add_field((ftype, "weak_lensing_convergence"), sampling_type="cell",
function=_weak_lensing_convergence,
units=unit_system["length"]**-1,
validators=[ValidateParameter("observer_redshift"),
diff -r 5a08f4cc1af1a18889e0dc93cb3afa908f2d3d2f -r 9b5937af58578d073179329863c7e220f8ec7df6 yt/fields/derived_field.py
--- a/yt/fields/derived_field.py
+++ b/yt/fields/derived_field.py
@@ -91,8 +91,8 @@
The dimensions of the field, only needed if units="auto" and only used
for error checking.
"""
- def __init__(self, name, function, units=None,
- take_log=True, validators=None, sampling_type = "mesh",
+ def __init__(self, name, sampling_type, function, units=None,
+ take_log=True, validators=None,
particle_type=None, vector_field=False, display_field=True,
not_in_all=False, display_name=None, output_units=None,
dimensions=None, ds=None):
diff -r 5a08f4cc1af1a18889e0dc93cb3afa908f2d3d2f -r 9b5937af58578d073179329863c7e220f8ec7df6 yt/fields/field_info_container.py
--- a/yt/fields/field_info_container.py
+++ b/yt/fields/field_info_container.py
@@ -97,9 +97,9 @@
output_units = units
if (ptype, f) not in self.field_list:
continue
- self.add_output_field((ptype, f),
- units = units, sampling_type = "particle",
- display_name = dn, output_units = output_units)
+ self.add_output_field((ptype, f), sampling_type="particle",
+ units = units, display_name = dn,
+ output_units = output_units)
for alias in aliases:
self.alias((ptype, alias), (ptype, f), units = output_units)
@@ -134,9 +134,8 @@
raise RuntimeError
if field[0] not in self.ds.particle_types:
continue
- self.add_output_field(field,
- units = self.ds.field_units.get(field, ""),
- sampling_type = "particle")
+ self.add_output_field(field, sampling_type="particle",
+ units = self.ds.field_units.get(field, ""))
self.setup_smoothed_fields(ptype,
num_neighbors=num_neighbors,
ftype=ftype)
@@ -196,12 +195,12 @@
units = ""
elif units == 1.0:
units = ""
- self.add_output_field(field, units = units,
+ self.add_output_field(field, sampling_type="cell", units = units,
display_name = display_name)
for alias in aliases:
self.alias(("gas", alias), field)
- def add_field(self, name, function=None, **kwargs):
+ def add_field(self, name, sampling_type, function=None, **kwargs):
"""
Add a new field, along with supplemental metadata, to the list of
available fields. This respects a number of arguments, all of which
@@ -250,12 +249,12 @@
kwargs.setdefault('ds', self.ds)
if function is None:
def create_function(f):
- self[name] = DerivedField(name, f, **kwargs)
+ self[name] = DerivedField(name, sampling_type, f, **kwargs)
return f
return create_function
if isinstance(name, tuple):
- self[name] = DerivedField(name, function, **kwargs)
+ self[name] = DerivedField(name, sampling_type, function, **kwargs)
return
if kwargs.get("particle_type", False):
@@ -265,10 +264,11 @@
if (ftype, name) not in self:
tuple_name = (ftype, name)
- self[tuple_name] = DerivedField(tuple_name, function, **kwargs)
+ self[tuple_name] = DerivedField(tuple_name, sampling_type, function,
+ **kwargs)
self.alias(name, tuple_name)
else:
- self[name] = DerivedField(name, function, **kwargs)
+ self[name] = DerivedField(name, sampling_type, function, **kwargs)
def load_all_plugins(self, ftype="gas"):
loaded = []
@@ -296,9 +296,9 @@
self.ds.derived_field_list = list(sorted(dfl, key=tupleize))
return loaded, unavailable
- def add_output_field(self, name, **kwargs):
+ def add_output_field(self, name, sampling_type, **kwargs):
kwargs.setdefault('ds', self.ds)
- self[name] = DerivedField(name, NullFunc, **kwargs)
+ self[name] = DerivedField(name, sampling_type, NullFunc, **kwargs)
def alias(self, alias_name, original_name, units = None):
if original_name not in self: return
diff -r 5a08f4cc1af1a18889e0dc93cb3afa908f2d3d2f -r 9b5937af58578d073179329863c7e220f8ec7df6 yt/fields/fluid_fields.py
--- a/yt/fields/fluid_fields.py
+++ b/yt/fields/fluid_fields.py
@@ -59,14 +59,14 @@
def _cell_mass(field, data):
return data[ftype, "density"] * data[ftype, "cell_volume"]
- registry.add_field((ftype, "cell_mass"),
+ registry.add_field((ftype, "cell_mass"), sampling_type="cell",
function=_cell_mass,
units=unit_system["mass"])
def _sound_speed(field, data):
tr = data.ds.gamma * data[ftype, "pressure"] / data[ftype, "density"]
return np.sqrt(tr)
- registry.add_field((ftype, "sound_speed"),
+ registry.add_field((ftype, "sound_speed"), sampling_type="cell",
function=_sound_speed,
units=unit_system["velocity"])
@@ -74,7 +74,7 @@
""" Radial component of M{|v|/c_sound} """
tr = data[ftype, "radial_velocity"] / data[ftype, "sound_speed"]
return np.abs(tr)
- registry.add_field((ftype, "radial_mach_number"),
+ registry.add_field((ftype, "radial_mach_number"), sampling_type="cell",
function=_radial_mach_number,
units = "")
@@ -82,14 +82,14 @@
return 0.5*data[ftype, "density"] * ( data[ftype, "velocity_x"]**2.0
+ data[ftype, "velocity_y"]**2.0
+ data[ftype, "velocity_z"]**2.0 )
- registry.add_field((ftype, "kinetic_energy"),
+ registry.add_field((ftype, "kinetic_energy"), sampling_type="cell",
function = _kin_energy,
units = unit_system["pressure"])
def _mach_number(field, data):
""" M{|v|/c_sound} """
return data[ftype, "velocity_magnitude"] / data[ftype, "sound_speed"]
- registry.add_field((ftype, "mach_number"),
+ registry.add_field((ftype, "mach_number"), sampling_type="cell",
function=_mach_number,
units = "")
@@ -103,7 +103,7 @@
tr = np.minimum(np.minimum(t1, t2), t3)
return tr
- registry.add_field((ftype, "courant_time_step"),
+ registry.add_field((ftype, "courant_time_step"), sampling_type="cell",
function=_courant_time_step,
units=unit_system["time"])
@@ -113,13 +113,13 @@
* (data[ftype, "density"] * data[ftype, "thermal_energy"])
return tr
- registry.add_field((ftype, "pressure"),
+ registry.add_field((ftype, "pressure"), sampling_type="cell",
function=_pressure,
units=unit_system["pressure"])
def _kT(field, data):
return (kboltz*data[ftype, "temperature"]).in_units("keV")
- registry.add_field((ftype, "kT"),
+ registry.add_field((ftype, "kT"), sampling_type="cell",
function=_kT,
units="keV",
display_name="Temperature")
@@ -132,7 +132,7 @@
gammam1 = 2./3.
tr = data[ftype,"kT"] / ((data[ftype, "density"]/mw)**gammam1)
return data.apply_units(tr, field.units)
- registry.add_field((ftype, "entropy"),
+ registry.add_field((ftype, "entropy"), sampling_type="cell",
units="keV*cm**2",
function=_entropy)
@@ -140,13 +140,13 @@
tr = data[ftype, "metal_density"] / data[ftype, "density"]
tr /= metallicity_sun
return data.apply_units(tr, "Zsun")
- registry.add_field((ftype, "metallicity"),
+ registry.add_field((ftype, "metallicity"), sampling_type="cell",
function=_metallicity,
units="Zsun")
def _metal_mass(field, data):
return data[ftype, "metal_density"] * data[ftype, "cell_volume"]
- registry.add_field((ftype, "metal_mass"),
+ registry.add_field((ftype, "metal_mass"), sampling_type="cell",
function=_metal_mass,
units=unit_system["mass"])
@@ -156,13 +156,13 @@
for species in data.ds.field_info.species_names:
field_data += data["gas", "%s_number_density" % species]
return field_data
- registry.add_field((ftype, "number_density"),
+ registry.add_field((ftype, "number_density"), sampling_type="cell",
function = _number_density,
units=unit_system["number_density"])
def _mean_molecular_weight(field, data):
return (data[ftype, "density"] / (mh * data[ftype, "number_density"]))
- registry.add_field((ftype, "mean_molecular_weight"),
+ registry.add_field((ftype, "mean_molecular_weight"), sampling_type="cell",
function=_mean_molecular_weight,
units="")
@@ -207,7 +207,7 @@
for axi, ax in enumerate('xyz'):
f = grad_func(axi, ax)
- registry.add_field((ftype, "%s_gradient_%s" % (fname, ax)),
+ registry.add_field((ftype, "%s_gradient_%s" % (fname, ax)), sampling_type="cell",
function = f,
validators = [ValidateSpatial(1, [grad_field])],
units = grad_units)
diff -r 5a08f4cc1af1a18889e0dc93cb3afa908f2d3d2f -r 9b5937af58578d073179329863c7e220f8ec7df6 yt/fields/fluid_vector_fields.py
--- a/yt/fields/fluid_vector_fields.py
+++ b/yt/fields/fluid_vector_fields.py
@@ -67,7 +67,7 @@
bv_validators = [ValidateSpatial(1, [(ftype, "density"), (ftype, "pressure")])]
for ax in 'xyz':
n = "baroclinic_vorticity_%s" % ax
- registry.add_field((ftype, n), function=eval("_%s" % n),
+ registry.add_field((ftype, n), sampling_type="cell", function=eval("_%s" % n),
validators=bv_validators,
units=unit_system["frequency"]**2)
@@ -119,7 +119,7 @@
(ftype, "velocity_z")])]
for ax in 'xyz':
n = "vorticity_%s" % ax
- registry.add_field((ftype, n),
+ registry.add_field((ftype, n), sampling_type="cell",
function=eval("_%s" % n),
units=unit_system["frequency"],
validators=vort_validators)
@@ -138,7 +138,7 @@
return data[ftype, "velocity_divergence"] * data[ftype, "vorticity_z"]
for ax in 'xyz':
n = "vorticity_stretching_%s" % ax
- registry.add_field((ftype, n),
+ registry.add_field((ftype, n), sampling_type="cell",
function=eval("_%s" % n),
units = unit_system["frequency"]**2,
validators=vort_validators)
@@ -159,7 +159,7 @@
data[ftype, "baroclinic_vorticity_z"]
for ax in 'xyz':
n = "vorticity_growth_%s" % ax
- registry.add_field((ftype, n),
+ registry.add_field((ftype, n), sampling_type="cell",
function=eval("_%s" % n),
units=unit_system["frequency"]**2,
validators=vort_validators)
@@ -175,7 +175,7 @@
result = np.sign(dot) * result
return result
- registry.add_field((ftype, "vorticity_growth_magnitude"),
+ registry.add_field((ftype, "vorticity_growth_magnitude"), sampling_type="cell",
function=_vorticity_growth_magnitude,
units=unit_system["frequency"]**2,
validators=vort_validators,
@@ -186,7 +186,7 @@
data[ftype, "vorticity_growth_y"]**2 +
data[ftype, "vorticity_growth_z"]**2)
- registry.add_field((ftype, "vorticity_growth_magnitude_absolute"),
+ registry.add_field((ftype, "vorticity_growth_magnitude_absolute"), sampling_type="cell",
function=_vorticity_growth_magnitude_absolute,
units=unit_system["frequency"]**2,
validators=vort_validators)
@@ -197,7 +197,7 @@
domegaz_dt = data[ftype, "vorticity_z"] / data[ftype, "vorticity_growth_z"]
return np.sqrt(domegax_dt**2 + domegay_dt**2 + domegaz_dt**2)
- registry.add_field((ftype, "vorticity_growth_timescale"),
+ registry.add_field((ftype, "vorticity_growth_timescale"), sampling_type="cell",
function=_vorticity_growth_timescale,
units=unit_system["time"],
validators=vort_validators)
@@ -232,7 +232,7 @@
(ftype, "radiation_acceleration_z")])]
for ax in 'xyz':
n = "vorticity_radiation_pressure_%s" % ax
- registry.add_field((ftype, n),
+ registry.add_field((ftype, n), sampling_type="cell",
function=eval("_%s" % n),
units=unit_system["frequency"]**2,
validators=vrp_validators)
@@ -257,7 +257,7 @@
for ax in 'xyz':
n = "vorticity_radiation_pressure_growth_%s" % ax
- registry.add_field((ftype, n),
+ registry.add_field((ftype, n), sampling_type="cell",
function=eval("_%s" % n),
units=unit_system["frequency"]**2,
validators=vrp_validators)
@@ -273,7 +273,7 @@
result = np.sign(dot) * result
return result
- registry.add_field((ftype, "vorticity_radiation_pressure_growth_magnitude"),
+ registry.add_field((ftype, "vorticity_radiation_pressure_growth_magnitude"), sampling_type="cell",
function=_vorticity_radiation_pressure_growth_magnitude,
units=unit_system["frequency"]**2,
validators=vrp_validators,
@@ -284,7 +284,7 @@
data[ftype, "vorticity_radiation_pressure_growth_y"]**2 +
data[ftype, "vorticity_radiation_pressure_growth_z"]**2)
- registry.add_field((ftype, "vorticity_radiation_pressure_growth_magnitude_absolute"),
+ registry.add_field((ftype, "vorticity_radiation_pressure_growth_magnitude_absolute"), sampling_type="cell",
function=_vorticity_radiation_pressure_growth_magnitude_absolute,
units="s**(-2)",
validators=vrp_validators)
@@ -298,7 +298,7 @@
data[ftype, "vorticity_radiation_pressure_growth_z"]
return np.sqrt(domegax_dt**2 + domegay_dt**2 + domegaz_dt**2)
- registry.add_field((ftype, "vorticity_radiation_pressure_growth_timescale"),
+ registry.add_field((ftype, "vorticity_radiation_pressure_growth_timescale"), sampling_type="cell",
function=_vorticity_radiation_pressure_growth_timescale,
units=unit_system["time"],
validators=vrp_validators)
@@ -344,7 +344,7 @@
new_field[sl_center, sl_center, sl_center] = f
return new_field
- registry.add_field((ftype, "shear"),
+ registry.add_field((ftype, "shear"), sampling_type="cell",
function=_shear,
validators=[ValidateSpatial(1,
[(ftype, "velocity_x"),
@@ -361,7 +361,7 @@
return data[ftype, "shear"] / data[ftype, "sound_speed"]
- registry.add_field((ftype, "shear_criterion"),
+ registry.add_field((ftype, "shear_criterion"), sampling_type="cell",
function=_shear_criterion,
units=unit_system["length"]**-1,
validators=[ValidateSpatial(1,
@@ -417,7 +417,7 @@
new_field[sl_center, sl_center, sl_center] = f
return new_field
- registry.add_field((ftype, "shear_mach"),
+ registry.add_field((ftype, "shear_mach"), sampling_type="cell",
function=_shear_mach,
units="",
validators=[ValidateSpatial(1,
diff -r 5a08f4cc1af1a18889e0dc93cb3afa908f2d3d2f -r 9b5937af58578d073179329863c7e220f8ec7df6 yt/fields/geometric_fields.py
--- a/yt/fields/geometric_fields.py
+++ b/yt/fields/geometric_fields.py
@@ -46,7 +46,7 @@
"""
return get_radius(data, "")
- registry.add_field(("index", "radius"),
+ registry.add_field(("index", "radius"), sampling_type="cell",
function=_radius,
validators=[ValidateParameter("center")],
units=unit_system["length"])
@@ -59,7 +59,7 @@
return data._reshape_vals(arr)
return arr
- registry.add_field(("index", "grid_level"),
+ registry.add_field(("index", "grid_level"), sampling_type="cell",
function=_grid_level,
units="",
validators=[ValidateSpatial(0)])
@@ -76,7 +76,7 @@
return data._reshape_vals(arr)
return arr
- registry.add_field(("index", "grid_indices"),
+ registry.add_field(("index", "grid_indices"), sampling_type="cell",
function=_grid_indices,
units="",
validators=[ValidateSpatial(0)],
@@ -87,7 +87,7 @@
return np.ones(data["index", "ones"].shape,
dtype="float64")/data["index", "dx"]
- registry.add_field(("index", "ones_over_dx"),
+ registry.add_field(("index", "ones_over_dx"), sampling_type="cell",
function=_ones_over_dx,
units=unit_system["length"]**-1,
display_field=False)
@@ -97,7 +97,7 @@
arr = np.zeros(data["index", "ones"].shape, dtype='float64')
return data.apply_units(arr, field.units)
- registry.add_field(("index", "zeros"),
+ registry.add_field(("index", "zeros"), sampling_type="cell",
function=_zeros,
units="",
display_field=False)
@@ -109,7 +109,7 @@
return data._reshape_vals(arr)
return data.apply_units(arr, field.units)
- registry.add_field(("index", "ones"),
+ registry.add_field(("index", "ones"), sampling_type="cell",
function=_ones,
units="",
display_field=False)
@@ -132,7 +132,7 @@
data["index", "z"].ravel(), LE, RE)
morton.shape = data["index", "x"].shape
return morton.view("f8")
- registry.add_field(("index", "morton_index"), function=_morton_index,
+ registry.add_field(("index", "morton_index"), sampling_type="cell", function=_morton_index,
units = "")
def _spherical_radius(field, data):
@@ -144,7 +144,7 @@
coords = get_periodic_rvec(data)
return data.ds.arr(get_sph_r(coords), "code_length").in_base(unit_system.name)
- registry.add_field(("index", "spherical_radius"),
+ registry.add_field(("index", "spherical_radius"), sampling_type="cell",
function=_spherical_radius,
validators=[ValidateParameter("center")],
units=unit_system["length"])
@@ -153,7 +153,7 @@
"""This field is deprecated and will be removed in a future release"""
return data['index', 'spherical_radius']
- registry.add_field(("index", "spherical_r"),
+ registry.add_field(("index", "spherical_r"), sampling_type="cell",
function=_spherical_r,
validators=[ValidateParameter("center")],
units=unit_system["length"])
@@ -171,7 +171,7 @@
coords = get_periodic_rvec(data)
return get_sph_theta(coords, normal)
- registry.add_field(("index", "spherical_theta"),
+ registry.add_field(("index", "spherical_theta"), sampling_type="cell",
function=_spherical_theta,
validators=[ValidateParameter("center"),
ValidateParameter("normal")],
@@ -190,7 +190,7 @@
coords = get_periodic_rvec(data)
return get_sph_phi(coords, normal)
- registry.add_field(("index", "spherical_phi"),
+ registry.add_field(("index", "spherical_phi"), sampling_type="cell",
function=_spherical_phi,
validators=[ValidateParameter("center"),
ValidateParameter("normal")],
@@ -206,7 +206,7 @@
coords = get_periodic_rvec(data)
return data.ds.arr(get_cyl_r(coords, normal), "code_length").in_base(unit_system.name)
- registry.add_field(("index", "cylindrical_radius"),
+ registry.add_field(("index", "cylindrical_radius"), sampling_type="cell",
function=_cylindrical_radius,
validators=[ValidateParameter("center"),
ValidateParameter("normal")],
@@ -216,7 +216,7 @@
"""This field is deprecated and will be removed in a future release"""
return data['index', 'cylindrical_radius']
- registry.add_field(("index", "cylindrical_r"),
+ registry.add_field(("index", "cylindrical_r"), sampling_type="cell",
function=_cylindrical_r,
validators=[ValidateParameter("center")],
units=unit_system["length"])
@@ -231,7 +231,7 @@
coords = get_periodic_rvec(data)
return data.ds.arr(get_cyl_z(coords, normal), "code_length").in_base(unit_system.name)
- registry.add_field(("index", "cylindrical_z"),
+ registry.add_field(("index", "cylindrical_z"), sampling_type="cell",
function=_cylindrical_z,
validators=[ValidateParameter("center"),
ValidateParameter("normal")],
@@ -250,7 +250,7 @@
coords = get_periodic_rvec(data)
return get_cyl_theta(coords, normal)
- registry.add_field(("index", "cylindrical_theta"),
+ registry.add_field(("index", "cylindrical_theta"), sampling_type="cell",
function=_cylindrical_theta,
validators=[ValidateParameter("center"),
ValidateParameter("normal")],
@@ -260,7 +260,7 @@
"""This field is dprecated and will be removed in a future release"""
return data["index", "spherical_theta"]
- registry.add_field(("index", "disk_angle"),
+ registry.add_field(("index", "disk_angle"), sampling_type="cell",
function=_disk_angle,
take_log=False,
display_field=False,
@@ -272,7 +272,7 @@
"""This field is deprecated and will be removed in a future release"""
return data["index", "cylindrical_z"]
- registry.add_field(("index", "height"),
+ registry.add_field(("index", "height"), sampling_type="cell",
function=_height,
validators=[ValidateParameter("center"),
ValidateParameter("normal")],
diff -r 5a08f4cc1af1a18889e0dc93cb3afa908f2d3d2f -r 9b5937af58578d073179329863c7e220f8ec7df6 yt/fields/local_fields.py
--- a/yt/fields/local_fields.py
+++ b/yt/fields/local_fields.py
@@ -12,6 +12,7 @@
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
+import warnings
from yt.utilities.logger import \
ytLogger as mylog
@@ -23,7 +24,7 @@
FieldInfoContainer
class LocalFieldInfoContainer(FieldInfoContainer):
- def add_field(self, name, function=None, **kwargs):
+ def add_field(self, name, function=None, sampling_type=None, **kwargs):
if not isinstance(name, tuple):
if kwargs.setdefault('particle_type', False):
name = ('all', name)
@@ -34,8 +35,19 @@
if not override and name in self:
mylog.warning("Field %s already exists. To override use " +
"force_override=True.", name)
+ if kwargs.setdefault('particle_type', False):
+ if sampling_type is not None and sampling_type != "particle":
+ raise RuntimeError("Clashing definition of 'sampling_type' and "
+ "'particle_type'. Note that 'particle_type' is "
+ "deprecated. Please just use 'sampling_type'.")
+ else:
+ sampling_type = "particle"
+ if sampling_type is None:
+ warnings.warn("Because 'sampling_type' not specified, yt will "
+ "assume a cell 'sampling_type'")
+ sampling_type = "cell"
return super(LocalFieldInfoContainer,
- self).add_field(name, function, **kwargs)
+ self).add_field(name, sampling_type, function, **kwargs)
# Empty FieldInfoContainer
local_fields = LocalFieldInfoContainer(None, [], None)
diff -r 5a08f4cc1af1a18889e0dc93cb3afa908f2d3d2f -r 9b5937af58578d073179329863c7e220f8ec7df6 yt/fields/magnetic_field.py
--- a/yt/fields/magnetic_field.py
+++ b/yt/fields/magnetic_field.py
@@ -46,26 +46,26 @@
data[ftype,"magnetic_field_y"]**2 +
data[ftype,"magnetic_field_z"]**2)
return np.sqrt(B2)
- registry.add_field((ftype,"magnetic_field_strength"),
+ registry.add_field((ftype,"magnetic_field_strength"), sampling_type="cell",
function=_magnetic_field_strength,
units=u)
def _magnetic_energy(field, data):
B = data[ftype,"magnetic_field_strength"]
return 0.5*B*B/mag_factors[B.units.dimensions]
- registry.add_field((ftype, "magnetic_energy"),
+ registry.add_field((ftype, "magnetic_energy"), sampling_type="cell",
function=_magnetic_energy,
units=unit_system["pressure"])
def _plasma_beta(field,data):
return data[ftype,'pressure']/data[ftype,'magnetic_energy']
- registry.add_field((ftype, "plasma_beta"),
+ registry.add_field((ftype, "plasma_beta"), sampling_type="cell",
function=_plasma_beta,
units="")
def _magnetic_pressure(field,data):
return data[ftype,'magnetic_energy']
- registry.add_field((ftype, "magnetic_pressure"),
+ registry.add_field((ftype, "magnetic_pressure"), sampling_type="cell",
function=_magnetic_pressure,
units=unit_system["pressure"])
@@ -83,7 +83,7 @@
return get_sph_theta_component(Bfields, theta, phi, normal)
- registry.add_field((ftype, "magnetic_field_poloidal"),
+ registry.add_field((ftype, "magnetic_field_poloidal"), sampling_type="cell",
function=_magnetic_field_poloidal,
units=u, validators=[ValidateParameter("normal")])
@@ -99,19 +99,19 @@
phi = data["index", 'spherical_phi']
return get_sph_phi_component(Bfields, phi, normal)
- registry.add_field((ftype, "magnetic_field_toroidal"),
+ registry.add_field((ftype, "magnetic_field_toroidal"), sampling_type="cell",
function=_magnetic_field_toroidal,
units=u, validators=[ValidateParameter("normal")])
def _alfven_speed(field,data):
B = data[ftype,'magnetic_field_strength']
return B/np.sqrt(mag_factors[B.units.dimensions]*data[ftype,'density'])
- registry.add_field((ftype, "alfven_speed"), function=_alfven_speed,
+ registry.add_field((ftype, "alfven_speed"), sampling_type="cell", function=_alfven_speed,
units=unit_system["velocity"])
def _mach_alfven(field,data):
return data[ftype,'velocity_magnitude']/data[ftype,'alfven_speed']
- registry.add_field((ftype, "mach_alfven"), function=_mach_alfven,
+ registry.add_field((ftype, "mach_alfven"), sampling_type="cell", function=_mach_alfven,
units="dimensionless")
def setup_magnetic_field_aliases(registry, ds_ftype, ds_fields, ftype="gas"):
@@ -161,6 +161,6 @@
return convert(data[fd])
return _mag_field
for ax, fd in zip("xyz", ds_fields):
- registry.add_field((ftype,"magnetic_field_%s" % ax),
+ registry.add_field((ftype,"magnetic_field_%s" % ax), sampling_type="cell",
function=mag_field(fd),
- units=unit_system[to_units.dimensions])
\ No newline at end of file
+ units=unit_system[to_units.dimensions])
diff -r 5a08f4cc1af1a18889e0dc93cb3afa908f2d3d2f -r 9b5937af58578d073179329863c7e220f8ec7df6 yt/fields/particle_fields.py
--- a/yt/fields/particle_fields.py
+++ b/yt/fields/particle_fields.py
@@ -103,6 +103,7 @@
return data.apply_units(d, field.units)
registry.add_field(("deposit", "%s_count" % ptype),
+ sampling_type="cell",
function = particle_count,
validators = [ValidateSpatial()],
units = '',
@@ -116,6 +117,7 @@
return data.apply_units(d, field.units)
registry.add_field(("deposit", "%s_mass" % ptype),
+ sampling_type="cell",
function = particle_mass,
validators = [ValidateSpatial()],
display_name = r"\mathrm{%s Mass}" % ptype_dn,
@@ -130,6 +132,7 @@
return d
registry.add_field(("deposit", "%s_density" % ptype),
+ sampling_type="cell",
function = particle_density,
validators = [ValidateSpatial()],
display_name = r"\mathrm{%s Density}" % ptype_dn,
@@ -143,6 +146,7 @@
return d
registry.add_field(("deposit", "%s_cic" % ptype),
+ sampling_type="cell",
function = particle_cic,
validators = [ValidateSpatial()],
display_name = r"\mathrm{%s CIC Density}" % ptype_dn,
@@ -171,7 +175,7 @@
function = _get_density_weighted_deposit_field(
"particle_velocity_%s" % ax, "cm/s", method)
registry.add_field(
- ("deposit", ("%s_"+name+"_velocity_%s") % (ptype, ax)),
+ ("deposit", ("%s_"+name+"_velocity_%s") % (ptype, ax)), sampling_type="cell",
function=function, units=unit_system["velocity"], take_log=False,
validators=[ValidateSpatial(0)])
@@ -179,7 +183,7 @@
function = _get_density_weighted_deposit_field(
"age", "s", method)
registry.add_field(
- ("deposit", ("%s_"+name+"_age") % (ptype)),
+ ("deposit", ("%s_"+name+"_age") % (ptype)), sampling_type="cell",
function=function, units=unit_system["time"], take_log=False,
validators=[ValidateSpatial(0)])
@@ -190,8 +194,8 @@
return data.apply_units(v, field.units)
registry.add_field((ptype, "particle_ones"),
+ sampling_type="particle",
function = particle_ones,
- sampling_type = "particle",
units = "",
display_name = r"Particle Count")
@@ -204,10 +208,10 @@
data.deposit(pos, [ids], method = "mesh_id")
return data.apply_units(ids, "")
registry.add_field((ptype, "mesh_id"),
+ sampling_type="particle",
function = particle_mesh_ids,
validators = [ValidateSpatial()],
- units = '',
- sampling_type = "particle")
+ units = '')
return list(set(registry.keys()).difference(orig))
@@ -228,16 +232,14 @@
for axi, ax in enumerate("xyz"):
v, p = _get_coord_funcs(axi, ptype)
registry.add_field((ptype, "particle_velocity_%s" % ax),
- sampling_type = "particle", function = v,
- units = "code_velocity")
+ sampling_type="particle", function = v, units = "code_velocity")
registry.add_field((ptype, "particle_position_%s" % ax),
- sampling_type = "particle", function = p,
- units = "code_length")
+ sampling_type="particle", function = p, units = "code_length")
def particle_vector_functions(ptype, coord_names, vel_names, registry):
unit_system = registry.ds.unit_system
-
+
# This will column_stack a set of scalars to create vector fields.
def _get_vec_func(_ptype, names):
@@ -248,13 +250,13 @@
return data.apply_units(c, field.units)
return particle_vectors
registry.add_field((ptype, "particle_position"),
+ sampling_type="particle",
function=_get_vec_func(ptype, coord_names),
- units = "code_length",
- particle_type=True)
+ units = "code_length")
registry.add_field((ptype, "particle_velocity"),
+ sampling_type="particle",
function=_get_vec_func(ptype, vel_names),
- units = unit_system["velocity"],
- particle_type=True)
+ units = unit_system["velocity"])
def get_angular_momentum_components(ptype, data, spos, svel):
if data.has_field_parameter("normal"):
@@ -282,8 +284,8 @@
+ (data[ptype, svel % 'z'] - bulk_velocity[2])**2 )
registry.add_field((ptype, "particle_velocity_magnitude"),
+ sampling_type="particle",
function=_particle_velocity_magnitude,
- particle_type=True,
take_log=False,
units=unit_system["velocity"])
@@ -301,8 +303,8 @@
registry.add_field((ptype, "particle_specific_angular_momentum"),
+ sampling_type="particle",
function=_particle_specific_angular_momentum,
- particle_type=True,
units=unit_system["specific_angular_momentum"],
validators=[ValidateParameter("center")])
@@ -318,11 +320,11 @@
f, v = _get_spec_ang_mom_comp(axi, ax, ptype)
registry.add_field(
(ptype, "particle_specific_angular_momentum_%s" % ax),
- sampling_type = "particle", function=f, units=unit_system["specific_angular_momentum"],
+ sampling_type="particle", function=f, units=unit_system["specific_angular_momentum"],
validators=[ValidateParameter("center")]
)
registry.add_field((ptype, "particle_angular_momentum_%s" % ax),
- function=v, units=unit_system["angular_momentum"], particle_type=True,
+ sampling_type="particle", function=v, units=unit_system["angular_momentum"],
validators=[ValidateParameter('center')])
def _particle_angular_momentum(field, data):
@@ -330,13 +332,13 @@
return am.T
registry.add_field((ptype, "particle_angular_momentum"),
+ sampling_type="particle",
function=_particle_angular_momentum,
- particle_type=True,
units=unit_system["angular_momentum"],
validators=[ValidateParameter("center")])
create_magnitude_field(registry, "particle_angular_momentum",
- unit_system["angular_momentum"],
+ unit_system["angular_momentum"],
ftype=ptype, particle_type=True)
def _particle_radius(field, data):
@@ -349,9 +351,9 @@
registry.add_field(
(ptype, "particle_radius"),
+ sampling_type="particle",
function=_particle_radius,
units=unit_system["length"],
- particle_type=True,
validators=[ValidateParameter("center")])
def _particle_position_relative(field, data):
@@ -370,8 +372,8 @@
registry.add_field(
(ptype, "particle_position_relative"),
+ sampling_type="particle",
function=_particle_position_relative,
- particle_type=True,
units=unit_system["length"],
validators=[ValidateParameter("normal"), ValidateParameter("center")])
@@ -391,8 +393,9 @@
return vel
registry.add_field((ptype, "particle_velocity_relative"),
+ sampling_type="particle",
function=_particle_velocity_relative,
- particle_type=True, units=unit_system["velocity"],
+ units=unit_system["velocity"],
validators=[ValidateParameter("normal"),
ValidateParameter("center")])
@@ -406,18 +409,17 @@
for axi, ax in enumerate("xyz"):
v, p = _get_coord_funcs_relative(axi, ptype)
registry.add_field((ptype, "particle_velocity_relative_%s" % ax),
- sampling_type = "particle", function = v,
- units = "code_velocity")
+ sampling_type="particle", function = v, units = "code_velocity")
registry.add_field((ptype, "particle_position_relative_%s" % ax),
- sampling_type = "particle", function = p,
- units = "code_length")
+ sampling_type="particle", function = p, units = "code_length")
# this is just particle radius but we add it with an alias for the sake of
# consistent naming
registry.add_field((ptype, "particle_position_spherical_radius"),
+ sampling_type="particle",
function=_particle_radius,
- particle_type=True, units=unit_system["length"],
+ units=unit_system["length"],
validators=[ValidateParameter("normal"),
ValidateParameter("center")])
@@ -426,8 +428,9 @@
return data[ptype, 'particle_position_spherical_radius']
registry.add_field((ptype, "particle_spherical_position_radius"),
+ sampling_type="particle",
function=_particle_spherical_position_radius,
- particle_type=True, units=unit_system["length"],
+ units=unit_system["length"],
validators=[ValidateParameter("normal"),
ValidateParameter("center")])
@@ -445,8 +448,8 @@
registry.add_field(
(ptype, "particle_position_spherical_theta"),
+ sampling_type="particle",
function=_particle_position_spherical_theta,
- particle_type=True,
units="",
validators=[ValidateParameter("center"), ValidateParameter("normal")])
@@ -455,8 +458,9 @@
return data[ptype, 'particle_position_spherical_theta']
registry.add_field((ptype, "particle_spherical_position_theta"),
+ sampling_type="particle",
function=_particle_spherical_position_theta,
- particle_type=True, units="",
+ units="",
validators=[ValidateParameter("normal"),
ValidateParameter("center")])
@@ -474,8 +478,8 @@
registry.add_field(
(ptype, "particle_position_spherical_phi"),
+ sampling_type="particle",
function=_particle_position_spherical_phi,
- particle_type=True,
units="",
validators=[ValidateParameter("normal"), ValidateParameter("center")])
@@ -484,8 +488,9 @@
return data[ptype, 'particle_position_spherical_phi']
registry.add_field((ptype, "particle_spherical_position_phi"),
+ sampling_type="particle",
function=_particle_spherical_position_phi,
- particle_type=True, units="",
+ units="",
validators=[ValidateParameter("center"),
ValidateParameter("normal")])
@@ -509,8 +514,9 @@
return sphr
registry.add_field((ptype, "particle_velocity_spherical_radius"),
+ sampling_type="particle",
function=_particle_velocity_spherical_radius,
- particle_type=True, units=unit_system["velocity"],
+ units=unit_system["velocity"],
validators=[ValidateParameter("normal"),
ValidateParameter("center")])
@@ -519,16 +525,18 @@
return data[ptype, 'particle_velocity_spherical_radius']
registry.add_field((ptype, "particle_spherical_velocity_radius"),
+ sampling_type="particle",
function=_particle_spherical_velocity_radius,
- particle_type=True, units=unit_system["velocity"],
+ units=unit_system["velocity"],
validators=[ValidateParameter("normal"),
ValidateParameter("center")])
# particel_velocity_spherical_radius is simply aliased to
# "particle_radial_velocity" for convenience
registry.add_field((ptype, "particle_radial_velocity"),
+ sampling_type="particle",
function=_particle_spherical_velocity_radius,
- particle_type=True, units=unit_system["velocity"],
+ units=unit_system["velocity"],
validators=[ValidateParameter("normal"),
ValidateParameter("center")])
@@ -553,8 +561,8 @@
registry.add_field(
(ptype, "particle_velocity_spherical_theta"),
+ sampling_type="particle",
function=_particle_velocity_spherical_theta,
- particle_type=True,
units=unit_system["velocity"],
validators=[ValidateParameter("normal"), ValidateParameter("center")])
@@ -563,8 +571,9 @@
return data[ptype, 'particle_velocity_spherical_theta']
registry.add_field((ptype, "particle_spherical_velocity_theta"),
+ sampling_type="particle",
function=_particle_spherical_velocity_theta,
- particle_type=True, units=unit_system["velocity"],
+ units=unit_system["velocity"],
validators=[ValidateParameter("normal"),
ValidateParameter("center")])
@@ -587,8 +596,8 @@
registry.add_field(
(ptype, "particle_velocity_spherical_phi"),
+ sampling_type="particle",
function=_particle_velocity_spherical_phi,
- particle_type=True,
units=unit_system["velocity"],
validators=[ValidateParameter("normal"), ValidateParameter("center")])
@@ -597,8 +606,9 @@
return data[ptype, 'particle_spherical_velocity_theta']
registry.add_field((ptype, "particle_spherical_velocity_phi"),
+ sampling_type="particle",
function=_particle_spherical_velocity_phi,
- particle_type=True, units=unit_system["velocity"],
+ units=unit_system["velocity"],
validators=[ValidateParameter("normal"),
ValidateParameter("center")])
@@ -617,9 +627,9 @@
registry.add_field(
(ptype, "particle_position_cylindrical_radius"),
+ sampling_type="particle",
function=_particle_position_cylindrical_radius,
units=unit_system["length"],
- particle_type=True,
validators=[ValidateParameter("normal"), ValidateParameter("center")])
def _particle_position_cylindrical_theta(field,data):
@@ -636,8 +646,8 @@
registry.add_field(
(ptype, "particle_position_cylindrical_theta"),
+ sampling_type="particle",
function=_particle_position_cylindrical_theta,
- particle_type=True,
units="",
validators=[ValidateParameter("center"), ValidateParameter("normal")])
@@ -656,9 +666,9 @@
registry.add_field(
(ptype, "particle_position_cylindrical_z"),
+ sampling_type="particle",
function=_particle_position_cylindrical_z,
units=unit_system["length"],
- particle_type=True,
validators=[ValidateParameter("normal"), ValidateParameter("center")])
def _particle_velocity_cylindrical_radius(field, data):
@@ -680,8 +690,8 @@
registry.add_field(
(ptype, "particle_velocity_cylindrical_radius"),
+ sampling_type="particle",
function=_particle_velocity_cylindrical_radius,
- particle_type=True,
units=unit_system["velocity"],
validators=[ValidateParameter("normal"), ValidateParameter("center")])
@@ -704,8 +714,8 @@
registry.add_field(
(ptype, "particle_velocity_cylindrical_theta"),
+ sampling_type="particle",
function=_particle_velocity_cylindrical_theta,
- particle_type=True,
units=unit_system["velocity"],
validators=[ValidateParameter("normal"), ValidateParameter("center")])
@@ -714,8 +724,9 @@
return data[ptype, 'particle_velocity_cylindrical_theta']
registry.add_field((ptype, "particle_cylindrical_velocity_theta"),
+ sampling_type="particle",
function=_particle_cylindrical_velocity_theta,
- particle_type=True, units="cm/s",
+ units="cm/s",
validators=[ValidateParameter("normal"),
ValidateParameter("center")])
@@ -737,8 +748,8 @@
registry.add_field(
(ptype, "particle_velocity_cylindrical_z"),
+ sampling_type="particle",
function=_particle_velocity_cylindrical_z,
- particle_type=True,
units=unit_system["velocity"],
validators=[ValidateParameter("normal"), ValidateParameter("center")])
@@ -747,8 +758,9 @@
return data[ptype, "particle_velocity_cylindrical_z"]
registry.add_field((ptype, "particle_cylindrical_velocity_z"),
+ sampling_type="particle",
function=_particle_cylindrical_velocity_z,
- particle_type=True, units=unit_system["velocity"],
+ units=unit_system["velocity"],
validators=[ValidateParameter("normal"),
ValidateParameter("center")])
@@ -769,9 +781,8 @@
v[np.isnan(v)] = 0.0
return v
fn = ("deposit", "%s_avg_%s" % (ptype, field_name))
- registry.add_field(fn, function=_pfunc_avg,
+ registry.add_field(fn, sampling_type="cell", function=_pfunc_avg,
validators = [ValidateSpatial(0)],
- particle_type = False,
units = field_units)
return fn
@@ -816,7 +827,7 @@
rv /= hsml.uq**3 / hsml.uq.in_base(unit_system.name).uq**3
rv = data.apply_units(rv, field_units)
return rv
- registry.add_field(field_name, function = _vol_weight,
+ registry.add_field(field_name, sampling_type="cell", function = _vol_weight,
validators = [ValidateSpatial(0)],
units = field_units)
registry.find_dependencies((field_name,))
@@ -833,9 +844,8 @@
nneighbors = nneighbors)
# Now some quick unit conversions.
return distances
- registry.add_field(field_name, function = _nth_neighbor,
+ registry.add_field(field_name, sampling_type="particle", function = _nth_neighbor,
validators = [ValidateSpatial(0)],
- sampling_type = "particle",
units = "code_length")
return [field_name]
@@ -850,6 +860,6 @@
for dep_type in data.ds.particle_types_raw])
registry.add_field((ptype, field_name),
+ sampling_type="particle",
function=_cat_field,
- particle_type=True,
units=units)
diff -r 5a08f4cc1af1a18889e0dc93cb3afa908f2d3d2f -r 9b5937af58578d073179329863c7e220f8ec7df6 yt/fields/species_fields.py
--- a/yt/fields/species_fields.py
+++ b/yt/fields/species_fields.py
@@ -75,17 +75,17 @@
"""
unit_system = registry.ds.unit_system
- registry.add_field((ftype, "%s_fraction" % species),
+ registry.add_field((ftype, "%s_fraction" % species), sampling_type="cell",
function = _create_fraction_func(ftype, species),
particle_type = particle_type,
units = "")
- registry.add_field((ftype, "%s_mass" % species),
+ registry.add_field((ftype, "%s_mass" % species), sampling_type="cell",
function = _create_mass_func(ftype, species),
particle_type = particle_type,
units = unit_system["mass"])
- registry.add_field((ftype, "%s_number_density" % species),
+ registry.add_field((ftype, "%s_number_density" % species), sampling_type="cell",
function = _create_number_density_func(ftype, species),
particle_type = particle_type,
units = unit_system["number_density"])
@@ -103,17 +103,17 @@
"""
unit_system = registry.ds.unit_system
- registry.add_field((ftype, "%s_density" % species),
+ registry.add_field((ftype, "%s_density" % species), sampling_type="cell",
function = _create_density_func(ftype, species),
particle_type = particle_type,
units = unit_system["density"])
- registry.add_field((ftype, "%s_mass" % species),
+ registry.add_field((ftype, "%s_mass" % species), sampling_type="cell",
function = _create_mass_func(ftype, species),
particle_type = particle_type,
units = unit_system["mass"])
- registry.add_field((ftype, "%s_number_density" % species),
+ registry.add_field((ftype, "%s_number_density" % species), sampling_type="cell",
function = _create_number_density_func(ftype, species),
particle_type = particle_type,
units = unit_system["number_density"])
@@ -145,13 +145,13 @@
unit_system = registry.ds.unit_system
elements = _get_all_elements(registry.species_names)
for element in elements:
- registry.add_field((ftype, "%s_nuclei_density" % element),
+ registry.add_field((ftype, "%s_nuclei_density" % element), sampling_type="cell",
function = _nuclei_density,
particle_type = particle_type,
units = unit_system["number_density"])
if len(elements) == 0:
for element in ["H", "He"]:
- registry.add_field((ftype, "%s_nuclei_density" % element),
+ registry.add_field((ftype, "%s_nuclei_density" % element), sampling_type="cell",
function = _default_nuclei_density,
particle_type = particle_type,
units = unit_system["number_density"])
diff -r 5a08f4cc1af1a18889e0dc93cb3afa908f2d3d2f -r 9b5937af58578d073179329863c7e220f8ec7df6 yt/fields/vector_operations.py
--- a/yt/fields/vector_operations.py
+++ b/yt/fields/vector_operations.py
@@ -44,7 +44,7 @@
mag += data[fn] * data[fn]
return np.sqrt(mag)
- registry.add_field((ftype, "%s_magnitude" % basename),
+ registry.add_field((ftype, "%s_magnitude" % basename), sampling_type="cell",
function=_magnitude, units=field_units,
validators=validators, particle_type=particle_type)
@@ -62,7 +62,7 @@
squared += data[fn] * data[fn]
return squared
- registry.add_field((ftype, "%s_squared" % basename),
+ registry.add_field((ftype, "%s_squared" % basename), sampling_type="cell",
function=_squared, units=field_units,
validators=validators, particle_type=particle_type)
@@ -110,7 +110,7 @@
rv[np.isnan(theta)] = 0.0
return rv
- registry.add_field((ftype, "%s_spherical_radius" % basename),
+ registry.add_field((ftype, "%s_spherical_radius" % basename), sampling_type="cell",
function=_spherical_radius_component,
units=field_units,
validators=[ValidateParameter("normal"),
@@ -127,17 +127,17 @@
return np.sqrt(data[ftype, "%s_magnitude" % basename]**2.0 -
data[ftype, "%s_spherical_radius" % basename]**2.0)
- registry.add_field((ftype, "radial_%s" % basename),
+ registry.add_field((ftype, "radial_%s" % basename), sampling_type="cell",
function=_radial,
units=field_units,
validators=[ValidateParameter("normal"),
ValidateParameter("center")])
- registry.add_field((ftype, "radial_%s_absolute" % basename),
+ registry.add_field((ftype, "radial_%s_absolute" % basename), sampling_type="cell",
function=_radial_absolute,
units=field_units)
- registry.add_field((ftype, "tangential_%s" % basename),
+ registry.add_field((ftype, "tangential_%s" % basename), sampling_type="cell",
function=_tangential,
units=field_units)
@@ -154,7 +154,7 @@
phi = resize_vector(data["index", "spherical_phi"], vectors)
return get_sph_theta_component(vectors, theta, phi, normal)
- registry.add_field((ftype, "%s_spherical_theta" % basename),
+ registry.add_field((ftype, "%s_spherical_theta" % basename), sampling_type="cell",
function=_spherical_theta_component,
units=field_units,
validators=[ValidateParameter("normal"),
@@ -173,7 +173,7 @@
phi = resize_vector(data["index", "spherical_phi"], vectors)
return get_sph_phi_component(vectors, phi, normal)
- registry.add_field((ftype, "%s_spherical_phi" % basename),
+ registry.add_field((ftype, "%s_spherical_phi" % basename), sampling_type="cell",
function=_spherical_phi_component,
units=field_units,
validators=[ValidateParameter("normal"),
@@ -192,13 +192,13 @@
return tr
return _cp_val
- registry.add_field((ftype, "cutting_plane_%s_x" % basename),
+ registry.add_field((ftype, "cutting_plane_%s_x" % basename), sampling_type="cell",
function=_cp_vectors('x'),
units=field_units)
- registry.add_field((ftype, "cutting_plane_%s_y" % basename),
+ registry.add_field((ftype, "cutting_plane_%s_y" % basename), sampling_type="cell",
function=_cp_vectors('y'),
units=field_units)
- registry.add_field((ftype, "cutting_plane_%s_z" % basename),
+ registry.add_field((ftype, "cutting_plane_%s_z" % basename), sampling_type="cell",
function=_cp_vectors('z'),
units=field_units)
@@ -223,12 +223,12 @@
field_units = Unit(field_units, registry=registry.ds.unit_registry)
div_units = field_units / registry.ds.unit_system["length"]
- registry.add_field((ftype, "%s_divergence" % basename),
+ registry.add_field((ftype, "%s_divergence" % basename), sampling_type="cell",
function=_divergence,
units=div_units,
validators=[ValidateSpatial(1)])
- registry.add_field((ftype, "%s_divergence_absolute" % basename),
+ registry.add_field((ftype, "%s_divergence_absolute" % basename), sampling_type="cell",
function=_divergence_abs,
units=div_units)
@@ -236,7 +236,7 @@
tr = data[ftype, "tangential_%s" % basename] / \
data[ftype, "%s_magnitude" % basename]
return np.abs(tr)
- registry.add_field((ftype, "tangential_over_%s_magnitude" % basename),
+ registry.add_field((ftype, "tangential_over_%s_magnitude" % basename), sampling_type="cell",
function=_tangential_over_magnitude,
take_log=False)
@@ -252,7 +252,7 @@
theta = resize_vector(data["index", 'cylindrical_theta'], vectors)
return get_cyl_r_component(vectors, theta, normal)
- registry.add_field((ftype, "%s_cylindrical_radius" % basename),
+ registry.add_field((ftype, "%s_cylindrical_radius" % basename), sampling_type="cell",
function=_cylindrical_radius_component,
units=field_units,
validators=[ValidateParameter("normal")])
@@ -261,7 +261,7 @@
"""This field is deprecated and will be removed in a future version"""
return data[ftype, '%s_cylindrical_radius' % basename]
- registry.add_field((ftype, "cylindrical_radial_%s" % basename),
+ registry.add_field((ftype, "cylindrical_radial_%s" % basename), sampling_type="cell",
function=_cylindrical_radial,
units=field_units)
@@ -269,7 +269,7 @@
"""This field is deprecated and will be removed in a future version"""
return np.abs(data[ftype, '%s_cylindrical_radius' % basename])
- registry.add_field((ftype, "cylindrical_radial_%s_absolute" % basename),
+ registry.add_field((ftype, "cylindrical_radial_%s_absolute" % basename), sampling_type="cell",
function=_cylindrical_radial_absolute,
units=field_units,
validators=[ValidateParameter("normal")])
@@ -287,7 +287,7 @@
theta = np.tile(theta, (3,) + (1,)*len(theta.shape))
return get_cyl_theta_component(vectors, theta, normal)
- registry.add_field((ftype, "%s_cylindrical_theta" % basename),
+ registry.add_field((ftype, "%s_cylindrical_theta" % basename), sampling_type="cell",
function=_cylindrical_theta_component,
units=field_units,
validators=[ValidateParameter("normal"),
@@ -302,11 +302,11 @@
"""This field is deprecated and will be removed in a future release"""
return np.abs(data['cylindrical_tangential_%s' % basename])
- registry.add_field((ftype, "cylindrical_tangential_%s" % basename),
+ registry.add_field((ftype, "cylindrical_tangential_%s" % basename), sampling_type="cell",
function=_cylindrical_tangential,
units=field_units)
- registry.add_field((ftype, "cylindrical_tangential_%s_absolute" % basename),
+ registry.add_field((ftype, "cylindrical_tangential_%s_absolute" % basename), sampling_type="cell",
function=_cylindrical_tangential_absolute,
units=field_units)
@@ -320,7 +320,7 @@
vectors = obtain_rv_vec(data, (xn, yn, zn), "bulk_%s" % basename)
return get_cyl_z_component(vectors, normal)
- registry.add_field((ftype, "%s_cylindrical_z" % basename),
+ registry.add_field((ftype, "%s_cylindrical_z" % basename), sampling_type="cell",
function=_cylindrical_z_component,
units=field_units,
validators=[ValidateParameter("normal"),
@@ -356,7 +356,7 @@
new_field2[1:-1, 1:-1, 1:-1] = new_field / weight_field
return new_field2
- registry.add_field((ftype, "averaged_%s" % basename),
+ registry.add_field((ftype, "averaged_%s" % basename), sampling_type="cell",
function=_averaged_field,
units=field_units,
validators=validators)
diff -r 5a08f4cc1af1a18889e0dc93cb3afa908f2d3d2f -r 9b5937af58578d073179329863c7e220f8ec7df6 yt/frontends/art/fields.py
--- a/yt/frontends/art/fields.py
+++ b/yt/frontends/art/fields.py
@@ -65,7 +65,7 @@
tr *= (data.ds.parameters['gamma'] - 1.)
tr /= data.ds.parameters['aexpn']**2
return tr * data['art', 'GasEnergy'] / data['art', 'Density']
- self.add_field(('gas', 'temperature'),
+ self.add_field(('gas', 'temperature'), sampling_type="cell",
function=_temperature,
units=unit_system["temperature"])
@@ -75,7 +75,7 @@
data[('gas','density')])
return velocity
for ax in 'xyz':
- self.add_field(('gas','velocity_%s' % ax),
+ self.add_field(('gas','velocity_%s' % ax), sampling_type="cell",
function = _get_vel(ax),
units=unit_system["velocity"])
@@ -85,7 +85,7 @@
data['gas','momentum_z']**2)**0.5
tr *= data['index','cell_volume'].in_units('cm**3')
return tr
- self.add_field(('gas', 'momentum_magnitude'),
+ self.add_field(('gas', 'momentum_magnitude'), sampling_type="cell",
function=_momentum_magnitude,
units=unit_system["momentum"])
@@ -93,7 +93,7 @@
tr = data['gas','momentum_magnitude']
tr /= data['gas','cell_mass']
return tr
- self.add_field(('gas', 'velocity_magnitude'),
+ self.add_field(('gas', 'velocity_magnitude'), sampling_type="cell",
function=_velocity_magnitude,
units=unit_system["velocity"])
@@ -101,7 +101,7 @@
tr = data['gas','metal_ia_density']
tr += data['gas','metal_ii_density']
return tr
- self.add_field(('gas','metal_density'),
+ self.add_field(('gas','metal_density'), sampling_type="cell",
function=_metal_density,
units=unit_system["density"])
@@ -109,7 +109,7 @@
tr = data['gas','metal_density']
tr /= data['gas','density']
return tr
- self.add_field(('gas', 'metal_mass_fraction'),
+ self.add_field(('gas', 'metal_mass_fraction'), sampling_type="cell",
function=_metal_mass_fraction,
units='')
@@ -117,7 +117,7 @@
tr = (1. - data.ds.parameters['Y_p'] -
data['gas', 'metal_mass_fraction'])
return tr
- self.add_field(('gas', 'H_mass_fraction'),
+ self.add_field(('gas', 'H_mass_fraction'), sampling_type="cell",
function=_H_mass_fraction,
units='')
@@ -125,6 +125,6 @@
tr = data['gas','metal_mass_fraction']
tr /= data['gas','H_mass_fraction']
return tr
- self.add_field(('gas', 'metallicity'),
+ self.add_field(('gas', 'metallicity'), sampling_type="cell",
function=_metallicity,
units='')
diff -r 5a08f4cc1af1a18889e0dc93cb3afa908f2d3d2f -r 9b5937af58578d073179329863c7e220f8ec7df6 yt/frontends/artio/fields.py
--- a/yt/frontends/artio/fields.py
+++ b/yt/frontends/artio/fields.py
@@ -59,8 +59,8 @@
("MASS", ("code_mass", ["particle_mass"], None)),
("PID", ("", ["particle_index"], None)),
("SPECIES", ("", ["particle_type"], None)),
- ("BIRTH_TIME", ("", [], None)), # code-units defined as dimensionless to
- # avoid incorrect conversion
+ ("BIRTH_TIME", ("", [], None)), # code-units defined as dimensionless to
+ # avoid incorrect conversion
("INITIAL_MASS", ("code_mass", ["initial_mass"], None)),
("METALLICITY_SNIa", ("", ["metallicity_snia"], None)),
("METALLICITY_SNII", ("", ["metallicity_snii"], None)),
@@ -73,7 +73,7 @@
return data["momentum_%s" % axis]/data["density"]
return velocity
for ax in 'xyz':
- self.add_field(("gas", "velocity_%s" % ax),
+ self.add_field(("gas", "velocity_%s" % ax), sampling_type="cell",
function = _get_vel(ax),
units = unit_system["velocity"])
@@ -97,10 +97,10 @@
# TODO: The conversion factor here needs to be addressed, as previously
# it was set as:
# unit_T = unit_v**2.0*mb / constants.k
- self.add_field(("gas", "temperature"), function = _temperature,
+ self.add_field(("gas", "temperature"), sampling_type="cell", function = _temperature,
units = unit_system["temperature"])
- # Create a metal_density field as sum of existing metal fields.
+ # Create a metal_density field as sum of existing metal fields.
flag1 = ("artio", "HVAR_METAL_DENSITY_Ia") in self.field_list
flag2 = ("artio", "HVAR_METAL_DENSITY_II") in self.field_list
if flag1 or flag2:
@@ -117,7 +117,7 @@
def _metal_density(field, data):
tr = data["metal_ii_density"]
return tr
- self.add_field(("gas","metal_density"),
+ self.add_field(("gas","metal_density"), sampling_type="cell",
function=_metal_density,
units=unit_system["density"],
take_log=True)
@@ -125,7 +125,7 @@
def setup_particle_fields(self, ptype):
if ptype == "STAR":
def _creation_time(field,data):
- # this test is necessary to avoid passing invalid tcode values
+ # this test is necessary to avoid passing invalid tcode values
# to the function tphys_from_tcode during field detection
# (1.0 is not a valid tcode value)
if isinstance(data, FieldDetector):
@@ -137,21 +137,18 @@
return data["STAR","creation_time"]
return data.ds.current_time - data["STAR","creation_time"]
- self.add_field((ptype, "creation_time"), function=_creation_time, units="yr",
- particle_type=True)
- self.add_field((ptype, "age"), function=_age, units="yr",
- particle_type=True)
+ self.add_field((ptype, "creation_time"), sampling_type="particle", function=_creation_time, units="yr")
+ self.add_field((ptype, "age"), sampling_type="particle", function=_age, units="yr")
if self.ds.cosmological_simulation:
def _creation_redshift(field,data):
- # this test is necessary to avoid passing invalid tcode values
+ # this test is necessary to avoid passing invalid tcode values
# to the function auni_from_tcode during field detection
# (1.0 is not a valid tcode value)
if isinstance(data, FieldDetector):
return data["STAR","BIRTH_TIME"]
return 1.0/data.ds._handle.auni_from_tcode_array(data["STAR","BIRTH_TIME"]) - 1.0
- self.add_field((ptype, "creation_redshift"), function=_creation_redshift,
- particle_type=True)
+ self.add_field((ptype, "creation_redshift"), sampling_type="particle", function=_creation_redshift)
super(ARTIOFieldInfo, self).setup_particle_fields(ptype)
diff -r 5a08f4cc1af1a18889e0dc93cb3afa908f2d3d2f -r 9b5937af58578d073179329863c7e220f8ec7df6 yt/frontends/athena/fields.py
--- a/yt/frontends/athena/fields.py
+++ b/yt/frontends/athena/fields.py
@@ -51,13 +51,13 @@
vel_field = ("athena", "velocity_%s" % comp)
mom_field = ("athena", "momentum_%s" % comp)
if vel_field in self.field_list:
- self.add_output_field(vel_field, units="code_length/code_time")
+ self.add_output_field(vel_field, sampling_type="cell", units="code_length/code_time")
self.alias(("gas","velocity_%s" % comp), vel_field,
units=unit_system["velocity"])
elif mom_field in self.field_list:
- self.add_output_field(mom_field,
+ self.add_output_field(mom_field, sampling_type="cell",
units="code_mass/code_time/code_length**2")
- self.add_field(("gas","velocity_%s" % comp),
+ self.add_field(("gas","velocity_%s" % comp), sampling_type="cell",
function=velocity_field(comp), units = unit_system["velocity"])
# Add pressure, energy, and temperature fields
def ekin1(data):
@@ -85,36 +85,36 @@
etot += emag(data)
return etot
if ("athena","pressure") in self.field_list:
- self.add_output_field(("athena","pressure"),
+ self.add_output_field(("athena","pressure"), sampling_type="cell",
units=pres_units)
self.alias(("gas","pressure"),("athena","pressure"),
units=unit_system["pressure"])
def _thermal_energy(field, data):
return data["athena","pressure"] / \
(data.ds.gamma-1.)/data["athena","density"]
- self.add_field(("gas","thermal_energy"),
+ self.add_field(("gas","thermal_energy"), sampling_type="cell",
function=_thermal_energy,
units=unit_system["specific_energy"])
def _total_energy(field, data):
return etot_from_pres(data)/data["athena","density"]
- self.add_field(("gas","total_energy"),
+ self.add_field(("gas","total_energy"), sampling_type="cell",
function=_total_energy,
units=unit_system["specific_energy"])
elif ("athena","total_energy") in self.field_list:
- self.add_output_field(("athena","total_energy"),
+ self.add_output_field(("athena","total_energy"), sampling_type="cell",
units=pres_units)
def _pressure(field, data):
return eint_from_etot(data)*(data.ds.gamma-1.0)
- self.add_field(("gas","pressure"), function=_pressure,
+ self.add_field(("gas","pressure"), sampling_type="cell", function=_pressure,
units=unit_system["pressure"])
def _thermal_energy(field, data):
return eint_from_etot(data)/data["athena","density"]
- self.add_field(("gas","thermal_energy"),
+ self.add_field(("gas","thermal_energy"), sampling_type="cell",
function=_thermal_energy,
units=unit_system["specific_energy"])
def _total_energy(field, data):
return data["athena","total_energy"]/data["athena","density"]
- self.add_field(("gas","total_energy"),
+ self.add_field(("gas","total_energy"), sampling_type="cell",
function=_total_energy,
units=unit_system["specific_energy"])
@@ -124,9 +124,7 @@
else:
mu = 0.6
return mu*mh*data["gas","pressure"]/data["gas","density"]/kboltz
- self.add_field(("gas","temperature"), function=_temperature,
+ self.add_field(("gas","temperature"), sampling_type="cell", function=_temperature,
units=unit_system["temperature"])
setup_magnetic_field_aliases(self, "athena", ["cell_centered_B_%s" % ax for ax in "xyz"])
-
-
diff -r 5a08f4cc1af1a18889e0dc93cb3afa908f2d3d2f -r 9b5937af58578d073179329863c7e220f8ec7df6 yt/frontends/boxlib/fields.py
--- a/yt/frontends/boxlib/fields.py
+++ b/yt/frontends/boxlib/fields.py
@@ -98,9 +98,8 @@
return velocity
for ax in 'xyz':
- self.add_field((ptype, "particle_velocity_%s" % ax),
+ self.add_field((ptype, "particle_velocity_%s" % ax), sampling_type="particle",
function=_get_vel(ax),
- particle_type=True,
units="code_length/code_time")
super(BoxlibFieldInfo, self).setup_particle_fields(ptype)
@@ -112,14 +111,14 @@
self.setup_momentum_to_velocity()
elif any(f[1] == "xvel" for f in self.field_list):
self.setup_velocity_to_momentum()
- self.add_field(("gas", "thermal_energy"),
+ self.add_field(("gas", "thermal_energy"), sampling_type="cell",
function=_thermal_energy,
units=unit_system["specific_energy"])
- self.add_field(("gas", "thermal_energy_density"),
+ self.add_field(("gas", "thermal_energy_density"), sampling_type="cell",
function=_thermal_energy_density,
units=unit_system["pressure"])
if ("gas", "temperature") not in self.field_aliases:
- self.add_field(("gas", "temperature"),
+ self.add_field(("gas", "temperature"), sampling_type="cell",
function=_temperature,
units=unit_system["temperature"])
@@ -129,7 +128,7 @@
return data["%smom" % axis]/data["density"]
return velocity
for ax in 'xyz':
- self.add_field(("gas", "velocity_%s" % ax),
+ self.add_field(("gas", "velocity_%s" % ax), sampling_type="cell",
function=_get_vel(ax),
units=self.ds.unit_system["velocity"])
@@ -139,7 +138,7 @@
return data["%svel" % axis]*data["density"]
return momentum
for ax in 'xyz':
- self.add_field(("gas", "momentum_%s" % ax),
+ self.add_field(("gas", "momentum_%s" % ax), sampling_type="cell",
function=_get_mom(ax),
units=mom_units)
@@ -203,6 +202,7 @@
units="")
func = _create_density_func(("gas", "%s_fraction" % nice_name))
self.add_field(name=("gas", "%s_density" % nice_name),
+ sampling_type="cell",
function = func,
units = self.ds.unit_system["density"])
# We know this will either have one letter, or two.
@@ -287,7 +287,7 @@
# We have a mass fraction
nice_name, tex_label = _nice_species_name(field)
# Overwrite field to use nicer tex_label display_name
- self.add_output_field(("boxlib", field),
+ self.add_output_field(("boxlib", field), sampling_type="cell",
units="",
display_name=tex_label)
self.alias(("gas", "%s_fraction" % nice_name),
@@ -295,6 +295,7 @@
units="")
func = _create_density_func(("gas", "%s_fraction" % nice_name))
self.add_field(name=("gas", "%s_density" % nice_name),
+ sampling_type="cell",
function=func,
units=unit_system["density"],
display_name=r'\rho %s' % tex_label)
@@ -317,7 +318,7 @@
nice_name, tex_label = _nice_species_name(field)
display_name = r'\dot{\omega}\left[%s\right]' % tex_label
# Overwrite field to use nicer tex_label'ed display_name
- self.add_output_field(("boxlib", field), units=unit_system["frequency"],
+ self.add_output_field(("boxlib", field), sampling_type="cell", units=unit_system["frequency"],
display_name=display_name)
self.alias(("gas", "%s_creation_rate" % nice_name),
("boxlib", field), units=unit_system["frequency"])
This diff is so big that we needed to truncate the remainder.
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