Skip to content

Commit

Permalink
Merge pull request #1355 from dopplershift/0.12-backports
Browse files Browse the repository at this point in the history
More backports for 0.12
  • Loading branch information
dopplershift committed Apr 18, 2020
2 parents 3f6e5f8 + 105825a commit abad235
Show file tree
Hide file tree
Showing 9 changed files with 42,846 additions and 21 deletions.
3 changes: 2 additions & 1 deletion src/metpy/io/_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ def open_as_needed(filename, mode='rb'):
elif filename.endswith('.gz'):
return gzip.GzipFile(filename, mode)
else:
return open(filename, mode)
kwargs = {'errors': 'surrogateescape'} if mode != 'rb' else {}
return open(filename, mode, **kwargs)


class NamedStruct(Struct):
Expand Down
35 changes: 18 additions & 17 deletions src/metpy/plots/declarative.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ class Panel(HasTraits):

@exporter.export
class PanelContainer(HasTraits):
"""Collects panels and set complete figure related settings (e.g., figsize)."""
"""Collects panels and set complete figure related settings (e.g., size)."""

size = Union([Tuple(Int(), Int()), Instance(type(None))], default_value=None)
size.__doc__ = """This trait takes a tuple of (width, height) to set the size of the
Expand Down Expand Up @@ -616,7 +616,7 @@ class MapPanel(Panel):
This trait can also be set with a string value associated with the named geographic regions
within MetPy. The tuples associated with the names are based on a PlatteCarree projection.
For a CONUS region, the following strings can be used: 'us', 'spcus', 'ncus', and 'afus'.
For regional plots, US state postal codes can be used.
For regional plots, US postal state abbreviations can be used.
"""

projection = Union([Unicode(), Instance('cartopy.crs.Projection')], default_value='data')
Expand All @@ -634,8 +634,8 @@ class MapPanel(Panel):
Like the projection, there are a couple of pre-defined feature layers that can be called
using a short name. The pre-defined layers are: 'coastline', 'states', 'borders', 'lakes',
'land', 'ocean', and 'rivers'. Additionally, this trait can be set using a Cartopy Feature
object.
'land', 'ocean', 'rivers', 'usstates', and 'uscounties'. Additionally, this trait can be
set using a Cartopy Feature object.
"""

title = Unicode()
Expand Down Expand Up @@ -730,15 +730,6 @@ def draw(self):
# Only need to run if we've actually changed.
if self._need_redraw:

# Draw all of the plots.
for p in self.plots:
with p.hold_trait_notifications():
p.draw()

# Add all of the maps
for feat in self._layer_features:
self.ax.add_feature(feat)

# Set the extent as appropriate based on the area. One special case for 'global'
if self.area == 'global':
self.ax.set_global()
Expand All @@ -751,6 +742,15 @@ def draw(self):
area = self.area
self.ax.set_extent(area, DEFAULT_LAT_LON)

# Draw all of the plots.
for p in self.plots:
with p.hold_trait_notifications():
p.draw()

# Add all of the maps
for feat in self._layer_features:
self.ax.add_feature(feat)

# Use the set title or generate one.
title = self.title or ',\n'.join(plot.name for plot in self.plots)
self.ax.set_title(title)
Expand Down Expand Up @@ -989,10 +989,11 @@ class ColorfillTraits(HasTraits):
"""

colorbar = Unicode(default_value=None, allow_none=True)
colorbar.__doc__ = """A boolean (True/False) on whether to add a colorbar to the plot.
colorbar.__doc__ = """A string (horizontal/vertical) on whether to add a colorbar to the plot.
To add a colorbar associated with the plot data set the trait to ``True``, the default
values is ``False``.
To add a colorbar associated with the plot, set the trait to ``horizontal`` or
``vertical``,specifying the orientation of the produced colorbar. The default value is
``None``.
"""


Expand Down Expand Up @@ -1088,7 +1089,7 @@ def _build(self):
linestyles=self.linestyle,
transform=imdata.metpy.cartopy_crs)
if self.clabels:
self.handle.clabel(inline=1, fmt='%.0f', inline_spacing=2,
self.handle.clabel(inline=1, fmt='%.0f', inline_spacing=8,
use_clabeltext=True)


Expand Down
5 changes: 3 additions & 2 deletions src/metpy/static-data-manifest.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
2020010600_sao.wmo e8f327f32d1765ae02c2c34c9393287a853a62afbf1987bf9a4f32894c7f24bd
AK-REGIONAL_8km_3.9_20160408_1445.gini 4919b80abe95a765a42a6e3904ef1e38b8be804dc52276ef5db6b587f85abd55
GFS_test.nc bd68670c5102c8085ebafe8bf301702b9b4574fbd8413a5d6ba6e0ba71efacc7
HI-REGIONAL_4km_3.9_20160616_1715.gini 30896dda51c9f933027d8086f0a86543efce12ea90a52981eccbce2e0ce1529e
KICX_20170712_1458 94bd4f795832f056f7489a5562acf76de9a9cab1694549562cc3154abb22527c
KTLX19990503_235621.gz 7a097251bb7a15dbcdec75812812e41a86c5eb9850f55c3d91d120c2c61e046e
KTLX20130520_201643_V06.gz 772e01b154a5c966982a6d0aa2fc78bc64f08a9b77165b74dc02d7aa5aa69275
KTLX20150530_000802_V06.bz2 d78689afc525c853dec8ccab4a4eccc2daacef5c7df198a35a3a791016e993b0
Level2_KFTG_20150430_1419.ar2v 77c3355c8a503561eb3cddc3854337e640d983a4acdfc27bdfbab60c0b18cfc1
TDAL20191021021543V08.raw.gz db299c0f31f1396caddb92ed1517d30494a6f47ca994138f85c925787176a0ef
Level2_FOP1_20191223_003655.ar2v 4a086f6190c0d324612922e9fcb46262c3a1d825810caa8a11aca3823db17ae3
Level2_KFTG_20150430_1419.ar2v 77c3355c8a503561eb3cddc3854337e640d983a4acdfc27bdfbab60c0b18cfc1
Level3_Composite_dhr_1km_20180309_2225.gini 19fcc0179c9d3e87c462262ea817e87f52f60db4830314b8f936baa3b9817a44
NAM_test.nc 12338ad06d5bd223e99e2872b20a9c80d58af0c546731e4b00a6619adc247cd0
NHEM-MULTICOMP_1km_IR_20151208_2100.gini c144b29284aa915e6fd1b8f01939c656f2c72c3d7a9e0af5397f93067fe0d952
SFC_obs.csv 582d434442880f8414a555f22f7faf9b07b1170f390628e68c5c182e4431f426
TDAL20191021021543V08.raw.gz db299c0f31f1396caddb92ed1517d30494a6f47ca994138f85c925787176a0ef
UPA_obs.csv 106fa93db40f32cf7cb5e969e5dacb3d4e3387f7a3379ba90cc15149754fc640
WEST-CONUS_4km_WV_20151208_2200.gini 6851b49d20de2ee3e6fc0ef86e6c0f8f22170a6bd03bd6940b28c3ec09b8e7f6
airport-codes.csv d3f5fc8cef4329f63280f4958547872c58c4af18320a004d1489863c1f395008
Expand Down
2 changes: 1 addition & 1 deletion src/metpy/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def diff(x, **kwargs):
# Can't just use units because of how things like temperature work
it = x.flat
true_units = (next(it) - next(it)).units
return ret * true_units
return true_units * ret
else:
return np.diff(x, **kwargs)

Expand Down
Loading

0 comments on commit abad235

Please sign in to comment.