Repository navigation
Split OND extraction, handle missing OND data, detect .pan/.ond encoding - #7
Open
dihannahdi wants to merge 2 commits into
Open
dihannahdi wants to merge 2 commits into
dihannahdi wants to merge 2 commits into
Conversation
With encoding=None, read the file as bytes and decode it as UTF-8 if it starts with a byte order mark or is valid UTF-8, otherwise as Windows-1252. PVsyst has written UTF-8 since version 6.80; older files and some files from manufacturers are Windows-1252. An explicit encoding behaves as before.
ond_to_sandia_inv is now fit_sandia(**extract_inverter_characteristics(content)), so the extracted curves and ratings can feed other inverter models too. Missing OND data (night loss, rated power or its unit, VNomEff, any of the three efficiency curves or their points) raises a ValueError that lists the missing keys. No default values are substituted.
This was referenced Nov 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As you asked in pvlib#1888, this targets your
ond_parserbranch so the diff shows only my changes. It sits directly on your branch (no merge ofmain), so it keeps the oldpvlib/testslayout.Extraction split.
extract_inverter_characteristics(content)now does the extraction, as adriesse suggested. It returns a dict whose keys match the arguments offit_sandia, andond_to_sandia_invbecomesfit_sandia(**extract_inverter_characteristics(content)). Your logic is unchanged: the unit multiplier applies toPNomConv, the curve points are used as they are, and the trailing emptyVNomEffentry is dropped.Missing data. Following ErlingxIFE's finding that many OND files are incomplete, missing
Night_Loss,PNomConvorUnitAffEnum,VNomEff, or any of theProfilPIOV1-3curves or points now raise aValueErrorthat lists the missing keys, instead of aKeyError. AVNomEffwithout three voltages, or aUnitAffEnumother thankWorW, also raises. No defaults are filled in.Encoding in
read_panond. This answers the "should read_panond default to UTF-8" question. Withencoding=Nonethe file is read as bytes and decoded as UTF-8 (with or without a BOM), falling back to Windows-1252. PVsyst has written UTF-8 since 6.80, while older and some manufacturer files are cp1252. An explicitencodingbehaves as before. Your test no longer needsencoding='utf-8-sig'.Docs. Both functions are added to the API reference. I left out a whatsnew entry because this branch predates the current whatsnew files. Once the branch is brought up to
main, I can add the entry and move the tests totests/; that version is already done in pvlib#2959, which I'll close in favour of this.Tested on this branch with Python 3.12, numpy 1.26 and pandas 2.1 (the branch predates numpy 2).
pvlib/tests/test_inverter.pyandpvlib/tests/iotools/test_panond.pypass (39 tests), and flake8 is clean on the diff.