Hello Gang,
My apologies for the delayed response, I was offline last week. I'm happy to hear that code snippet is useful!
My goal with the code was to recreate the run_model method of the ModelChain class by incorporating bifacial irradiance, and custom loss models (dc, ac, and plant level losses). It's simplest to ignore the loss models for now and only look at the function my_irradiance_model. The first chunk of code is identical to the run_model method documented
here.
The second chunk of code does as follows:
1. Call the pvlib.bifacial.pvfactors_timeseries function documented
here.
2. With this bifacial timeseries, set the back irradiance as an attribute of my ModelChain class.
3. With this bifacial timeseries, set a total bifacial irradiance by combining the front irradiance with the back irradiance * the bifaciality factor of the module.
To make the my_irradiance_model method a part of my ModelChain class, I first created an instance of a ModelChain, which I named mc:
mc = ModelChain(...)
Then I assign the method to mc using the "types" package:
mc.my_irradiance_model = types.MethodType(my_irradiance_model, mc)
Now, I can call mc.my_irradiance_model(weather) to run a ModelChain method that includes bifaciality.
Sorry if that's a little difficult to follow, I might be better at answering some direct questions. If it helps, here is the code in its entirety:
https://github.com/btaute/solar-models/blob/master/solar_functions.py. It could certainly use some refactoring, but it successfully allowed me to run utility scale bifacial solar plant energy estimates in both R and Python when I first wrote it.