MoonRaker / pvlib-python

A set of documented functions for simulating the performance of photovoltaic energy systems.
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

radiation conversion code #9

Closed wholmgren closed 8 years ago

wholmgren commented 8 years ago

I was surprised to see this code already done. Where does this algorithm come from? As you may have seen, pvlib tries to put published references in the docstrings.

I expected that we'd use the pvlib.clearsky.ineichen function to calculate clear sky ghi, dni, dhi, then multiply by some function of cloud cover. I was thinking linear to get started, but it would be pretty easy to fit a 2nd or 3rd order polynomial to some irradiance data measured here on campus.

Your approach is interesting and I'm not sure which is best.

Also, change addRadiation to add_radiation.

wholmgren commented 8 years ago

Here's an example of how to use clearsky.ineichen...

location = [32.2,-110.9] # Tucson, AZ
start = datetime.now() # today's date
end = start + timedelta(days=7) # 7 days from today
timerange = pd.date_range(start, end, tz=tz)
forecast_data = fm.get_query_data(location,timerange)
cs = pvlib.clearsky.ineichen(forecast_data.index, pvlib.location.Location(*location), solarposition_method='nrel_numpy')
cs_scaled = cs.mul((100-forecast_data['total_clouds']) / 100, axis=0)

A lot of room for improvement here, but it shows the idea.

gfs_ineichen_fx_irrad

MoonRaker commented 8 years ago

I have implemented a model from Liu & Jordan as well as the pvlib.clearsky.ineichen conversion you mentioned above. By default values for radiation are calculated using the Liu & Jordan model if they are not being queried. That being said, the probably needs to be some validation done that these values all agree and that it is clear how the model returns radiation data.

wholmgren commented 8 years ago

All models except for HRRR_ESRL need to calculate all radiation components because the models do not use an accurate equation of time.

wholmgren commented 8 years ago

The calc_radiation function is very hard to understand, perhaps because there are some errors in it. Let's talk about it as soon as possible.

MoonRaker commented 8 years ago

I am planning on simplifying the calc_radiation function. This should should help readability and also cur down on the errors.

MoonRaker commented 8 years ago

All models calculate radiation for dni, dhi, and ghi using the liujordan model except for the HRRR_ESRL because of the equation of time issue.