[yt-svn] commit/yt: 4 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Sat Feb 1 10:07:21 PST 2014
4 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/1840fa3e5da4/
Changeset: 1840fa3e5da4
Branch: yt
User: jzuhone
Date: 2014-01-31 23:22:13
Summary: 1) Some more flexibility in defining responses, fixed a couple of bugs.
2) Including particle_trajectories and photon_simulator in the amods setup.py
Affected #: 2 files
diff -r d85c1291287fa5e92510950868fb582e562b18a3 -r 1840fa3e5da47ea6cb1763900947b861e77f94ae yt/analysis_modules/photon_simulator/photon_simulator.py
--- a/yt/analysis_modules/photon_simulator/photon_simulator.py
+++ b/yt/analysis_modules/photon_simulator/photon_simulator.py
@@ -27,6 +27,7 @@
cm_per_km, erg_per_keV
from yt.utilities.cosmology import Cosmology
from yt.utilities.orientation import Orientation
+from yt.utilities.definitions import mpc_conversion
from yt.utilities.parallel_tools.parallel_analysis_interface import \
communication_system, parallel_root_only, get_mpi_type, \
op_names, parallel_capable
@@ -415,7 +416,8 @@
def project_photons(self, L, area_new=None, exp_time_new=None,
redshift_new=None, dist_new=None,
absorb_model=None, psf_sigma=None,
- sky_center=None, responses=None):
+ sky_center=None, responses=None,
+ convolve_energies=False):
r"""
Projects photons onto an image plane given a line of sight.
@@ -443,8 +445,10 @@
sky_center : array_like, optional
Center RA, Dec of the events in degrees.
responses : list of strings, optional
- The names of the ARF and RMF files to convolve the photons with.
-
+ The names of the ARF and/or RMF files to convolve the photons with.
+ convolve_energies : boolean, optional
+ If this is set, the photon energies will be convolved with the RMF>
+
Examples
--------
>>> L = np.array([0.1,-0.2,0.3])
@@ -487,7 +491,8 @@
if responses is not None:
parameters["ARF"] = responses[0]
- parameters["RMF"] = responses[1]
+ if len(responses) == 2:
+ parameters["RMF"] = responses[1]
area_new = parameters["ARF"]
if (exp_time_new is None and area_new is None and
@@ -509,8 +514,13 @@
elo = f["SPECRESP"].data.field("ENERG_LO")
ehi = f["SPECRESP"].data.field("ENERG_HI")
eff_area = np.nan_to_num(f["SPECRESP"].data.field("SPECRESP"))
- weights = self._normalize_arf(parameters["RMF"])
- eff_area *= weights
+ if "RMF" in parameters:
+ weights = self._normalize_arf(parameters["RMF"])
+ eff_area *= weights
+ else:
+ mylog.warning("You specified an ARF but not an RMF. This is ok if the "+
+ "responses are normalized properly. If not, you may "+
+ "get inconsistent results.")
f.close()
Aratio = eff_area.max()/self.parameters["FiducialArea"]
else:
@@ -523,7 +533,7 @@
else:
if redshift_new is None:
zobs = 0.0
- D_A = dist[0]*self.pf.units["kpc"]/self.pf.units[dist[1]]
+ D_A = dist_new[0]*mpc_conversion["kpc"]/mpc_conversion[dist[1]]
else:
zobs = redshift_new
D_A = self.cosmo.AngularDiameterDistance(0.0,zobs)*1000.
@@ -609,7 +619,7 @@
if comm.rank == 0: mylog.info("Total number of observed photons: %d" % (num_events))
- if responses is not None:
+ if "RMF" in parameters and convolve_energies:
events, info = self._convolve_with_rmf(parameters["RMF"], events)
for k, v in info.items(): parameters[k] = v
@@ -733,8 +743,8 @@
self.wcs.wcs.cunit = ["deg"]*2
(self.events["xsky"],
self.events["ysky"]) = \
- self.wcs.wcs_pix2world(self.events["xpix"], self.events["ypix"],
- 1, ra_dec_order=True)
+ self.wcs.wcs_pix2world(self.events["xpix"],
+ self.events["ypix"], 1)
def keys(self):
return self.events.keys()
diff -r d85c1291287fa5e92510950868fb582e562b18a3 -r 1840fa3e5da47ea6cb1763900947b861e77f94ae yt/analysis_modules/setup.py
--- a/yt/analysis_modules/setup.py
+++ b/yt/analysis_modules/setup.py
@@ -22,4 +22,6 @@
config.add_subpackage("two_point_functions")
config.add_subpackage("radmc3d_export")
config.add_subpackage("sunyaev_zeldovich")
+ config.add_subpackage("particle_trajectories")
+ config.add_subpackage("photon_simulator")
return config
https://bitbucket.org/yt_analysis/yt/commits/81c9cc76d817/
Changeset: 81c9cc76d817
Branch: yt
User: jzuhone
Date: 2014-01-31 23:22:32
Summary: Merging
Affected #: 13 files
diff -r 1840fa3e5da47ea6cb1763900947b861e77f94ae -r 81c9cc76d81746db9a1183a8033fefb0243bee41 yt/analysis_modules/radmc3d_export/RadMC3DInterface.py
--- a/yt/analysis_modules/radmc3d_export/RadMC3DInterface.py
+++ b/yt/analysis_modules/radmc3d_export/RadMC3DInterface.py
@@ -182,10 +182,14 @@
LE = self.domain_left_edge
RE = self.domain_right_edge
+ # Radmc3D wants the cell wall positions in cgs. Convert here:
+ LE_cgs = LE * self.pf.units['cm']
+ RE_cgs = RE * self.pf.units['cm']
+
# calculate cell wall positions
- xs = [str(x) for x in np.linspace(LE[0], RE[0], dims[0]+1)]
- ys = [str(y) for y in np.linspace(LE[1], RE[1], dims[1]+1)]
- zs = [str(z) for z in np.linspace(LE[2], RE[2], dims[2]+1)]
+ xs = [str(x) for x in np.linspace(LE_cgs[0], RE_cgs[0], dims[0]+1)]
+ ys = [str(y) for y in np.linspace(LE_cgs[1], RE_cgs[1], dims[1]+1)]
+ zs = [str(z) for z in np.linspace(LE_cgs[2], RE_cgs[2], dims[2]+1)]
# writer file header
grid_file = open(self.grid_filename, 'w')
diff -r 1840fa3e5da47ea6cb1763900947b861e77f94ae -r 81c9cc76d81746db9a1183a8033fefb0243bee41 yt/data_objects/hierarchy.py
--- a/yt/data_objects/hierarchy.py
+++ b/yt/data_objects/hierarchy.py
@@ -319,7 +319,11 @@
obj = self.get_data("/Objects", name)
if obj is None:
return
- obj = cPickle.loads(obj.value)
+ if isinstance(obj, np.ndarray):
+ obj = obj.tostring()
+ elif hasattr(obj, 'value'):
+ obj = obj.value
+ obj = cPickle.loads(obj)
if iterable(obj) and len(obj) == 2:
obj = obj[1] # Just the object, not the pf
if hasattr(obj, '_fix_pickle'): obj._fix_pickle()
diff -r 1840fa3e5da47ea6cb1763900947b861e77f94ae -r 81c9cc76d81746db9a1183a8033fefb0243bee41 yt/data_objects/object_finding_mixin.py
--- a/yt/data_objects/object_finding_mixin.py
+++ b/yt/data_objects/object_finding_mixin.py
@@ -15,6 +15,7 @@
import numpy as np
+from yt.config import ytcfg
from yt.funcs import *
from yt.utilities.lib import \
get_box_grids_level, \
@@ -54,7 +55,19 @@
def find_max_cell_location(self, field, finest_levels = 3):
if finest_levels is not False:
- gi = (self.grid_levels >= self.max_level - finest_levels).ravel()
+ # This prevents bad values for the case that the number of grids to
+ # search is smaller than the number of processors being applied to
+ # the task, by
+ nproc = ytcfg.getint("yt", "__topcomm_parallel_size")
+ while 1:
+ gi = (self.grid_levels >= self.max_level - finest_levels).ravel()
+ if gi.sum() >= nproc:
+ break
+ elif finest_levels >= self.max_level:
+ raise YTTooParallel
+ else:
+ finest_levels += 1
+
source = self.grid_collection([0.0]*3, self.grids[gi])
else:
source = self.all_data()
diff -r 1840fa3e5da47ea6cb1763900947b861e77f94ae -r 81c9cc76d81746db9a1183a8033fefb0243bee41 yt/frontends/athena/fields.py
--- a/yt/frontends/athena/fields.py
+++ b/yt/frontends/athena/fields.py
@@ -78,7 +78,7 @@
def _convertDensity(data) :
return data.convert("Density")
def _density(field, data) :
- return data["density"]
+ return data["density"].copy()
add_field("Density", function=_density, take_log=False,
units=r"\rm{g}/\rm{cm}^3", projected_units=r"\rm{g}/\rm{cm}^2",
convert_function=_convertDensity)
@@ -87,21 +87,21 @@
return data.convert("x-velocity")
def _xvelocity(field, data):
if "velocity_x" in data.pf.field_info:
- return data["velocity_x"]
+ return data["velocity_x"].copy()
else:
return data["momentum_x"]/data["density"]
add_field("x-velocity", function=_xvelocity, take_log=False,
units=r"\rm{cm}/\rm{s}", convert_function=_convertVelocity)
def _yvelocity(field, data):
if "velocity_y" in data.pf.field_info:
- return data["velocity_y"]
+ return data["velocity_y"].copy()
else:
return data["momentum_y"]/data["density"]
add_field("y-velocity", function=_yvelocity, take_log=False,
units=r"\rm{cm}/\rm{s}", convert_function=_convertVelocity)
def _zvelocity(field, data):
if "velocity_z" in data.pf.field_info:
- return data["velocity_z"]
+ return data["velocity_z"].copy()
else:
return data["momentum_z"]/data["density"]
add_field("z-velocity", function=_zvelocity, take_log=False,
@@ -128,7 +128,7 @@
return data.convert("Density")*data.convert("x-velocity")**2
def _pressure(field, data) :
if "pressure" in data.pf.field_info:
- return data["pressure"]
+ return data["pressure"].copy()
else:
eint = data["total_energy"] - 0.5*(data["momentum_x"]**2 +
data["momentum_y"]**2 +
@@ -154,17 +154,17 @@
def _convertBfield(data):
return np.sqrt(4*np.pi*data.convert("Density")*data.convert("x-velocity")**2)
def _Bx(field, data):
- return data['cell_centered_B_x']
+ return data['cell_centered_B_x'].copy()
add_field("Bx", function=_Bx, take_log=False,
units=r"\rm{Gauss}", display_name=r"B_x",
convert_function=_convertBfield)
def _By(field, data):
- return data['cell_centered_B_y']
+ return data['cell_centered_B_y'].copy()
add_field("By", function=_By, take_log=False,
units=r"\rm{Gauss}", display_name=r"B_y",
convert_function=_convertBfield)
def _Bz(field, data):
- return data['cell_centered_B_z']
+ return data['cell_centered_B_z'].copy()
add_field("Bz", function=_Bz, take_log=False,
units=r"\rm{Gauss}", display_name=r"B_z",
convert_function=_convertBfield)
diff -r 1840fa3e5da47ea6cb1763900947b861e77f94ae -r 81c9cc76d81746db9a1183a8033fefb0243bee41 yt/utilities/command_line.py
--- a/yt/utilities/command_line.py
+++ b/yt/utilities/command_line.py
@@ -1037,7 +1037,7 @@
mpd.upload()
class YTInstInfoCmd(YTCommand):
- name = "instinfo"
+ name = ["instinfo", "version"]
args = (
dict(short="-u", long="--update-source", action="store_true",
default = False,
@@ -1055,6 +1055,7 @@
def __call__(self, opts):
import pkg_resources
+ import yt
yt_provider = pkg_resources.get_provider("yt")
path = os.path.dirname(yt_provider.module_path)
print
@@ -1071,10 +1072,11 @@
vstring = get_yt_version()
if vstring is not None:
print
- print "The current version of the code is:"
+ print "The current version and changeset for the code is:"
print
print "---"
- print vstring.strip()
+ print "Version = %s" % yt.__version__
+ print "Changeset = %s" % vstring.strip()
print "---"
print
if "site-packages" not in path:
@@ -1614,6 +1616,7 @@
def __call__(self, opts):
import pkg_resources
+ import yt
yt_provider = pkg_resources.get_provider("yt")
path = os.path.dirname(yt_provider.module_path)
print
@@ -1631,10 +1634,11 @@
if "site-packages" not in path:
vstring = get_hg_version(path)
print
- print "The current version of the code is:"
+ print "The current version and changeset for the code is:"
print
print "---"
- print vstring.strip()
+ print "Version = %s" % yt.__version__
+ print "Changeset = %s" % vstring.strip()
print "---"
print
print "This installation CAN be automatically updated."
diff -r 1840fa3e5da47ea6cb1763900947b861e77f94ae -r 81c9cc76d81746db9a1183a8033fefb0243bee41 yt/utilities/exceptions.py
--- a/yt/utilities/exceptions.py
+++ b/yt/utilities/exceptions.py
@@ -210,6 +210,10 @@
class YTEmptyProfileData(Exception):
pass
+class YTTooParallel(YTException):
+ def __str__(self):
+ return "You've used too many processors for this dataset."
+
class YTDuplicateFieldInProfile(Exception):
def __init__(self, field, new_spec, old_spec):
self.field = field
diff -r 1840fa3e5da47ea6cb1763900947b861e77f94ae -r 81c9cc76d81746db9a1183a8033fefb0243bee41 yt/utilities/lib/marching_cubes.pyx
--- a/yt/utilities/lib/marching_cubes.pyx
+++ b/yt/utilities/lib/marching_cubes.pyx
@@ -535,6 +535,7 @@
vertices = np.zeros((triangles.count*3,3), dtype='float64')
if do_sample == 0:
FillAndWipeTriangles(vertices, triangles.first)
+ return vertices
cdef int nskip
if do_sample == 1:
nskip = 1
diff -r 1840fa3e5da47ea6cb1763900947b861e77f94ae -r 81c9cc76d81746db9a1183a8033fefb0243bee41 yt/visualization/color_maps.py
--- a/yt/visualization/color_maps.py
+++ b/yt/visualization/color_maps.py
@@ -120,7 +120,7 @@
# Add colormaps in _colormap_data.py that weren't defined here
_vs = np.linspace(0,1,255)
for k,v in _cm.color_map_luts.iteritems():
- if k not in yt_colormaps:
+ if k not in yt_colormaps and k not in mcm.cmap_d:
cdict = { 'red': zip(_vs,v[0],v[0]),
'green': zip(_vs,v[1],v[1]),
'blue': zip(_vs,v[2],v[2]) }
diff -r 1840fa3e5da47ea6cb1763900947b861e77f94ae -r 81c9cc76d81746db9a1183a8033fefb0243bee41 yt/visualization/eps_writer.py
--- a/yt/visualization/eps_writer.py
+++ b/yt/visualization/eps_writer.py
@@ -26,9 +26,12 @@
from .plot_types import \
VMPlot, \
ProfilePlot
+from .plot_collection import PlotCollection
from .plot_window import PlotWindow
+from .profile_plotter import PhasePlot
from .plot_modifications import get_smallest_appropriate_unit
+
class DualEPS(object):
def __init__(self, figsize=(12,12)):
r"""Initializes the DualEPS class to which we can progressively add layers
@@ -57,6 +60,14 @@
#=============================================================================
+ def return_field(self, plot):
+ if isinstance(plot, PlotWindow) or isinstance(plot, PhasePlot):
+ return plot.plots.keys()[0]
+ else:
+ return None
+
+#=============================================================================
+
def axis_box(self, xrange=(0,1), yrange=(0,1), xlabel="", ylabel="",
xlog=False, ylog=False, xdata=None, ydata=None,
tickcolor=None, bare_axes=False,
@@ -275,18 +286,17 @@
>>> d.axis_box_yt(p)
>>> d.save_fig()
"""
- if isinstance(plot, PlotWindow):
+ if isinstance(plot, (PlotWindow, PhasePlot)):
plot.refresh()
- width = plot.width[0]
else:
plot._redraw_image()
- if isinstance(plot, VMPlot):
- width = plot.width
- if isinstance(plot, VMPlot) or isinstance(plot, PlotWindow):
+ if isinstance(plot, (VMPlot, PlotWindow)):
if isinstance(plot, PlotWindow):
data = plot._frb
+ width = plot.width[0]
else:
data = plot.data
+ width = plot.width
if units == None:
units = get_smallest_appropriate_unit(width, plot.pf)
_xrange = (0, width * plot.pf[units])
@@ -314,6 +324,26 @@
_ylabel = 'Image y (%s)' % (units)
if tickcolor == None:
_tickcolor = pyx.color.cmyk.white
+ elif isinstance(plot, PhasePlot):
+ k = plot.plots.keys()[0]
+ _xrange = plot[k].axes.get_xlim()
+ _yrange = plot[k].axes.get_ylim()
+ _xlog = plot.profile.x_log
+ _ylog = plot.profile.y_log
+ if bare_axes:
+ _xlabel = ""
+ _ylabel = ""
+ else:
+ if xlabel != None:
+ _xlabel = xlabel
+ else:
+ _xlabel = plot[k].axes.get_xlabel()
+ if ylabel != None:
+ _ylabel = ylabel
+ else:
+ _ylabel = plot[k].axes.get_ylabel()
+ if tickcolor == None:
+ _tickcolor = None
else:
_xrange = plot._axes.get_xlim()
_yrange = plot._axes.get_ylim()
@@ -412,7 +442,7 @@
plot.colorbar = None
plot._redraw_image()
_p1 = plot._figure
- elif isinstance(plot, PlotWindow):
+ elif isinstance(plot, (PlotWindow, PhasePlot)):
self.field = field
if self.field == None:
self.field = plot.plots.keys()[0]
@@ -424,18 +454,22 @@
plot.refresh()
_p1 = plot.plots[self.field].figure
# hack to account for non-square display ratios (not sure why)
- shift = 12.0 / 340
+ if isinstance(plot, PlotWindow):
+ shift = 12.0 / 340
elif isinstance(plot, ProfilePlot):
plot._redraw_image()
# Remove colorbar
_p1 = plot._figure
_p1.delaxes(_p1.axes[1])
+ else:
+ raise RuntimeError("Unknown plot type")
+
_p1.axes[0].set_axis_off() # remove axes
_p1.axes[0].set_position([-shift,0,1,1]) # rescale figure
_p1.set_facecolor('w') # set background color
figure_canvas = FigureCanvasAgg(_p1)
figure_canvas.draw()
- size = _p1.get_size_inches() * _p1.dpi
+ size = (_p1.get_size_inches() * _p1.dpi).astype('int')
image = pyx.bitmap.image(size[0], size[1], "RGB",
figure_canvas.tostring_rgb())
#figure_canvas.print_png('test.png')
@@ -507,6 +541,12 @@
# Scale the colorbar
shift = (0.5*(1.0-shrink[0])*size[0], 0.5*(1.0-shrink[1])*size[1])
+ # To facilitate strething rather than shrinking
+ # If stretched in both directions (makes no sense?) then y dominates.
+ if(shrink[0] > 1.0):
+ shift = (0.05*self.figsize[0], 0.5*(1.0-shrink[1])*size[1])
+ if(shrink[1] > 1.0):
+ shift = (0.5*(1.0-shrink[0])*size[0], 0.05*self.figsize[1])
size = (size[0] * shrink[0], size[1] * shrink[1])
origin = (origin[0] + shift[0], origin[1] + shift[1])
@@ -567,7 +607,7 @@
#=============================================================================
- def colorbar_yt(self, plot, **kwargs):
+ def colorbar_yt(self, plot, field=None, **kwargs):
r"""Wrapper around DualEPS.colorbar to take information from a yt plot.
Accepts all parameters that DualEPS.colorbar takes.
@@ -587,7 +627,9 @@
>>> d.save_fig()
"""
_cmap = None
- if isinstance(plot, PlotWindow):
+ if field != None:
+ self.field = field
+ if isinstance(plot, (PlotWindow, PhasePlot)):
_cmap = plot._colormaps[self.field]
else:
if plot.cmap != None:
@@ -601,10 +643,13 @@
_zlabel = _zlabel.replace("_","\;")
_zlog = plot.log_field
_zrange = (plot.norm.vmin, plot.norm.vmax)
- elif isinstance(plot, PlotWindow):
+ elif isinstance(plot, (PlotWindow, PhasePlot)):
proj = plot._plot_type.endswith("Projection") and \
plot.data_source.weight_field == None
- _zlabel = plot.pf.field_info[self.field].get_label(proj)
+ if isinstance(plot, PlotWindow):
+ _zlabel = plot.pf.field_info[self.field].get_label(proj)
+ else:
+ _zlabel = plot.data_source.pf.field_info[self.field].get_label(proj)
_zlabel = _zlabel.replace("_","\;")
_zlog = plot.get_log(self.field)[self.field]
if plot.plots[self.field].zmin == None:
@@ -656,6 +701,59 @@
#=============================================================================
+ def arrow(self, size=0.2, label="", loc=(0.05,0.08), labelloc="top",
+ color=pyx.color.cmyk.white,
+ linewidth=pyx.style.linewidth.normal):
+ r"""Draws an arrow in the current figure
+
+ Parameters
+ ----------
+ size : float
+ Length of arrow (base to tip) in units of the figure size.
+ label : string
+ Annotation label of the arrow.
+ loc : tuple of floats
+ Location of the left hand side of the arrow in units of
+ the figure size.
+ labelloc : string
+ Location of the label with respect to the line. Can be
+ "top" or "bottom"
+ color : `pyx.color.*.*`
+ Color of the arrow. Example: pyx.color.cymk.white
+ linewidth : `pyx.style.linewidth.*`
+ Width of the arrow. Example: pyx.style.linewidth.normal
+
+ Examples
+ --------
+ >>> d = DualEPS()
+ >>> d.axis_box(xrange=(0,100), yrange=(1e-3,1), ylog=True)
+ >>> d.insert_image("arrow_image.jpg")
+ >>> d.arrow(size=0.2, label="Black Hole!", loc=(0.05, 0.1))
+ >>> d.save_fig()
+ """
+ line = pyx.path.line(self.figsize[0]*loc[0],
+ self.figsize[1]*loc[1],
+ self.figsize[0]*(loc[0]+size),
+ self.figsize[1]*loc[1])
+ self.canvas.stroke(line, [linewidth, color, pyx.deco.earrow()])
+
+
+ if labelloc == "bottom":
+ yoff = -0.1*size
+ valign = pyx.text.valign.top
+ else:
+ yoff = +0.1*size
+ valign = pyx.text.valign.bottom
+ if label != "":
+ self.canvas.text(self.figsize[0]*(loc[0]+0.5*size),
+ self.figsize[1]*(loc[1]+yoff), label,
+ [color, valign, pyx.text.halign.center])
+
+
+
+
+#=============================================================================
+
def scale_line(self, size=0.2, label="", loc=(0.05,0.08), labelloc="top",
color=pyx.color.cmyk.white,
linewidth=pyx.style.linewidth.normal):
@@ -686,6 +784,7 @@
>>> d.scale_line(size=0.2, label="1 kpc", loc=(0.05, 0.1))
>>> d.save_fig()
"""
+
line = pyx.path.line(self.figsize[0]*loc[0],
self.figsize[1]*loc[1],
self.figsize[0]*(loc[0]+size),
@@ -783,13 +882,13 @@
#=============================================================================
#=============================================================================
-def multiplot(ncol, nrow, yt_plots=None, images=None, xranges=None,
- yranges=None, xlabels=None, ylabels=None,
+def multiplot(ncol, nrow, yt_plots=None, fields=None, images=None,
+ xranges=None, yranges=None, xlabels=None, ylabels=None,
xdata=None, ydata=None, colorbars=None,
shrink_cb=0.95, figsize=(8,8), margins=(0,0), titles=None,
savefig=None, format="eps", yt_nocbar=False, bare_axes=False,
xaxis_flags=None, yaxis_flags=None,
- cb_flags=None):
+ cb_flags=None, cb_location=None, plot_collection=False):
r"""Convenience routine to create a multi-panel figure from yt plots or
JPEGs. The images are first placed from the origin, and then
bottom-to-top and left-to-right.
@@ -834,6 +933,11 @@
axes.
cb_flags : list of booleans
Flags for each plot to have a colorbar or not.
+ cb_location : list of strings
+ Strings to control the location of the colorbar (left, right,
+ top, bottom)
+ plot_collection : boolean
+ Set to true to yt_plots is a PlotCollection
Examples
--------
@@ -858,8 +962,9 @@
yt plots.
"""
# Error check
+ npanels = ncol*nrow
if images != None:
- if len(images) != ncol*nrow:
+ if len(images) != npanels:
raise RuntimeError("Number of images (%d) doesn't match nrow(%d)"\
" x ncol(%d)." % (len(images), nrow, ncol))
return
@@ -872,26 +977,29 @@
_yt = True
else:
_yt = False
+ if fields == None:
+ fields = [None] * npanels
# If no ranges or labels given and given only images, fill them in.
if not _yt:
if xranges is None:
xranges = []
- for i in range(nrow*ncol): xranges.append((0,1))
+ for i in range(npanels): xranges.append((0,1))
if yranges is None:
yranges = []
- for i in range(nrow*ncol): yranges.append((0,1))
+ for i in range(npanels): yranges.append((0,1))
if xlabels is None:
xlabels = []
- for i in range(nrow*ncol): xlabels.append("")
+ for i in range(npanels): xlabels.append("")
if ylabels is None:
ylabels = []
- for i in range(nrow*ncol): ylabels.append("")
+ for i in range(npanels): ylabels.append("")
d = DualEPS(figsize=figsize)
count = 0
for j in range(nrow):
- ypos = j*(figsize[1] + margins[1])
+ invj = nrow - j - 1
+ ypos = invj*(figsize[1] + margins[1])
for i in range(ncol):
xpos = i*(figsize[0] + margins[0])
index = j*ncol + i
@@ -930,7 +1038,8 @@
ylabel = ylabels[j]
else:
ylabel = None
- d.insert_image_yt(yt_plots[index], pos=(xpos, ypos))
+ d.insert_image_yt(yt_plots[index], pos=(xpos, ypos),
+ field=fields[index])
d.axis_box_yt(yt_plots[index], pos=(xpos, ypos),
bare_axes=bare_axes, xaxis_side=xaxis,
yaxis_side=yaxis,
@@ -956,7 +1065,8 @@
100.0 * d.canvas.bbox().bottom().t,
100.0 * d.canvas.bbox().top().t - d.figsize[1])
for j in range(nrow):
- ypos0 = j*(figsize[1] + margins[1])
+ invj = nrow - j - 1
+ ypos0 = invj*(figsize[1] + margins[1])
for i in range(ncol):
xpos0 = i*(figsize[0] + margins[0])
index = j*ncol + i
@@ -964,32 +1074,49 @@
if cb_flags != None:
if cb_flags[index] == False:
continue
- if ncol == 1:
- orientation = "right"
+ if cb_location == None:
+ if ncol == 1:
+ orientation = "right"
+ elif i == 0:
+ orientation = "left"
+ elif i+1 == ncol:
+ orientation = "right"
+ elif j == 0:
+ orientation = "bottom"
+ elif j+1 == nrow:
+ orientation = "top"
+ else:
+ orientation = None # Marker for interior plot
+ else:
+ if fields[index] not in cb_location.keys():
+ raise RuntimeError("%s not found in cb_location dict" %
+ fields[index])
+ return
+ orientation = cb_location[fields[index]]
+ if orientation == "right":
xpos = bbox[1]
ypos = ypos0
- elif j == 0:
- orientation = "bottom"
+ elif orientation == "left":
+ xpos = bbox[0]
+ ypos = ypos0
+ elif orientation == "bottom":
ypos = bbox[2]
xpos = xpos0
- elif i == 0:
- orientation = "left"
- xpos = bbox[0]
- ypos = ypos0
- elif i+1 == ncol:
- orientation = "right"
- xpos = bbox[1]
- ypos = ypos0
- elif j+1 == nrow:
- orientation = "top"
+ elif orientation == "top":
ypos = bbox[3]
xpos = xpos0
else:
+ mylog.warning("Unknown colorbar location %s. "
+ "No colorbar displayed." % orientation)
orientation = None # Marker for interior plot
if orientation != None:
if _yt:
+ # Set field if undefined
+ if fields[index] == None:
+ fields[index] = d.return_field(yt_plots[index])
d.colorbar_yt(yt_plots[index],
+ field=fields[index],
pos=[xpos,ypos],
shrink=shrink_cb,
orientation=orientation)
@@ -1009,8 +1136,8 @@
#=============================================================================
-def multiplot_yt(ncol, nrow, plot_col, **kwargs):
- r"""Wrapper for multiplot that takes a yt PlotCollection.
+def multiplot_yt(ncol, nrow, plots, fields=None, **kwargs):
+ r"""Wrapper for multiplot that takes a yt PlotWindow or PlotCollection.
Accepts all parameters used in multiplot.
@@ -1020,8 +1147,8 @@
Number of columns in the figure.
nrow : integer
Number of rows in the figure.
- plot_col : `PlotCollection`
- yt PlotCollection that has the plots to be used.
+ plots : `PlotCollection` or `PlotWindow`
+ yt PlotCollection or PlotWindow that has the plots to be used.
Examples
--------
@@ -1040,18 +1167,42 @@
>>> mp = multiplot_yt(2,2,pc,savefig="yt",shrink_cb=0.9, bare_axes=False,
>>> yt_nocbar=False, margins=(0.5,0.5))
"""
- if len(plot_col.plots) < nrow*ncol:
- raise RuntimeError("Number of plots in PlotCollection is less "\
- "than nrow(%d) x ncol(%d)." % \
- (len(plot_col.plots), nrow, ncol))
+ # Determine whether the plots are organized in a PlotCollection,
+ # PlotWindow, or list of PlotWindows
+ if isinstance(plots, PlotCollection):
+ if len(plots.plots) < nrow*ncol:
+ raise RuntimeError("Number of plots in PlotCollection is less "\
+ "than nrow(%d) x ncol(%d)." % \
+ (len(plots.plots), nrow, ncol))
+ return
+ figure = multiplot(ncol, nrow, yt_plots=plots.plots,
+ plot_collection=True, **kwargs)
+ elif isinstance(plots, PlotWindow):
+ if fields == None:
+ fields = plots.fields
+ if len(fields) < nrow*ncol:
+ raise RuntimeError("Number of plots is less "\
+ "than nrow(%d) x ncol(%d)." % \
+ (len(fields), nrow, ncol))
+ return
+ figure = multiplot(ncol, nrow, yt_plots=plots, fields=fields, **kwargs)
+ elif isinstance(plots, list) and isinstance(plots[0], PlotWindow):
+ if len(plots) < nrow*ncol:
+ raise RuntimeError("Number of plots is less "\
+ "than nrow(%d) x ncol(%d)." % \
+ (len(fields), nrow, ncol))
+ return
+ figure = multiplot(ncol, nrow, yt_plots=plots, fields=fields, **kwargs)
+ else:
+ raise RuntimeError("Unknown plot type in multiplot_yt")
return
- figure = multiplot(ncol, nrow, yt_plots=plot_col.plots, **kwargs)
return figure
#=============================================================================
-def single_plot(plot, figsize=(12,12), cb_orient="right", bare_axes=False,
- savefig=None, colorbar=True, file_format='eps', **kwargs):
+def single_plot(plot, field=None, figsize=(12,12), cb_orient="right",
+ bare_axes=False, savefig=None, colorbar=True,
+ file_format='eps', **kwargs):
r"""Wrapper for DualEPS routines to create a figure directy from a yt
plot. Calls insert_image_yt, axis_box_yt, and colorbar_yt.
@@ -1080,7 +1231,7 @@
>>> single_plot(p, savefig="figure1")
"""
d = DualEPS(figsize=figsize)
- d.insert_image_yt(plot)
+ d.insert_image_yt(plot, field=field)
d.axis_box_yt(plot, bare_axes=bare_axes, **kwargs)
if colorbar:
d.colorbar_yt(plot, orientation=cb_orient)
diff -r 1840fa3e5da47ea6cb1763900947b861e77f94ae -r 81c9cc76d81746db9a1183a8033fefb0243bee41 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -1149,8 +1149,6 @@
self.set_axes_unit(axes_unit)
def _recreate_frb(self):
- if self._frb is not None:
- raise NotImplementedError
super(OffAxisProjectionPlot, self)._recreate_frb()
_metadata_template = """
diff -r 1840fa3e5da47ea6cb1763900947b861e77f94ae -r 81c9cc76d81746db9a1183a8033fefb0243bee41 yt/visualization/profile_plotter.py
--- a/yt/visualization/profile_plotter.py
+++ b/yt/visualization/profile_plotter.py
@@ -28,7 +28,9 @@
from .plot_window import WindowPlotMPL
from .base_plot_types import ImagePlotMPL
-from .plot_container import ImagePlotContainer
+from .plot_container import \
+ ImagePlotContainer, \
+ log_transform, linear_transform
from .image_writer import \
write_image, apply_colormap
from yt.data_objects.profiles import \
@@ -532,6 +534,7 @@
self.plot_title = {}
self.z_log = {}
self.z_title = {}
+ self._initfinished = False
if profile is None:
profile = create_profile(data_source,
@@ -545,6 +548,7 @@
figure_size, fontsize)
# This is a fallback, in case we forget.
self._setup_plots()
+ self._initfinished = True
def _get_field_title(self, field_z, profile):
pf = profile.data_source.pf
@@ -621,6 +625,10 @@
self.plots[f].axes.xaxis.set_label_text(x_title)
self.plots[f].axes.yaxis.set_label_text(y_title)
self.plots[f].cax.yaxis.set_label_text(z_title)
+ if z_scale == "log":
+ self._field_transform[f] = log_transform
+ else:
+ self._field_transform[f] = linear_transform
if f in self.plot_title:
self.plots[f].axes.set_title(self.plot_title[f])
@@ -702,6 +710,7 @@
def __init__(self, x_data, y_data, data,
x_scale, y_scale, z_scale, cmap,
zlim, size, fontsize, figure, axes, cax):
+ self._initfinished = False
self._draw_colorbar = True
self._draw_axes = True
self._cache_layout(size, fontsize)
@@ -723,6 +732,7 @@
figure, axes, cax)
self._init_image(x_data, y_data, data, x_scale, y_scale, z_scale,
zlim, cmap)
+ self._initfinished = True
def _init_image(self, x_data, y_data, image_data,
x_scale, y_scale, z_scale, zlim, cmap):
diff -r 1840fa3e5da47ea6cb1763900947b861e77f94ae -r 81c9cc76d81746db9a1183a8033fefb0243bee41 yt/visualization/volume_rendering/camera.py
--- a/yt/visualization/volume_rendering/camera.py
+++ b/yt/visualization/volume_rendering/camera.py
@@ -239,8 +239,7 @@
else:
self.use_kd = isinstance(volume, AMRKDTree)
self.volume = volume
- self.center = (self.re + self.le) / 2.0
- self.region = self.pf.h.region(self.center, self.le, self.re)
+ self.region = None
def _setup_box_properties(self, width, center, unit_vectors):
self.width = width
@@ -299,6 +298,9 @@
>>> write_bitmap(im, 'render_with_grids.png')
"""
+ if self.region is None:
+ self.region = self.pf.h.region((self.re + self.le) / 2.0,
+ self.le, self.re)
corners = self.region.grid_corners
levels = self.region.grid_levels[:,0]
diff -r 1840fa3e5da47ea6cb1763900947b861e77f94ae -r 81c9cc76d81746db9a1183a8033fefb0243bee41 yt/visualization/volume_rendering/transfer_functions.py
--- a/yt/visualization/volume_rendering/transfer_functions.py
+++ b/yt/visualization/volume_rendering/transfer_functions.py
@@ -620,7 +620,7 @@
--------
>>> tf = ColorTransferFunction( (-10.0, -5.0) )
- >>> tf.sample_colormap(-7.0, 0.01, 'algae')
+ >>> tf.sample_colormap(-7.0, 0.01, colormap='algae')
"""
if col_bounds is None:
rel = (v - self.x_bounds[0])/(self.x_bounds[1] - self.x_bounds[0])
https://bitbucket.org/yt_analysis/yt/commits/7fc45263beb3/
Changeset: 7fc45263beb3
Branch: yt
User: jzuhone
Date: 2014-01-31 23:24:01
Summary: Merged yt_analysis/yt into yt
Affected #: 1 file
diff -r 81c9cc76d81746db9a1183a8033fefb0243bee41 -r 7fc45263beb3c09c957a9628fe874400b5772919 yt/visualization/profile_plotter.py
--- a/yt/visualization/profile_plotter.py
+++ b/yt/visualization/profile_plotter.py
@@ -641,6 +641,7 @@
[ax.xaxis.label, ax.yaxis.label, cbax.yaxis.label]
for label in labels:
label.set_color(self._font_color)
+ self._plot_valid = True
def save(self, name=None, mpl_kwargs=None):
r"""
https://bitbucket.org/yt_analysis/yt/commits/b0300cca82d7/
Changeset: b0300cca82d7
Branch: yt
User: jzuhone
Date: 2014-02-01 18:13:18
Summary: Merging
Affected #: 4 files
diff -r 7fc45263beb3c09c957a9628fe874400b5772919 -r b0300cca82d776823aa41859da24c606588f9363 MANIFEST.in
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -1,4 +1,9 @@
-include distribute_setup.py README* CREDITS COPYING.txt CITATION
+include distribute_setup.py README* CREDITS COPYING.txt CITATION nose.cfg
recursive-include yt/gui/reason/html *.html *.png *.ico *.js
-recursive-include yt *.pyx *.pxd *.h README*
-recursive-include yt/utilities/kdtree *.f90 *.v Makefile LICENSE
\ No newline at end of file
+recursive-include yt *.pyx *.pxd *.h README* *.glsl *.cu
+recursive-include yt/utilities/kdtree *.f90 *.v Makefile LICENSE
+recursive-include yt/analysis_modules/halo_finding/rockstar *.py *.pyx
+prune yt/frontends/_skeleton
+prune tests
+graft yt/gui/reason/html/resources
+exclude clean.sh .hgchurn
diff -r 7fc45263beb3c09c957a9628fe874400b5772919 -r b0300cca82d776823aa41859da24c606588f9363 yt/analysis_modules/halo_finding/setup.py
--- a/yt/analysis_modules/halo_finding/setup.py
+++ b/yt/analysis_modules/halo_finding/setup.py
@@ -1,9 +1,7 @@
#!/usr/bin/env python
-import setuptools
-import os
-import sys
import os.path
+
def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration
config = Configuration('halo_finding', parent_package, top_path)
@@ -12,6 +10,5 @@
config.add_subpackage("parallel_hop")
if os.path.exists("rockstar.cfg"):
config.add_subpackage("rockstar")
- config.make_config_py() # installs __config__.py
- #config.make_svn_version_py()
+ config.make_config_py() # installs __config__.py
return config
diff -r 7fc45263beb3c09c957a9628fe874400b5772919 -r b0300cca82d776823aa41859da24c606588f9363 yt/analysis_modules/photon_simulator/photon_simulator.py
--- a/yt/analysis_modules/photon_simulator/photon_simulator.py
+++ b/yt/analysis_modules/photon_simulator/photon_simulator.py
@@ -447,7 +447,7 @@
responses : list of strings, optional
The names of the ARF and/or RMF files to convolve the photons with.
convolve_energies : boolean, optional
- If this is set, the photon energies will be convolved with the RMF>
+ If this is set, the photon energies will be convolved with the RMF.
Examples
--------
@@ -490,6 +490,7 @@
parameters = {}
if responses is not None:
+ responses = ensure_list(responses)
parameters["ARF"] = responses[0]
if len(responses) == 2:
parameters["RMF"] = responses[1]
@@ -533,7 +534,11 @@
else:
if redshift_new is None:
zobs = 0.0
- D_A = dist_new[0]*mpc_conversion["kpc"]/mpc_conversion[dist[1]]
+ if dist_new[1] not in mpc_conversion:
+ mylog.error("Please specify dist_new in one of the following units: %s",
+ mpc_conversion.keys())
+ raise KeyError
+ D_A = dist_new[0]*mpc_conversion["kpc"]/mpc_conversion[dist_new[1]]
else:
zobs = redshift_new
D_A = self.cosmo.AngularDiameterDistance(0.0,zobs)*1000.
diff -r 7fc45263beb3c09c957a9628fe874400b5772919 -r b0300cca82d776823aa41859da24c606588f9363 yt/analysis_modules/setup.py
--- a/yt/analysis_modules/setup.py
+++ b/yt/analysis_modules/setup.py
@@ -1,12 +1,10 @@
#!/usr/bin/env python
-import setuptools
def configuration(parent_package='', top_path=None):
from numpy.distutils.misc_util import Configuration
config = Configuration('analysis_modules', parent_package, top_path)
config.make_config_py() # installs __config__.py
- #config.make_svn_version_py()
config.add_subpackage("absorption_spectrum")
config.add_subpackage("coordinate_transformation")
config.add_subpackage("cosmological_observation")
@@ -16,12 +14,15 @@
config.add_subpackage("halo_profiler")
config.add_subpackage("hierarchy_subset")
config.add_subpackage("level_sets")
+ config.add_subpackage("particle_trajectories")
+ config.add_subpackage("photon_simulator")
config.add_subpackage("radial_column_density")
config.add_subpackage("spectral_integrator")
config.add_subpackage("star_analysis")
config.add_subpackage("two_point_functions")
config.add_subpackage("radmc3d_export")
- config.add_subpackage("sunyaev_zeldovich")
+ config.add_subpackage("sunrise_export")
+ config.add_subpackage("sunyaev_zeldovich")
config.add_subpackage("particle_trajectories")
config.add_subpackage("photon_simulator")
return config
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