[yt-svn] commit/yt: 7 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Wed Nov 29 10:24:41 PST 2017
7 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/d3f983b6241a/
Changeset: d3f983b6241a
User: jzuhone
Date: 2017-08-16 02:52:54+00:00
Summary: Spacing
Affected #: 1 file
diff -r 0e28d5ea5938979f536edf8f55dbc078f3406102 -r d3f983b6241ada107c0bd3eff4a6294548a128fd yt/analysis_modules/ppv_cube/ppv_cube.py
--- a/yt/analysis_modules/ppv_cube/ppv_cube.py
+++ b/yt/analysis_modules/ppv_cube/ppv_cube.py
@@ -44,10 +44,10 @@
return -vz
return _v_los
-fits_info = {"velocity":("m/s","VOPT","v"),
- "frequency":("Hz","FREQ","f"),
- "energy":("eV","ENER","E"),
- "wavelength":("angstrom","WAVE","lambda")}
+fits_info = {"velocity": ("m/s", "VOPT", "v"),
+ "frequency": ("Hz", "FREQ", "f"),
+ "energy": ("eV", "ENER", "E"),
+ "wavelength": ("angstrom", "WAVE", "lambda")}
class PPVCube(object):
def __init__(self, ds, normal, field, velocity_bounds, center="c",
https://bitbucket.org/yt_analysis/yt/commits/5604cd21c979/
Changeset: 5604cd21c979
User: jzuhone
Date: 2017-08-16 02:53:28+00:00
Summary: Separate out the functions with and without thermal broadening
Affected #: 2 files
diff -r d3f983b6241ada107c0bd3eff4a6294548a128fd -r 5604cd21c97946266e70a9f72e5285d4968db5c2 yt/analysis_modules/ppv_cube/ppv_cube.py
--- a/yt/analysis_modules/ppv_cube/ppv_cube.py
+++ b/yt/analysis_modules/ppv_cube/ppv_cube.py
@@ -320,11 +320,17 @@
return self.data[item]
def _create_intensity(self):
- def _intensity(field, data):
- v = self.current_v-data["v_los"].in_cgs().v
- T = (data["temperature"]).in_cgs().v
- w = ppv_utils.compute_weight(self.thermal_broad, self.dv_cgs,
- self.particle_mass, v.flatten(), T.flatten())
- w[np.isnan(w)] = 0.0
- return data[self.field]*w.reshape(v.shape)
+ if self.thermal_broad:
+ def _intensity(field, data):
+ v = self.current_v-data["v_los"].in_cgs().v
+ T = data["temperature"].in_cgs().v
+ w = ppv_utils.compute_weight(self.thermal_broad, self.dv_cgs,
+ self.particle_mass, v.flatten(), T.flatten())
+ w[np.isnan(w)] = 0.0
+ return data[self.field]*w.reshape(v.shape)
+ else:
+ def _intensity(field, data):
+ w = 1.-np.fabs(self.current_v-data["v_los"].in_cgs().v)/self.dv_cgs
+ w[w < 0.0] = 0.0
+ return data[self.field]*w
return _intensity
diff -r d3f983b6241ada107c0bd3eff4a6294548a128fd -r 5604cd21c97946266e70a9f72e5285d4968db5c2 yt/analysis_modules/ppv_cube/ppv_utils.pyx
--- a/yt/analysis_modules/ppv_cube/ppv_utils.pyx
+++ b/yt/analysis_modules/ppv_cube/ppv_utils.pyx
@@ -2,7 +2,7 @@
cimport numpy as np
cimport cython
from yt.utilities.physical_constants import kboltz
-from libc.math cimport exp, fabs, sqrt
+from libc.math cimport exp, sqrt
cdef double kb = kboltz.v
cdef double pi = np.pi
@@ -24,13 +24,7 @@
w = np.zeros(n)
for i in range(n):
- if thermal_broad:
- if T[i] > 0.0:
- v2_th = 2.*kb*T[i]/m_part
- w[i] = dv*exp(-v[i]*v[i]/v2_th)/sqrt(v2_th*pi)
- else:
- x = 1.-fabs(v[i])/dv
- if x > 0.0:
- w[i] = x
+ v2_th = 2.*kb*T[i]/m_part
+ w[i] = dv*exp(-v[i]*v[i]/v2_th)/sqrt(v2_th*pi)
return w
https://bitbucket.org/yt_analysis/yt/commits/9049b8aa1791/
Changeset: 9049b8aa1791
User: jzuhone
Date: 2017-09-19 14:04:51+00:00
Summary: Add unit test for no thermal broadening
Affected #: 1 file
diff -r 5604cd21c97946266e70a9f72e5285d4968db5c2 -r 9049b8aa179117b48138fca7b1fd70c02920cb6b yt/analysis_modules/ppv_cube/tests/test_ppv.py
--- a/yt/analysis_modules/ppv_cube/tests/test_ppv.py
+++ b/yt/analysis_modules/ppv_cube/tests/test_ppv.py
@@ -59,3 +59,27 @@
c = dE*np.exp(-((cube.vmid-E_shift)/delta_E)**2)/(np.sqrt(np.pi)*delta_E)
assert_allclose_units(a, c, 1.0e-2)
+
+def test_ppv_nothermalbroad():
+
+ np.random.seed(seed=0x4d3d3d3)
+
+ dims = (16, 16, 128)
+ v_shift = 1.0e6*u.cm/u.s
+ sigma_v = 2.0e6*u.cm/u.s
+ data = {"density":(np.ones(dims),"g/cm**3"),
+ "velocity_x":(np.zeros(dims),"cm/s"),
+ "velocity_y":(np.zeros(dims),"cm/s"),
+ "velocity_z":(np.random.normal(loc=v_shift.v,scale=sigma_v.v,size=dims), "cm/s")}
+
+ ds = load_uniform_grid(data, dims)
+
+ cube = PPVCube(ds, "z", "density", (-100., 100., 128, "km/s"),
+ dims=16, thermal_broad=False)
+
+ dv = cube.dv
+ v_noth = np.sqrt(2)*(sigma_v).in_units("km/s")
+ a = cube.data.mean(axis=(0,1)).v
+ b = dv*np.exp(-((cube.vmid+v_shift)/v_noth)**2)/(np.sqrt(np.pi)*v_noth)
+
+ assert_allclose_units(a, b, atol=5.0e-3)
https://bitbucket.org/yt_analysis/yt/commits/a4fe83d61266/
Changeset: a4fe83d61266
User: jzuhone
Date: 2017-09-19 14:09:12+00:00
Summary: raise an error if there is no temperature field and we try to do thermal broadening
Affected #: 1 file
diff -r 9049b8aa179117b48138fca7b1fd70c02920cb6b -r a4fe83d612668189f43b31bdc32011d8ed40a5bb yt/analysis_modules/ppv_cube/ppv_cube.py
--- a/yt/analysis_modules/ppv_cube/ppv_cube.py
+++ b/yt/analysis_modules/ppv_cube/ppv_cube.py
@@ -142,6 +142,10 @@
width = ds.coordinates.sanitize_width(normal, width, depth)
width = tuple(el.in_units('code_length').v for el in width)
+ if not hasattr(ds.fields.gas, "temperature") and thermal_broad:
+ raise RuntimeError("thermal_broad cannot be True if there is "
+ "no 'temperature' field!")
+
if no_shifting and not thermal_broad:
raise RuntimeError("no_shifting cannot be True when thermal_broad is False!")
https://bitbucket.org/yt_analysis/yt/commits/dd1a52238a36/
Changeset: dd1a52238a36
User: jzuhone
Date: 2017-11-29 15:47:32+00:00
Summary: Add gas field type in appropriate places
Affected #: 1 file
diff -r a4fe83d612668189f43b31bdc32011d8ed40a5bb -r dd1a52238a3601234f00680a6c7d0e45a8535861 yt/analysis_modules/ppv_cube/ppv_cube.py
--- a/yt/analysis_modules/ppv_cube/ppv_cube.py
+++ b/yt/analysis_modules/ppv_cube/ppv_cube.py
@@ -30,17 +30,17 @@
def create_vlos(normal, no_shifting):
if no_shifting:
def _v_los(field, data):
- return data.ds.arr(data["zeros"], "cm/s")
+ return data.ds.arr(data["gas", "zeros"], "cm/s")
elif isinstance(normal, string_types):
def _v_los(field, data):
- return -data["velocity_%s" % normal]
+ return -data["gas", "velocity_%s" % normal]
else:
orient = Orientation(normal)
los_vec = orient.unit_vectors[2]
def _v_los(field, data):
- vz = data["velocity_x"]*los_vec[0] + \
- data["velocity_y"]*los_vec[1] + \
- data["velocity_z"]*los_vec[2]
+ vz = data["gas", "velocity_x"]*los_vec[0] + \
+ data["gas", "velocity_y"]*los_vec[1] + \
+ data["gas", "velocity_z"]*los_vec[2]
return -vz
return _v_los
@@ -326,15 +326,15 @@
def _create_intensity(self):
if self.thermal_broad:
def _intensity(field, data):
- v = self.current_v-data["v_los"].in_cgs().v
- T = data["temperature"].in_cgs().v
+ v = self.current_v-data["gas", "v_los"].in_cgs().v
+ T = data["gas", "temperature"].in_cgs().v
w = ppv_utils.compute_weight(self.thermal_broad, self.dv_cgs,
self.particle_mass, v.flatten(), T.flatten())
w[np.isnan(w)] = 0.0
return data[self.field]*w.reshape(v.shape)
else:
def _intensity(field, data):
- w = 1.-np.fabs(self.current_v-data["v_los"].in_cgs().v)/self.dv_cgs
+ w = 1.-np.fabs(self.current_v-data["gas", "v_los"].in_cgs().v)/self.dv_cgs
w[w < 0.0] = 0.0
return data[self.field]*w
return _intensity
https://bitbucket.org/yt_analysis/yt/commits/68869ff593ef/
Changeset: 68869ff593ef
User: jzuhone
Date: 2017-11-29 16:17:17+00:00
Summary: bugfix
Affected #: 1 file
diff -r dd1a52238a3601234f00680a6c7d0e45a8535861 -r 68869ff593efc2c06b2ba5a932c90433a51df400 yt/analysis_modules/ppv_cube/ppv_cube.py
--- a/yt/analysis_modules/ppv_cube/ppv_cube.py
+++ b/yt/analysis_modules/ppv_cube/ppv_cube.py
@@ -30,7 +30,7 @@
def create_vlos(normal, no_shifting):
if no_shifting:
def _v_los(field, data):
- return data.ds.arr(data["gas", "zeros"], "cm/s")
+ return data.ds.arr(data["index", "zeros"], "cm/s")
elif isinstance(normal, string_types):
def _v_los(field, data):
return -data["gas", "velocity_%s" % normal]
https://bitbucket.org/yt_analysis/yt/commits/befe05adfea9/
Changeset: befe05adfea9
User: ngoldbaum
Date: 2017-11-29 18:24:26+00:00
Summary: Merge pull request #1562 from jzuhone/fix_ppv
Make sure that PPVCube does not fail if there is no temperature field
Affected #: 3 files
diff -r ed6f781404856bf839b22a1539c6a7abce5b3859 -r befe05adfea96a3285199c09543b6c22295d946f yt/analysis_modules/ppv_cube/ppv_cube.py
--- a/yt/analysis_modules/ppv_cube/ppv_cube.py
+++ b/yt/analysis_modules/ppv_cube/ppv_cube.py
@@ -30,24 +30,24 @@
def create_vlos(normal, no_shifting):
if no_shifting:
def _v_los(field, data):
- return data.ds.arr(data["zeros"], "cm/s")
+ return data.ds.arr(data["index", "zeros"], "cm/s")
elif isinstance(normal, string_types):
def _v_los(field, data):
- return -data["velocity_%s" % normal]
+ return -data["gas", "velocity_%s" % normal]
else:
orient = Orientation(normal)
los_vec = orient.unit_vectors[2]
def _v_los(field, data):
- vz = data["velocity_x"]*los_vec[0] + \
- data["velocity_y"]*los_vec[1] + \
- data["velocity_z"]*los_vec[2]
+ vz = data["gas", "velocity_x"]*los_vec[0] + \
+ data["gas", "velocity_y"]*los_vec[1] + \
+ data["gas", "velocity_z"]*los_vec[2]
return -vz
return _v_los
-fits_info = {"velocity":("m/s","VOPT","v"),
- "frequency":("Hz","FREQ","f"),
- "energy":("eV","ENER","E"),
- "wavelength":("angstrom","WAVE","lambda")}
+fits_info = {"velocity": ("m/s", "VOPT", "v"),
+ "frequency": ("Hz", "FREQ", "f"),
+ "energy": ("eV", "ENER", "E"),
+ "wavelength": ("angstrom", "WAVE", "lambda")}
class PPVCube(object):
def __init__(self, ds, normal, field, velocity_bounds, center="c",
@@ -142,6 +142,10 @@
width = ds.coordinates.sanitize_width(normal, width, depth)
width = tuple(el.in_units('code_length').v for el in width)
+ if not hasattr(ds.fields.gas, "temperature") and thermal_broad:
+ raise RuntimeError("thermal_broad cannot be True if there is "
+ "no 'temperature' field!")
+
if no_shifting and not thermal_broad:
raise RuntimeError("no_shifting cannot be True when thermal_broad is False!")
@@ -320,11 +324,17 @@
return self.data[item]
def _create_intensity(self):
- def _intensity(field, data):
- v = self.current_v-data["v_los"].in_cgs().v
- T = (data["temperature"]).in_cgs().v
- w = ppv_utils.compute_weight(self.thermal_broad, self.dv_cgs,
- self.particle_mass, v.flatten(), T.flatten())
- w[np.isnan(w)] = 0.0
- return data[self.field]*w.reshape(v.shape)
+ if self.thermal_broad:
+ def _intensity(field, data):
+ v = self.current_v-data["gas", "v_los"].in_cgs().v
+ T = data["gas", "temperature"].in_cgs().v
+ w = ppv_utils.compute_weight(self.thermal_broad, self.dv_cgs,
+ self.particle_mass, v.flatten(), T.flatten())
+ w[np.isnan(w)] = 0.0
+ return data[self.field]*w.reshape(v.shape)
+ else:
+ def _intensity(field, data):
+ w = 1.-np.fabs(self.current_v-data["gas", "v_los"].in_cgs().v)/self.dv_cgs
+ w[w < 0.0] = 0.0
+ return data[self.field]*w
return _intensity
diff -r ed6f781404856bf839b22a1539c6a7abce5b3859 -r befe05adfea96a3285199c09543b6c22295d946f yt/analysis_modules/ppv_cube/ppv_utils.pyx
--- a/yt/analysis_modules/ppv_cube/ppv_utils.pyx
+++ b/yt/analysis_modules/ppv_cube/ppv_utils.pyx
@@ -2,7 +2,7 @@
cimport numpy as np
cimport cython
from yt.utilities.physical_constants import kboltz
-from libc.math cimport exp, fabs, sqrt
+from libc.math cimport exp, sqrt
cdef double kb = kboltz.v
cdef double pi = np.pi
@@ -24,13 +24,7 @@
w = np.zeros(n)
for i in range(n):
- if thermal_broad:
- if T[i] > 0.0:
- v2_th = 2.*kb*T[i]/m_part
- w[i] = dv*exp(-v[i]*v[i]/v2_th)/sqrt(v2_th*pi)
- else:
- x = 1.-fabs(v[i])/dv
- if x > 0.0:
- w[i] = x
+ v2_th = 2.*kb*T[i]/m_part
+ w[i] = dv*exp(-v[i]*v[i]/v2_th)/sqrt(v2_th*pi)
return w
diff -r ed6f781404856bf839b22a1539c6a7abce5b3859 -r befe05adfea96a3285199c09543b6c22295d946f yt/analysis_modules/ppv_cube/tests/test_ppv.py
--- a/yt/analysis_modules/ppv_cube/tests/test_ppv.py
+++ b/yt/analysis_modules/ppv_cube/tests/test_ppv.py
@@ -59,3 +59,27 @@
c = dE*np.exp(-((cube.vmid-E_shift)/delta_E)**2)/(np.sqrt(np.pi)*delta_E)
assert_allclose_units(a, c, 1.0e-2)
+
+def test_ppv_nothermalbroad():
+
+ np.random.seed(seed=0x4d3d3d3)
+
+ dims = (16, 16, 128)
+ v_shift = 1.0e6*u.cm/u.s
+ sigma_v = 2.0e6*u.cm/u.s
+ data = {"density":(np.ones(dims),"g/cm**3"),
+ "velocity_x":(np.zeros(dims),"cm/s"),
+ "velocity_y":(np.zeros(dims),"cm/s"),
+ "velocity_z":(np.random.normal(loc=v_shift.v,scale=sigma_v.v,size=dims), "cm/s")}
+
+ ds = load_uniform_grid(data, dims)
+
+ cube = PPVCube(ds, "z", "density", (-100., 100., 128, "km/s"),
+ dims=16, thermal_broad=False)
+
+ dv = cube.dv
+ v_noth = np.sqrt(2)*(sigma_v).in_units("km/s")
+ a = cube.data.mean(axis=(0,1)).v
+ b = dv*np.exp(-((cube.vmid+v_shift)/v_noth)**2)/(np.sqrt(np.pi)*v_noth)
+
+ assert_allclose_units(a, b, atol=5.0e-3)
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