Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Create a Miller Composite chart based on Miller 1972 in Python with MetPy and Matplotlib.

Get the data

This example will use data from the North American Mesoscale Model Analysis for 18 UTC 27 April 2011.

---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
Cell In[2], line 27
     23                 'Pressure_reduced_to_MSL_msl',
     24                 'Dew_point_temperature_height_above_ground')
     25 
     26 # Obtain the data we've queried for
---> 27 data_18z = ncss.get_data(query)
     28 
     29 # Make into an xarray Dataset object
     30 ds_18z = xr.open_dataset(NetCDF4DataStore(data_18z)).metpy.parse_cf()

File ~/micromamba/envs/metpy-cookbook/lib/python3.14/site-packages/siphon/ncss.py:114, in NCSS.get_data(self, query)
     93 def get_data(self, query):
     94     """Fetch parsed data from a THREDDS server using NCSS.
     95 
     96     Requests data from the NCSS endpoint given the parameters in `query` and
   (...)    112 
    113     """
--> 114     resp = self.get_query(query)
    115     return response_handlers(resp, self.unit_handler)

File ~/micromamba/envs/metpy-cookbook/lib/python3.14/site-packages/siphon/http_util.py:406, in HTTPEndPoint.get_query(self, query)
    386 """Make a GET request, including a query, to the endpoint.
    387 
    388 The path of the request is to the base URL assigned to the endpoint.
   (...)    403 
    404 """
    405 url = self._base[:-1] if self._base[-1] == '/' else self._base
--> 406 return self.get(url, query)

File ~/micromamba/envs/metpy-cookbook/lib/python3.14/site-packages/siphon/http_util.py:488, in HTTPEndPoint.get(self, path, params)
    486     else:
    487         text = resp.text
--> 488     raise requests.HTTPError(f'Error accessing {resp.request.url}\n'
    489                              f'Server Error ({resp.status_code: d}: {text})')
    490 return resp

HTTPError: Error accessing https://www.ncei.noaa.gov/thredds/ncss/grid/model-namanl-old/201104/20110427/namanl_218_20110427_1800_000.grb?var=v-component_of_wind_isobaric&var=Relative_humidity_isobaric&var=Geopotential_height_isobaric&var=Best_4_layer_lifted_index_layer_between_two_pressure_difference_from_ground_layer&var=Pressure_reduced_to_MSL_msl&var=Temperature_isobaric&var=u-component_of_wind_isobaric&var=Absolute_vorticity_isobaric&var=Dew_point_temperature_height_above_ground&temporal=all&west=-135&east=-60&south=15&north=65&addLatLon=True
Server Error ( 404: FileNotFound: No such file or directory)

Repeat the above process to query for the analysis from 12 hours earlier (06 UTC) to calculate pressure falls and height change.

Subset the Data

With the data pulled in, we will now subset to the specific levels desired

Prepare Variables for Plotting

With the data queried and subset, we will make any needed calculations in preparation for plotting.

The following fields should be plotted:

500-hPa cyclonic vorticity advection

Surface-based Lifted Index

The axis of the 300-hPa, 500-hPa, and 850-hPa jets

Surface dewpoint

700-hPa dewpoint depression

12-hr surface pressure falls and 500-hPa height changes

For the jet axes, we will calculate the windspeed at each level, and plot the highest values

700-hPa dewpoint depression will be calculated from Temperature_isobaric and RH

12-hr surface pressure falls and 500-hPa height changes

To plot the jet axes, we will mask the wind fields below the upper 1/3 of windspeed.

Create the Plot

With the data now ready, we will create the plot

Plot the composite