Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Infer spectral models correctly #2253

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

echedey-ls
Copy link
Contributor

@echedey-ls echedey-ls commented Oct 11, 2024

  • Closes Inferring spectral model returns 'first_solar' when not expected #2017
  • I am familiar with the contributing guidelines
  • 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.

Fix #2017 - note the approach may have been different. In this case, spectral inference has been deferred until weather is known, in order to take its available parameters for the inference.

Tested for script:

Code cleaned up from #2017

import pandas as pd
import pvlib


from pvlib.modelchain import ModelChain
from pvlib.location import Location
from pvlib.pvsystem import PVSystem
from pvlib.temperature import TEMPERATURE_MODEL_PARAMETERS


location = Location(
    latitude=40.30117520975112,
    longitude=-3.6973221576701967,
    tz="Europe/Madrid",
    altitude=660,
    name="Ormazabal Getafe",
)
modules = pvlib.pvsystem.retrieve_sam("CECMod")
inverters = pvlib.pvsystem.retrieve_sam("CECInverter")
module = modules["JA_Solar_JAP72S01_330_SC"]
inverter = inverters["SMA_America__STP_33_US_41__480V_"]
temp_par = TEMPERATURE_MODEL_PARAMETERS["sapm"]["open_rack_glass_glass"]
system = PVSystem(
    surface_tilt=19,
    surface_azimuth=170,
    module_parameters=module,
    inverter_parameters=inverter,
    temperature_model_parameters=temp_par,
    modules_per_string=17,
    strings_per_inverter=6,
)
modelchain = ModelChain(system, location, aoi_model="physical")

times = pd.date_range(
    start="2023-06-01", end="2023-12-15", freq="h", tz=location.tz
)
solar_position = location.get_solarposition(times)
clearsky = location.get_clearsky(times)

modelchain.run_model(clearsky)

Still haven't added tests, please let me know what you think about the behaviour first.

Copy link
Member

@cwhanse cwhanse left a comment

Choose a reason for hiding this comment

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

Maybe we're trying too hard to help. I'm inclined to default to the no_loss model if parameters are not found, regardless of Technology, Material or weather.

Or just do away with the inference altogether and set to no_loss if spectral_model=None

pvlib/modelchain.py Outdated Show resolved Hide resolved
pvlib/modelchain.py Outdated Show resolved Hide resolved
pvlib/modelchain.py Show resolved Hide resolved
pvlib/modelchain.py Outdated Show resolved Hide resolved
pvlib/modelchain.py Outdated Show resolved Hide resolved
echedey-ls and others added 3 commits October 15, 2024 17:13
Co-Authored-By: Cliff Hansen <5393711+cwhanse@users.noreply.github.com>
@echedey-ls
Copy link
Contributor Author

echedey-ls commented Oct 15, 2024

Or just do away with the inference altogether and set to no_loss if spectral_model=None

I've defaulted to spectral_model="no_loss" and documented the infer_spectral_model as a helper function so the user can opt in to inference. I will write the tests now.
Nvm, it didn't work as many tests expect SAPM to be used whenever possible, so I've documented how it works when trying to infer without weather and that's it.

@echedey-ls echedey-ls marked this pull request as ready for review October 20, 2024 19:39
@echedey-ls
Copy link
Contributor Author

L256 codecov warning in the diff is related to a PEP8 line change and the one in L910 is related to a different issue, #2259.

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.

Inferring spectral model returns 'first_solar' when not expected
2 participants