question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pre-configured ModelChains

See original GitHub issue

Is 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:closed
  • Created 3 years ago
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
wholmgrencommented, Aug 11, 2020

Factory pattern is a good idea. Location has a couple of factories like from_tmy, so it fits with the library. I think I’d go for a class method on the ModelChain class 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 PVSytem that help people avoid the less-than-explicit API of “put these keys in modeling_parameters and these keys in inverter_parameters”.

(I fixed the link in @kanderso-nrel’s post)

0reactions
cwhansecommented, Aug 12, 2020

In #1022, I like having the PVWATTS_CONFIG dict for maintenance. I prefer the ModelChain.with_pvwatts method over the subclass, but not strongly. I think the with_pvwatts style is more explicit and easier to understand than the subclass approach.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ModelChain. run_model_from_effective_irradiance
Effective irradiance is irradiance in the plane-of-array after any adjustments for soiling, reflections and spectrum. Parameters. data (DataFrame, or list or ...
Read more >
JRodos Administration and Maintenance
Model chains - creating and manipulating model chains . ... JRodos supports storing the calculation results in a preconfigured folder on the filesystem....
Read more >
Manual: Introduction to joints
Emulates a ball and socket joint, like a hip or shoulder. Constrains rigid body movement along all linear degrees of freedom, and enables...
Read more >
Model editing with Sculptor
... to prepare an alignment using the sequences of model chains assigned on the ... segment is shorter than a preset limit (determined...
Read more >
Functionality Matrix
Create analytical models and model chains. Edit data on the web. Create OGC-compliant web services ... preconfigured within the server; you cannot add...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found