Repository navigation
Add OND to Sandia inverter translator, split extraction, and detect .pan/.ond encoding - #2959
Closed
dihannahdi wants to merge 9 commits into
Closed
dihannahdi wants to merge 9 commits into
dihannahdi wants to merge 9 commits into
Conversation
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>
Hey @dihannahdi! 🎉Thanks for opening your first pull request! We appreciate your If AI is used for any portion of this PR, you must vet the content Finally, be sure the PR description includes the PR |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
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.
docs/sphinx/source/referencefor API changes.docs/sphinx/source/whatsnewfor 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`).remote-data) and Milestone are assigned to the Pull Request and linked Issue.This continues #1888 by @cwhanse, which adds
inverter.ond_to_sandia_invto fit Sandia inverter parameters from a PVsyst OND file. His two commits are kept as they were, rebased onto currentmain. A separate commit moves the Huawei OND test file totests/data/and points the test at it, since the tests now live intests/.Separate extraction function (@adriesse). The data extraction is now
inverter.extract_inverter_characteristics(content). It returns a dict withac_power,dc_power,dc_voltage,dc_voltage_level,p_ac_0andp_nt, which are the arguments offit_sandia, so it can also feed other inverter models.ond_to_sandia_invis nowfit_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 threeProfilPIOVefficiency curves or their points,extract_inverter_characteristicsraises aValueErrorthat lists the missing OND keys. No default values are substituted. AVNomEffthat does not hold three voltages and an unsupportedUnitAffEnumalso raiseValueError. These cases are tested with modified copies of the test file written totmp_path.Encoding in
read_panond. The signature is unchanged. Whenencodingis 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, aValueErrorsuggests passingencoding. 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 explicitencodingbehaves as before, and the decoded text goes through the existing parser.Tested.
tests/test_inverter.pyandtests/iotools/test_panond.pypass (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 intests/data(finite parameters,Pacoequal toPMaxOUTin W), and the BOM, UTF-8 without BOM, cp1252 (byte0xB0), 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 thefit_<model>pattern in the module docstring. The unit handling treatsUnitAffEnum=kWas 1000 W andWas 1; I have only seenkWfiles.