[yt-svn] commit/yt: 9 new changesets
Bitbucket
commits-noreply at bitbucket.org
Fri Aug 31 04:22:01 PDT 2012
9 new commits in yt:
https://bitbucket.org/yt_analysis/yt/changeset/57cc327cb898/
changeset: 57cc327cb898
branch: yt
user: ngoldbaum
date: 2012-08-31 03:51:12
summary: Fixing a sign error in pixel_scale()
affected #: 1 file
diff -r 9c119e2bbb44180dfe7701c974dcb5f3b66d297e -r 57cc327cb89845570867307066d8b803f68e3dd5 yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -80,11 +80,11 @@
def pixel_scale(self,plot):
x0, x1 = plot.xlim
xx0, xx1 = plot._axes.get_xlim()
- dx = (xx0 - xx1)/(x1 - x0)
+ dx = (xx1 - xx0)/(x1 - x0)
y0, y1 = plot.ylim
yy0, yy1 = plot._axes.get_ylim()
- dy = (yy0 - yy1)/(y1 - y0)
+ dy = (yy1 - yy0)/(y1 - y0)
return (dx,dy)
https://bitbucket.org/yt_analysis/yt/changeset/7b0508f05dcc/
changeset: 7b0508f05dcc
branch: yt
user: ngoldbaum
date: 2012-08-31 05:23:22
summary: Making the grids callback conform rely on plot coordinates rather than pixel coordinates. This fixes the annotate=true option.
affected #: 1 file
diff -r 57cc327cb89845570867307066d8b803f68e3dd5 -r 7b0508f05dccf7996bee669c82d1b802417fd2c1 yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -312,39 +312,36 @@
def __call__(self, plot):
x0, x1 = plot.xlim
y0, y1 = plot.ylim
- width, height = plot.image._A.shape
xx0, xx1 = plot._axes.get_xlim()
yy0, yy1 = plot._axes.get_ylim()
xi = x_dict[plot.data.axis]
yi = y_dict[plot.data.axis]
- dx = width / (x1-x0)
- dy = height / (y1-y0)
+ (dx, dy) = self.pixel_scale(plot)
+ (xpix, ypix) = plot.image._A.shape
px_index = x_dict[plot.data.axis]
py_index = y_dict[plot.data.axis]
dom = plot.data.pf.domain_right_edge - plot.data.pf.domain_left_edge
- if self.periodic:
- pxs, pys = na.mgrid[-1:1:3j,-1:1:3j]
- else:
- pxs, pys = na.mgrid[0:0:1j,0:0:1j]
+ #if self.periodic:
+ # pxs, pys = na.mgrid[-1:1:3j,-1:1:3j]
+ #else:
+ pxs, pys = na.mgrid[0:0:1j,0:0:1j]
GLE = plot.data.grid_left_edge
GRE = plot.data.grid_right_edge
for px_off, py_off in zip(pxs.ravel(), pys.ravel()):
pxo = px_off * dom[px_index]
pyo = py_off * dom[py_index]
- left_edge_px = (GLE[:,px_index]+pxo-x0)*dx
- left_edge_py = (GLE[:,py_index]+pyo-y0)*dy
- right_edge_px = (GRE[:,px_index]+pxo-x0)*dx
- right_edge_py = (GRE[:,py_index]+pyo-y0)*dy
+ left_edge_x = (GLE[:,px_index]+pxo-x0)*dx + xx0
+ left_edge_y = (GLE[:,py_index]+pyo-y0)*dy + yy0
+ right_edge_x = (GRE[:,px_index]+pxo-x0)*dx + xx0
+ right_edge_y = (GRE[:,py_index]+pyo-y0)*dy + yy0
+ visible = ( xpix * (right_edge_x - left_edge_x) / (xx1 - xx0) > self.min_pix ) & \
+ ( ypix * (right_edge_y - left_edge_y) / (yy1 - yy0) > self.min_pix )
+ if visible.nonzero()[0].size == 0: continue
verts = na.array(
- [(left_edge_px, left_edge_px, right_edge_px, right_edge_px),
- (left_edge_py, right_edge_py, right_edge_py, left_edge_py)])
- visible = ( right_edge_px - left_edge_px > self.min_pix ) & \
- ( right_edge_px - left_edge_px > self.min_pix )
+ [(left_edge_x, left_edge_x, right_edge_x, right_edge_x),
+ (left_edge_y, right_edge_y, right_edge_y, left_edge_y)])
verts=verts.transpose()[visible,:,:]
- if verts.size == 0: continue
edgecolors = (0.0,0.0,0.0,self.alpha)
- verts[:,:,0]= (xx1-xx0)*(verts[:,:,0]/width) + xx0
- verts[:,:,1]= (yy1-yy0)*(verts[:,:,1]/height) + yy0
grid_collection = matplotlib.collections.PolyCollection(
verts, facecolors="none",
edgecolors=edgecolors)
@@ -352,8 +349,8 @@
plot._axes.add_collection(grid_collection)
if self.annotate:
ids = [g.id for g in plot.data._grids]
- for n in range(len(left_edge_px)):
- plot._axes.text(left_edge_px[n]+2,left_edge_py[n]+2,ids[n])
+ for n in range(len(left_edge_x)):
+ plot._axes.text(left_edge_x[n]+(2*(xx1-xx0)/xpix),left_edge_y[n]+(2*(yy1-yy0)/ypix),ids[n])
plot._axes.hold(False)
class StreamlineCallback(PlotCallback):
https://bitbucket.org/yt_analysis/yt/changeset/9a5c39e1b2fb/
changeset: 9a5c39e1b2fb
branch: yt
user: ngoldbaum
date: 2012-08-31 05:25:49
summary: Renaming the annotate option of the grids callback to draw_ids. This is to avoid confusion with the name of the callback in the plot window interface.
affected #: 1 file
diff -r 7b0508f05dccf7996bee669c82d1b802417fd2c1 -r 9a5c39e1b2fb4697b1af9eebc3831bc4eddec8e0 yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -295,18 +295,18 @@
class GridBoundaryCallback(PlotCallback):
_type_name = "grids"
- def __init__(self, alpha=1.0, min_pix=1, annotate=False, periodic=True):
+ def __init__(self, alpha=1.0, min_pix=1, draw_ids=False, periodic=True):
"""
- annotate_grids(alpha=1.0, min_pix=1, annotate=False, periodic=True)
+ annotate_grids(alpha=1.0, min_pix=1, draw_ids=False, periodic=True)
Adds grid boundaries to a plot, optionally with *alpha*-blending.
Cuttoff for display is at *min_pix* wide.
- *annotate* puts the grid id in the corner of the grid. (Not so great in projections...)
+ *draw_ids* puts the grid id in the corner of the grid. (Not so great in projections...)
"""
PlotCallback.__init__(self)
self.alpha = alpha
self.min_pix = min_pix
- self.annotate = annotate # put grid numbers in the corner.
+ self.draw_ids = draw_ids # put grid numbers in the corner.
self.periodic = periodic
def __call__(self, plot):
@@ -347,7 +347,7 @@
edgecolors=edgecolors)
plot._axes.hold(True)
plot._axes.add_collection(grid_collection)
- if self.annotate:
+ if self.draw_ids:
ids = [g.id for g in plot.data._grids]
for n in range(len(left_edge_x)):
plot._axes.text(left_edge_x[n]+(2*(xx1-xx0)/xpix),left_edge_y[n]+(2*(yy1-yy0)/ypix),ids[n])
https://bitbucket.org/yt_analysis/yt/changeset/a038fe48d289/
changeset: a038fe48d289
branch: yt
user: ngoldbaum
date: 2012-08-31 05:29:30
summary: Turning on the logic for periodic boundary conditions in the grid callback.
affected #: 1 file
diff -r 9a5c39e1b2fb4697b1af9eebc3831bc4eddec8e0 -r a038fe48d28983883e24dad24ecd16a7b63458bc yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -321,10 +321,10 @@
px_index = x_dict[plot.data.axis]
py_index = y_dict[plot.data.axis]
dom = plot.data.pf.domain_right_edge - plot.data.pf.domain_left_edge
- #if self.periodic:
- # pxs, pys = na.mgrid[-1:1:3j,-1:1:3j]
- #else:
- pxs, pys = na.mgrid[0:0:1j,0:0:1j]
+ if self.periodic:
+ pxs, pys = na.mgrid[-1:1:3j,-1:1:3j]
+ else:
+ pxs, pys = na.mgrid[0:0:1j,0:0:1j]
GLE = plot.data.grid_left_edge
GRE = plot.data.grid_right_edge
for px_off, py_off in zip(pxs.ravel(), pys.ravel()):
https://bitbucket.org/yt_analysis/yt/changeset/59cea3bf549c/
changeset: 59cea3bf549c
branch: yt
user: ngoldbaum
date: 2012-08-31 08:37:59
summary: Making it so that only visible grids have id annotations drawn.
affected #: 1 file
diff -r a038fe48d28983883e24dad24ecd16a7b63458bc -r 59cea3bf549cc864b3a28148fbad3e4287fa0355 yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -349,7 +349,7 @@
plot._axes.add_collection(grid_collection)
if self.draw_ids:
ids = [g.id for g in plot.data._grids]
- for n in range(len(left_edge_x)):
+ for n in visible.nonzero()[0]:
plot._axes.text(left_edge_x[n]+(2*(xx1-xx0)/xpix),left_edge_y[n]+(2*(yy1-yy0)/ypix),ids[n])
plot._axes.hold(False)
https://bitbucket.org/yt_analysis/yt/changeset/b2e45258e0fb/
changeset: b2e45258e0fb
branch: yt
user: ngoldbaum
date: 2012-08-31 08:40:51
summary: Fixing a bug in the set_width method of plot window that will cause it to crash if supplied with a (width,unit) tuple
affected #: 1 file
diff -r 59cea3bf549cc864b3a28148fbad3e4287fa0355 -r b2e45258e0fb56b439e53f0fc145077f0f09356d yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -364,7 +364,7 @@
"""
if iterable(width) and isinstance(width[1],str):
unit = width[1]
- width = width[0]
+ width = (width[0],width[0])
elif not iterable(width):
width = (width,width)
Wx, Wy = width
https://bitbucket.org/yt_analysis/yt/changeset/00fe4774d2c6/
changeset: 00fe4774d2c6
branch: yt
user: ngoldbaum
date: 2012-08-31 08:47:07
summary: Updating set_width to accept tuples of (width, unit) tuples
affected #: 1 file
diff -r b2e45258e0fb56b439e53f0fc145077f0f09356d -r 00fe4774d2c6ec73747384f4a94c620f0b51e418 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -354,25 +354,48 @@
parameters
----------
- width : float, array of floats, or (float, unit) tuple.
- the width of the image.
+ width : float, array of floats, (float, unit) tuple, or arry of (float, unit) tuples.
+ Width can have four different formats to support windows with variable
+ x and y widths. They are:
+
+ ================================== =======================
+ format example
+ ================================== =======================
+ (float, string) (10,'kpc')
+ ((float, string), (float, string)) ((10,'kpc'),(15,'kpc'))
+ float 0.2
+ (float, float) (0.2, 0.3)
+ ================================== =======================
+
+ For example, (10, 'kpc') requests a plot window that is 10 kiloparsecs
+ wide in the x and y directions, ((10,'kpc'),(15,'kpc')) requests a window
+ that is 10 kiloparsecs wide along the x axis and 15 kiloparsecs wide along
+ the y axis. In the other two examples, code units are assumed, for example
+ (0.2, 0.3) requests a plot that has and x width of 0.2 and a y width of 0.3
+ in code units. the width of the image.
unit : str
the unit the width has been specified in.
defaults to code units. If width is a tuple this
argument is ignored
"""
- if iterable(width) and isinstance(width[1],str):
- unit = width[1]
- width = (width[0],width[0])
- elif not iterable(width):
- width = (width,width)
+ if iterable(width):
+ if isinstance(width[1],str):
+ w, unit = width
+ width = (w, w)
+ elif isinstance(width[1], tuple):
+ wx,unitx = width[0]
+ wy,unity = width[1]
+ width = (wx/self.pf[unitx],wy/self.pf[unity])
+ else:
+ width = (width, width)
Wx, Wy = width
width = (Wx,Wy)
width = [w / self.pf[unit] for w in width]
centerx = (self.xlim[1] + self.xlim[0])/2
centery = (self.ylim[1] + self.ylim[0])/2
+
self.xlim = (centerx - width[0]/2.,
centerx + width[0]/2.)
self.ylim = (centery - width[1]/2.,
https://bitbucket.org/yt_analysis/yt/changeset/bdde37db29a8/
changeset: bdde37db29a8
branch: yt
user: ngoldbaum
date: 2012-08-31 08:50:51
summary: Updating the draw_ids keyword to respect the clip box for the plot. If this isn't set then ids wil be draw for grids that have loer left hand corners outside the plot window.
affected #: 1 file
diff -r 00fe4774d2c6ec73747384f4a94c620f0b51e418 -r bdde37db29a88f8ba3720afda6fca0de49996951 yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -350,7 +350,7 @@
if self.draw_ids:
ids = [g.id for g in plot.data._grids]
for n in visible.nonzero()[0]:
- plot._axes.text(left_edge_x[n]+(2*(xx1-xx0)/xpix),left_edge_y[n]+(2*(yy1-yy0)/ypix),ids[n])
+ plot._axes.text(left_edge_x[n]+(2*(xx1-xx0)/xpix),left_edge_y[n]+(2*(yy1-yy0)/ypix),ids[n],clip_on=True)
plot._axes.hold(False)
class StreamlineCallback(PlotCallback):
https://bitbucket.org/yt_analysis/yt/changeset/327b4358244a/
changeset: 327b4358244a
branch: yt
user: MatthewTurk
date: 2012-08-31 13:22:00
summary: Merged in ngoldbaum/yt-cleancopy (pull request #255)
affected #: 2 files
diff -r d55d789c548f33b563121fe511cd689fc36f8e9a -r 327b4358244afdbf8507002e02c79d4ea9b3dd1d yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -80,11 +80,11 @@
def pixel_scale(self,plot):
x0, x1 = plot.xlim
xx0, xx1 = plot._axes.get_xlim()
- dx = (xx0 - xx1)/(x1 - x0)
+ dx = (xx1 - xx0)/(x1 - x0)
y0, y1 = plot.ylim
yy0, yy1 = plot._axes.get_ylim()
- dy = (yy0 - yy1)/(y1 - y0)
+ dy = (yy1 - yy0)/(y1 - y0)
return (dx,dy)
@@ -295,30 +295,29 @@
class GridBoundaryCallback(PlotCallback):
_type_name = "grids"
- def __init__(self, alpha=1.0, min_pix=1, annotate=False, periodic=True):
+ def __init__(self, alpha=1.0, min_pix=1, draw_ids=False, periodic=True):
"""
- annotate_grids(alpha=1.0, min_pix=1, annotate=False, periodic=True)
+ annotate_grids(alpha=1.0, min_pix=1, draw_ids=False, periodic=True)
Adds grid boundaries to a plot, optionally with *alpha*-blending.
Cuttoff for display is at *min_pix* wide.
- *annotate* puts the grid id in the corner of the grid. (Not so great in projections...)
+ *draw_ids* puts the grid id in the corner of the grid. (Not so great in projections...)
"""
PlotCallback.__init__(self)
self.alpha = alpha
self.min_pix = min_pix
- self.annotate = annotate # put grid numbers in the corner.
+ self.draw_ids = draw_ids # put grid numbers in the corner.
self.periodic = periodic
def __call__(self, plot):
x0, x1 = plot.xlim
y0, y1 = plot.ylim
- width, height = plot.image._A.shape
xx0, xx1 = plot._axes.get_xlim()
yy0, yy1 = plot._axes.get_ylim()
xi = x_dict[plot.data.axis]
yi = y_dict[plot.data.axis]
- dx = width / (x1-x0)
- dy = height / (y1-y0)
+ (dx, dy) = self.pixel_scale(plot)
+ (xpix, ypix) = plot.image._A.shape
px_index = x_dict[plot.data.axis]
py_index = y_dict[plot.data.axis]
dom = plot.data.pf.domain_right_edge - plot.data.pf.domain_left_edge
@@ -331,29 +330,27 @@
for px_off, py_off in zip(pxs.ravel(), pys.ravel()):
pxo = px_off * dom[px_index]
pyo = py_off * dom[py_index]
- left_edge_px = (GLE[:,px_index]+pxo-x0)*dx
- left_edge_py = (GLE[:,py_index]+pyo-y0)*dy
- right_edge_px = (GRE[:,px_index]+pxo-x0)*dx
- right_edge_py = (GRE[:,py_index]+pyo-y0)*dy
+ left_edge_x = (GLE[:,px_index]+pxo-x0)*dx + xx0
+ left_edge_y = (GLE[:,py_index]+pyo-y0)*dy + yy0
+ right_edge_x = (GRE[:,px_index]+pxo-x0)*dx + xx0
+ right_edge_y = (GRE[:,py_index]+pyo-y0)*dy + yy0
+ visible = ( xpix * (right_edge_x - left_edge_x) / (xx1 - xx0) > self.min_pix ) & \
+ ( ypix * (right_edge_y - left_edge_y) / (yy1 - yy0) > self.min_pix )
+ if visible.nonzero()[0].size == 0: continue
verts = na.array(
- [(left_edge_px, left_edge_px, right_edge_px, right_edge_px),
- (left_edge_py, right_edge_py, right_edge_py, left_edge_py)])
- visible = ( right_edge_px - left_edge_px > self.min_pix ) & \
- ( right_edge_px - left_edge_px > self.min_pix )
+ [(left_edge_x, left_edge_x, right_edge_x, right_edge_x),
+ (left_edge_y, right_edge_y, right_edge_y, left_edge_y)])
verts=verts.transpose()[visible,:,:]
- if verts.size == 0: continue
edgecolors = (0.0,0.0,0.0,self.alpha)
- verts[:,:,0]= (xx1-xx0)*(verts[:,:,0]/width) + xx0
- verts[:,:,1]= (yy1-yy0)*(verts[:,:,1]/height) + yy0
grid_collection = matplotlib.collections.PolyCollection(
verts, facecolors="none",
edgecolors=edgecolors)
plot._axes.hold(True)
plot._axes.add_collection(grid_collection)
- if self.annotate:
+ if self.draw_ids:
ids = [g.id for g in plot.data._grids]
- for n in range(len(left_edge_px)):
- plot._axes.text(left_edge_px[n]+2,left_edge_py[n]+2,ids[n])
+ for n in visible.nonzero()[0]:
+ plot._axes.text(left_edge_x[n]+(2*(xx1-xx0)/xpix),left_edge_y[n]+(2*(yy1-yy0)/ypix),ids[n],clip_on=True)
plot._axes.hold(False)
class StreamlineCallback(PlotCallback):
diff -r d55d789c548f33b563121fe511cd689fc36f8e9a -r 327b4358244afdbf8507002e02c79d4ea9b3dd1d yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -354,25 +354,48 @@
parameters
----------
- width : float, array of floats, or (float, unit) tuple.
- the width of the image.
+ width : float, array of floats, (float, unit) tuple, or arry of (float, unit) tuples.
+ Width can have four different formats to support windows with variable
+ x and y widths. They are:
+
+ ================================== =======================
+ format example
+ ================================== =======================
+ (float, string) (10,'kpc')
+ ((float, string), (float, string)) ((10,'kpc'),(15,'kpc'))
+ float 0.2
+ (float, float) (0.2, 0.3)
+ ================================== =======================
+
+ For example, (10, 'kpc') requests a plot window that is 10 kiloparsecs
+ wide in the x and y directions, ((10,'kpc'),(15,'kpc')) requests a window
+ that is 10 kiloparsecs wide along the x axis and 15 kiloparsecs wide along
+ the y axis. In the other two examples, code units are assumed, for example
+ (0.2, 0.3) requests a plot that has and x width of 0.2 and a y width of 0.3
+ in code units. the width of the image.
unit : str
the unit the width has been specified in.
defaults to code units. If width is a tuple this
argument is ignored
"""
- if iterable(width) and isinstance(width[1],str):
- unit = width[1]
- width = width[0]
- elif not iterable(width):
- width = (width,width)
+ if iterable(width):
+ if isinstance(width[1],str):
+ w, unit = width
+ width = (w, w)
+ elif isinstance(width[1], tuple):
+ wx,unitx = width[0]
+ wy,unity = width[1]
+ width = (wx/self.pf[unitx],wy/self.pf[unity])
+ else:
+ width = (width, width)
Wx, Wy = width
width = (Wx,Wy)
width = [w / self.pf[unit] for w in width]
centerx = (self.xlim[1] + self.xlim[0])/2
centery = (self.ylim[1] + self.ylim[0])/2
+
self.xlim = (centerx - width[0]/2.,
centerx + width[0]/2.)
self.ylim = (centery - width[1]/2.,
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