[Yt-svn] yt: 3 new changesets
hg at spacepope.org
hg at spacepope.org
Thu Dec 9 15:15:34 PST 2010
hg Repository: yt
details: yt/rev/479f2cff227c
changeset: 3593:479f2cff227c
user: Britton Smith <brittonsmith at gmail.com>
date:
Thu Dec 09 17:50:09 2010 -0500
description:
Fixing mpi_catarray to handle 1D arrays again.
hg Repository: yt
details: yt/rev/c9e814f3ab52
changeset: 3594:c9e814f3ab52
user: Britton Smith <brittonsmith at gmail.com>
date:
Thu Dec 09 17:50:41 2010 -0500
description:
Merged.
hg Repository: yt
details: yt/rev/68ef4be28392
changeset: 3595:68ef4be28392
user: Britton Smith <brittonsmith at gmail.com>
date:
Thu Dec 09 18:15:18 2010 -0500
description:
Make print_key_parameters a root only process.
diffstat:
yt/data_objects/static_output.py | 22 +++
yt/utilities/parallel_tools/parallel_analysis_interface.py | 5 +-
yt/visualization/plot_collection.py | 44 +++++++-
yt/visualization/plot_types.py | 3 +-
yt/visualization/plot_window.py | 79 +++++++++----
5 files changed, 126 insertions(+), 27 deletions(-)
diffs (283 lines):
diff -r 2eccd4b9743d -r 68ef4be28392 yt/data_objects/static_output.py
--- a/yt/data_objects/static_output.py Wed Dec 08 17:56:14 2010 -0500
+++ b/yt/data_objects/static_output.py Thu Dec 09 18:15:18 2010 -0500
@@ -29,6 +29,8 @@
from yt.funcs import *
from yt.config import ytcfg
+from yt.utilities.parallel_tools.parallel_analysis_interface import \
+ parallel_root_only
from yt.utilities.parameter_file_storage import \
ParameterFileStore, \
NoParameterShelf, \
@@ -85,6 +87,7 @@
_pf_store.check_pf(self)
except NoParameterShelf:
pass
+ self.print_key_parameters()
def __reduce__(self):
args = (self._hash(),)
@@ -165,6 +168,25 @@
hierarchy = property(_get_hierarchy, _set_hierarchy)
h = property(_get_hierarchy, _set_hierarchy)
+ @parallel_root_only
+ def print_key_parameters(self):
+ for a in ["current_time", "domain_dimensions", "domain_left_edge",
+ "domain_right_edge", "cosmological_simulation"]:
+ if not hasattr(self, a):
+ mylog.error("Missing %s in parameter file definition!", a)
+ continue
+ v = getattr(self, a)
+ mylog.info("Parameters: %-25s = %s", a, v)
+ if hasattr(self, "cosmological_simulation") and \
+ getattr(self, "cosmological_simulation"):
+ for a in ["current_redshift", "omega_lambda", "omega_matter",
+ "hubble_constant"]:
+ if not hasattr(self, a):
+ mylog.error("Missing %s in parameter file definition!", a)
+ continue
+ v = getattr(self, a)
+ mylog.info("Parameters: %-25s = %s", a, v)
+
def _reconstruct_pf(*args, **kwargs):
pfs = ParameterFileStore()
pf = pfs.get_pf_hash(*args)
diff -r 2eccd4b9743d -r 68ef4be28392 yt/utilities/parallel_tools/parallel_analysis_interface.py
--- a/yt/utilities/parallel_tools/parallel_analysis_interface.py Wed Dec 08 17:56:14 2010 -0500
+++ b/yt/utilities/parallel_tools/parallel_analysis_interface.py Thu Dec 09 18:15:18 2010 -0500
@@ -1033,7 +1033,10 @@
ncols = -1
size = 0
else:
- ncols, size = data.shape
+ if len(data) == 1:
+ ncols = size = data.shape
+ else:
+ ncols, size = data.shape
ncols = MPI.COMM_WORLD.allreduce(ncols, op=MPI.MAX)
if data is None:
data = na.empty((ncols,0), dtype='float64') # This only works for
diff -r 2eccd4b9743d -r 68ef4be28392 yt/visualization/plot_collection.py
--- a/yt/visualization/plot_collection.py Wed Dec 08 17:56:14 2010 -0500
+++ b/yt/visualization/plot_collection.py Thu Dec 09 18:15:18 2010 -0500
@@ -1558,7 +1558,6 @@
retval = func(self, *args, **kwargs)
retval._redraw_image()
retval._fig_num = new_fig.number
- self.pylab.show()
self.pylab.draw()
return retval
return pylabify
@@ -1611,7 +1610,7 @@
"""
for plot in self.plots:
plot._redraw_image()
- self.pylab.show()
+ self.pylab.draw()
def clear_figures(self):
r"""Clear all interactive figures affiliated with this collection.
@@ -1624,6 +1623,47 @@
self.pylab.figure(plot._fig_num)
self.pylab.clf()
+ def interactive_zoom(self):
+ r"""Enter an interactive zooming session for all plots.
+
+ Use this to enter an interactive session where zoom factors
+ can be entered that are used to set the widths of the plot
+ collection. This function has no arguments, but will return
+ the final width upon exit.
+
+ Caution: Tested and works with TkAgg and MacOSX backends. Threaded
+ backends like Qt4Agg are likely to fail.
+
+ Controls:
+ Any numeric value: Zooms by this factor
+ 0: Exit interactive zoom session
+ -1: Reset to width of 1.0 in code units
+ empty: zooms by previously entered factor.
+
+ Returns:
+ width: (float) The final width of the plot collection
+ """
+ print 'Enter Zoom Factor, 0 to exit, -1 to reset to width=1.0'
+ zfactor = 1.0
+ while(True):
+ new_zoom = raw_input('zoom:')
+ if new_zoom is not '':
+ try:
+ zfactor = float(new_zoom)
+ except:
+ print 'Please enter a valid number, or 0 to exit'
+ continue
+ else:
+ print 'Using previous zoom value of %e' % zfactor
+ if zfactor == 0.0:
+ break
+ elif zfactor == -1.0:
+ self.set_width(1.0,'1')
+ else:
+ self.set_width(self.plots[0].__dict__['width']/zfactor,'1')
+ print 'Returning final width of %e' % self.plots[0].width
+ return self.plots[0].width
+
def get_multi_plot(nx, ny, colorbar = 'vertical', bw = 4, dpi=300):
r"""Construct a multiple axes plot object, with or without a colorbar, into
which multiple plots may be inserted.
diff -r 2eccd4b9743d -r 68ef4be28392 yt/visualization/plot_types.py
--- a/yt/visualization/plot_types.py Wed Dec 08 17:56:14 2010 -0500
+++ b/yt/visualization/plot_types.py Thu Dec 09 18:15:18 2010 -0500
@@ -231,7 +231,8 @@
elif hasattr(matplotlib.cm, cmap):
cmap = getattr(matplotlib.cm, cmap)
self.cmap = cmap
-
+ self._redraw_image()
+
def __setitem__(self, item, val):
self.im[item] = val
diff -r 2eccd4b9743d -r 68ef4be28392 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py Wed Dec 08 17:56:14 2010 -0500
+++ b/yt/visualization/plot_window.py Thu Dec 09 18:15:18 2010 -0500
@@ -32,13 +32,18 @@
def invalidate_data(f):
def newfunc(*args, **kwargs):
+ f(*args, **kwargs)
args[0]._data_valid = False
- return f(*args, **kwargs)
+ args[0]._plot_valid = False
+ args[0]._recreate_frb()
+ args[0]._setup_plots()
+
return newfunc
def invalidate_plot(f):
def newfunc(*args, **kwargs):
args[0]._plot_valid = False
+ args[0]._setup_plots()
return f(*args, **kwargs)
return newfunc
@@ -56,54 +61,76 @@
Data is handled by a FixedResolutionBuffer object.
"""
+ self.plots = {}
self.data_source = data_source
- self.bounds = bounds
self.buff_size = buff_size
self.antialias = True
-
- self.plots = {}
- self._recreate_frb()
- self._frb._get_data_source_fields()
- self._setup_plots()
- self._data_valid = True
+ self.set_window(bounds) # this automatically updates the data and plot
def __getitem__(self, item):
return self.plots[item]
def _recreate_frb(self):
try:
+ bounds = self.bounds
self._frb = FixedResolutionBuffer(self.data_source,
- self.bounds, self.buff_size,
+ bounds, self.buff_size,
self.antialias)
except:
raise RuntimeError("Failed to repixelize.")
+ self._frb._get_data_source_fields()
self._data_valid = True
def _setup_plots(self):
for f in self.fields:
self.plots[f] = YtWindowPlot(self._frb[f])
+ self._plot_valid = True
@property
def fields(self):
return self._frb.data.keys()
- def save(self):
- for p in self.plots:
- self.plots[p].save("blah")
+ def save(self,name):
+ for k,v in self.plots.iteritems():
+ n = "%s_%s" % (name, k)
+ v.save(n)
- # def save(self):
- # """
- # REPLACE THIS
- # """
- # for field in self._frb.data.keys():
- # name = "%s.png" % field
- # print "writing %s" % name
- # write_image(self._frb[field],name)
-
@invalidate_data
def pan(self):
pass
+ @property
+ def width(self):
+ Wx = self.xlim[1] - self.xlim[0]
+ Wy = self.ylim[1] - self.ylim[0]
+ return (Wx, Wy)
+
+ @property
+ def bounds(self):
+ return self.xlim+self.ylim
+
+ @invalidate_data
+ def zoom(self, factor):
+ """
+ This zooms the window by *factor*.
+ """
+ Wx, Wy = self.width
+ centerx = self.xlim[0] + Wx*0.5
+ centery = self.ylim[0] + Wy*0.5
+ nWx, nWy = Wx/factor, Wy/factor
+ self.xlim = (centerx - nWx*0.5, centerx + nWx*0.5)
+ self.ylim = (centery - nWy*0.5, centery + nWy*0.5)
+ #self._run_callbacks()
+
+ @invalidate_data
+ def pan(self, deltas):
+ """
+ This accepts a tuple of *deltas*, composed of (delta_x, delta_y) that
+ will pan the window by those values in absolute coordinates.
+ """
+ self.xlim = (self.xlim[0] + deltas[0], self.xlim[1] + deltas[0])
+ self.ylim = (self.ylim[0] + deltas[1], self.ylim[1] + deltas[1])
+
@invalidate_plot
def set_cmap(self):
pass
@@ -113,12 +140,18 @@
pass
@invalidate_data
- def set_window(self):
- pass
+ def set_window(self, bounds):
+ self.xlim = bounds[0:2]
+ self.ylim = bounds[2:]
@invalidate_data
def set_width(self):
pass
+ @property
+ def width(self):
+ Wx = self.xlim[1] - self.xlim[0]
+ Wy = self.ylim[1] - self.ylim[0]
+ return (Wx, Wy)
# @invalidate_plot
# def set_zlim(self):
More information about the yt-svn
mailing list