bsrn.visualization.separation.plot_k_vs_kt#

bsrn.visualization.separation.plot_k_vs_kt(df, models, lat, lon, ghi_col='ghi', dhi_col='dhi', k_mod_cols=None, output_file=None, title=None)[source]#

Faceted scatter plot of k (diffuse fraction) vs kt (clearness index) from a DataFrame. 根据 DataFrame 绘制 k vs kt 散点图,按模型分面。

One panel per model; measured (gray) and model (colored) in each panel. 每个模型一个面板;各面板内为实测(灰)与模型(着色)点。

Parameters:
  • df (pd.DataFrame) – Input data with DatetimeIndex and at least ghi_col and dhi_col. 输入数据,需含 DatetimeIndex 及 ghi、dhi 列。

  • models (sequence of str) – Model names to plot, e.g. ('erbs', 'brl'). Each in SUPPORTED_SEPARATION_MODELS. 要绘制的模型名,如 ('erbs', 'brl')

  • lat (float) – Latitude. [degrees] 纬度。[度]

  • lon (float) – Longitude. [degrees] 经度。[度]

  • ghi_col (str, default "ghi") – Column name for GHI. GHI 列名。

  • dhi_col (str, default "dhi") – Column name for DHI. DHI 列名。

  • k_mod_cols (dict or None, optional) – Map model name to column name for model k. If None, runs each separation model. For engerer2 and yang4, k must be pre-computed and provided here (both need clear-sky GHI). 模型名到 k 列名的映射。engerer2、yang4 的 k 须预先计算并通过此处传入。

  • output_file (str, optional) – Path to save the figure. 保存路径。

  • title (str, optional) – Overall plot title. 图标题。

Notes

To include Engerer2 or Yang4 (both require clear-sky GHI): add clear-sky GHI to df (e.g. bsrn.physics.clearsky.add_clearsky_columns()), run the separation with ghi_clear=df["ghi_clear"].values, assign the result’s "k" to a column, then pass k_mod_cols={"engerer2": "k_engerer2", "yang4": "k_yang4"}. 要绘制 Engerer2/Yang4: 先在 df 中加入晴空 GHI,调用对应 separation(…, ghi_clear=…),将 k 写入列再通过 k_mod_cols 传入。

Returns:

p – The ggplot object. If output_file was set, this is a new instance (the one used for saving is not safe to draw again after plt.close). 若传了 output_file,返回的是**新**构建的对象(保存用的对象在 close 后不宜再次 draw)。

Return type:

plotnine.ggplot