[Yt-svn] yt-commit r775 - in trunk/yt: lagos raven
mturk at wrangler.dreamhost.com
mturk at wrangler.dreamhost.com
Mon Sep 15 04:35:57 PDT 2008
Author: mturk
Date: Mon Sep 15 04:35:56 2008
New Revision: 775
URL: http://yt.spacepope.org/changeset/775
Log:
Added licensing to the .pyx files in yt/lagos/, updated FixedResolution with a
convert_to_pixels function and fixed the orientation of its buffer,
added a convert_to_pixels function to the PlotCallback base class (but it's not
widely used yet...) added an annotation to the HopCircleCallback to put the
halo id inside the circle, and fixed the particle_type attribute of the various
ParticleRadius fields.
Modified:
trunk/yt/lagos/DerivedFields.py
trunk/yt/lagos/Interpolators.pyx
trunk/yt/lagos/RTIntegrator.pyx
trunk/yt/raven/Callbacks.py
trunk/yt/raven/FixedResolution.py
Modified: trunk/yt/lagos/DerivedFields.py
==============================================================================
--- trunk/yt/lagos/DerivedFields.py (original)
+++ trunk/yt/lagos/DerivedFields.py Mon Sep 15 04:35:56 2008
@@ -753,7 +753,8 @@
return data.convert("cm")
add_field("ParticleRadius", function=_ParticleRadius,
validators=[ValidateParameter("center")],
- convert_function = _ConvertRadiusCGS, units=r"\rm{cm}")
+ convert_function = _ConvertRadiusCGS, units=r"\rm{cm}",
+ particle_type = True)
add_field("Radius", function=_Radius,
validators=[ValidateParameter("center")],
convert_function = _ConvertRadiusCGS, units=r"\rm{cm}")
@@ -765,13 +766,15 @@
convert_function = _ConvertRadiusMpc, units=r"\rm{Mpc}")
add_field("ParticleRadiusMpc", function=_ParticleRadius,
validators=[ValidateParameter("center")],
- convert_function = _ConvertRadiusMpc, units=r"\rm{Mpc}")
+ convert_function = _ConvertRadiusMpc, units=r"\rm{Mpc}",
+ particle_type=True)
def _ConvertRadiuskpc(data):
return data.convert("kpc")
add_field("ParticleRadiuskpc", function=_ParticleRadius,
validators=[ValidateParameter("center")],
- convert_function = _ConvertRadiuskpc, units=r"\rm{kpc}")
+ convert_function = _ConvertRadiuskpc, units=r"\rm{kpc}",
+ particle_type=True)
add_field("Radiuskpc", function=_Radius,
validators=[ValidateParameter("center")],
convert_function = _ConvertRadiuskpc, units=r"\rm{kpc}")
@@ -780,7 +783,8 @@
return data.convert("kpch")
add_field("ParticleRadiuskpch", function=_ParticleRadius,
validators=[ValidateParameter("center")],
- convert_function = _ConvertRadiuskpc, units=r"\rm{kpc}/\rm{h}")
+ convert_function = _ConvertRadiuskpc, units=r"\rm{kpc}/\rm{h}",
+ particle_type=True)
add_field("Radiuskpch", function=_Radius,
validators=[ValidateParameter("center")],
convert_function = _ConvertRadiuskpc, units=r"\rm{kpc}/\rm{h}")
@@ -789,7 +793,8 @@
return data.convert("pc")
add_field("ParticleRadiuspc", function=_ParticleRadius,
validators=[ValidateParameter("center")],
- convert_function = _ConvertRadiuspc, units=r"\rm{pc}")
+ convert_function = _ConvertRadiuspc, units=r"\rm{pc}",
+ particle_type=True)
add_field("Radiuspc", function=_Radius,
validators=[ValidateParameter("center")],
convert_function = _ConvertRadiuspc, units=r"\rm{pc}")
@@ -798,13 +803,15 @@
return data.convert("au")
add_field("ParticleRadiusAU", function=_ParticleRadius,
validators=[ValidateParameter("center")],
- convert_function = _ConvertRadiusAU, units=r"\rm{AU}")
+ convert_function = _ConvertRadiusAU, units=r"\rm{AU}",
+ particle_type=True)
add_field("RadiusAU", function=_Radius,
validators=[ValidateParameter("center")],
convert_function = _ConvertRadiusAU, units=r"\rm{AU}")
add_field("ParticleRadiusCode", function=_ParticleRadius,
- validators=[ValidateParameter("center")])
+ validators=[ValidateParameter("center")],
+ particle_type=True)
add_field("RadiusCode", function=_Radius,
validators=[ValidateParameter("center")])
Modified: trunk/yt/lagos/Interpolators.pyx
==============================================================================
--- trunk/yt/lagos/Interpolators.pyx (original)
+++ trunk/yt/lagos/Interpolators.pyx Mon Sep 15 04:35:56 2008
@@ -1,3 +1,28 @@
+"""
+Simple interpolators
+
+Author: Matthew Turk <matthewturk at gmail.com>
+Affiliation: KIPAC/SLAC/Stanford
+Homepage: http://yt.enzotools.org/
+License:
+ Copyright (C) 2008 Matthew Turk. All Rights Reserved.
+
+ This file is part of yt.
+
+ yt is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+
import numpy as np
cimport numpy as np
cimport cython
Modified: trunk/yt/lagos/RTIntegrator.pyx
==============================================================================
--- trunk/yt/lagos/RTIntegrator.pyx (original)
+++ trunk/yt/lagos/RTIntegrator.pyx Mon Sep 15 04:35:56 2008
@@ -1,3 +1,28 @@
+"""
+Simle integrators for the radiative transfer equation
+
+Author: Matthew Turk <matthewturk at gmail.com>
+Affiliation: KIPAC/SLAC/Stanford
+Homepage: http://yt.enzotools.org/
+License:
+ Copyright (C) 2008 Matthew Turk. All Rights Reserved.
+
+ This file is part of yt.
+
+ yt is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+
import numpy as np
cimport numpy as np
cimport cython
Modified: trunk/yt/raven/Callbacks.py
==============================================================================
--- trunk/yt/raven/Callbacks.py (original)
+++ trunk/yt/raven/Callbacks.py Mon Sep 15 04:35:56 2008
@@ -31,6 +31,16 @@
def __init__(self, *args, **kwargs):
pass
+ def convert_to_pixels(self, plot, coord):
+ x0, x1 = plot.xlim
+ y0, y1 = plot.ylim
+ l, b, width, height = plot._axes.bbox.get_bounds()
+ xi = lagos.x_dict[plot.data.axis]
+ yi = lagos.y_dict[plot.data.axis]
+ dx = plot.image._A.shape[0] / (x1-x0)
+ dy = plot.image._A.shape[1] / (y1-y0)
+ return ((coord[0] - x0)*dx, (coord[1] - y0)*dy)
+
class QuiverCallback(PlotCallback):
def __init__(self, field_x, field_y, factor):
"""
@@ -361,10 +371,12 @@
plot._axes.hold(False)
class HopCircleCallback(PlotCallback):
- def __init__(self, hop_output, axis, max_number=None):
+ def __init__(self, hop_output, axis, max_number=None,
+ annotate=False):
self.axis = axis
self.hop_output = hop_output
self.max_number = max_number
+ self.annotate = annotate
def __call__(self, plot):
from matplotlib.patches import Circle
@@ -375,11 +387,13 @@
yi = lagos.y_dict[plot.data.axis]
dx = plot.image._A.shape[0] / (x1-x0)
dy = plot.image._A.shape[1] / (y1-y0)
- for hop in self.hop_output[:self.max_number]:
- radius = hop.maximum_radius() * dx
- center = hop.center_of_mass()
+ for halo in self.hop_output[:self.max_number]:
+ radius = halo.maximum_radius() * dx
+ center = halo.center_of_mass()
center_x = (center[xi] - x0)*dx
center_y = (center[yi] - y0)*dy
cir = Circle((center_x, center_y), radius, fill=False)
plot._axes.add_patch(cir)
+ if self.annotate:
+ plot._axes.text(center_x, center_y, "%s" % halo.id)
Modified: trunk/yt/raven/FixedResolution.py
==============================================================================
--- trunk/yt/raven/FixedResolution.py (original)
+++ trunk/yt/raven/FixedResolution.py Mon Sep 15 04:35:56 2008
@@ -50,13 +50,28 @@
self.data_source['pdy'],
self.data_source[item],
self.buff_size[0], self.buff_size[1],
- self.bounds, int(self.antialias))
+ self.bounds, int(self.antialias)).transpose()
self[item] = buff
return buff
def __setitem__(self, item, val):
self.data[item] = val
+ def convert_to_pixel(self, coords):
+ dpx = (self.bounds[1]-self.bounds[0])/self.buff_size[0]
+ dpy = (self.bounds[3]-self.bounds[2])/self.buff_size[1]
+ px = (coords[0] - self.bounds[0])/dpx
+ py = (coords[1] - self.bounds[2])/dpy
+ return (px, py)
+
+ def convert_distance_x(self, distance):
+ dpx = (self.bounds[1]-self.bounds[0])/self.buff_size[0]
+ return distance/dpx
+
+ def convert_distance_y(self, distance):
+ dpy = (self.bounds[3]-self.bounds[2])/self.buff_size[1]
+ return distance/dpy
+
class AnnuliProfiler(object):
def __init__(self, fixed_buffer, center, num_bins, min_radius, max_radius):
"""
@@ -94,3 +109,5 @@
def __setitem__(self, item, val):
self.data[item] = val
+ def sum(self, item):
+ return self[item].sum()
More information about the yt-svn
mailing list