diff --git a/examples/calculations/Sounding_Calculations.py b/examples/calculations/Sounding_Calculations.py index 0791a382ab0..e549f0769aa 100644 --- a/examples/calculations/Sounding_Calculations.py +++ b/examples/calculations/Sounding_Calculations.py @@ -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] @@ -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] diff --git a/examples/plots/Mesonet_Stationplot.py b/examples/plots/Mesonet_Stationplot.py index ed7e5b18a04..f25c93c8a2b 100644 --- a/examples/plots/Mesonet_Stationplot.py +++ b/examples/plots/Mesonet_Stationplot.py @@ -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']) diff --git a/examples/plots/Simplified_Image_Plot.py b/examples/plots/Simplified_Image_Plot.py index 4a9ea9c3336..2009e4d10ad 100644 --- a/examples/plots/Simplified_Image_Plot.py +++ b/examples/plots/Simplified_Image_Plot.py @@ -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 diff --git a/examples/plots/nhc_wind_probabilities.py b/examples/plots/nhc_wind_probabilities.py index 653d357adc2..6721f4de8f9 100644 --- a/examples/plots/nhc_wind_probabilities.py +++ b/examples/plots/nhc_wind_probabilities.py @@ -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 @@ -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 diff --git a/examples/plots/spc_convective_outlook.py b/examples/plots/spc_convective_outlook.py index 56e294ec14f..274b481d1df 100644 --- a/examples/plots/spc_convective_outlook.py +++ b/examples/plots/spc_convective_outlook.py @@ -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. diff --git a/src/metpy/io/nexrad.py b/src/metpy/io/nexrad.py index 2bacef97801..3ae34de1880 100644 --- a/src/metpy/io/nexrad.py +++ b/src/metpy/io/nexrad.py @@ -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: diff --git a/tests/plots/test_util.py b/tests/plots/test_util.py index 95911d97f61..db302cc16ee 100644 --- a/tests/plots/test_util.py +++ b/tests/plots/test_util.py @@ -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'