Skip to content

Split OND extraction, handle missing OND data, detect .pan/.ond encoding - #7

Open
dihannahdi wants to merge 2 commits into
cwhanse:ond_parserfrom
dihannahdi:ond-parser-updates
Open

dihannahdi wants to merge 2 commits into
cwhanse:ond_parserfrom
dihannahdi:ond-parser-updates

Conversation

@dihannahdi

Copy link
Copy Markdown

As you asked in pvlib#1888, this targets your ond_parser branch so the diff shows only my changes. It sits directly on your branch (no merge of main), so it keeps the old pvlib/tests layout.

Extraction split. extract_inverter_characteristics(content) now does the extraction, as adriesse suggested. It returns a dict whose keys match the arguments of fit_sandia, and ond_to_sandia_inv becomes fit_sandia(**extract_inverter_characteristics(content)). Your logic is unchanged: the unit multiplier applies to PNomConv, the curve points are used as they are, and the trailing empty VNomEff entry is dropped.

Missing data. Following ErlingxIFE's finding that many OND files are incomplete, missing Night_Loss, PNomConv or UnitAffEnum, VNomEff, or any of the ProfilPIOV1-3 curves or points now raise a ValueError that lists the missing keys, instead of a KeyError. A VNomEff without three voltages, or a UnitAffEnum other than kW or W, also raises. No defaults are filled in.

Encoding in read_panond. This answers the "should read_panond default to UTF-8" question. With encoding=None the 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 explicit encoding behaves as before. Your test no longer needs encoding='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 to tests/; 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.py and pvlib/tests/iotools/test_panond.py pass (39 tests), and flake8 is clean on the diff.

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.
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.

1 participant