### Instance Setup Before Initialization Source: https://unidata.github.io/MetPy/latest/api/generated/metpy.plots.FilledContourPlot.html This method is called before the instance's `__init__` method is executed, allowing for setup operations. ```python setup_instance(_** kwargs: Any_) → None# ``` -------------------------------- ### Install MetPy from Source Source: https://unidata.github.io/MetPy/latest/userguide/installguide.html Builds and installs MetPy from the source code. Use this if you have cloned the repository and want to install locally. ```bash pip install . ``` -------------------------------- ### Install MetPy with pip Source: https://unidata.github.io/MetPy/latest/userguide/installguide.html The recommended method for installing MetPy for most users. This command installs the latest stable release. ```bash pip install metpy ``` -------------------------------- ### Instance Setup Source: https://unidata.github.io/MetPy/latest/api/generated/metpy.plots.FilledContourPlot.html This method is called before the instance's __init__ method. ```APIDOC ## setup_instance ### Description This is called **before** self.__init__ is called. ### Parameters #### kwargs - **kwargs** (_Any_) – Additional keyword arguments for setup. ``` -------------------------------- ### get_product Source: https://unidata.github.io/MetPy/latest/api/generated/metpy.remote.NEXRADLevel3Archive.html Get a product from the archive. ```APIDOC ## get_product(site, prod_id, dt=None) ### Description Get a product from the archive. ### Parameters * **site** (str) - The site to search for data * **prod_id** (str) - The product ID to search for data * **dt** (datetime.datetime, optional) - The desired date/time for the model run; the one closest matching in time will be returned. This should have the proper timezone included; if not specified, UTC will be assumed. If None, defaults to the current UTC date/time. ### See Also `product_ids`, `sites`, `get_range` ``` -------------------------------- ### Install MetPy in Editable Mode Source: https://unidata.github.io/MetPy/latest/devel/CONTRIBUTING.html Create an editable install of MetPy. This allows your changes in the source code to be reflected immediately without reinstalling. ```bash pip install -e . ``` -------------------------------- ### Example Output Source: https://unidata.github.io/MetPy/latest/examples/calculations/Thickness_Hydrostatic.html The result of the hydrostatic thickness calculation, displayed in meters. ```text 5332.4331211279705 meter ``` -------------------------------- ### Get Product Source: https://unidata.github.io/MetPy/latest/api/generated/metpy.remote.GOESArchive.html Retrieve a specific product from the GOES archive for a given date and optional mode/band. ```APIDOC ## GOESArchive.get_product(product, dt=None, mode=None, band=None) ### Description Get a product from the archive. ### Parameters * **product** (str) - The site to search for data * **dt** (datetime.datetime, optional) - The desired date/time for the model run; the one closest matching in time will be returned. This should have the proper timezone included; if not specified, UTC will be assumed. If `None`, defaults to the current UTC date/time. * **mode** (str or int, optional) - The particular mode to select. If not given, the query will try to select an appropriate mode based on data available. * **band** (str or int, optional) - The particular band (or channel) to select. Not all products have multiple bands. If not given, the query will try to select an appropriate band, but may error giving the channels available if multiple bands are available. ### See Also `product_ids`, `get_range` ``` -------------------------------- ### Import MetPy and Libraries Source: https://unidata.github.io/MetPy/latest/_downloads/324acb7faa1ec1d6ac5849ea2223364d/Smoothing.ipynb Imports necessary libraries for data manipulation, plotting, and MetPy calculations. Ensure these are installed. ```python from itertools import product import matplotlib.pyplot as plt import numpy as np import metpy.calc as mpcalc ``` -------------------------------- ### get_with_range Source: https://unidata.github.io/MetPy/latest/api/generated/metpy.plots.ctables.ColortableRegistry.html Get a color table and a corresponding BoundaryNorm using a start and end range. ```APIDOC ## get_with_range ### Description Get a color table from the registry with a corresponding norm. Builds a `matplotlib.colors.BoundaryNorm` using _start_ , _end_ , and the number of colors, based on the color table obtained from _name_. ### Parameters * **name** (str) - The name under which the color table will be stored * **start** (float) - The starting boundary * **end** (float) - The ending boundary ### Returns `matplotlib.colors.BoundaryNorm`, `matplotlib.colors.ListedColormap` - The boundary norm based on _start_ and _end_ with the number of colors from the number of entries matching the color table, and the color table itself. ``` -------------------------------- ### setup_instance Source: https://unidata.github.io/MetPy/latest/api/generated/metpy.plots.MapPanel.html This is called before self.__init__ is called. ```APIDOC ## setup_instance ### Description This is called **before** self.__init__ is called. ### Method `setup_instance(_** kwargs: Any_)` ### Parameters - **kwargs** (Any) - Arbitrary keyword arguments. ``` -------------------------------- ### setup_instance Source: https://unidata.github.io/MetPy/latest/api/generated/metpy.plots.ImagePlot.html This is called before self.__init__ is called. ```APIDOC ## setup_instance ### Description This is called **before** self.__init__ is called. ### Method `setup_instance(_** kwargs: Any_)` ### Parameters * **kwargs** (Any) - Arbitrary keyword arguments. ``` -------------------------------- ### get_with_steps Source: https://unidata.github.io/MetPy/latest/api/generated/metpy.plots.ctables.ColortableRegistry.html Get a color table and a corresponding BoundaryNorm using a start value and step size. ```APIDOC ## get_with_steps ### Description Get a color table from the registry with a corresponding norm. Builds a `matplotlib.colors.BoundaryNorm` using _start_ , _step_ , and the number of colors, based on the color table obtained from _name_. ### Parameters * **name** (str) - The name under which the color table will be stored * **start** (float) - The starting boundary * **step** (float) - The step between boundaries ### Returns `matplotlib.colors.BoundaryNorm`, `matplotlib.colors.ListedColormap` - The boundary norm based on _start_ and _step_ with the number of colors from the number of entries matching the color table, and the color table itself. ``` -------------------------------- ### setup_instance Source: https://unidata.github.io/MetPy/latest/api/generated/metpy.plots.ContourPlot.html This method is called before self.__init__ is called. ```APIDOC ## setup_instance ### Description This is called **before** self.__init__ is called. ### Parameters * **kwargs** (_Any_) – Additional keyword arguments. ``` -------------------------------- ### Calculate and Plot Stretching Deformation Source: https://unidata.github.io/MetPy/latest/_downloads/fd475021e6195a260fca1e7e2b1c803e/Stretching_Deformation.ipynb Loads example wind data, calculates stretching deformation using `metpy.calc.stretching_deformation`, and plots the result with wind barbs. Ensure MetPy and Matplotlib are installed. ```python import matplotlib.pyplot as plt import metpy.calc as mpcalc from metpy.cbook import example_data # load example data ds = example_data() # Calculate the stretching deformation of the flow str_def = mpcalc.stretching_deformation(ds.uwind, ds.vwind) # start figure and set axis fig, ax = plt.subplots(figsize=(5, 5)) # plot stretching deformation and scale by 1e5 cf = ax.contourf(ds.lon, ds.lat, str_def * 1e5, range(-80, 81, 1), cmap=plt.cm.PuOr_r) plt.colorbar(cf, pad=0, aspect=50) ax.barbs(ds.lon.values, ds.lat.values, ds.uwind, ds.vwind, color='black', length=5, alpha=0.5) ax.set(xlim=(260, 270), ylim=(30, 40)) ax.set_title('Stretching Deformation Calculation') plt.show() ``` -------------------------------- ### setup_instance Source: https://unidata.github.io/MetPy/latest/api/generated/metpy.plots.PlotObs.html Initialization method called before the instance's __init__ method. ```APIDOC ## setup_instance ### Description This is called **before** self.__init__ is called. ### Method setup_instance(_** kwargs: Any_) ``` -------------------------------- ### Calculate and Plot Wind Speed Source: https://unidata.github.io/MetPy/latest/_downloads/73ef2d00e1a399534eca354fa92c10ae/Wind_Speed.ipynb Loads example wind data, calculates wind speed using `metpy.calc.wind_speed`, and plots the results with wind barbs. Ensure MetPy and Matplotlib are installed. ```python import matplotlib.pyplot as plt import metpy.calc as mpcalc from metpy.cbook import example_data # load example data ds = example_data() # Calculate the total deformation of the flow wind_speed = mpcalc.wind_speed(ds.uwind, ds.vwind) # start figure and set axis fig, ax = plt.subplots(figsize=(5, 5)) # plot wind speed cf = ax.contourf(ds.lon, ds.lat, wind_speed, range(5, 80, 5), cmap=plt.cm.BuPu) plt.colorbar(cf, pad=0, aspect=50) ax.barbs(ds.lon.values, ds.lat.values, ds.uwind, ds.vwind, color='black', length=5, alpha=0.5) ax.set(xlim=(260, 270), ylim=(30, 40)) ax.set_title('Wind Speed Calculation') plt.show() ``` -------------------------------- ### Calculate and Plot Absolute Vorticity Source: https://unidata.github.io/MetPy/latest/_downloads/de54c6faa330a37497a365cfd608a074/Absolute_Vorticity.ipynb Use this snippet to calculate absolute vorticity from u and v wind components and visualize it with contourf and wind barbs. Ensure MetPy and Matplotlib are installed and example data is available. ```python import matplotlib.pyplot as plt import metpy.calc as mpcalc from metpy.cbook import example_data # load example data ds = example_data() # Calculate the vertical vorticity of the flow avor = mpcalc.absolute_vorticity(ds.uwind, ds.vwind) # start figure and set axis fig, ax = plt.subplots(figsize=(5, 5)) # plot and scale absolute vorticity by 1e5 cf = ax.contourf(ds.lon, ds.lat, avor * 1e5, range(-80, 81, 1), cmap=plt.cm.PuOr_r) plt.colorbar(cf, pad=0, aspect=50) ax.barbs(ds.lon.values, ds.lat.values, ds.uwind, ds.vwind, color='black', length=5, alpha=0.5) ax.set(xlim=(260, 270), ylim=(30, 40)) ax.set_title('Absolute Vorticity Calculation') plt.show() ``` -------------------------------- ### setup_instance Source: https://unidata.github.io/MetPy/latest/api/generated/metpy.plots.PlotGeometry.html This method is called before self.__init__ is called during instance initialization. ```APIDOC ## setup_instance ### Description This is called **before** self.__init__ is called. ### Parameters #### kwargs - **kwargs** (_Any_) – Arbitrary keyword arguments to be passed during instance setup. ``` -------------------------------- ### Calculate and Plot Q-Vectors Source: https://unidata.github.io/MetPy/latest/_downloads/9c27973db96412dabcb4103ddee326d2/QVector.ipynb This snippet calculates temperature advection and Q-vectors from example xarray data. It then plots isotherms, temperature advection, and the Q-vectors themselves using Matplotlib, including a key for vector scale. Ensure MetPy and Matplotlib are installed. ```python import matplotlib.pyplot as plt import numpy as np import metpy.calc as mpcalc from metpy.cbook import example_data from metpy.units import units # load example data ds = example_data() # Calculate the temperature advection of the flow tadv = mpcalc.advection(ds.temperature, ds.uwind, ds.vwind) # Calculate the q-vectors. Passing in a fixed value of static stability, but could also # use `mpcalc.static_stability()`. u_qvect, v_qvect = mpcalc.q_vector(ds.uwind, ds.vwind, ds.temperature, 850 * units.hPa, static_stability=2e-6 * units('J / kg / Pa^2')) # start figure and set axis fig, ax = plt.subplots(figsize=(5, 5)) # plot isotherms cs = ax.contour(ds.lon, ds.lat, ds.temperature, range(4, 26, 2), colors='tab:red', linestyles='dashed', linewidths=3) plt.clabel(cs, fmt='%d', fontsize=16) # plot temperature advection in Kelvin per 3 hours cf = ax.contourf(ds.lon, ds.lat, tadv.metpy.convert_units('kelvin/hour') * 3, range(-6, 7, 1), cmap=plt.cm.bwr, alpha=0.75) plt.colorbar(cf, pad=0, aspect=50) # calculate a scale length quantity of our vectors based on their mean scale = (np.hypot(u_qvect, v_qvect).mean() * np.sqrt(u_qvect.size)).data # plot Q-vectors as arrows, every other arrow qvec = ax.quiver(ds.lon.values[::2], ds.lat.values[::2], u_qvect[::2, ::2], v_qvect[::2, ::2], color='black', scale=scale.m, alpha=0.5, width=0.01) # calculate representative arrow for key key = scale / 10 # add key for arrow length qk = ax.quiverkey(qvec, 0.65, 0.905, key.m, f'{key:0.2~P}', labelpos='E', coordinates='figure') ax.set(xlim=(260, 270), ylim=(30, 40)) ax.set_title('Q-Vector Calculation', loc='left') plt.show() ``` -------------------------------- ### Import Libraries and Setup Source: https://unidata.github.io/MetPy/latest/examples/calculations/Smoothing.html Imports necessary libraries for plotting and calculations, and sets up a random data grid with noise for demonstration. ```python from itertools import product import matplotlib.pyplot as plt import numpy as np import metpy.calc as mpcalc ``` ```python rng = np.random.default_rng(61461542) size = 128 x, y = np.mgrid[:size, :size] distance = np.sqrt((x - size / 2) ** 2 + (y - size / 2) ** 2) raw_data = rng.random((size, size)) * 0.3 + distance / distance.max() * 0.7 fig, ax = plt.subplots(1, 1, figsize=(4, 4)) ax.set_title('Raw Data') ax.imshow(raw_data, vmin=0, vmax=1) ax.axis('off') plt.show() ``` -------------------------------- ### Calculate and Plot Temperature Advection Source: https://unidata.github.io/MetPy/latest/_downloads/4d4c25299feb8e3fe80f0a671f3ee7d3/Advection.ipynb Use this snippet to compute temperature advection from wind and temperature data. It plots the isotherms, the calculated advection (converted to Kelvin per 3 hours), and wind barbs. Ensure MetPy and Matplotlib are installed and example data is available. ```python import matplotlib.pyplot as plt import metpy.calc as mpcalc from metpy.cbook import example_data # load example data ds = example_data() # Calculate the temperature advection of the flow tadv = mpcalc.advection(ds.temperature, ds.uwind, ds.vwind) # See the units that come back from the advection function print(tadv.data.units) # start figure and set axis fig, ax = plt.subplots(figsize=(5, 5)) # plot isotherms cs = ax.contour(ds.lon, ds.lat, ds.temperature, range(4, 26, 2), colors='tab:red', linestyles='dashed', linewidths=3) plt.clabel(cs, fmt='%d', fontsize=16) # plot temperature advection and convert units to Kelvin per 3 hours cf = ax.contourf(ds.lon, ds.lat, tadv.metpy.convert_units('kelvin/hour') * 3, range(-6, 7, 1), cmap=plt.cm.bwr, alpha=0.75) plt.colorbar(cf, pad=0, aspect=50) ax.barbs(ds.lon.values[::2], ds.lat.values[::2], ds.uwind[::2, ::2], ds.vwind[::2, ::2], color='black', length=6, alpha=0.5) ax.set(xlim=(260, 270), ylim=(30, 40)) ax.set_title('Temperature Advection Calculation') plt.show() ``` -------------------------------- ### ArrowPlot.setup_instance Source: https://unidata.github.io/MetPy/latest/api/generated/metpy.plots.ArrowPlot.html This method is called before self.__init__ is called. ```APIDOC ## ArrowPlot.setup_instance ### Description This is called **before** self.__init__ is called. ### Method setup_instance(_** kwargs: Any_) -> None ``` -------------------------------- ### metpy.units.setup_registry Source: https://unidata.github.io/MetPy/latest/api/generated/metpy.units.html Sets up a given registry with MetPy's default tweaks and settings. ```APIDOC ## `setup_registry(reg)` ### Description Set up a given registry with MetPy's default tweaks and settings. ### Parameters #### Path Parameters - **reg** (pint.UnitRegistry) - Required - The registry to set up. ``` -------------------------------- ### Install MetPy with conda Source: https://unidata.github.io/MetPy/latest/userguide/installguide.html Installs MetPy and its dependencies from the conda-forge channel. This is an alternative for users who prefer the conda package manager. ```bash conda install -c conda-forge metpy ``` -------------------------------- ### Instantiate GiniFile Source: https://unidata.github.io/MetPy/latest/api/generated/metpy.io.GiniFile.html Create an instance of GiniFile by providing the filename or a file-like object. Gzip and bzip2 compressed files are supported. ```python f = GiniFile("my_gini_file.gini") f = GiniFile("my_gini_file.gini.gz") f = GiniFile(file_obj) ``` -------------------------------- ### Define Cross Section Start and End Points Source: https://unidata.github.io/MetPy/latest/_downloads/7fd39302ff9f3fa4a7870d3c31b04722/cross_section.ipynb Specifies the geographic coordinates (latitude, longitude) for the start and end of the desired cross-section. ```python start = (37.0, -105.0) end = (35.5, -65.0) ``` -------------------------------- ### GempakGrid.__init__ Source: https://unidata.github.io/MetPy/latest/api/generated/metpy.io.GempakGrid.html Instantiate GempakFile object from file. ```APIDOC ## GempakGrid.__init__ ### Description Instantiate GempakFile object from file. ### Parameters * `file`: Path to the GEMPAK grid file. * `*args`: Variable length argument list. * `**kwargs`: Arbitrary keyword arguments. ``` -------------------------------- ### Install MetPy Dependencies Source: https://unidata.github.io/MetPy/latest/devel/CONTRIBUTING.html Install all necessary MetPy dependency packages from conda-forge using the requirement files. Ensure you are in the 'metpy' directory when running this command. ```bash conda install --file ci/requirements.txt --file ci/extra_requirements.txt --file ci/test_requirements.txt ``` -------------------------------- ### GempakSurface.__init__ Source: https://unidata.github.io/MetPy/latest/api/generated/metpy.io.GempakSurface.html Instantiates a GempakSurface object from a file. ```APIDOC ## GempakSurface.__init__ ### Description Instantiate GempakFile object from file. ### Parameters * **file** (str) - The path to the GEMPAK surface data file. * **args** - Additional positional arguments. * **kwargs** - Additional keyword arguments. ``` -------------------------------- ### ColdFront Class Initialization Source: https://unidata.github.io/MetPy/latest/api/generated/metpy.plots.ColdFront.html Initializes a ColdFront object to draw a path as a cold front with customizable pips/triangles along the path. ```APIDOC ## class metpy.plots.ColdFront ### Description Draw a path as a cold front, with (default blue) pips/triangles along the path. Initialize the front path effect. ### Parameters * **color** (_str_ _or_ _tuple_ _[__float_ _]_) – Color to use for the effect. * **size** (_int_ _or_ _float_) – The size of the markers to plot in points. Defaults to 10. * **spacing** (_int_ _or_ _float_) – The spacing between markers in normalized coordinates. Defaults to 1. * **flip** (_bool_) – Whether the symbol should be flipped to the other side of the path. Defaults to _False_. * **filled** (_bool_) – Whether the symbol should be filled with the color. Defaults to _True_. ``` -------------------------------- ### MetPy Software Citation Example Source: https://unidata.github.io/MetPy/latest/userguide/citing.html Example citation for MetPy software in a common citation style. Includes authors, year, title, publisher, and DOI. ```text May, R. M., Arms, S. C., Marsh, P., Bruning, E., Leeman, J. R., Goebbert, K., Thielen, J. E., Bruick, Z., and Camron, M. D., 2025: MetPy: A Python Package for Meteorological Data. Unidata, Unidata/MetPy, doi:10.5065/D6WW7G29. ``` -------------------------------- ### metpy.calc.dry_lapse Source: https://unidata.github.io/MetPy/latest/api/generated/metpy.calc.dry_lapse.html Calculate the temperature at a level assuming only dry processes. This function lifts a parcel starting at `temperature`, conserving potential temperature. The starting pressure can be given by `reference_pressure`. ```APIDOC ## dry_lapse ### Description Calculate the temperature at a level assuming only dry processes. This function lifts a parcel starting at `temperature`, conserving potential temperature. The starting pressure can be given by `reference_pressure`. ### Parameters * **pressure** (`pint.Quantity`) – Atmospheric pressure level(s) of interest * **temperature** (`pint.Quantity`) – Starting temperature * **reference_pressure** (`pint.Quantity`, optional) – Reference pressure; if not given, it defaults to the first element of the pressure array. ### Returns `pint.Quantity` – The parcel’s resulting temperature at levels given by `pressure` ### Examples ```python >>> from metpy.calc import dry_lapse >>> from metpy.units import units >>> plevs = [1000, 925, 850, 700] * units.hPa >>> dry_lapse(plevs, 15 * units.degC).to('degC') ``` ### See Also `moist_lapse`, `parcel_profile`, `potential_temperature` ### Notes Only reliably functions on 1D profiles (not higher-dimension vertical cross sections or grids) unless reference_pressure is specified. Changed in version 1.0: Renamed `ref_pressure` parameter to `reference_pressure` ``` -------------------------------- ### Configure Map Panel and Show Figure Source: https://unidata.github.io/MetPy/latest/_downloads/ebb1d490725ed27549701eaf2c36b8b4/declarative_tutorial.ipynb Set up a MapPanel with specified area, projection, layers, title, and add the configured plots. Then, create a PanelContainer, set its size, add the panel, and display the figure. ```python # Set the attributes for the map and add our data to the map panel = MapPanel() panel.area = [-125, -74, 20, 55] panel.projection = 'lcc' panel.layers = ['states', 'coastline', 'borders'] panel.title = f'{cfill.level.m}-hPa Heights and Wind Speed at {plot_time}' panel.plots = [cfill, cntr2, barbs] # Set the attributes for the panel and put the panel in the figure pc = PanelContainer() pc.size = (15, 15) pc.panels = [panel] # Show the figure pc.show() ``` -------------------------------- ### moist_lapse Source: https://unidata.github.io/MetPy/latest/api/generated/metpy.calc.moist_lapse.html Calculate the temperature at a level assuming liquid saturation processes. This function lifts a parcel starting at temperature. The starting pressure can be given by reference_pressure. Essentially, this function is calculating moist pseudo-adiabats. ```APIDOC ## moist_lapse ### Description Calculate the temperature at a level assuming liquid saturation processes. This function lifts a parcel starting at temperature. The starting pressure can be given by reference_pressure. Essentially, this function is calculating moist pseudo-adiabats. ### Parameters * **pressure** (`pint.Quantity`) – Atmospheric pressure level(s) of interest * **temperature** (`pint.Quantity`) – Starting temperature * **reference_pressure** (`pint.Quantity`, optional) – Reference pressure; if not given, it defaults to the first element of the pressure array. ### Returns `pint.Quantity` – The resulting parcel temperature at levels given by pressure ### Examples ```python >>> from metpy.calc import moist_lapse >>> from metpy.units import units >>> plevs = [925, 850, 700, 500, 300, 200] * units.hPa >>> moist_lapse(plevs, 5 * units.degC).to('degC') ``` ### See Also `dry_lapse`, `parcel_profile` ### Notes This function is implemented by integrating the following differential equation: dTdP=1PRdT+LvrsCpd+Lv2rsϵRdT2. This equation comes from [Bakhshaii2013]. Only reliably functions on 1D profiles (not higher-dimension vertical cross sections or grids). Changed in version 1.0: Renamed `ref_pressure` parameter to `reference_pressure` ``` -------------------------------- ### Configure and Display a Map Panel Source: https://unidata.github.io/MetPy/latest/tutorials/declarative_tutorial.html Sets up a map panel with specified area, projection, layers, and title, then displays it using a PanelContainer. Useful for creating static map visualizations. ```python panel = MapPanel() panel.area = [-125, -74, 20, 55] panel.projection = 'lcc' panel.layers = ['states', 'coastline', 'borders'] panel.title = f'{cfill.level.m}-hPa Heights and Wind Speed at {plot_time}' panel.plots = [cfill, cntr2, barbs] pc = PanelContainer() pc.size = (15, 15) pc.panels = [panel] pc.show() ``` -------------------------------- ### Basic Skew-T Plotting Setup Source: https://unidata.github.io/MetPy/latest/_downloads/cdca3e0cb8a2930cccab0e29b97ef52a/upperair_soundings.ipynb Initializes a Matplotlib figure and a SkewT object, then plots the observed pressure, temperature, and dewpoint data, along with wind barbs. ```python # Create a figure. fig = plt.figure(1, figsize=(8, 8)) # Create a SkewT object. skew = SkewT(fig=fig) # Plot the data using skew skew.plot(p, T, 'r') skew.plot(p, Td, 'g') skew.plot_barbs(p, u, v) skew.plot_dry_adiabats() skew.plot_moist_adiabats() skew.plot_wave_lines() skew.plot_mixing_lines() ``` -------------------------------- ### class_traits Source: https://unidata.github.io/MetPy/latest/api/generated/metpy.plots.PlotScalar.html Gets a dictionary of all the traits of this class. ```APIDOC ## _classmethod _class_traits ### Description Get a `dict` of all the traits of this class. The dictionary is keyed on the name and the values are the TraitType objects. ### Parameters * `**metadata`: Metadata to filter traits by. ``` -------------------------------- ### Build and Upload PyPI Packages Source: https://unidata.github.io/MetPy/latest/devel/infrastructureguide.html Commands to build Python packages and upload them to PyPI. Ensure you have the 'build' and 'twine' packages installed. The 'dist/' directory should only contain files for the current release. ```bash python -m build ``` ```bash twine upload dist/* ``` -------------------------------- ### traits Source: https://unidata.github.io/MetPy/latest/api/generated/metpy.plots.ImagePlot.html Get a `dict` of all the traits of this class. ```APIDOC ## traits ### Description Get a `dict` of all the traits of this class. The dictionary is keyed on the name and the values are the TraitType objects. The TraitTypes returned don’t know anything about the values that the various HasTrait’s instances are holding. The metadata kwargs allow functions to be passed in which filter traits based on metadata values. The functions should take a single value as an argument and return a boolean. If any function returns False, then the trait is not included in the output. If a metadata key doesn’t exist, None will be passed to the function. ### Method `traits(_** metadata: Any_)` ### Parameters * **metadata** (Any) - Metadata keyword arguments to filter traits. ``` -------------------------------- ### Unit Registry Setup Source: https://unidata.github.io/MetPy/latest/api/generated/metpy.units.html This function sets up the unit registry, which is essential for MetPy's unit handling capabilities. ```APIDOC ## setup_registry ### Description Sets up the unit registry for MetPy. ### Parameters None ### Returns None ``` -------------------------------- ### traits Source: https://unidata.github.io/MetPy/latest/api/generated/metpy.plots.MapPanel.html Get a `dict` of all the traits of this class. ```APIDOC ## traits ### Description Get a `dict` of all the traits of this class. The dictionary is keyed on the name and the values are the TraitType objects. The TraitTypes returned don’t know anything about the values that the various HasTrait’s instances are holding. The metadata kwargs allow functions to be passed in which filter traits based on metadata values. The functions should take a single value as an argument and return a boolean. If any function returns False, then the trait is not included in the output. If a metadata key doesn’t exist, None will be passed to the function. ### Method `traits(_** metadata: Any_)` ### Parameters - **metadata** (Any) - Metadata keyword arguments to filter traits. ``` -------------------------------- ### unit_vectors_from_cross_section Source: https://unidata.github.io/MetPy/latest/api/generated/metpy.calc.cross_section_components.html Get unit vectors for a cross-section. ```APIDOC ## unit_vectors_from_cross_section ### Description Get the unit vectors corresponding to the axes of a cross-section. ### Parameters * **ds** (xarray.Dataset) - The Dataset containing the cross-section data. ### Returns (xarray.DataArray, xarray.DataArray) - A tuple containing the unit vectors for the cross-section axes. ### Example ```python # Assuming 'ds' is an xarray Dataset with cross-section data unit_vec_x, unit_vec_y = metpy.calc.unit_vectors_from_cross_section(ds) ``` ``` -------------------------------- ### Create and Configure Map Panel Source: https://unidata.github.io/MetPy/latest/_downloads/ebb1d490725ed27549701eaf2c36b8b4/declarative_tutorial.ipynb Set up a map panel for plotting weather data. Specify the layout, projection, area of interest, layers, title, and plots to be displayed. ```python # Panel for plot with Map features panel = MapPanel() panel.layout = (1, 1, 1) panel.projection = 'lcc' panel.area = 'in' panel.layers = ['states'] panel.title = f'Surface plot for {obs_time}' panel.plots = [obs] # Bringing it all together pc = PanelContainer() pc.size = (10, 10) pc.panels = [panel] pc.show() ``` -------------------------------- ### metpy.calc.lcl Source: https://unidata.github.io/MetPy/latest/api/generated/metpy.calc.lcl.html Calculate the lifted condensation level (LCL) from the starting point. The starting state for the parcel is defined by temperature, dewpoint, and pressure. If these are arrays, this function will return a LCL for every index. This function does work with surface grids as a result. ```APIDOC ## metpy.calc.lcl ### Description Calculate the lifted condensation level (LCL) from the starting point. The starting state for the parcel is defined by temperature, dewpoint, and pressure. If these are arrays, this function will return a LCL for every index. This function does work with surface grids as a result. ### Parameters * **pressure** (`pint.Quantity`) – Starting atmospheric pressure * **temperature** (`pint.Quantity`) – Starting temperature * **dewpoint** (`pint.Quantity`) – Starting dewpoint * **max_iters** (optional) – Maximum number of iterations to use in the calculation. * **eps** (optional) – The desired precision for the calculation. ### Returns * `pint.Quantity` – LCL pressure * `pint.Quantity` – LCL temperature ### Examples ```python >>> from metpy.calc import lcl >>> from metpy.units import units >>> lcl(943 * units.hPa, 33 * units.degC, 28 * units.degC) (, ) ``` ### Notes From [Romps2017], this directly solves for the temperature at the LCL, Eq 22a, TLCL=c[W−1(RHl1/acexp⁡c)]−1T and the pressure at the LCL, Eq 22b, pLCL=p(TLCLT)cpm/Rm where a (Eq 22d), b (Eq 22e), and c (Eq 22f) are derived constants, and W−1 is the k=−1 branch of the Lambert W function. Changed in version 1.0: Renamed `dewpt` parameter to `dewpoint` ``` -------------------------------- ### names Source: https://unidata.github.io/MetPy/latest/api/generated/metpy.plots.StationPlotLayout.html Get the list of names used by the StationPlotLayout. ```APIDOC ## names() ### Description Get the list of names used by the layout. ``` -------------------------------- ### Set up map, parse bulletin, and plot surface analysis Source: https://unidata.github.io/MetPy/latest/_downloads/d0fb0bcc036dab38c2a49ad11eb0832b/Plotting_Surface_Analysis.ipynb Configures a Lambert Conformal map projection, parses a WPC surface analysis bulletin using MetPy, plots the features using the defined function, and displays the map with a title and MetPy logo. ```python # Set up a default figure and map fig = plt.figure(figsize=(7, 7), dpi=150) ax = fig.add_subplot( 1, 1, 1, projection=ccrs.LambertConformal(central_longitude=-100) ) ax.add_feature(cfeature.COASTLINE) ax.add_feature(cfeature.OCEAN) ax.add_feature(cfeature.LAND) ax.add_feature(cfeature.BORDERS) ax.add_feature(cfeature.STATES) ax.add_feature(cfeature.LAKES) # Parse the bulletin and plot it df = parse_wpc_surface_bulletin(get_test_data('WPC_sfc_fronts_20210628_1800.txt')) plot_bulletin(ax, df) ax.set_title(f'WPC Surface Analysis Valid {df.valid.dt.strftime("%HZ %d %b %Y")[0]}') add_metpy_logo(fig, 275, 295, size='large') plt.show() ``` -------------------------------- ### _classmethod_trait_events Source: https://unidata.github.io/MetPy/latest/api/generated/metpy.plots.PlotSurfaceAnalysis.html Get a `dict` of all the event handlers of this class. ```APIDOC ## _classmethod_trait_events(name: str | None = None) -> dict[str, EventHandler] ### Description Get a `dict` of all the event handlers of this class. ### Method `_classmethod_trait_events` ### Parameters #### Path Parameters - **name** (str | None) - Optional - The name of a trait of this class. If name is `None` then all the event handlers of this class will be returned instead. Defaults to `None`. ### Returns A `dict` of the event handlers associated with a trait name, or all event handlers. ``` -------------------------------- ### Import Necessary Libraries for Static Stability Source: https://unidata.github.io/MetPy/latest/_downloads/1474899b96adbc9492d387961a72cf37/Static_Stability.ipynb Import pandas for data manipulation, MetPy's `static_stability` and `get_test_data` for calculations and data retrieval, `Rd` for the gas constant, and `units` for handling physical quantities. ```python import pandas as pd from metpy.calc import static_stability from metpy.cbook import get_test_data from metpy.constants import Rd from metpy.units import units ``` -------------------------------- ### trait_names Source: https://unidata.github.io/MetPy/latest/api/generated/metpy.plots.ContourPlot.html Gets a list of all the names of this class' traits. ```APIDOC ## trait_names ### Description Get a list of all the names of this class' traits. ### Parameters * **metadata** (_Any_) – Metadata keyword arguments to filter traits. ### Returns A list of trait names. ``` -------------------------------- ### Initialize and Plot Station Data with MetPy Source: https://unidata.github.io/MetPy/latest/_downloads/bb9caa5586d62e19ca46e30c02d29b43/Station_Plot.ipynb This snippet shows how to set up a map projection, add map features, and then initialize a StationPlot object to display meteorological data. It includes plotting temperature, dew point, sea-level pressure with custom formatting, cloud cover symbols, current weather symbols, wind barbs, and station IDs. ```python plt.rcParams['savefig.dpi'] = 255 # Create the figure and an axes set to the projection. fig = plt.figure(figsize=(20, 10)) add_metpy_logo(fig, 1100, 300, size='large') ax = fig.add_subplot(1, 1, 1, projection=proj) # Add some various map elements to the plot to make it recognizable. ax.add_feature(cfeature.LAND) ax.add_feature(cfeature.OCEAN) ax.add_feature(cfeature.LAKES) ax.add_feature(cfeature.COASTLINE) ax.add_feature(cfeature.STATES) ax.add_feature(cfeature.BORDERS) # Set plot bounds ax.set_extent((-118, -73, 23, 50)) # # Here's the actual station plot # # Start the station plot by specifying the axes to draw on, as well as the # lon/lat of the stations (with transform). We also the fontsize to 12 pt. stationplot = StationPlot(ax, data['longitude'].values, data['latitude'].values, clip_on=True, transform=ccrs.PlateCarree(), fontsize=12) # Plot the temperature and dew point to the upper and lower left, respectively, of # the center point. Each one uses a different color. stationplot.plot_parameter('NW', data['air_temperature'].values, color='red') stationplot.plot_parameter('SW', data['dew_point_temperature'].values, color='darkgreen') # A more complex example uses a custom formatter to control how the sea-level pressure # values are plotted. This uses the standard trailing 3-digits of the pressure value # in tenths of millibars. stationplot.plot_parameter('NE', data['air_pressure_at_sea_level'].values, formatter=lambda v: format(10 * v, '.0f')[-3:]) # Plot the cloud cover symbols in the center location. This uses the codes made above and # uses the `sky_cover` mapper to convert these values to font codes for the # weather symbol font. stationplot.plot_symbol('C', data['cloud_coverage'].values, sky_cover) # 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['current_wx1_symbol'].values, current_weather) # Add wind barbs stationplot.plot_barb(data['eastward_wind'].values, data['northward_wind'].values) # Also plot the actual text of the station id. Instead of cardinal directions, # plot further out by specifying a location of 2 increments in x and 0 in y. stationplot.plot_text((2, 0), data['station_id'].values) plt.show() ``` -------------------------------- ### trait_metadata Source: https://unidata.github.io/MetPy/latest/api/generated/metpy.plots.ContourPlot.html Gets metadata values for a trait by key. ```APIDOC ## trait_metadata ### Description Get metadata values for trait by key. ### Parameters * **traitname** (_str_) – The name of the trait. * **key** (_str_) – The metadata key. * **default** (_Any_) – The default value to return if the key is not found. ### Returns The metadata value associated with the key. ``` -------------------------------- ### ArrowPlot.trait_names Source: https://unidata.github.io/MetPy/latest/api/generated/metpy.plots.ArrowPlot.html Get a list of all the names of this class' traits. ```APIDOC ## ArrowPlot.trait_names ### Description Get a list of all the names of this class' traits. ### Method trait_names(_** metadata: Any_) -> list[str] ``` -------------------------------- ### GOESArchive Initialization Source: https://unidata.github.io/MetPy/latest/api/generated/metpy.remote.GOESArchive.html Initialize the GOESArchive client for a specific GOES satellite. ```APIDOC ## GOESArchive.__init__(satellite) ### Description Initialize the archive client. ### Parameters * **satellite** (str or int) - The specific GOES satellite to access (e.g. 16, 17, 18). ``` -------------------------------- ### ArrowPlot.trait_metadata Source: https://unidata.github.io/MetPy/latest/api/generated/metpy.plots.ArrowPlot.html Get metadata values for a trait by key. ```APIDOC ## ArrowPlot.trait_metadata ### Description Get metadata values for trait by key. ### Method trait_metadata(_traitname : str_, _key : str_, _default : Any = None_) -> Any ``` -------------------------------- ### metpy.units.setup_registry Source: https://unidata.github.io/MetPy/latest/api/generated/metpy.units.setup_registry.html Initializes and configures the unit registry used by MetPy. This function ensures that all necessary units and their conversions are available for use in calculations and data processing. ```APIDOC ## setup_registry() ### Description Initializes the MetPy unit registry. This function should be called before using MetPy's unit-aware functionalities to ensure all standard units and conversions are loaded. ### Parameters This function does not take any parameters. ### Returns None. The function modifies the global unit registry. ### Example ```python import metpy.units as units # Call setup_registry to initialize the unit registry units.setup_registry() # Now you can use MetPy units wind_speed = 10 * units.knots print(wind_speed) ``` ``` -------------------------------- ### trait_metadata Source: https://unidata.github.io/MetPy/latest/api/generated/metpy.plots.ImagePlot.html Get metadata values for trait by key. ```APIDOC ## trait_metadata ### Description Get metadata values for trait by key. ### Method `trait_metadata(_traitname : str_, _key : str_, _default : Any = None_)` ### Parameters * **traitname** (str) - The name of the trait. * **key** (str) - The key of the metadata to retrieve. * **default** (Any, optional) - The default value to return if the metadata is not found. Defaults to None. ``` -------------------------------- ### Calculate Equilibrium Level (EL) Source: https://unidata.github.io/MetPy/latest/api/generated/metpy.calc.el.html This example demonstrates how to calculate the equilibrium level (EL) using MetPy. It involves defining pressure, temperature, and relative humidity profiles, calculating the dewpoint, computing a parcel profile, and finally calling the `el` function. The `el` function returns the pressure and temperature at the EL. ```python from metpy.calc import el, dewpoint_from_relative_humidity, parcel_profile from metpy.units import units # pressure p = [1008., 1000., 950., 900., 850., 800., 750., 700., 650., 600., 550., 500., 450., 400., 350., 300., 250., 200., 175., 150., 125., 100., 80., 70., 60., 50., 40., 30., 25., 20.] * units.hPa # temperature T = [29.3, 28.1, 23.5, 20.9, 18.4, 15.9, 13.1, 10.1, 6.7, 3.1, -0.5, -4.5, -9.0, -14.8, -21.5, -29.7, -40.0, -52.4, -59.2, -66.5, -74.1, -78.5, -76.0, -71.6, -66.7, -61.3, -56.3, -51.7, -50.7, -47.5] * units.degC # relative humidity rh = [.85, .65, .36, .39, .82, .72, .75, .86, .65, .22, .52, .66, .64, .20, .05, .75, .76, .45, .25, .48, .76, .88, .56, .88, .39, .67, .15, .04, .94, .35] * units.dimensionless # calculate dewpoint Td = dewpoint_from_relative_humidity(T, rh) # compute parcel profile temperature prof = parcel_profile(p, T[0], Td[0]).to('degC') # calculate EL el(p, T, Td, prof) ``` -------------------------------- ### trait_metadata Source: https://unidata.github.io/MetPy/latest/api/generated/metpy.plots.MapPanel.html Get metadata values for trait by key. ```APIDOC ## trait_metadata ### Description Get metadata values for trait by key. ### Method `trait_metadata(_traitname : str_, _key : str_, _default : Any = None_)` ### Parameters - **traitname** (str) - The name of the trait. - **key** (str) - The metadata key. - **default** (Any, optional) - The default value to return if the key is not found. Defaults to None. ``` -------------------------------- ### Level3File Initialization Source: https://unidata.github.io/MetPy/latest/api/generated/metpy.io.Level3File.html Instantiate a Level3File object by providing the path to the Level 3 radar file. ```APIDOC ## Level3File ### Description Create instance of `Level3File`. ### Parameters #### Path Parameters - **filename** (str or file-like object) - Required - If str, the name of the file to be opened. If file-like object, this will be read from directly. ``` -------------------------------- ### Create Sample Data for Gradient Calculation Source: https://unidata.github.io/MetPy/latest/_downloads/62a1acd718d4c5b9717787544d4cf09f/Gradient.ipynb Generates sample temperature data along with corresponding x and y coordinate arrays for gradient computation. ```python data = np.array([[23, 24, 23], [25, 26, 25], [27, 28, 27], [24, 25, 24]]) * units.degC # Create an array of x position data (the coordinates of our temperature data) x = np.array([[1, 2, 3], [1, 2, 3], [1, 2, 3], [1, 2, 3]]) * units.kilometer y = np.array([[1, 1, 1], [2, 2, 2], [3, 3, 3], [4, 4, 4]]) * units.kilometer ``` -------------------------------- ### trait_events Source: https://unidata.github.io/MetPy/latest/api/generated/metpy.plots.ImagePlot.html Get a `dict` of all the event handlers of this class. ```APIDOC ## trait_events ### Description Get a `dict` of all the event handlers of this class. ### Method `trait_events(_name : str | None = None_)` ### Parameters * **name** (str | None, optional) - The name of a trait of this class. If name is `None` then all the event handlers of this class will be returned instead. Defaults to None. ### Returns The event handlers associated with a trait name, or all event handlers. ```