Skip to content

Add OND to Sandia inverter translator, split extraction, and detect .pan/.ond encoding - #2959

Closed
dihannahdi wants to merge 9 commits into
pvlib:mainfrom
dihannahdi:ond-sandia-translator
Closed

dihannahdi wants to merge 9 commits into
pvlib:mainfrom
dihannahdi:ond-sandia-translator

Conversation

@dihannahdi

@dihannahdi dihannahdi commented Nov 23, 2026 •

Copy link
Copy Markdown
  • Continues add translator for OND files #1888
  • I am familiar with the contributing guidelines
  • I attest that all AI-generated material has been vetted for accuracy and is in compliance with the pvlib license
  • Tests added
  • Updates entries in docs/sphinx/source/reference for API changes.
  • Adds description and name entries in the appropriate "what's new" file in docs/sphinx/source/whatsnew for all changes. Includes link to the GitHub Issue with :issue:`num` or this Pull Request with :pull:`num`. Includes contributor name and/or GitHub username (link with :ghuser:`user`).
  • New code is fully documented. Includes numpydoc compliant docstrings, examples, and comments where necessary.
  • Pull request is nearly complete and ready for detailed review.
  • Maintainer: Appropriate GitHub Labels (including remote-data) and Milestone are assigned to the Pull Request and linked Issue.

This continues #1888 by @cwhanse, which adds inverter.ond_to_sandia_inv to fit Sandia inverter parameters from a PVsyst OND file. His two commits are kept as they were, rebased onto current main. A separate commit moves the Huawei OND test file to tests/data/ and points the test at it, since the tests now live in tests/.

Separate extraction function (@adriesse). The data extraction is now inverter.extract_inverter_characteristics(content). It returns a dict with ac_power, dc_power, dc_voltage, dc_voltage_level, p_ac_0 and p_nt, which are the arguments of fit_sandia, so it can also feed other inverter models. ond_to_sandia_inv is now fit_sandia(**extract_inverter_characteristics(content)). I read "extract_inverter_characteristics" as the name and the dict as the return form; happy to change either.

Missing data (@ErlingxIFE). If the OND content lacks night-time loss (Night_Loss), the rated power or its unit, VNomEff, or any of the three ProfilPIOV efficiency curves or their points, extract_inverter_characteristics raises a ValueError that lists the missing OND keys. No default values are substituted. A VNomEff that does not hold three voltages and an unsupported UnitAffEnum also raise ValueError. These cases are tested with modified copies of the test file written to tmp_path.

Encoding in read_panond. The signature is unchanged. When encoding is not given, the file is read as bytes and decoded as UTF-8 if it starts with a BOM (utf-8-sig) or is valid UTF-8, and as Windows-1252 otherwise. If neither works, a ValueError suggests passing encoding. Previously the platform's default encoding was used, so the same file could parse differently depending on the OS locale. This follows the discussion in #1888: PVsyst has written UTF-8 since version 6.80 (many files with a BOM), while older and some manufacturer files are Windows-1252. An explicit encoding behaves as before, and the decoded text goes through the existing parser.

Tested. tests/test_inverter.py and tests/iotools/test_panond.py pass (Python 3.14, pandas 3.1, numpy 2.5). New tests cover the Huawei reference values, the extracted arrays, each missing-data case, a fit of the CPS OND file already in tests/data (finite parameters, Paco equal to PMaxOUT in W), and the BOM, UTF-8 without BOM, cp1252 (byte 0xB0), explicit-encoding and undecodable cases. flake8 5.0.4 on the diff, run as in CI, is clean.

Notes for review: the translator keeps the name ond_to_sandia_inv, which differs from the fit_<model> pattern in the module docstring. The unit handling treats UnitAffEnum=kW as 1000 W and W as 1; I have only seen kW files.

cwhanse and others added 8 commits November 23, 2026 21:53
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…OND data

Split the data extraction out of ond_to_sandia_inv so the characteristics
can be used to fit other inverter models. Raise a ValueError naming the
missing OND keys instead of failing with a KeyError.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When encoding is not given, use UTF-8 if the file has a byte order mark
or is valid UTF-8, and Windows-1252 otherwise, instead of the platform
default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

Hey @dihannahdi! 🎉

Thanks for opening your first pull request! We appreciate your
contribution. Please ensure you have reviewed and understood the
contributing guidelines.

If AI is used for any portion of this PR, you must vet the content
for technical accuracy.

Finally, be sure the PR description includes the PR
checklist,
and complete the items you are able to.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@dihannahdi

Copy link
Copy Markdown
Author

Moved to cwhanse#7 as requested in #1888.

@dihannahdi dihannahdi closed this Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants