|
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 |
|
3 | | -from __future__ import absolute_import, unicode_literals |
4 | 3 |
|
5 | | -# Scientific stack. |
6 | | -import numpy as np |
7 | | -import numpy.ma as ma |
| 4 | +from __future__ import (absolute_import, division, print_function) |
| 5 | + |
8 | 6 | import matplotlib.pyplot as plt |
| 7 | + |
9 | 8 | import mpl_toolkits.axisartist as AA |
10 | 9 |
|
11 | | -from pandas import Series |
12 | 10 | from mpl_toolkits.axes_grid1 import host_subplot |
13 | 11 |
|
14 | | -from .utilities import extrap1d |
| 12 | +import numpy as np |
| 13 | +import numpy.ma as ma |
15 | 14 |
|
16 | | -__all__ = ['get_maxdepth', |
17 | | - 'extrap_sec', |
18 | | - 'gen_topomask', |
19 | | - 'plot', |
20 | | - 'plot_vars', |
21 | | - 'plot_section'] |
| 15 | +from pandas import Series |
| 16 | + |
| 17 | +from .utilities import extrap1d |
22 | 18 |
|
23 | 19 |
|
24 | 20 | def get_maxdepth(self): |
@@ -159,20 +155,20 @@ def plot_vars(self, variables=None, **kwds): |
159 | 155 |
|
160 | 156 | # Axis location. |
161 | 157 | host_new_axis = ax0.get_grid_helper().new_fixed_axis |
162 | | - ax0.axis["bottom"] = host_new_axis(loc="top", axes=ax0, offset=(0, 0)) |
| 158 | + ax0.axis['bottom'] = host_new_axis(loc='top', axes=ax0, offset=(0, 0)) |
163 | 159 | par_new_axis = ax1.get_grid_helper().new_fixed_axis |
164 | | - ax1.axis["top"] = par_new_axis(loc="bottom", axes=ax1, offset=(0, 0)) |
| 160 | + ax1.axis['top'] = par_new_axis(loc='bottom', axes=ax1, offset=(0, 0)) |
165 | 161 |
|
166 | 162 | ax0.plot(self[variables[0]], self.index, 'r.', label='Temperature') |
167 | 163 | ax1.plot(self[variables[1]], self.index, 'b.', label='Salinity') |
168 | 164 |
|
169 | | - ax0.set_ylabel("Pressure [dbar]") |
170 | | - ax0.set_xlabel("Temperature [\u00b0C]") |
171 | | - ax1.set_xlabel("Salinity [kg g$^{-1}$]") |
| 165 | + ax0.set_ylabel('Pressure [dbar]') |
| 166 | + ax0.set_xlabel('Temperature [\u00b0C]') |
| 167 | + ax1.set_xlabel('Salinity [kg g$^{-1}$]') |
172 | 168 | ax1.invert_yaxis() |
173 | 169 |
|
174 | | - try: # FIXME with metadata. |
175 | | - fig.suptitle(r"Station %s profile" % self.name) |
| 170 | + try: |
| 171 | + fig.suptitle(r'Station %s profile' % self.name) |
176 | 172 | except AttributeError: |
177 | 173 | pass |
178 | 174 |
|
@@ -202,10 +198,11 @@ def plot_section(self, reverse=False, filled=False, **kw): |
202 | 198 | lat = lat[::-1] |
203 | 199 | data = data.T[::-1].T |
204 | 200 | h = h[::-1] |
| 201 | + lon, lat = map(np.atleast_2d, (lon, lat)) |
205 | 202 | x = np.append(0, np.cumsum(gsw.distance(lon, lat)[0] / 1e3)) |
206 | 203 | z = self.index.values.astype(float) |
207 | 204 |
|
208 | | - if filled: # FIXME: Cause discontinuities. |
| 205 | + if filled: # CAVEAT: this method cause discontinuities. |
209 | 206 | data = data.filled(fill_value=np.nan) |
210 | 207 | data = extrap_sec(data, x, z, w1=0.97, w2=0.03) |
211 | 208 |
|
@@ -257,18 +254,13 @@ def plot_section(self, reverse=False, filled=False, **kw): |
257 | 254 | ax.xaxis.set_tick_params(tickdir='out', labelsize=labelsize, pad=1) |
258 | 255 | ax.yaxis.set_tick_params(tickdir='out', labelsize=labelsize, pad=1) |
259 | 256 |
|
260 | | - if False: # TODO: +/- Black-and-White version. |
261 | | - cs = ax.contour(x, z, data, colors='grey', levels=levels, |
262 | | - extend=extend, linewidths=1., alpha=1., zorder=2) |
263 | | - ax.clabel(cs, fontsize=8, colors='grey', fmt=fmt, zorder=1) |
264 | | - cb = None |
265 | | - if True: # Color version. |
266 | | - cs = ax.contourf(x, z, data, cmap=cmap, levels=levels, alpha=1., |
267 | | - extend=extend, zorder=2) # manual=True |
268 | | - # Colorbar. |
269 | | - cb = fig.colorbar(mappable=cs, ax=ax, orientation='vertical', |
270 | | - aspect=aspect, shrink=shrink, fraction=fraction, |
271 | | - pad=pad) |
| 257 | + # Color version. |
| 258 | + cs = ax.contourf(x, z, data, cmap=cmap, levels=levels, alpha=1., |
| 259 | + extend=extend, zorder=2) # manual=True |
| 260 | + # Colorbar. |
| 261 | + cb = fig.colorbar(mappable=cs, ax=ax, orientation='vertical', |
| 262 | + aspect=aspect, shrink=shrink, fraction=fraction, |
| 263 | + pad=pad) |
272 | 264 | return fig, ax, cb |
273 | 265 |
|
274 | 266 |
|
|
0 commit comments