### Install development version Source: https://python-windrose.github.io/windrose/development.html Install the package in editable mode or directly from the remote repository. ```bash $ python -m pip install . ``` ```bash $ python -m pip install git+https://github.com/python-windrose/windrose.git ``` -------------------------------- ### Install Windrose Package Source: https://python-windrose.github.io/windrose/_sources/install.rst.txt Use this command to install the latest release version of the windrose package from PyPi. ```bash $ pip install windrose ``` -------------------------------- ### Overlay Windrose on Map with inset_axes Source: https://python-windrose.github.io/windrose/usage-output.html Illustrates setting a windrose axes on top of another axes, specifically for overlaying a map. Relies on matplotlib's inset_axes utilities. Ensure cartopy is installed for map functionalities. ```python import cartopy.crs as ccrs import cartopy.io.img_tiles as cimgt import matplotlib.pyplot as plt import numpy as np from mpl_toolkits.axes_grid1.inset_locator import inset_axes import windrose ws = np.random.random(500) * 6 wd = np.random.random(500) * 360 minlon, maxlon, minlat, maxlat = (6.5, 7.0, 45.85, 46.05) proj = ccrs.PlateCarree() fig = plt.figure(figsize=(12, 6)) # Draw main ax on top of which we will add windroses main_ax = fig.add_subplot(1, 1, 1, projection=proj) main_ax.set_extent([minlon, maxlon, minlat, maxlat], crs=proj) main_ax.gridlines(draw_labels=True) main_ax.coastlines() request = cimgt.OSM() main_ax.add_image(request, 12) # Coordinates of the station we were measuring windspeed cham_lon, cham_lat = (6.8599, 45.9259) passy_lon, passy_lat = (6.7, 45.9159) # Inset axe it with a fixed size wrax_cham = inset_axes( main_ax, width=1, # size in inches height=1, # size in inches loc="center", # center bbox at given position bbox_to_anchor=(cham_lon, cham_lat), # position of the axe bbox_transform=main_ax.transData, # use data coordinate (not axe coordinate) axes_class=windrose.WindroseAxes, # specify the class of the axe ) # Inset axe with size relative to main axe height_deg = 0.1 wrax_passy = inset_axes( main_ax, width="100%", # size in % of bbox height="100%", # size in % of bbox # loc="center", # don"t know why, but this doesn"t work. # specify the center lon and lat of the plot, and size in degree bbox_to_anchor=( passy_lon - height_deg / 2, passy_lat - height_deg / 2, height_deg, height_deg, ), bbox_transform=main_ax.transData, axes_class=windrose.WindroseAxes, ) wrax_cham.bar(wd, ws) wrax_passy.bar(wd, ws) for ax in [wrax_cham, wrax_passy]: ax.tick_params(labelleft=False, labelbottom=False) ``` -------------------------------- ### Accessing Video Export CLI Help Source: https://python-windrose.github.io/windrose/usage-output.html Displays the command line interface help for the video animation script. ```bash $ python samples/example_animate.py --help ``` -------------------------------- ### Clone the windrose repository Source: https://python-windrose.github.io/windrose/development.html Use these commands to download the source code and enter the project directory. ```bash $ git clone https://github.com/python-windrose/windrose.git $ cd windrose ``` -------------------------------- ### Initialize WindroseAxes Source: https://python-windrose.github.io/windrose/api.html Constructor for the primary WindroseAxes class. ```python _class _windrose.WindroseAxes(_* args_, _** kwargs_) ``` -------------------------------- ### Display Weibull Distribution Parameters Source: https://python-windrose.github.io/windrose/usage-output.html Prints the optimal parameters calculated for the Weibull distribution fitted to the wind speed data. This follows the computation of the PDF. ```python print(f"{params=}") ``` -------------------------------- ### Create Axes via Factory Source: https://python-windrose.github.io/windrose/api.html Factory method to instantiate either WindroseAxes or WindAxes. ```python _static _create(_typ_ , _ax =None_, _* args_, _** kwargs_) ``` -------------------------------- ### Run unit tests Source: https://python-windrose.github.io/windrose/development.html Execute the test suite using pytest. ```bash $ python -m pytest -vv tests ``` ```bash $ python -m pytest -vv tests/test_windrose.py::test_windrose_np_plot_and_pd_plot ``` -------------------------------- ### POST /windrose/wrpdf Source: https://python-windrose.github.io/windrose/api.html Draws the probability density function and returns Weibull distribution parameters. ```APIDOC ## POST /windrose/wrpdf ### Description Draws the probability density function and returns Weibull distribution parameters. ### Method POST ### Endpoint /windrose/wrpdf ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **var** (1D array) - Required - Values of the variable to compute. Typically the wind speeds. - **bins** (integer or 1D array) - Optional - Number of bins, or a sequence of bins variable. If not set, bins=10. - **Nx** (integer) - Optional - Number of points for the PDF curve. Default is 100. - **bar_color** (string) - Optional - Color for the histogram bars. Default is 'b'. - **plot_color** (string) - Optional - Color for the PDF curve. Default is 'g'. - **Nbins** (integer) - Optional - Number of bins for the histogram. Default is 10. - **ax** (matplotlib axes object) - Optional - Axes to plot on. - **rmax** (float) - Optional - Maximum radius for the plot. - **figsize** (tuple) - Optional - Figure size (width, height). - **args** - Optional - Additional arguments for plotting. - **kwargs** - Optional - Additional keyword arguments for plotting. ### Request Example { "var": [10, 15, 20, 25, 30], "bins": 5, "Nx": 50, "bar_color": "red", "plot_color": "blue" } ### Response #### Success Response (200) - **Weibull parameters** (dict) - Dictionary containing the calculated Weibull distribution parameters (e.g., 'alpha', 'beta', 'gamma'). #### Response Example { "alpha": 15.5, "beta": 2.1, "gamma": 0.0 } ``` -------------------------------- ### windrose.WindroseAxes Methods Source: https://python-windrose.github.io/windrose/genindex.html Documentation for methods available in the WindroseAxes class. ```APIDOC ## WindroseAxes Methods ### bar() **Description**: Plots a bar representation of wind data. ### box() **Description**: Plots a box representation of wind data. ### clear() **Description**: Clears the current windrose axes. ### contour() **Description**: Draws contour lines on the windrose plot. ### contourf() **Description**: Draws filled contour lines on the windrose plot. ### legend() **Description**: Adds a legend to the windrose plot. ### set() **Description**: Sets various properties of the windrose axes. ### set_legend() **Description**: Configures the legend for the windrose plot. ### set_radii_angle() **Description**: Sets the radii and angle properties for the windrose plot. ``` -------------------------------- ### Initialize WindAxes Source: https://python-windrose.github.io/windrose/api.html Constructor for the WindAxes class used for windrose plotting. ```python _class _windrose.WindAxes(_* args_, _** kwargs_) ``` -------------------------------- ### Create WindAxes from existing axes Source: https://python-windrose.github.io/windrose/api.html Static method to initialize a WindAxes instance from an existing matplotlib axes or figure. ```python _static _from_ax(_ax =None_, _fig =None_, _figsize =(8, 8)_, _* args_, _** kwargs_) ``` -------------------------------- ### Windrose API Overview Source: https://python-windrose.github.io/windrose/api.html Overview of the primary classes and functions available in the Windrose library. ```APIDOC ## Windrose API Reference ### Classes - **WindAxes**: Handles basic wind axis operations including `from_ax()`, `pdf()`, and `set()`. - **WindAxesFactory**: Provides `create()` method for axis generation. - **WindroseAxes**: Main class for wind rose plotting, supporting `bar()`, `box()`, `clear()`, `contour()`, `contourf()`, `from_ax()`, `legend()`, `set()`, `set_legend()`, and `set_radii_angle()`. ### Utility and Plotting Functions - **Data Cleaning**: `clean()`, `clean_df()` - **Plotting**: `histogram()`, `plot_windrose()`, `plot_windrose_df()`, `plot_windrose_np()` - **Wrappers**: `wrbar()`, `wrbox()`, `wrcontour()`, `wrcontourf()`, `wrpdf()`, `wrscatter()` ``` -------------------------------- ### Compute Probability Density Function (PDF) for Wind Speed Source: https://python-windrose.github.io/windrose/usage-output.html Computes the probability density function for wind speed data using specified bins. Returns the axes object and parameters for a fitted Weibull distribution. Requires wind speed data (ws). ```python from windrose import WindAxes ax = WindAxes.from_ax() bins = np.arange(0, 6 + 1, 0.5) bins = bins[1:] ax, params = ax.pdf(ws, bins=bins) ``` -------------------------------- ### Generate Random Wind Data Source: https://python-windrose.github.io/windrose/usage-output.html Initializes random wind speed and direction arrays for testing purposes. ```python import numpy as np N = 500 ws = np.random.random(N) * 6 wd = np.random.random(N) * 360 ``` -------------------------------- ### windrose Classes Source: https://python-windrose.github.io/windrose/genindex.html Documentation for classes available in the windrose module. ```APIDOC ## windrose Classes ### WindAxes **Description**: Represents a wind axes object. ### WindAxesFactory **Description**: Factory class for creating WindAxes objects. #### static create() **Description**: Creates a new WindAxes instance. ### WindroseAxes **Description**: Represents a windrose axes object, inheriting from WindAxes. #### static from_ax() **Description**: Creates a WindroseAxes instance from an existing axes object. #### set() **Description**: Sets properties for the WindroseAxes. ``` -------------------------------- ### WindroseAxes Methods Source: https://python-windrose.github.io/windrose/api.html Methods available for WindroseAxes objects. ```APIDOC ## WindroseAxes Methods ### Description Methods available for WindroseAxes objects. ### Methods #### `from_ax` ```python _static _from_ax(_ax =None_, _fig =None_, _rmax =None_, _figsize =(8, 8)_, _rect =None_, _* args_, _** kwargs_) ``` Return a WindroseAxes object for the figure fig. #### `legend` ```python legend(_loc ='lower left'_, _decimal_places =1_, _units =None_, _** kwargs_) ``` Sets the legend location and her properties. ### Parameters #### `legend` Parameters - **loc** (int, string or pair of floats, default: 'lower left') - see `matplotlib.pyplot.legend`. - **decimal_places** (int, default 1) - The decimal places of the formatted legend. - **units** (str, default None) - **isaxes** (boolean, default True) - whether this is an axes legend. - **prop** (FontProperties (__size='smaller'__)) - the font property. - **borderpad** (float) - the fractional whitespace inside the legend border. - **shadow** (boolean) - if True, draw a shadow behind legend. - **labelspacing** (float, 0.005) - the vertical space between the legend entries. - **handlelenght** (float, 0.05) - the length of the legend lines. - **handletextsep** (float, 0.02) - the space between the legend line and legend text. - **borderaxespad** (float, 0.02) - the border between the axes and legend edge. - **kwarg** - Every other kwarg argument supported by `matplotlib.pyplot.legend` ``` -------------------------------- ### windrose Module Functions Source: https://python-windrose.github.io/windrose/genindex.html Documentation for functions available in the windrose module. ```APIDOC ## windrose Module Functions ### clean() **Description**: Cleans wind data. ### clean_df() **Description**: Cleans wind data from a pandas DataFrame. ### histogram() **Description**: Generates a histogram of wind data. ### plot_windrose() **Description**: Plots a windrose from raw data. ### plot_windrose_df() **Description**: Plots a windrose from a pandas DataFrame. ### plot_windrose_np() **Description**: Plots a windrose from a NumPy array. ### wrbar() **Description**: Alias for bar() method in WindroseAxes. ### wrbox() **Description**: Alias for box() method in WindroseAxes. ### wrcontour() **Description**: Alias for contour() method in WindroseAxes. ### wrcontourf() **Description**: Alias for contourf() method in WindroseAxes. ### wrpdf() **Description**: Generates a PDF plot of wind data. ### wrscatter() **Description**: Plots a scatter representation of wind data. ``` -------------------------------- ### Create Windrose Subplots per Month with Seaborn Source: https://python-windrose.github.io/windrose/usage-output.html Demonstrates creating subplots for windroses, grouped by month, using seaborn's FacetGrid. This allows for easy comparison of wind patterns across different months. Requires pandas for data manipulation. ```python import numpy as np import pandas as pd import seaborn as sns from matplotlib import pyplot as plt from windrose import WindroseAxes, plot_windrose wind_data = pd.DataFrame( { "ws": np.random.random(1200) * 6, "wd": np.random.random(1200) * 360, "month": np.repeat(range(1, 13), 100), } ) def plot_windrose_subplots(data, *, direction, var, color=None, **kwargs): """wrapper function to create subplots per axis""" ax = plt.gca() ax = WindroseAxes.from_ax(ax=ax) plot_windrose(direction_or_df=data[direction], var=data[var], ax=ax, **kwargs) # this creates the raw subplot structure with a subplot per value in month. g = sns.FacetGrid( data=wind_data, # the column name for each level a subplot should be created col="month", # place a maximum of 3 plots per row col_wrap=3, subplot_kws={"projection": "windrose"}, sharex=False, sharey=False, despine=False, height=3.5, ) g.map_dataframe( plot_windrose_subplots, direction="wd", var="ws", normed=True, # manually set bins, so they match for each subplot bins=(0.1, 1, 2, 3, 4, 5), calm_limit=0.1, kind="bar", ) # make the subplots easier to compare, by having the same y-axis range y_ticks = range(0, 17, 4) for ax in g.axes: ax.set_legend( title=r"$m \cdot s^{-1}$", bbox_to_anchor=(1.15, -0.1), loc="lower right" ) ax.set_rgrids(y_ticks, y_ticks) # adjust the spacing between the subplots to have sufficient space between plots plt.subplots_adjust(wspace=-0.2) ``` -------------------------------- ### Visualization Methods Source: https://python-windrose.github.io/windrose/api.html Methods for plotting windrose data using various styles and inputs. ```APIDOC ## windrose.plot_windrose ### Description Plot windrose from a pandas DataFrame or a numpy array. ## windrose.plot_windrose_df ### Description Plot windrose from a pandas DataFrame. ## windrose.plot_windrose_np ### Description Plot windrose from a numpy array. ## windrose.wrbar ### Description Plot a windrose in bar mode. For each var bins and for each sector, a colored bar will be drawn on the axes. ### Parameters - **direction** (1D array) - Required - Directions the wind blows from, North centred. - **var** (1D array) - Required - Values of the variable to compute. - **nsector** (integer) - Optional - Number of sectors used to compute the windrose table. ``` -------------------------------- ### wrbox - Plot Windrose in Proportional Box Mode Source: https://python-windrose.github.io/windrose/api.html Generates a windrose plot where each sector contains colored boxes proportional to the variable's bins. ```APIDOC ## POST /windrose/wrbox ### Description Plots a windrose in proportional box mode. For each variable bin and for each sector, a colored box will be drawn on the axes. ### Method POST ### Endpoint /windrose/wrbox ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **direction** (1D array) - Required - Directions the wind blows from, North centered. - **var** (1D array) - Required - Values of the variable to compute. Typically the wind speeds. - **nsector** (integer) - Optional - Number of sectors used to compute the windrose table. If not set, nsector=16, then each sector will be 360/16=22.5°, and the resulting computed table will be aligned with the cardinal points. - **sectoroffset** (float) - Optional - The offset for the sectors between [-180/nsector, 180/nsector]. By default, the offset is zero, and the first sector is [-360/nsector/2, 360/nsector/2] or [-11.25, 11.25] for nsector=16. If offset is non-zero, the first sector will be [-360/nsector + offset, 360/nsector + offset] and etc. - **bins** (1D array or integer) - Optional - Number of bins, or a sequence of bins variable. If not set, bins=6 between min(var) and max(var). - **blowto** (bool) - Optional - If True, the windrose will be pi rotated, to show where the wind blows to (useful for pollutant rose). - **colors** (string or tuple) - Optional - One string color (‘k’ or ‘black’), in this case all bins will be plotted in this color; a tuple of matplotlib color args (string, float, rgb, etc), different levels will be plotted in different colors in the order specified. - **cmap** (a cm Colormap instance from `matplotlib.cm`) - Optional - If cmap == None and colors == None, a default Colormap is used. - **edgecolor** (string) - Optional - The string color each edge box will be plotted. Default: no edgecolor. - **calm_limit** (float) - Optional - Calm limit for the var parameter. If not None, a centered red circle will be drawn for representing the calms occurrences and all data below this value will be removed from the computation. ### Request Example { "direction": [0, 45, 90, 135, 180, 225, 270, 315], "var": [5, 10, 15, 20, 25, 30, 35, 40], "nsector": 8, "bins": [0, 10, 20, 30, 40], "blowto": false, "colors": "blue", "edgecolor": "black" } ### Response #### Success Response (200) - **plot_url** (string) - URL to the generated windrose plot image. #### Response Example { "plot_url": "/plots/windrose_box_example.png" } ``` -------------------------------- ### Set Axes Properties Source: https://python-windrose.github.io/windrose/api.html Configures multiple axes properties simultaneously. ```python set(_*_ , _adjustable= _, _agg_filter= _, _alpha= _, _anchor= _, _animated= _, _aspect= _, _autoscale_on= _, _autoscalex_on= _, _autoscaley_on= _, _axes_locator= _, _axisbelow= _, _box_aspect= _, _clip_box= _, _clip_on= _, _clip_path= _, _facecolor= _, _forward_navigation_events= _, _frame_on= _, _gid= _, _in_layout= _, _label= _, _mouseover= _, _navigate= _, _path_effects= _, _picker= _, _position= _, _prop_cycle= _, _rasterization_zorder= _, _rasterized= _, _sketch_params= _, _snap= _, _subplotspec= _, _title= _, _transform= _, _url= _, _visible= _, _xbound= _, _xlabel= _, _xlim= _, _xmargin= _, _xscale= _, _xticklabels= _, _xticks= _, _ybound= _, _ylabel= _, _ylim= _, _ymargin= _, _yscale= _, _yticklabels= _, _yticks= _, _zorder= _) ``` -------------------------------- ### Create a Windrose Plot with Contour Source: https://python-windrose.github.io/windrose/usage-output.html Initializes a WindroseAxes object and plots wind data with contour lines. Requires wind direction (wd) and wind speed (ws) data, and matplotlib colormaps. ```python ax = WindroseAxes.from_ax() ax.contour(wd, ws, bins=np.arange(0, 8, 1), cmap=cm.hot, lw=3) ax.set_legend() ``` -------------------------------- ### POST /windrose/wrscatter Source: https://python-windrose.github.io/windrose/api.html Draws a scatter plot of wind direction versus wind speed. ```APIDOC ## POST /windrose/wrscatter ### Description Draws a scatter plot of wind direction versus wind speed. ### Method POST ### Endpoint /windrose/wrscatter ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **direction** (1D array) - Required - Directions the wind blows from, North centered. - **var** (1D array) - Required - Values of the variable to compute. Typically the wind speeds. - **ax** (matplotlib axes object) - Optional - Axes to plot on. - **rmax** (float) - Optional - Maximum radius for the plot. - **figsize** (tuple) - Optional - Figure size (width, height). - **args** - Optional - Additional arguments for plotting. - **kwargs** - Optional - Additional keyword arguments for plotting. ### Request Example { "direction": [45, 135, 225, 315], "var": [5, 10, 15, 20] } ### Response #### Success Response (200) - **None** - This function plots directly to the provided or created axes and does not return a specific JSON response body. #### Response Example None ``` -------------------------------- ### POST /windrose/wrcontourf Source: https://python-windrose.github.io/windrose/api.html Plots a windrose in filled mode. For each variable bin, a line is drawn on the axes, a segment between each sector (center to center). Each line can be formatted (color, width, etc.) like with standard plot pylab commands. ```APIDOC ## POST /windrose/wrcontourf ### Description Plots a windrose in filled mode. For each variable bin, a line is drawn on the axes, a segment between each sector (center to center). Each line can be formatted (color, width, …) like with standard plot pylab command. ### Method POST ### Endpoint /windrose/wrcontourf ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **direction** (1D array) - Required - Directions the wind blows from, North centered - **var** (1D array) - Required - Values of the variable to compute. Typically the wind speeds - **nsector** (integer) - Optional - Number of sectors used to compute the windrose table. If not set, nsector=16, then each sector will be 360/16=22.5°, and the resulting computed table will be aligned with the cardinals points. - **bins** (1D array or integer) - Optional - Number of bins, or a sequence of bins variable. If not set, bins=6, then bins=linspace(min(var), max(var), 6) - **blowto** (bool) - Optional - If True, the windrose will be pi rotated, to show where the wind blow to (useful for pollutant rose). - **colors** (string or tuple) - Optional - One string color (‘k’ or ‘black’), in this case all bins will be plotted in this color; a tuple of matplotlib color args (string, float, rgb, etc), different levels will be plotted in different colors in the order specified. - **cmap** (a cm Colormap instance from `matplotlib.cm`) - Optional - If cmap == None and colors == None, a default Colormap is used. - **calm_limit** (float) - Optional - Calm limit for the var parameter. If not None, a centered red circle will be draw for representing the calms occurrences and all data below this value will be removed from the computation. - **ax** (matplotlib axes object) - Optional - Axes to plot on. - **rmax** (float) - Optional - Maximum radius for the plot. - **figsize** (tuple) - Optional - Figure size (width, height). - **kwargs** (others) - Optional - Any supported argument of `matplotlib.pyplot.plot` ### Request Example { "direction": [0, 90, 180, 270], "var": [10, 15, 20, 25], "nsector": 8, "bins": [0, 10, 20, 30], "colors": "blue" } ### Response #### Success Response (200) - **None** - This function plots directly to the provided or created axes and does not return a specific JSON response body. #### Response Example None ``` -------------------------------- ### Plotting Windrose with Pandas DataFrame Source: https://python-windrose.github.io/windrose/usage-output.html Demonstrates creating a windrose plot using a Pandas DataFrame with speed and direction columns. ```python import pandas as pd N = 500 ws = np.random.random(N) * 6 wd = np.random.random(N) * 360 df = pd.DataFrame({"speed": ws, "direction": wd}) plot_windrose(df, kind="contour", bins=np.arange(0, 8, 1), cmap=cm.hot, lw=3) ``` -------------------------------- ### Plot Probability Density Function Source: https://python-windrose.github.io/windrose/api.html Draws a PDF and returns Weibull distribution parameters. ```python pdf(_var_ , _bins =None_, _Nx =100_, _bar_color ='b'_, _plot_color ='g'_, _Nbins =10_, _* args_, _** kwargs_) ``` -------------------------------- ### windrose.WindroseAxes Attributes Source: https://python-windrose.github.io/windrose/genindex.html Documentation for attributes of the WindroseAxes class. ```APIDOC ## windrose.WindroseAxes Attributes ### name **Description**: The name of the windrose axes. ``` -------------------------------- ### Create a Stacked Histogram Source: https://python-windrose.github.io/windrose/usage-output.html Generates a normed stacked histogram plot of wind data. ```python from windrose import WindroseAxes ax = WindroseAxes.from_ax() ax.bar(wd, ws, normed=True, opening=0.8, edgecolor="white") ax.set_legend() ``` -------------------------------- ### Plotting a Windrose in Box Mode Source: https://python-windrose.github.io/windrose/api.html The `box` function plots a windrose in proportional box mode. For each variable bin and each sector, a colored box is drawn on the axes. ```APIDOC ## POST /api/windrose/box ### Description Plots a windrose in proportional box mode. For each variable bin and for each sector, a colored box will be drawn on the axes. ### Method POST ### Endpoint /api/windrose/box ### Parameters #### Path Parameters None #### Query Parameters - **nsector** (integer, optional) - Number of sectors used to compute the windrose table. Defaults to 16. - **sectoroffset** (float, optional) - The offset for the sectors. Defaults to 0. - **bins** (1D array or integer, optional) - Number of bins, or a sequence of bins variable. Defaults to 6 between min(var) and max(var). - **blowto** (bool, optional) - If True, the windrose will be pi rotated to show where the wind blows to. - **colors** (string or tuple, optional) - Color for all bins or a tuple of colors for different levels. - **cmap** (matplotlib.cm.Colormap instance, optional) - Colormap to use if colors is None. - **edgecolor** (string, optional) - The color for each edge box. Defaults to no edgecolor. - **calm_limit** (float, optional) - Calm limit for the var parameter. If not None, a centered red circle will be drawn for calms, and data below this value will be removed. #### Request Body - **direction** (1D array) - Required - Directions the wind blows from, North centered. - **var** (1D array) - Required - Values of the variable to compute (e.g., wind speeds). ### Request Example ```json { "direction": [0, 90, 180, 270], "var": [10, 15, 5, 20], "nsector": 8, "bins": [0, 10, 20], "colors": "blue" } ``` ### Response #### Success Response (200) - **plot_url** (string) - URL to the generated windrose plot. #### Response Example ```json { "plot_url": "/plots/windrose_box_12345.png" } ``` ``` -------------------------------- ### Windrose Computation Parameters Source: https://python-windrose.github.io/windrose/api.html Parameters used for computing the windrose table. ```APIDOC ## Windrose Computation Parameters ### Description Parameters used for computing the windrose table. ### Parameters #### Input Variables - **var** (1D array) - Values of the variable to compute. Typically the wind speeds. - **nsector** (integer, optional) - Number of sectors used to compute the windrose table. If not set, nsector=16, then each sector will be 360/16=22.5°, and the resulting computed table will be aligned with the cardinals points. - **bins** (1D array or integer, optional) - Number of bins, or a sequence of bins variable. If not set, bins=6, then bins=linspace(min(var), max(var), 6). - **blowto** (bool, optional) - If True, the windrose will be pi rotated, to show where the wind blow to (useful for pollutant rose). - **colors** (string or tuple, optional) - One string color ('k' or 'black'), in this case all bins will be plotted in this color; a tuple of matplotlib color args (string, float, rgb, etc), different levels will be plotted in different colors in the order specified. - **cmap** (a cm Colormap instance from `matplotlib.cm`, optional) - If cmap == None and colors == None, a default Colormap is used. - **calm_limit** (float, optional) - Calm limit for the var parameter. If not None, a centered red circle will be draw for representing the calms occurrences and all data below this value will be removed from the computation. - **kwargs** (others) - Any supported argument of `matplotlib.pyplot.plot` ``` -------------------------------- ### Download Warning for Cartopy Source: https://python-windrose.github.io/windrose/usage-output.html This is a download warning message from the cartopy library, indicating that it is downloading coastline data. It does not require code modification but informs about data fetching. ```python /home/runner/micromamba/envs/TEST/lib/python3.13/site-packages/cartopy/io/__init__.py:242: DownloadWarning: Downloading: https://naturalearth.s3.amazonaws.com/10m_physical/ne_10m_coastline.zip warnings.warn(f'Downloading: {url}', DownloadWarning) ``` -------------------------------- ### wrcontour - Plot Windrose in Linear Mode Source: https://python-windrose.github.io/windrose/api.html Generates a windrose plot in linear mode, drawing lines between sectors based on variable bins. ```APIDOC ## POST /windrose/wrcontour ### Description Plots a windrose in linear mode. For each variable bin, a line will be drawn on the axes, a segment between each sector (center to center). Each line can be formatted (color, width, …) like with standard plot pylab command. ### Method POST ### Endpoint /windrose/wrcontour ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **direction** (1D array) - Required - Directions the wind blows from, North centered. - **var** (1D array) - Required - Values of the variable to compute. Typically the wind speeds. - **nsector** (integer) - Optional - Number of sectors used to compute the windrose table. If not set, nsector=16, then each sector will be 360/16=22.5°, and the resulting computed table will be aligned with the cardinal points. - **bins** (1D array or integer) - Optional - Number of bins, or a sequence of bins variable. If not set, bins=6, then bins=linspace(min(var), max(var), 6). - **blowto** (bool) - Optional - If True, the windrose will be pi rotated, to show where the wind blows to (useful for pollutant rose). - **colors** (string or tuple) - Optional - One string color (‘k’ or ‘black’), in this case all bins will be plotted in this color; a tuple of matplotlib color args (string, float, rgb, etc), different levels will be plotted in different colors in the order specified. ### Request Example { "direction": [0, 45, 90, 135, 180, 225, 270, 315], "var": [5, 10, 15, 20, 25, 30, 35, 40], "nsector": 8, "bins": [0, 10, 20, 30, 40], "blowto": false, "colors": ["red", "green", "blue"] } ### Response #### Success Response (200) - **plot_url** (string) - URL to the generated windrose plot image. #### Response Example { "plot_url": "/plots/windrose_contour_example.png" } ``` -------------------------------- ### Histogram Calculation Source: https://python-windrose.github.io/windrose/api.html Method to compute the frequency distribution of wind data across sectors. ```APIDOC ## windrose.histogram ### Description Returns an array where, for each sector of wind, we have the number of times the wind comes with a particular variable value. ### Parameters - **direction** (1D array) - Required - Directions the wind blows from, North centred. - **var** (1D array) - Required - Values of the variable to compute. - **bins** (list) - Required - List of var category against which we compute the table. - **nsector** (integer) - Required - Number of sectors. - **normed** (boolean) - Optional - The resulting table is normed in percent or not (default False). - **blowto** (boolean) - Optional - If true, the table will be reversed (default False). ``` -------------------------------- ### Create a Box Plot Source: https://python-windrose.github.io/windrose/usage-output.html Generates a non-normed box plot representation with specified bin limits. ```python ax = WindroseAxes.from_ax() ax.box(wd, ws, bins=np.arange(0, 8, 1)) ax.set_legend() ``` -------------------------------- ### Windrose Plotting API Source: https://python-windrose.github.io/windrose/api.html This section details the methods available for creating and customizing windrose plots using the Windrose library. ```APIDOC ## Windrose Plotting API This API provides functionalities to create and customize windrose plots. ### Classes * **`WindAxes`**: Represents a windrose axes object for plotting. * **`WindAxesFactory`**: A factory class for creating `WindAxes` or `WindAxes` instances. ### Methods #### `WindAxes.pdf(var, bins=None, Nx=100, bar_color='b', plot_color='g', Nbins=10, *args, **kwargs)` **Description**: Draws a probability density function and returns Weibull distribution parameters. **Parameters**: * **var** (1D array) - The variable to compute the probability density function from. * **bins** (1D array or integer, optional) - Number of bins or a sequence of bin edges. Defaults to 6 bins between min(var) and max(var). * **Nx** (integer, optional) - Number of points for the PDF curve. Defaults to 100. * **bar_color** (string, optional) - Color for the bars in the plot. Defaults to 'b'. * **plot_color** (string, optional) - Color for the PDF curve. Defaults to 'g'. * **Nbins** (integer, optional) - Number of sectors for the windrose. Defaults to 10. #### `WindAxes.set(*args, **kwargs)` **Description**: Sets multiple properties of the axes at once. **Supported Properties**: * `adjustable`: {'box', 'datalim'} * `agg_filter`: a filter function * `alpha`: float or None * `anchor`: (float, float) or {'C', 'SW', ...} * `animated`: bool * `aspect`: {'auto', 'equal'} or float * `autoscale_on`: bool * `autoscalex_on`: unknown * `autoscaley_on`: unknown * `axes_locator`: Callable[[Axes, Renderer], Bbox] * `axisbelow`: bool or 'line' * `box_aspect`: float or None * `clip_box`: BboxBase or None * `clip_on`: bool * `clip_path`: Patch or (Path, Transform) or None * `facecolor` or `fc`: :mpltype:`color` * `figure`: Figure or SubFigure * `forward_navigation_events`: bool or "auto" * `frame_on`: bool * `gid`: str * `in_layout`: bool * `label`: object * `mouseover`: bool * `navigate`: bool * `navigate_mode`: unknown * `path_effects`: list of .AbstractPathEffect * `picker`: None or bool or float or callable * `position`: [left, bottom, width, height] or Bbox * `prop_cycle`: cycler.Cycler * `rasterization_zorder`: float or None * `rasterized`: bool * `sketch_params`: (scale: float, length: float, randomness: float) * `snap`: bool or None * `subplotspec`: unknown * `title`: str * `transform`: Transform * `url`: str * `visible`: bool * `xbound`: (lower: float, upper: float) * `xlabel`: str * `xlim`: (left: float, right: float) * `xmargin`: float greater than -0.5 * `xscale`: unknown * `xticklabels`: unknown * `xticks`: unknown * `ybound`: (lower: float, upper: float) * `ylabel`: str * `ylim`: (bottom: float, top: float) * `ymargin`: float greater than -0.5 * `yscale`: unknown * `yticklabels`: unknown * `yticks`: unknown * `zorder`: float #### `WindroseAxes.bar(direction, var, **kwargs)` **Description**: Plots a windrose in bar mode. For each variable bin and for each sector, a colored bar will be drawn on the axes. **Parameters**: * **direction** (1D array) - Directions the wind blows from, North centered. * **var** (1D array) - Values of the variable to compute. Typically the wind speeds. * **nsector** (integer, optional) - Number of sectors used to compute the windrose table. If not set, nsector=16, then each sector will be 360/16=22.5°, and the resulting computed table will be aligned with the cardinal points. * **sectoroffset** (float, optional) - The offset for the sectors between [-180/nsector, 180/nsector]. By default, the offset is zero, and the first sector is [-360/nsector/2, 360/nsector/2] or [-11.25, 11.25] for nsector=16. If offset is non-zero, the first sector will be [-360/nsector + offset, 360/nsector + offset] and etc. * **bins** (1D array or integer, optional) - Number of bins, or a sequence of bins variable. If not set, bins=6 between min(var) and max(var). * **blowto** (bool, optional) - If True, the windrose will be pi rotated, to show where the wind blows to (useful for pollutant rose). ### Factory Methods #### `WindAxesFactory.create(typ, ax=None, *args, **kwargs)` **Description**: Creates a `WindroseAxes` or `WindAxes` instance. **Parameters**: * **typ** (string) - Type of axes to create. Must be either 'windroseaxes' or 'windaxes'. * 'windroseaxes': Creates a `WindroseAxes` object. * 'windaxes': Creates a `WindAxes` object. * **ax** (matplotlib.Axes, optional) - An existing Matplotlib Axes object to draw the windrose on. If None, a new Axes object will be created. ``` -------------------------------- ### Windrose Properties Source: https://python-windrose.github.io/windrose/api.html Properties that can be set for a windrose object. ```APIDOC ## Windrose Properties ### Description Properties that can be set for a windrose object. ### Method ```python set(_*_, _adjustable= _, _agg_filter= _, _alpha= _, _anchor= _, _animated= _, _aspect= _, _autoscale_on= _, _autoscalex_on= _, _autoscaley_on= _, _axes_locator= _, _axisbelow= _, _box_aspect= _, _clip_box= _, _clip_on= _, _clip_path= _, _facecolor= _, _forward_navigation_events= _, _frame_on= _, _gid= _, _in_layout= _, _label= _, _legend= _, _mouseover= _, _navigate= _, _path_effects= _, _picker= _, _position= _, _prop_cycle= _, _radii_angle= _, _rasterization_zorder= _, _rasterized= _, _rgrids= _, _rlabel_position= _, _rlim= _, _rmax= _, _rmin= _, _rorigin= _, _rscale= _, _rticks= _, _sketch_params= _, _snap= _, _subplotspec= _, _theta_direction= _, _theta_offset= _, _theta_zero_location= _, _thetagrids= _, _thetalim= _, _thetamax= _, _thetamin= _, _title= _, _transform= _, _url= _, _visible= _, _xbound= _, _xlabel= _, _xlim= _, _xmargin= _, _xscale= _, _xticklabels= _, _xticks= _, _ybound= _, _ylabel= _, _ylim= _, _ymargin= _, _yscale= _, _yticklabels= _, _yticks= _, _zorder= _) ``` Set multiple properties at once. Supported properties are: ### Properties (List of supported properties would go here if provided in the source text) ```