Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes bug in issue 1758 #1876

Merged
merged 1 commit into from
May 28, 2021
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
2 changes: 1 addition & 1 deletion examples/plots/Station_Plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@

# Same this time, but plot current weather to the left of center, using the
# `current_weather` mapper to convert symbols to the right glyphs.
stationplot.plot_symbol('W', data['present_weather'].values, current_weather)
stationplot.plot_symbol('W', data['current_wx1_symbol'].values, current_weather)

# Add wind barbs
stationplot.plot_barb(data['eastward_wind'].values, data['northward_wind'].values)
Expand Down
2 changes: 1 addition & 1 deletion examples/plots/Station_Plot_with_Layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
# Map weather strings to WMO codes, which we can use to convert to symbols
# Only use the first symbol if there are multiple
wx_text = data_arr['weather'].fillna('')
data['present_weather'] = [wx_code_map[s.split()[0] if ' ' in s else s] for s in wx_text]
data['current_wx1_symbol'] = [wx_code_map[s.split()[0] if ' ' in s else s] for s in wx_text]

###########################################
# All the data wrangling is finished, just need to set up plotting and go:
Expand Down
6 changes: 3 additions & 3 deletions src/metpy/io/metar.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,9 +609,9 @@ def merge(x, key=' '):
'air_temperature': temp,
'dew_point_temperature': dewp,
'altimeter': altim,
'present_weather': current_wx1_symbol,
'past_weather': current_wx2_symbol,
'past_weather2': current_wx3_symbol},
'current_wx1_symbol': current_wx1_symbol,
'current_wx2_symbol': current_wx2_symbol,
'current_wx3_symbol': current_wx3_symbol},
index=station_id)

# Calculate sea-level pressure from function in metpy.calc
Expand Down
6 changes: 3 additions & 3 deletions src/metpy/plots/station_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ def __repr__(self):
simple_layout.add_value('NE', 'air_pressure_at_sea_level', units='mbar',
fmt=lambda v: format(10 * v, '03.0f')[-3:])
simple_layout.add_symbol('C', 'cloud_coverage', sky_cover)
simple_layout.add_symbol('W', 'present_weather', current_weather)
simple_layout.add_symbol('W', 'current_wx1_symbol', current_weather)

#: Full NWS station plot `layout`__
#:
Expand All @@ -644,7 +644,7 @@ def __repr__(self):
nws_layout.add_value((1, 1), 'air_pressure_at_sea_level', units='mbar',
fmt=lambda v: format(10 * v, '03.0f')[-3:])
nws_layout.add_value((-2, 0), 'visibility_in_air', fmt='.0f', units='miles')
nws_layout.add_symbol((-1, 0), 'present_weather', current_weather)
nws_layout.add_symbol((-1, 0), 'current_wx1_symbol', current_weather)
nws_layout.add_symbol((0, 0), 'cloud_coverage', sky_cover)
nws_layout.add_value((1, 0), 'tendency_of_air_pressure', units='mbar',
fmt=lambda v: ('-' if v < 0 else '') + format(10 * abs(v), '02.0f'))
Expand All @@ -653,4 +653,4 @@ def __repr__(self):
nws_layout.add_value((-1, -1), 'dew_point_temperature', units='degF')

# TODO: Fix once we have the past weather symbols converted
nws_layout.add_symbol((1, -1), 'past_weather', current_weather)
nws_layout.add_symbol((1, -1), 'current_wx2_symbol', current_weather)
4 changes: 2 additions & 2 deletions tests/plots/test_station_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def test_simple_layout():
'air_pressure_at_sea_level': np.array([29.92, 28.00]) * units.inHg,
'eastward_wind': np.array([2, 0]) * units.knots,
'northward_wind': np.array([0, 5]) * units.knots, 'cloud_coverage': [3, 8],
'present_weather': [65, 75], 'unused': [1, 2]}
'current_wx1_symbol': [65, 75], 'unused': [1, 2]}

# Make the plot
sp = StationPlot(fig.add_subplot(1, 1, 1), x, y, fontsize=12)
Expand All @@ -212,7 +212,7 @@ def test_nws_layout():
'air_pressure_at_sea_level': np.array([999.8]) * units('mbar'),
'eastward_wind': np.array([15.]) * units.knots,
'northward_wind': np.array([15.]) * units.knots, 'cloud_coverage': [7],
'present_weather': [80], 'high_cloud_type': [1], 'medium_cloud_type': [3],
'current_wx1_symbol': [80], 'high_cloud_type': [1], 'medium_cloud_type': [3],
'low_cloud_type': [2], 'visibility_in_air': np.array([5.]) * units.mile,
'tendency_of_air_pressure': np.array([-0.3]) * units('mbar'),
'tendency_of_air_pressure_symbol': [8]}
Expand Down
2 changes: 1 addition & 1 deletion tutorials/declarative_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@
obs.time_window = timedelta(minutes=15)
obs.level = None
obs.fields = ['cloud_coverage', 'air_temperature', 'dew_point_temperature',
'air_pressure_at_sea_level', 'present_weather']
'air_pressure_at_sea_level', 'current_wx1_symbol']
obs.plot_units = [None, 'degF', 'degF', None, None]
obs.locations = ['C', 'NW', 'SW', 'NE', 'W']
obs.formats = ['sky_cover', None, None, lambda v: format(v * 10, '.0f')[-3:],
Expand Down