Skip to content

Proposal: split up pvlib/ivtools/sdm.py #2252

Closed

Description

@kandersolar

pvlib/ivtools/sdm.py is currently rather lengthy at ~1350 lines of code. Near-term additions (#2212 and #2185) will bring it to ~2000. I suggest we split up sdm.py into submodules, similar to what was recently done in pvlib.spectrum (#2125).

Current and future functionality spans:

  • estimating parameter values for various SDMs using various data sources
  • converting parameter values from one SDM to another (WIP: Convert between CEC and PVsyst single diode models #2212)
  • calculating derived values (PVsyst temp coeff)
  • calculating SDE parameters (if we move the calcparams_XX functions here)

How should it be split up? As a starting point, one idea is to organize the parameter fitting functions according to the data source:

This division has the advantage of keeping fit_pvsyst_sandia and fit_desoto_sandia together, which is nice because they share a lot of code.

Questions:

  • Should the calcparams_XX functions be moved to pvlib.ivtools.sdm?
  • Does this division accommodate future functionality additions?

Activity

  1. echedey-ls commented on Oct 10, 2024

    @echedey-ls
    Member

    I love that idea.
    Can we drop the first underscore in filenames suggestions? Users importing from file namespace (instead of submodule through __init__.py) may think these are private files (weak internal use in PEP-8. Source.)

    Should the calcparams_XX functions be moved to pvlib.ivtools.sdm?
    Given they are currently in pvlib.pvsystem, +1. But probably in a separate PR, or at least be extra careful with deprecations.

  2. cwhanse commented on Oct 10, 2024

    @cwhanse
    Member

    Imagining myself as a user, it seems more natural to first look for a function that fit a specific model (e.g. CEC) and then filter by the kind of data available (IEC61853 or datasheet), which suggests ivtools.sdm.cec. As you point out, though, that pattern would require importing (from somewhere) a number of private/supporting functions that are used by both of the sandia methods.

  3. kandersolar commented on Oct 10, 2024

    @kandersolar
    MemberAuthor

    I was imagining that the user experience would not change; all functions would still be accessed and documented via pvlib.ivtools.sdm.<function_name>. Users need not even know about the underlying modules. Rather, the effect of the reorganization would be to improve the developer experience.

  4. kandersolar commented on Oct 11, 2024

    @kandersolar
    MemberAuthor

    After more thought, I am warming to the idea of organizing by model. I will open a PR for consideration.

  5. added this to the v0.11.2 milestone on Oct 15, 2024
  6. modified the milestones: v0.11.2, on Dec 10, 2024
  7. modified the milestones: , v0.11.4 on Mar 14, 2025
  8. modified the milestones: v0.12.1, v0.13.0 on Jun 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions