[Yt-svn] yt: Adding a ProjectionTransferFunction, to do very simple off-a...
hg at spacepope.org
hg at spacepope.org
Thu Apr 15 07:43:24 PDT 2010
hg Repository: yt
details: yt/rev/4825a94c4d27
changeset: 1564:4825a94c4d27
user: Matthew Turk <matthewturk at gmail.com>
date:
Thu Apr 15 10:41:32 2010 -0400
description:
Adding a ProjectionTransferFunction, to do very simple off-axis projections.
Right now the field needs to be linear, not log, but you can do:
linear = vr.ProjectionTransferFunction()
pf.field_info["Density"].take_log = False
vp = pf.h.volume_rendering(L, W, c, (512,512), linear)
vp.ray_cast()
and it gives you a nice looking off-axis projection image. This is better than
the disk stacker!
diffstat:
yt/_amr_utils/VolumeIntegrator.pyx | 9 +++++++--
yt/extensions/volume_rendering/TransferFunction.py | 16 ++++++++++++++++
yt/extensions/volume_rendering/__init__.py | 3 ++-
3 files changed, 25 insertions(+), 3 deletions(-)
diffs (87 lines):
diff -r c900b2dfdc66 -r 4825a94c4d27 yt/_amr_utils/VolumeIntegrator.pyx
--- a/yt/_amr_utils/VolumeIntegrator.pyx Fri Apr 09 11:05:00 2010 -0700
+++ b/yt/_amr_utils/VolumeIntegrator.pyx Thu Apr 15 10:41:32 2010 -0400
@@ -84,10 +84,12 @@
int weight_field_id
int weight_table_id
int nbins
+ int pass_through
cdef void FIT_initialize_table(FieldInterpolationTable *fit, int nbins,
np.float64_t *values, np.float64_t bounds1, np.float64_t bounds2,
- int field_id, int weight_field_id = -1, int weight_table_id = -1):
+ int field_id, int weight_field_id = -1, int weight_table_id = -1,
+ int pass_through = 0):
fit.bounds[0] = bounds1; fit.bounds[1] = bounds2
fit.nbins = nbins
fit.dbin = (fit.bounds[1] - fit.bounds[0])/fit.nbins
@@ -97,11 +99,13 @@
fit.field_id = field_id
fit.weight_field_id = weight_field_id
fit.weight_table_id = weight_table_id
+ fit.pass_through = pass_through
cdef np.float64_t FIT_get_value(FieldInterpolationTable *fit,
np.float64_t *dvs):
cdef np.float64_t bv, dy, dd, tf
cdef int bin_id
+ if fit.pass_through == 1: return dvs[fit.field_id]
bin_id = <int> ((dvs[fit.field_id] - fit.bounds[0]) * fit.idbin)
dd = dvs[fit.field_id] - (fit.bounds[0] + bin_id * fit.dbin) # x - x0
if bin_id > fit.nbins - 2 or bin_id < 0: return 0.0
@@ -157,7 +161,8 @@
tf_obj.tables[i].x_bounds[0],
tf_obj.tables[i].x_bounds[1],
tf_obj.field_ids[i], tf_obj.weight_field_ids[i],
- tf_obj.weight_table_ids[i])
+ tf_obj.weight_table_ids[i],
+ tf_obj.tables[i].pass_through)
self.my_field_tables.append((tf_obj.tables[i],
tf_obj.tables[i].y))
self.field_tables[i].field_id = tf_obj.field_ids[i]
diff -r c900b2dfdc66 -r 4825a94c4d27 yt/extensions/volume_rendering/TransferFunction.py
--- a/yt/extensions/volume_rendering/TransferFunction.py Fri Apr 09 11:05:00 2010 -0700
+++ b/yt/extensions/volume_rendering/TransferFunction.py Thu Apr 15 10:41:32 2010 -0400
@@ -30,6 +30,7 @@
class TransferFunction(object):
def __init__(self, x_bounds, nbins=256):
+ self.pass_through = 0
self.nbins = nbins
self.x_bounds = x_bounds
self.x = na.linspace(x_bounds[0], x_bounds[1], nbins).astype('float64')
@@ -177,6 +178,21 @@
for v, a in zip(na.mgrid[mi:ma:N*1j], alpha):
self.sample_colormap(v, w, a, colormap=colormap)
+class ProjectionTransferFunction(MultiVariateTransferFunction):
+ def __init__(self, x_bounds = (-1e30, 1e30)):
+ MultiVariateTransferFunction.__init__(self)
+ self.x_bounds = x_bounds
+ self.nbins = 2
+ self.linear_mapping = TransferFunction(x_bounds, 2)
+ self.linear_mapping.pass_through = 1
+ self.add_field_table(self.linear_mapping, 0)
+ self.alpha = TransferFunction(x_bounds, 2)
+ self.alpha.y *= 0.0
+ self.alpha.y += 1.0
+ self.add_field_table(self.alpha, 0)
+ self.link_channels(0, [0,1,2]) # same emission for all rgb
+ self.link_channels(2, [3,4,5]) # this will remove absorption
+
class PlanckTransferFunction(MultiVariateTransferFunction):
def __init__(self, T_bounds, rho_bounds, nbins=256,
red='R', green='V', blue='B',
diff -r c900b2dfdc66 -r 4825a94c4d27 yt/extensions/volume_rendering/__init__.py
--- a/yt/extensions/volume_rendering/__init__.py Fri Apr 09 11:05:00 2010 -0700
+++ b/yt/extensions/volume_rendering/__init__.py Thu Apr 15 10:41:32 2010 -0400
@@ -27,7 +27,8 @@
from TransferFunction import TransferFunction, ColorTransferFunction, \
PlanckTransferFunction, \
- MultiVariateTransferFunction
+ MultiVariateTransferFunction, \
+ ProjectionTransferFunction
from yt.amr_utils import PartitionedGrid, VectorPlane, \
TransferFunctionProxy
from grid_partitioner import HomogenizedBrickCollection, \
More information about the yt-svn
mailing list