csep.plots.plot_Molchan_diagram
- csep.plots.plot_Molchan_diagram(forecast, catalog, linear=True, plot_uniform=True, ax=None, show=True, **kwargs)[source]
Plot the Molchan Diagram based on forecast and test catalogs using the contingency table. The Area Skill score and its error are shown in the legend.
The Molchan diagram is computed following this procedure:
Obtain spatial rates from the GriddedForecast and the observed events from the catalog.
Rank the rates in descending order (highest rates first).
Sort forecasted rates by ordering found in (2), and normalize rates so their sum is equal to unity.
Obtain binned spatial rates from the observed catalog.
Sort gridded observed rates by ordering found in (2).
Test each ordered and normalized forecasted rate defined in (3) as a threshold value to obtain the corresponding contingency table.
Define the “nu” (Miss rate) and “tau” (Fraction of spatial alarmed cells) for each threshold using the information provided by the corresponding contingency table defined in (6).
Note: 1. The testing catalog and forecast should have exactly the same time-window (duration). 2. Forecasts should be defined over the same region. 3. If calling this function multiple times, update the color in the arguments. 4. The user can choose the x-scale (linear or log).
Usage Tutorials
- Parameters:
forecast (GriddedForecast) – The forecast object.
catalog (CSEPCatalog) – The evaluation catalog.
linear (bool, optional) – If True, a linear x-axis is used; if False, a logarithmic x-axis is used. Defaults to True.
plot_uniform (bool, optional) – If True, include a uniform forecast on the plot. Defaults to True.
show (bool, optional) – If True, displays the plot. Defaults to True.
ax (matplotlib.axes.Axes, optional) – Axes object to plot on. If None, creates a new figure. Defaults to None.
**kwargs (optional) –
Additional keyword arguments for customization:
figsize (tuple): The size of the figure.
forecast_label (str): Label for the forecast data in the plot.
color (str): Color for the Molchan diagram line.
linestyle (str): Line style for the Molchan diagram line.
xlabel (str): Label for the X-axis.
xlabel_fontsize (int): Font size for the X-axis label.
ylabel (str): Label for the Y-axis.
ylabel_fontsize (int): Font size for the Y-axis label.
legend_loc (str): Location of the legend. Defaults to ‘best’.
legend_fontsize (int): Font size of the legend text.
tight_layout (bool): Whether to use tight layout for the figure. Defaults to True.
- Returns:
The Axes object with the plot.
- Return type:
- Raises:
RuntimeError – If the catalog and forecast do not have the same region.