Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions examples/calculations/Sounding_Calculations.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,11 @@ def effective_layer(p, t, td, h, height_layer=False):
- pbot/hbot, ptop/htop: pressure/height of the bottom level,
pressure/height of the top level
"""
from metpy.calc import cape_cin, parcel_profile
from metpy.units import units

pbot = None

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

for i in range(bot_idx + 1, p.shape[0]):
prof = parcel_profile(p[i:], t[i], td[i])
sbcape, sbcin = cape_cin(p[i:], t[i:], td[i:], prof)
prof = mpcalc.parcel_profile(p[i:], t[i], td[i])
sbcape, sbcin = mpcalc.cape_cin(p[i:], t[i:], td[i:], prof)
if sbcape < 100 * units('J/kg') or sbcin < -250 * units('J/kg'):
ptop = p[i]
htop = h[i]
Expand Down
2 changes: 1 addition & 1 deletion examples/plots/Mesonet_Stationplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

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

# Drop stations with missing values of data we want
data = data.dropna(how='any', subset=['PRES', 'TAIR', 'TDEW', 'WDIR', 'WSPD'])
Expand Down
4 changes: 2 additions & 2 deletions examples/plots/Simplified_Image_Plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
import xarray as xr

from metpy.cbook import get_test_data
from metpy.io import GiniFile
from metpy.plots import ImagePlot, MapPanel, PanelContainer

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

img = ImagePlot()
img.data = data
Expand Down
5 changes: 3 additions & 2 deletions examples/plots/nhc_wind_probabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@

###########################
# Read in the shapefile file containing the wind probabilities.
wind_data = geopandas.read_file(get_test_data('nhc_wind_prob_2021082012.zip'))
wind_data = geopandas.read_file(get_test_data('nhc_wind_prob_2021082012.zip',
as_file_obj=False))

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

###########################
# Read in the shapefile file containing the cities.
cities = geopandas.read_file(get_test_data('us_cities.zip'))
cities = geopandas.read_file(get_test_data('us_cities.zip', as_file_obj=False))

###########################
# There are thousands of cities in the United States. We choose a few cities here that we want
Expand Down
3 changes: 2 additions & 1 deletion examples/plots/spc_convective_outlook.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

###########################
# Read in the geoJSON file containing the convective outlook.
day1_outlook = geopandas.read_file(get_test_data('spc_day1otlk_20210317_1200_lyr.geojson'))
day1_outlook = geopandas.read_file(get_test_data('spc_day1otlk_20210317_1200_lyr.geojson',
as_file_obj=False))

###########################
# Preview the data.
Expand Down
2 changes: 1 addition & 1 deletion src/metpy/io/nexrad.py
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ class LegacyMapper(DataMapper):

def __init__(self, prod):
"""Initialize the values and labels from the product."""
# Don't worry about super() since we're using our own lut assembled sequentially
super().__init__()
self.labels = []
self.lut = []
for t in prod.thresholds:
Expand Down
4 changes: 2 additions & 2 deletions tests/plots/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ def test_add_timestamp_xarray():
"""Test that add_timestamp can work with xarray datetime accessor."""
with autoclose_figure() as fig:
ax = fig.add_subplot(1, 1, 1)
ds = xr.open_dataset(get_test_data('AK-REGIONAL_8km_3.9_20160408_1445.gini'),
engine='gini')
ds = xr.open_dataset(get_test_data('AK-REGIONAL_8km_3.9_20160408_1445.gini',
as_file_obj=False), engine='gini')
txt = add_timestamp(ax, ds.time.dt, pretext='')
assert txt.get_text() == '2016-04-08T14:45:20Z'

Expand Down