[yt-svn] commit/yt: xarthisius: Allow to create rectangular FRBs by adding optional keyword for height
Bitbucket
commits-noreply at bitbucket.org
Wed Apr 11 02:29:49 PDT 2012
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/changeset/c03ace942052/
changeset: c03ace942052
branch: yt
user: xarthisius
date: 2012-04-11 11:24:41
summary: Allow to create rectangular FRBs by adding optional keyword for height
affected #: 1 file
diff -r 337d67c4ceef7fb1a3e4f8fc4185fe2ed6539d0a -r c03ace9420524bcf14dd8ca777cecf24dad87a0a yt/data_objects/data_containers.py
--- a/yt/data_objects/data_containers.py
+++ b/yt/data_objects/data_containers.py
@@ -849,7 +849,7 @@
for field in temp_data.keys():
self[field] = temp_data[field]
- def to_frb(self, width, resolution, center = None):
+ def to_frb(self, width, resolution, center=None, height=None):
r"""This function returns a FixedResolutionBuffer generated from this
object.
@@ -864,6 +864,8 @@
This can either be a floating point value, in the native domain
units of the simulation, or a tuple of the (value, unit) style.
This will be the width of the FRB.
+ height : height specifier
+ This will be the height of the FRB, by default it is equal to width.
resolution : int or tuple of ints
The number of pixels on a side of the final FRB.
center : array-like of floats, optional
@@ -890,13 +892,18 @@
if iterable(width):
w, u = width
width = w/self.pf[u]
+ if height is None:
+ height = width
+ elif iterable(height):
+ h, u = height
+ height = h/self.pf[u]
if not iterable(resolution):
resolution = (resolution, resolution)
from yt.visualization.fixed_resolution import FixedResolutionBuffer
xax = x_dict[self.axis]
yax = y_dict[self.axis]
- bounds = (center[xax] - width/2.0, center[xax] + width/2.0,
- center[yax] - width/2.0, center[yax] + width/2.0)
+ bounds = (center[xax] - width*0.5, center[xax] + width*0.5,
+ center[yax] - height*0.5, center[yax] + height*0.5)
frb = FixedResolutionBuffer(self, bounds, resolution)
return frb
@@ -1311,7 +1318,7 @@
return "%s/c%s_L%s" % \
(self._top_node, cen_name, L_name)
- def to_frb(self, width, resolution):
+ def to_frb(self, width, resolution, height=None):
r"""This function returns an ObliqueFixedResolutionBuffer generated
from this object.
@@ -1329,6 +1336,8 @@
This can either be a floating point value, in the native domain
units of the simulation, or a tuple of the (value, unit) style.
This will be the width of the FRB.
+ height : height specifier
+ This will be the height of the FRB, by default it is equal to width.
resolution : int or tuple of ints
The number of pixels on a side of the final FRB.
@@ -1350,10 +1359,15 @@
if iterable(width):
w, u = width
width = w/self.pf[u]
+ if height is None:
+ height = width
+ elif iterable(height):
+ h, u = height
+ height = h/self.pf[u]
if not iterable(resolution):
resolution = (resolution, resolution)
from yt.visualization.fixed_resolution import ObliqueFixedResolutionBuffer
- bounds = (-width/2.0, width/2.0, -width/2.0, width/2.0)
+ bounds = (-width/2.0, width/2.0, -height/2.0, height/2.0)
frb = ObliqueFixedResolutionBuffer(self, bounds, resolution)
return frb
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