Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[BUG]: modelchain fills nan with 0

未关闭
#2,823 8 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
54/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
pandas, python
领域
data

调研方向

Start in pvlib/modelchain.py at the two fillna(0) calls linked in the issue (around lines 668 and 769), then read the related tests to understand their intended behavior. Reproduce the reported case and check whether those calls replace NaNs in the AC results; done means NaNs are preserved without breaking existing ModelChain tests.

由索引模型根据 Issue 内容生成。

描述

Describe the bug

We fillna(0) twice in modelchain.py
https://github.com/pvlib/pvlib-python/blob/9a0ad5504d821a81ec2a4531b40034794c6c42bd/pvlib/modelchain.py#L769
https://github.com/pvlib/pvlib-python/blob/9a0ad5504d821a81ec2a4531b40034794c6c42bd/pvlib/modelchain.py#L668

I can open a PR deleting these lines, which would make more sense to me, unless there was a specific reason to do so ?

To Reproduce

def calculate_pv_system_production(
    pv_system: SimplifiedPVSystem, solar_inputs: SolarInputs
) -> np.ndarray:
    """
    Returns AC power output in kW using the PVWatts model.
    """
    # 1. Location
    location = pvlib.location.Location(
        latitude=pv_system.coordinates.latitude,
        longitude=pv_system.coordinates.longitude,
        tz=str(pv_system.timezone),
        altitude=pv_system.coordinates.altitude,
    )

    # 2. System
    system = pvlib.pvsystem.PVSystem(  # todo review all of these parameters with dict
        surface_tilt=pv_system.surface_tilt,
        surface_azimuth=pv_system.surface_azimuth,
        module_parameters={
            "pdc0": pv_system.solar_power_kwp * 1000,  # W peak DC
            "gamma_pdc": pv_system.temp_coefficient,
        },
        inverter_parameters={
            "pdc0": pv_system.solar_power_kwp * 1000,
            "eta_inv_nom": pv_system.inverter_efficiency,
        },
        temperature_model_parameters=pvlib.temperature.TEMPERATURE_MODEL_PARAMETERS[
            "sapm"
        ]["open_rack_glass_glass"],
    )

    # 3. ModelChain
    mc = pvlib.modelchain.ModelChain(
        system,
        location,
        dc_model="pvwatts",
        ac_model="pvwatts",
        aoi_model="physical",
        spectral_model="no_loss",
        losses_model="pvwatts",
    )

    # 4. Run model — pvlib computes sun position internally from location + times
    weather_data = {
        "dni": solar_inputs.dni_wm2,
        "dhi": solar_inputs.dhi_wm2,
        "ghi": solar_inputs.ghi_wm2,
    }
    if solar_inputs.outdoor_air_temp_c is not None:
        weather_data["temp_air"] = solar_inputs.outdoor_air_temp_c

    solar_inputs_pvlib_format = pd.DataFrame(
        index=solar_inputs.ts,
        data=weather_data,
    )

    mc.run_model(solar_inputs_pvlib_format)

    # 5. Return AC power in kW
    return (mc.results.ac / 1000).to_numpy()

Expected behavior
Don't fill NaNs with 0, keep NaNs

Screenshots
This
Image
Becomes

Image

Versions:

  • pvlib.__version__: 0.15.2
  • pandas.__version__:
  • python: 3.10
主要语言
Python
星标
1.7k
派生
1.2k
平均合并
3 天 18 小时
30 天内合并 PR
13

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

pvlib/pvlib-python 的其他 Issue

查看 pvlib/pvlib-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。