8000 update mpl_toolkit function · python-control/python-control@df0051c · GitHub
[go: up one dir, main page]

Skip to content

Commit df0051c

Browse files
committed
update mpl_toolkit function
1 parent 08d5e6c commit df0051c

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

control/grid.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@ def __call__(self, direction, factor, values):
1919

2020

2121
class ModifiedExtremeFinderCycle(angle_helper.ExtremeFinderCycle):
22-
'''Changed to allow only left hand-side polar grid'''
22+
'''Changed to allow only left hand-side polar grid
23+
24+
https://matplotlib.org/_modules/mpl_toolkits/axisartist/angle_helper.html#ExtremeFinderCycle.__call__
25+
'''
2326
def __call__(self, transform_xy, x1, y1, x2, y2):
24-
x_, y_ = np.linspace(x1, x2, self.nx), np.linspace(y1, y2, self.ny)
25-
x, y = np.meshgrid(x_, y_)
27+
x, y = np.meshgrid(
28+
np.linspace(x1, x2, self.nx), np.linspace(y1, y2, self.ny))
2629
lon, lat = transform_xy(np.ravel(x), np.ravel(y))
2730

2831
with np.errstate(invalid='ignore'):
@@ -41,7 +44,25 @@ def __call__(self, transform_xy, x1, y1, x2, y2):
4144
lat_min, lat_max = np.nanmin(lat), np.nanmax(lat)
4245

4346
lon_min, lon_max, lat_min, lat_max = \
44-
self._adjust_extremes(lon_min, lon_max, lat_min, lat_max)
47+
self._add_pad(lon_min, lon_max, lat_min, lat_max)
48+
49+
# check cycle
50+
if self.lon_cycle:
51+
lon_max = min(lon_max, lon_min + self.lon_cycle)
52+
if self.lat_cycle:
53+
lat_max = min(lat_max, lat_min + self.lat_cycle)
54+
55+
if self.lon_minmax is not None:
56+
min0 = self.lon_minmax[0]
57+
lon_min = max(min0, lon_min)
58+
max0 = self.lon_minmax[1]
59+
lon_max = min(max0, lon_max)
60+
61+
if self.lat_minmax is not None:
62+
min0 = self.lat_minmax[0]
63+
lat_min = max(min0, lat_min)
64+
max0 = self.lat_minmax[1]
65+
lat_max = min(max0, lat_max)
4566

4667
return lon_min, lon_max, lat_min, lat_max
4768

0 commit comments

Comments
 (0)
0