Skip to content

Apply wavelength along DataFrame rows in qe_to_sr and sr_to_qe - #2972

Open
Beehtrix wants to merge 2 commits into
pvlib:mainfrom
Beehtrix:fix-qe-sr-dataframe-axis-2970
Open

Beehtrix wants to merge 2 commits into
pvlib:mainfrom
Beehtrix:fix-qe-sr-dataframe-axis-2970

Conversation

@Beehtrix

@Beehtrix Beehtrix commented Dec 2, 2026

Copy link
Copy Markdown
  • Closes Spectral conversions apply the wavelength index across DataFrame columns #2970
  • 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. (no API change)
  • 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.

qe_to_sr and sr_to_qe multiplied or divided by the wavelength as a 1-D operand. pandas aligns that operand with a DataFrame's columns, so a table with one wavelength per row used one wavelength per device: a square table gave wrong values and a rectangular one raised a length error. DataFrames are now converted along the row axis, and the wavelength is used by position (so a wavelength Series with different labels no longer produces NaN rows).

Series, 1-D arrays, scalars and the existing row-wise 2-D ndarray behaviour are unchanged. Following the comment on the issue, the docstrings now state the accepted shapes: a DataFrame has one spectrum per column; a 2-D ndarray has one spectrum per row with wavelengths along the last axis; wavelength needs one value per wavelength and is matched by position.

Tests cover the issue's example, square and rectangular tables, explicit wavelength, a positional Series wavelength, normalization, scalars and 2-D arrays. tests/spectrum passes and flake8 is clean. The whatsnew entry is in v0.16.2.rst with :issue: and :ghuser:; I'll add :pull: once this has a number.

Copilot AI lite review requested due to automatic review settings December 2, 2026 21:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown

Hey @Beehtrix! 🎉

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.

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.

Spectral conversions apply the wavelength index across DataFrame columns

2 participants