[yt-svn] commit/yt: atmyers: Merged in MatthewTurk/yt (pull request #1826)
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Mon Nov 9 11:17:54 PST 2015
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/commits/ce128db22c39/
Changeset: ce128db22c39
Branch: yt
User: atmyers
Date: 2015-11-09 19:17:44+00:00
Summary: Merged in MatthewTurk/yt (pull request #1826)
Defer to coordinate handlers for width.
Affected #: 3 files
diff -r 452d6d6c36e658d9c2df5753619b07824ca2f5bc -r ce128db22c39c0e0e7ecaa0d1e1d69a2e91ea315 yt/geometry/coordinates/geographic_coordinates.py
--- a/yt/geometry/coordinates/geographic_coordinates.py
+++ b/yt/geometry/coordinates/geographic_coordinates.py
@@ -196,11 +196,15 @@
raise NotImplementedError
def convert_to_cartesian(self, coord):
+ if hasattr(self.ds, "surface_height"):
+ surface_height = self.ds.surface_height
+ else:
+ surface_height = self.ds.quan(0.0, "code_length")
if isinstance(coord, np.ndarray) and len(coord.shape) > 1:
alt = self.axis_id['altitude']
lon = self.axis_id['longitude']
lat = self.axis_id['latitude']
- r = coord[:,alt] + self.ds.surface_height
+ r = coord[:,alt] + surface_height
theta = coord[:,lon] * np.pi/180
phi = coord[:,lat] * np.pi/180
nc = np.zeros_like(coord)
@@ -212,7 +216,7 @@
a, b, c = coord
theta = b * np.pi/180
phi = a * np.pi/180
- r = self.ds.surface_height + c
+ r = surface_height + c
nc = (np.cos(phi) * np.sin(theta)*r,
np.sin(phi) * np.sin(theta)*r,
np.cos(theta) * r)
@@ -230,19 +234,6 @@
def convert_from_spherical(self, coord):
raise NotImplementedError
- # Despite being mutables, we uses these here to be clear about how these
- # are generated and to ensure that they are not re-generated unnecessarily
- axis_name = { 0 : 'latitude', 1 : 'longitude', 2 : 'altitude',
- 'latitude' : 'latitude',
- 'longitude' : 'longitude',
- 'altitude' : 'altitude',
- 'Latitude' : 'latitude',
- 'Longitude' : 'longitude',
- 'Altitude' : 'altitude',
- 'lat' : 'latitude',
- 'lon' : 'longitude',
- 'alt' : 'altitude' }
-
_image_axis_name = None
@property
def image_axis_name(self):
@@ -287,9 +278,31 @@
0.0 * display_center[1],
0.0 * display_center[2])
elif name == 'longitude':
- c = self.ds.domain_right_edge[self.axis_id['altitude']]/2.0
+ ri = self.axis_id['altitude']
+ c = (self.ds.domain_right_edge[ri] +
+ self.ds.domain_left_edge[ri])/2.0
display_center = [0.0 * display_center[0],
0.0 * display_center[1],
0.0 * display_center[2]]
display_center[self.axis_id['latitude']] = c
return center, display_center
+
+ def sanitize_width(self, axis, width, depth):
+ name = self.axis_name[axis]
+ if width is not None:
+ width = super(GeographicCoordinateHandler, self).sanitize_width(
+ axis, width, depth)
+ elif name == 'altitude':
+ width = [self.ds.domain_width[self.y_axis['altitude']],
+ self.ds.domain_width[self.x_axis['altitude']]]
+ elif name == 'latitude':
+ ri = self.axis_id['altitude']
+ # Remember, in spherical coordinates when we cut in theta,
+ # we create a conic section
+ width = [2.0*self.ds.domain_width[ri],
+ 2.0*self.ds.domain_width[ri]]
+ elif name == 'longitude':
+ ri = self.axis_id['altitude']
+ width = [self.ds.domain_width[ri],
+ 2.0*self.ds.domain_width[ri]]
+ return width
diff -r 452d6d6c36e658d9c2df5753619b07824ca2f5bc -r ce128db22c39c0e0e7ecaa0d1e1d69a2e91ea315 yt/geometry/coordinates/spherical_coordinates.py
--- a/yt/geometry/coordinates/spherical_coordinates.py
+++ b/yt/geometry/coordinates/spherical_coordinates.py
@@ -235,7 +235,7 @@
2.0*self.ds.domain_width[ri]]
elif name == 'phi':
ri = self.axis_id['r']
- width = [self.ds.domain_right_edge[ri] / 2.0,
+ width = [self.ds.domain_right_edge[ri],
2.0*self.ds.domain_width[ri]]
return width
diff -r 452d6d6c36e658d9c2df5753619b07824ca2f5bc -r ce128db22c39c0e0e7ecaa0d1e1d69a2e91ea315 yt/visualization/plot_window.py
--- a/yt/visualization/plot_window.py
+++ b/yt/visualization/plot_window.py
@@ -88,46 +88,9 @@
from pyparsing import ParseFatalException
def get_window_parameters(axis, center, width, ds):
- if ds.geometry in ("cartesian", "spectral_cube"):
- width = ds.coordinates.sanitize_width(axis, width, None)
- center, display_center = ds.coordinates.sanitize_center(center, axis)
- elif ds.geometry in ("polar", "cylindrical"):
- # Set our default width to be the full domain
- axis_name = ds.coordinates.axis_name[axis]
- center, display_center = ds.coordinates.sanitize_center(center, axis)
- # Note: regardless of axes, these are set up to give consistent plots
- # when plotted, which is not strictly a "right hand rule" for axes.
- r_ax, theta_ax, z_ax = (ds.coordinates.axis_id[ax]
- for ax in ('r', 'theta', 'z'))
- if axis_name == "r": # soup can label
- width = [2.0*np.pi * ds.domain_width.uq, ds.domain_width[z_ax]]
- elif axis_name == "theta":
- width = [ds.domain_right_edge[r_ax], ds.domain_width[z_ax]]
- elif axis_name == "z":
- width = [2.0*ds.domain_right_edge[r_ax],
- 2.0*ds.domain_right_edge[r_ax]]
- elif ds.geometry == "spherical":
- center, display_center = ds.coordinates.sanitize_center(center, axis)
- if axis == 0:
- # latitude slice
- width = ds.arr([2*np.pi, np.pi], "code_length")
- elif axis == 1:
- width = [2.0*ds.domain_right_edge[0], 2.0*ds.domain_right_edge[0]]
- elif axis == 2:
- width = [ds.domain_right_edge[0], 2.0*ds.domain_right_edge[0]]
- elif ds.geometry == "geographic":
- center, display_center = ds.coordinates.sanitize_center(center, axis)
- if axis == 0:
- width = [2.0*(ds.domain_right_edge[2] + ds.surface_height),
- 2.0*(ds.domain_right_edge[2] + ds.surface_height)]
- elif axis == 1:
- width = [(ds.domain_left_edge[2] + ds.domain_width[2] + ds.surface_height),
- 2.0*(ds.domain_right_edge[2] + ds.surface_height)]
- elif axis == 2:
- # latitude slice
- width = ds.arr([360, 180], "code_length")
- else:
- raise NotImplementedError
+ axis_name = ds.coordinates.axis_name[axis]
+ width = ds.coordinates.sanitize_width(axis, width, None)
+ center, display_center = ds.coordinates.sanitize_center(center, axis)
xax = ds.coordinates.x_axis[axis]
yax = ds.coordinates.y_axis[axis]
bounds = (display_center[xax]-width[0] / 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