pre-configured ModelChains
See original GitHub issueIs your feature request related to a problem? Please describe.
ModelChain has a lot of options and can be challenging to configure. This also makes it difficult to implement reference implementations of workflows.
Describe the solution you’d like
Create wrappers for pre-configured ModelChains. For example, a PVWatts version of ModelChain might look like:
# modelchain.py
PVWatts = functools.partial(
ModelChain,
dc_model='pvwatts', ac_model='pvwatts', losses_model='pvwatts',
transposition_model='perez', aoi_model='physical'
)
# user code
my_model_chain = PVWatts(my_location, my_system)
This SO post discusses some subtleties with using partial with classes, so the actual implementation might require the helper function in that post.
Describe alternatives you’ve considered We could subclass ModelChain but that seems like overkill for this. Inheritance leads to brittle code, in my experience, so I prefer to avoid it if possible.
We could supply dicts of parameters e.g.
# modelchain.py
pvwatts_config = dict(
dc_model='pvwatts', ac_model='pvwatts', losses_model='pvwatts',
transposition_model='perez', aoi_model='physical'
)
# user code
my_model_chain = ModelChain(my_location, my_system, **pvwatts_config)
Any other ideas?
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (13 by maintainers)

Top Related StackOverflow Question
Factory pattern is a good idea.
Locationhas a couple of factories likefrom_tmy, so it fits with the library. I think I’d go for a class method on theModelChainclass but don’t feel strongly about it.We might want a different method for each predefined chain because they won’t necessarily have the same parameters. For example, a PVWatts chain would not expose transposition to the user (documentation says to use Perez) but another chain might leave that to the user as a kwarg.
I could see similar factories for
PVSytemthat help people avoid the less-than-explicit API of “put these keys inmodeling_parametersand these keys ininverter_parameters”.(I fixed the link in @kanderso-nrel’s post)
In #1022, I like having the
PVWATTS_CONFIGdict for maintenance. I prefer theModelChain.with_pvwattsmethod over the subclass, but not strongly. I think thewith_pvwattsstyle is more explicit and easier to understand than the subclass approach.