Skip to content

Commit 9a4901c

Browse files
authored
Merge pull request #3943 from dopplershift/cleanup
Miscellaneous cleanup
2 parents ae69c58 + c46f4c0 commit 9a4901c

File tree

7 files changed

+15
-16
lines changed

7 files changed

+15
-16
lines changed

examples/calculations/Sounding_Calculations.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,11 @@ def effective_layer(p, t, td, h, height_layer=False):
3737
- pbot/hbot, ptop/htop: pressure/height of the bottom level,
3838
pressure/height of the top level
3939
"""
40-
from metpy.calc import cape_cin, parcel_profile
41-
from metpy.units import units
42-
4340
pbot = None
4441

4542
for i in range(p.shape[0]):
46-
prof = parcel_profile(p[i:], t[i], td[i])
47-
sbcape, sbcin = cape_cin(p[i:], t[i:], td[i:], prof)
43+
prof = mpcalc.parcel_profile(p[i:], t[i], td[i])
44+
sbcape, sbcin = mpcalc.cape_cin(p[i:], t[i:], td[i:], prof)
4845
if sbcape >= 100 * units('J/kg') and sbcin > -250 * units('J/kg'):
4946
pbot = p[i]
5047
hbot = h[i]
@@ -54,8 +51,8 @@ def effective_layer(p, t, td, h, height_layer=False):
5451
return None, None
5552

5653
for i in range(bot_idx + 1, p.shape[0]):
57-
prof = parcel_profile(p[i:], t[i], td[i])
58-
sbcape, sbcin = cape_cin(p[i:], t[i:], td[i:], prof)
54+
prof = mpcalc.parcel_profile(p[i:], t[i], td[i])
55+
sbcape, sbcin = mpcalc.cape_cin(p[i:], t[i:], td[i:], prof)
5956
if sbcape < 100 * units('J/kg') or sbcin < -250 * units('J/kg'):
6057
ptop = p[i]
6158
htop = h[i]

examples/plots/Mesonet_Stationplot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
# Current observations can be downloaded here:
3333
# https://www.mesonet.org/index.php/weather/category/past_data_files
34-
data = pd.read_csv(get_test_data('mesonet_sample.txt'), na_values=' ')
34+
data = pd.read_csv(get_test_data('mesonet_sample.txt', as_file_obj=False), na_values=' ')
3535

3636
# Drop stations with missing values of data we want
3737
data = data.dropna(how='any', subset=['PRES', 'TAIR', 'TDEW', 'WDIR', 'WSPD'])

examples/plots/Simplified_Image_Plot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@
1414
import xarray as xr
1515

1616
from metpy.cbook import get_test_data
17-
from metpy.io import GiniFile
1817
from metpy.plots import ImagePlot, MapPanel, PanelContainer
1918

20-
data = xr.open_dataset(GiniFile(get_test_data('NHEM-MULTICOMP_1km_IR_20151208_2100.gini')))
19+
data = xr.open_dataset(get_test_data('NHEM-MULTICOMP_1km_IR_20151208_2100.gini',
20+
as_file_obj=False))
2121

2222
img = ImagePlot()
2323
img.data = data

examples/plots/nhc_wind_probabilities.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222

2323
###########################
2424
# Read in the shapefile file containing the wind probabilities.
25-
wind_data = geopandas.read_file(get_test_data('nhc_wind_prob_2021082012.zip'))
25+
wind_data = geopandas.read_file(get_test_data('nhc_wind_prob_2021082012.zip',
26+
as_file_obj=False))
2627

2728
###########################
2829
# Add the color scheme to the GeoDataFrame. This is the same color scheme used by the National
@@ -33,7 +34,7 @@
3334

3435
###########################
3536
# Read in the shapefile file containing the cities.
36-
cities = geopandas.read_file(get_test_data('us_cities.zip'))
37+
cities = geopandas.read_file(get_test_data('us_cities.zip', as_file_obj=False))
3738

3839
###########################
3940
# There are thousands of cities in the United States. We choose a few cities here that we want

examples/plots/spc_convective_outlook.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818

1919
###########################
2020
# Read in the geoJSON file containing the convective outlook.
21-
day1_outlook = geopandas.read_file(get_test_data('spc_day1otlk_20210317_1200_lyr.geojson'))
21+
day1_outlook = geopandas.read_file(get_test_data('spc_day1otlk_20210317_1200_lyr.geojson',
22+
as_file_obj=False))
2223

2324
###########################
2425
# Preview the data.

src/metpy/io/nexrad.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -984,7 +984,7 @@ class LegacyMapper(DataMapper):
984984

985985
def __init__(self, prod):
986986
"""Initialize the values and labels from the product."""
987-
# Don't worry about super() since we're using our own lut assembled sequentially
987+
super().__init__()
988988
self.labels = []
989989
self.lut = []
990990
for t in prod.thresholds:

tests/plots/test_util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ def test_add_timestamp_xarray():
5454
"""Test that add_timestamp can work with xarray datetime accessor."""
5555
with autoclose_figure() as fig:
5656
ax = fig.add_subplot(1, 1, 1)
57-
ds = xr.open_dataset(get_test_data('AK-REGIONAL_8km_3.9_20160408_1445.gini'),
58-
engine='gini')
57+
ds = xr.open_dataset(get_test_data('AK-REGIONAL_8km_3.9_20160408_1445.gini',
58+
as_file_obj=False), engine='gini')
5959
txt = add_timestamp(ax, ds.time.dt, pretext='')
6060
assert txt.get_text() == '2016-04-08T14:45:20Z'
6161

0 commit comments

Comments
 (0)