[yt-svn] commit/yt: 5 new changesets
Bitbucket
commits-noreply at bitbucket.org
Sun Jun 24 04:54:23 PDT 2012
5 new commits in yt:
https://bitbucket.org/yt_analysis/yt/changeset/0e971d288d91/
changeset: 0e971d288d91
branch: yt
user: ngoldbaum
date: 2012-06-23 21:57:10
summary: Adding OffAxisSlicePlot. This also includes minor fixes to
plot_window and FixedResolutionBuffer to allow plot window to work
with ObliqueFRB
affected #: 5 files
diff -r c5d54e6e4232b812e4754e926318aa0c5f60d587 -r 0e971d288d919ace47b798cf09133cc525483732 yt/mods.py
--- a/yt/mods.py
+++ b/yt/mods.py
@@ -118,7 +118,7 @@
get_multi_plot, FixedResolutionBuffer, ObliqueFixedResolutionBuffer, \
callback_registry, write_bitmap, write_image, annotate_image, \
apply_colormap, scale_image, write_projection, write_fits, \
- SlicePlot, ProjectionPlot
+ SlicePlot, OffAxisSlicePlot, ProjectionPlot, OffAxisProjectionPlot
from yt.visualization.volume_rendering.api import \
ColorTransferFunction, PlanckTransferFunction, ProjectionTransferFunction, \
diff -r c5d54e6e4232b812e4754e926318aa0c5f60d587 -r 0e971d288d919ace47b798cf09133cc525483732 yt/utilities/math_utils.py
--- a/yt/utilities/math_utils.py
+++ b/yt/utilities/math_utils.py
@@ -623,6 +623,46 @@
return na.array(result)
def get_rotation_matrix(theta, rot_vector):
+ """
+ Given an angle theta and a 3D vector rot_vector, this routine
+ computes the rotation matrix corresponding to rotating theta
+ radians about rot_vector.
+
+ Parameters
+ ----------
+ theta : scalar
+ The angle in radians.
+
+ rot_vector : array_like
+ The axis of rotation. Must be 3D.
+
+ Returns
+ -------
+ rot_matrix : ndarray
+ A new 3x3 2D array. This is the representation of a
+ rotation of theta radians about rot_vector in the simulation
+ box coordinate frame
+
+ See Also
+ --------
+ ortho_find
+
+ Examples
+ --------
+ >>> a = [0,1,0]
+ >>> theta = 0.785398163 # pi/4
+ >>> rot = mu.get_rotation_matrix(theta,a)
+ >>> rot
+ array([[ 0.70710678, 0. , 0.70710678],
+ [ 0. , 1. , 0. ],
+ [-0.70710678, 0. , 0.70710678]])
+ >>> na.dot(rot,a)
+ array([ 0., 1., 0.])
+ # since a is an eigenvector by construction
+ >>> na.dot(rot,[1,0,0])
+ array([ 0.70710678, 0. , -0.70710678])
+ """
+
ux = rot_vector[0]
uy = rot_vector[1]
uz = rot_vector[2]
diff -r c5d54e6e4232b812e4754e926318aa0c5f60d587 -r 0e971d288d919ace47b798cf09133cc525483732 yt/visualization/api.py
--- a/yt/visualization/api.py
+++ b/yt/visualization/api.py
@@ -65,5 +65,8 @@
from plot_window import \
SlicePlot, \
- ProjectionPlot
+ OffAxisSlicePlot, \
+ ProjectionPlot, \
+ OffAxisProjectionPlot
+
diff -r c5d54e6e4232b812e4754e926318aa0c5f60d587 -r 0e971d288d919ace47b798cf09133cc525483732 yt/visualization/fixed_resolution.py
--- a/yt/visualization/fixed_resolution.py
+++ b/yt/visualization/fixed_resolution.py
@@ -33,6 +33,7 @@
import weakref
class FixedResolutionBuffer(object):
+ _exclude_fields = ('pz','pdz','dx','x','y','z')
def __init__(self, data_source, bounds, buff_size, antialias = True,
periodic = False):
r"""
@@ -132,7 +133,7 @@
self.data[item] = val
def _get_data_source_fields(self):
- exclude = self.data_source._key_fields + ['pz','pdz','x','y','z']
+ exclude = self.data_source._key_fields + list(self._exclude_fields)
for f in self.data_source.fields:
if f not in exclude:
self[f]
diff -r c5d54e6e4232b812e4754e926318aa0c5f60d587 -r 0e971d288d919ace47b798cf09133cc525483732 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -3,6 +3,8 @@
Author: J. S. Oishi <jsoishi at gmail.com>
Affiliation: KIPAC/SLAC/Stanford
+Author: Nathan Goldbaum <goldbaum at ucolick.org>
+Affiliation: UCSC Astronomy
Homepage: http://yt-project.org/
License:
Copyright (C) 2010-2011 J. S. Oishi. All Rights Reserved.
@@ -31,7 +33,8 @@
from .image_writer import \
write_image, apply_colormap
from .fixed_resolution import \
- FixedResolutionBuffer
+ FixedResolutionBuffer, \
+ ObliqueFixedResolutionBuffer
from .plot_modifications import get_smallest_appropriate_unit
from .tick_locators import LogLocator, LinearLocator
@@ -42,6 +45,8 @@
y_dict, y_names, \
axis_names, \
axis_labels
+from yt.utilities.math_utils import \
+ ortho_find
def invalidate_data(f):
@wraps(f)
@@ -97,6 +102,16 @@
proj = pf.h.proj(axis,fields,weight_field=weight_field,max_level=max_level,center=center)
return PWViewerMPL(proj,bounds,origin=origin)
+def OffAxisSlicePlot(pf, normal, fields, center=None, width=None):
+ (bounds,center_rot) = GetOffAxisBoundsAndCenter(normal,center,width,pf)
+ cutting = pf.h.cutting(normal,center,fields=fields)
+ # Hard-coding the origin keyword since the other two options
+ # aren't well-defined for off-axis data objects
+ return PWViewerMPL(cutting,bounds,origin='center-window',periodic=False,oblique=True)
+
+def OffAxisProjectionPlot():
+ pass
+
def GetBoundsAndCenter(axis, center, width, pf):
if width == None:
width = (pf.domain_right_edge - pf.domain_left_edge)
@@ -113,13 +128,36 @@
center[y_dict[axis]]+width/2]
return (bounds,center)
+def GetOffAxisBoundsAndCenter(normal, center, width, pf):
+ if width == None:
+ width = (pf.domain_right_edge - pf.domain_left_edge)
+ if iterable(width):
+ w,u = width
+ width = w/pf[u]
+ if center == None:
+ v, center = pf.h.mind_max("Density")
+ elif center == "center" or center == "c":
+ center = [0,0,0]
+ else:
+ center = [(c - pf.domain_left_edge[i])/
+ (pf.domain_right_edge[i] - pf.domain_left_edge[i]) - 0.5
+ for i,c in enumerate(center)]
+ (normal,perp1,perp2) = ortho_find(normal)
+ mat = na.transpose(na.column_stack((perp1,perp2,normal)))
+ center = na.dot(mat,center)
+ bounds = [center[0]-width/2,
+ center[0]+width/2,
+ center[1]-width/2,
+ center[1]+width/2]
+ return (bounds,center)
+
class PlotWindow(object):
_plot_valid = False
_colorbar_valid = False
_contour_info = None
_vector_info = None
def __init__(self, data_source, bounds, buff_size=(800,800), antialias = True,
- periodic = True, origin='center-window'):
+ periodic = True, origin='center-window', oblique=False):
r"""
PlotWindow(data_source, bounds, buff_size=(800,800), antialias = True)
@@ -153,12 +191,13 @@
self.center = None
self.plots = {}
self._periodic = periodic
+ self.oblique = oblique
self.data_source = data_source
self.buff_size = buff_size
self.antialias = True
self.set_window(bounds) # this automatically updates the data and plot
self.origin = origin
- if self.data_source.center is not None:
+ if self.data_source.center is not None and oblique == False:
center = [self.data_source.center[i] for i in range(len(self.data_source.center)) if i != self.data_source.axis]
self.set_center(center)
self._initfinished = True
@@ -169,9 +208,14 @@
def _recreate_frb(self):
try:
bounds = self.bounds
- self._frb = FixedResolutionBuffer(self.data_source,
- bounds, self.buff_size,
- self.antialias, periodic=self._periodic)
+ if self.oblique == False:
+ self._frb = FixedResolutionBuffer(self.data_source,
+ bounds, self.buff_size,
+ self.antialias, periodic=self._periodic)
+ else:
+ self._frb = ObliqueFixedResolutionBuffer(self.data_source,
+ bounds, self.buff_size,
+ self.antialias, periodic=self._periodic)
except:
raise RuntimeError("Failed to repixelize.")
self._frb._get_data_source_fields()
@@ -392,7 +436,7 @@
def get_field_units(self, field, strip_mathml = True):
ds = self._frb.data_source
pf = self.pf
- if ds._type_name == "slice":
+ if ds._type_name == "slice" or "cutting":
units = pf.field_info[field].get_units()
elif ds._type_name == "proj":
units = pf.field_info[field].get_projected_units()
@@ -417,29 +461,40 @@
self._colorbar_valid = True
for f in self.fields:
md = self.get_metadata(f, strip_mathml = False, return_string = False)
+ axis_index = self.data_source.axis
+
if self.origin == 'center-window':
- extent = [self.xlim[i] - (self.xlim[0]+self.xlim[1])/2. for i in (0,1)]
- extent.extend([self.ylim[i] - (self.ylim[0]+self.ylim[1])/2. for i in (0,1)])
+ xc = (self.xlim[0]+self.xlim[1])/2
+ yc = (self.ylim[0]+self.ylim[1])/2
elif self.origin == 'center-domain':
- pass
+ xc = (self.pf.domain_left_edge[x_dict[axis_index]]+
+ self.pf.domain_right_edge[x_dict[axis_index]])/2
+ yc = (self.pf.domain_left_edge[y_dict[axis_index]]+
+ self.pf.domain_right_edge[y_dict[axis_index]])/2
elif self.origin == 'left-domain':
- pass
+ xc = self.pf.domain_left_edge[x_dict[axis_index]]
+ yc = self.pf.domain_left_edge[y_dict[axis_index]]
else:
- raise RuntimeError('Origin keyword not recognized')
-
+ raise RuntimeError('origin keyword: \"%(k)s\" not recognized' % {'k': self.origin})
+
+ extent = [self.xlim[i] - xc for i in (0,1)]
+ extent.extend([self.xlim[i] - yc for i in (0,1)])
extent = [el*self.pf[md['unit']] for el in extent]
self.plots[f] = WindowPlotMPL(self._frb[f], extent)
cb = matplotlib.pyplot.colorbar(self.plots[f].image,cax = self.plots[f].cax)
- axis_index = self.data_source.axis
-
- labels = [r'$\rm{'+axis_labels[axis_index][i].encode('string-escape')+
- r'\/\/('+md['unit'].encode('string-escape')+r')}$' for i in (0,1)]
+ try:
+ labels = [r'$\rm{'+axis_labels[axis_index][i].encode('string-escape')+
+ r'\/\/('+md['unit'].encode('string-escape')+r')}$' for i in (0,1)]
+ except IndexError:
+ labels = [r'$\rm{Image\/x}\/\/\rm{('+md['unit'].encode('string-escape')+r')}$',
+ r'$\rm{Image\/y}\/\/\rm{('+md['unit'].encode('string-escape')+r')}$']
+
self.plots[f].axes.set_xlabel(labels[0])
self.plots[f].axes.set_ylabel(labels[1])
-
+
cb.set_label(r'$\rm{'+f.encode('string-escape')+r'}\/\/('+md['units']+r')$')
self._plot_valid = True
https://bitbucket.org/yt_analysis/yt/changeset/efe70b25121a/
changeset: efe70b25121a
branch: yt
user: ngoldbaum
date: 2012-06-23 21:59:26
summary: Merging
affected #: 5 files
diff -r 0e971d288d919ace47b798cf09133cc525483732 -r efe70b25121a4fe4321beac4bb819cc0634d6252 scripts/iyt
--- a/scripts/iyt
+++ b/scripts/iyt
@@ -28,12 +28,6 @@
else:
api_version = '0.11'
-if IPython.__version__.startswith("0.10"):
- api_version = '0.10'
-elif IPython.__version__.startswith("0.11") or \
- IPython.__version__.startswith("0.12"):
- api_version = '0.11'
-
if api_version == "0.10" and "DISPLAY" in os.environ:
from matplotlib import rcParams
ipbackends = dict(Qt4 = IPython.Shell.IPShellMatplotlibQt4,
diff -r 0e971d288d919ace47b798cf09133cc525483732 -r efe70b25121a4fe4321beac4bb819cc0634d6252 yt/funcs.py
--- a/yt/funcs.py
+++ b/yt/funcs.py
@@ -26,6 +26,7 @@
import time, types, signal, inspect, traceback, sys, pdb, os
import contextlib
import warnings, struct, subprocess
+from distutils import version
from math import floor, ceil
from yt.utilities.exceptions import *
@@ -231,10 +232,10 @@
"""
import IPython
- if IPython.__version__.startswith("0.10"):
- api_version = '0.10'
- elif IPython.__version__.startswith("0.11"):
- api_version = '0.11'
+ if version.LooseVersion(IPython.__version__) <= version.LooseVersion('0.10'):
+ api_version = '0.10'
+ else:
+ api_version = '0.11'
stack = inspect.stack()
frame = inspect.stack()[num_up]
diff -r 0e971d288d919ace47b798cf09133cc525483732 -r efe70b25121a4fe4321beac4bb819cc0634d6252 yt/utilities/parallel_tools/parallel_analysis_interface.py
--- a/yt/utilities/parallel_tools/parallel_analysis_interface.py
+++ b/yt/utilities/parallel_tools/parallel_analysis_interface.py
@@ -344,8 +344,10 @@
dynamic = False):
if dynamic:
from .task_queue import dynamic_parallel_objects
- dynamic_parallel_objects(objects, njobs=njobs,
- storage=storage)
+ for my_obj in dynamic_parallel_objects(objects, njobs=njobs,
+ storage=storage):
+ yield my_obj
+ return
if not parallel_capable:
njobs = 1
diff -r 0e971d288d919ace47b798cf09133cc525483732 -r efe70b25121a4fe4321beac4bb819cc0634d6252 yt/utilities/parallel_tools/task_queue.py
--- a/yt/utilities/parallel_tools/task_queue.py
+++ b/yt/utilities/parallel_tools/task_queue.py
@@ -63,7 +63,7 @@
msg = self.comm.comm.recv(source = 0, tag=2)
msg = self.subcomm.bcast(msg, root=0)
if msg['msg'] == messages['end']['msg']:
- mylog.info("Notified to end")
+ mylog.debug("Notified to end")
raise StopIteration
return msg['value']
https://bitbucket.org/yt_analysis/yt/changeset/ad096b628bc0/
changeset: ad096b628bc0
branch: yt
user: ngoldbaum
date: 2012-06-23 22:12:11
summary: Removing OffAxisProjectionPlot
affected #: 1 file
diff -r efe70b25121a4fe4321beac4bb819cc0634d6252 -r ad096b628bc06d7fb076dda5f4ffcbdc52b012b5 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -109,9 +109,6 @@
# aren't well-defined for off-axis data objects
return PWViewerMPL(cutting,bounds,origin='center-window',periodic=False,oblique=True)
-def OffAxisProjectionPlot():
- pass
-
def GetBoundsAndCenter(axis, center, width, pf):
if width == None:
width = (pf.domain_right_edge - pf.domain_left_edge)
https://bitbucket.org/yt_analysis/yt/changeset/4cd11526ea44/
changeset: 4cd11526ea44
branch: yt
user: ngoldbaum
date: 2012-06-23 22:15:06
summary: Removing OffAxisProjectionPlot from yt.mods
affected #: 2 files
diff -r ad096b628bc06d7fb076dda5f4ffcbdc52b012b5 -r 4cd11526ea4498768720f6ac9acdb20e43761a9a yt/mods.py
--- a/yt/mods.py
+++ b/yt/mods.py
@@ -118,7 +118,7 @@
get_multi_plot, FixedResolutionBuffer, ObliqueFixedResolutionBuffer, \
callback_registry, write_bitmap, write_image, annotate_image, \
apply_colormap, scale_image, write_projection, write_fits, \
- SlicePlot, OffAxisSlicePlot, ProjectionPlot, OffAxisProjectionPlot
+ SlicePlot, OffAxisSlicePlot, ProjectionPlot
from yt.visualization.volume_rendering.api import \
ColorTransferFunction, PlanckTransferFunction, ProjectionTransferFunction, \
diff -r ad096b628bc06d7fb076dda5f4ffcbdc52b012b5 -r 4cd11526ea4498768720f6ac9acdb20e43761a9a yt/visualization/api.py
--- a/yt/visualization/api.py
+++ b/yt/visualization/api.py
@@ -66,7 +66,6 @@
from plot_window import \
SlicePlot, \
OffAxisSlicePlot, \
- ProjectionPlot, \
- OffAxisProjectionPlot
+ ProjectionPlot
https://bitbucket.org/yt_analysis/yt/changeset/fa7af00298ae/
changeset: fa7af00298ae
branch: yt
user: ngoldbaum
date: 2012-06-23 22:35:35
summary: Adding a north_vector keyword for OffAxisSlicePlot. Also
reintroducing a transpose for ObliqueFRB. All plots now agree in
orientation
affected #: 2 files
diff -r 4cd11526ea4498768720f6ac9acdb20e43761a9a -r fa7af00298ae69314894dd6b43378ede72967b72 yt/visualization/fixed_resolution.py
--- a/yt/visualization/fixed_resolution.py
+++ b/yt/visualization/fixed_resolution.py
@@ -375,6 +375,6 @@
self.data_source.center, self.data_source._inv_mat, indices,
self.data_source[item],
self.buff_size[0], self.buff_size[1],
- self.bounds)
+ self.bounds).transpose()
self[item] = buff
return buff
diff -r 4cd11526ea4498768720f6ac9acdb20e43761a9a -r fa7af00298ae69314894dd6b43378ede72967b72 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -102,9 +102,9 @@
proj = pf.h.proj(axis,fields,weight_field=weight_field,max_level=max_level,center=center)
return PWViewerMPL(proj,bounds,origin=origin)
-def OffAxisSlicePlot(pf, normal, fields, center=None, width=None):
+def OffAxisSlicePlot(pf, normal, fields, center=None, width=None, north_vector=None):
(bounds,center_rot) = GetOffAxisBoundsAndCenter(normal,center,width,pf)
- cutting = pf.h.cutting(normal,center,fields=fields)
+ cutting = pf.h.cutting(normal,center,fields=fields,north_vector=north_vector)
# Hard-coding the origin keyword since the other two options
# aren't well-defined for off-axis data objects
return PWViewerMPL(cutting,bounds,origin='center-window',periodic=False,oblique=True)
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