forked from Unidata/MetPy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e9d67ac
commit 5e4eb72
Showing
11 changed files
with
10,675 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Copyright (c) 2019 MetPy Developers. | ||
# Distributed under the terms of the BSD 3-Clause License. | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
""" | ||
========================================= | ||
Surface Analysis using Declarative Syntax | ||
========================================= | ||
The MetPy declarative syntax allows for a simplified interface to creating common | ||
meteorological analyses including surface observation plots. | ||
""" | ||
|
||
######################################## | ||
from datetime import datetime, timedelta | ||
|
||
import cartopy.crs as ccrs | ||
import pandas as pd | ||
|
||
from metpy.cbook import get_test_data | ||
import metpy.plots as mpplots | ||
|
||
######################################## | ||
# **Getting the data** | ||
# | ||
# In this example, data is originally from the Iowa State ASOS archive | ||
# (https://mesonet.agron.iastate.edu/request/download.phtml) downloaded through a separate | ||
# Python script. The data are pre-processed to determine sky cover and weather symbols from | ||
# text output. | ||
|
||
data = pd.read_csv(get_test_data('SFC_obs.csv', as_file_obj=False), | ||
infer_datetime_format=True, parse_dates=['valid']) | ||
|
||
######################################## | ||
# **Plotting the data** | ||
# | ||
# Use the declarative plotting interface to plot surface observations over the state of | ||
# Georgia. | ||
|
||
# Plotting the Observations using a 15 minute time window for surface observations | ||
obs = mpplots.PlotObs() | ||
obs.data = data | ||
obs.time = datetime(1993, 3, 12, 13) | ||
obs.time_window = timedelta(minutes=15) | ||
obs.level = None | ||
obs.fields = ['tmpf', 'dwpf', 'emsl', 'cloud_cover', 'wxsym'] | ||
obs.locations = ['NW', 'SW', 'NE', 'C', 'W'] | ||
obs.colors = ['red', 'green', 'black', 'black', 'blue'] | ||
obs.formats = [None, None, lambda v: format(10 * v, '.0f')[-3:], 'sky_cover', | ||
'current_weather'] | ||
obs.vector_field = ('uwind', 'vwind') | ||
obs.reduce_points = 1 | ||
|
||
# Add map features for the particular panel | ||
panel = mpplots.MapPanel() | ||
panel.layout = (1, 1, 1) | ||
panel.area = 'ga' | ||
panel.projection = ccrs.PlateCarree() | ||
panel.layers = ['coastline', 'borders', 'states'] | ||
panel.plots = [obs] | ||
|
||
# Collecting panels for complete figure | ||
pc = mpplots.PanelContainer() | ||
pc.size = (10, 10) | ||
pc.panels = [panel] | ||
|
||
# Showing the results | ||
pc.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Copyright (c) 2019 MetPy Developers. | ||
# Distributed under the terms of the BSD 3-Clause License. | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
""" | ||
========================================= | ||
Surface Analysis using Declarative Syntax | ||
========================================= | ||
The MetPy declarative syntax allows for a simplified interface to creating common | ||
meteorological analyses including surface observation plots. | ||
""" | ||
|
||
######################################## | ||
from datetime import datetime | ||
|
||
import pandas as pd | ||
|
||
from metpy.cbook import get_test_data | ||
import metpy.plots as mpplots | ||
from metpy.units import units | ||
|
||
|
||
######################################## | ||
# **Getting the data** | ||
# | ||
# In this example, data is originally from the Iowa State Upper-air archive | ||
# (https://mesonet.agron.iastate.edu/archive/raob/) available through a Siphon method. | ||
# The data are pre-processed to attach latitude/lognitude locations for each RAOB site. | ||
|
||
data = pd.read_csv(get_test_data('UPA_obs.csv', as_file_obj=False)) | ||
|
||
######################################## | ||
# **Plotting the data** | ||
# | ||
# Use the declarative plotting interface to create a CONUS upper-air map for 500 hPa | ||
|
||
# Plotting the Observations | ||
obs = mpplots.PlotObs() | ||
obs.data = data | ||
obs.time = datetime(1993, 3, 14, 0) | ||
obs.level = 500 * units.hPa | ||
obs.fields = ['temperature', 'dewpoint', 'height'] | ||
obs.locations = ['NW', 'SW', 'NE'] | ||
obs.formats = [None, None, lambda v: format(v, '.0f')[:3]] | ||
obs.vector_field = ('u_wind', 'v_wind') | ||
obs.reduce_points = 0 | ||
|
||
# Add map features for the particular panel | ||
panel = mpplots.MapPanel() | ||
panel.layout = (1, 1, 1) | ||
panel.area = (-124, -72, 20, 53) | ||
panel.projection = 'lcc' | ||
panel.layers = ['coastline', 'borders', 'states', 'land', 'ocean'] | ||
panel.plots = [obs] | ||
|
||
# Collecting panels for complete figure | ||
pc = mpplots.PanelContainer() | ||
pc.size = (15, 10) | ||
pc.panels = [panel] | ||
|
||
# Showing the results | ||
pc.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.