Open iblasi opened 3 days ago
I found a solution looking to another documentation example where it creates the required variable: https://pvlib-python.readthedocs.io/en/stable/gallery/irradiance-transposition/plot_rtranpose_year.html
So the issue can be solved modifying the final code in the following way to add dni_extra
variable.
# GHI 2 POA. Estimate global horizontal irradiance (GHI) from global plane-of-array (POA) irradiance
# https://pvlib-python.readthedocs.io/en/stable/reference/generated/pvlib.irradiance.ghi_from_poa_driesse_2023.html
solar_position['poa_global'] = 1000 * np.random.rand(len(solar_position))
solar_position['dni_extra'] = pvlib.irradiance.get_extra_radiation(solar_position.index)
solar_position['ghi'] = pvlib.irradiance.ghi_from_poa_driesse_2023(surface_tilt=tracking_data['surface_tilt'],
surface_azimuth=tracking_data['surface_azimuth'],
solar_zenith=solar_position['apparent_zenith'],
solar_azimuth=solar_position['azimuth'],
poa_global=solar_position['poa_global'],
dni_extra=solar_position['dni_extra'])
Still an issue
Although this solves the runtime error, the documentation should be updated and do not define it as optional, or if the optional parameter dni_extra
is None, create that value with the get_extra_radiation
function as described.
Note: This example has random poa_global
values so some NaN might appear on the ghi
result. I suppose tht it will be due to these random values, but I haven't checked it.
Confirmed. Every test of ghi_from_poa_driesse_2023
specifies dni_extra=1366.1
, so we didn't catch this.
The private function _ghi_from_poa
requires a value of dni_extra
that can be multiplied by a float. I think setting dni_extra=1366.1
as the default could be the fix here.
My bad! I am currently inclined to provide fewer defaults to make people think more about what they're doing. So another option would be to remove the default value here.
I too fret about default values! One thought I’ve had is to make such parameters Optional[float] (so a float or None is expected), but do NOT give it a default value. In this way, the user must explicitly choose and pass None to “opt in” to using the default value. A downside here is that the (arguably) breaking change of changing the default value is more hidden because it no longer appears right in the function signature.
Mark Campanelli LinkedIn https://www.linkedin.com/in/markcampanelli/ Intelligent Measurement Systems LLC https://intelligentmeasurementsystems.com Try PVfit https://pvfit.app today!
On Wed, Oct 30, 2024 at 04:45 Anton Driesse @.***> wrote:
My bad! I am currently included to provide fewer defaults to make people think more about what they're doing. So another option would be to remove the default value here.
— Reply to this email directly, view it on GitHub https://github.com/pvlib/pvlib-python/issues/2279#issuecomment-2446531227, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAISX42JYATUVPLRXQHHM2TZ6C2DZAVCNFSM6AAAAABQ2IYO7SVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINBWGUZTCMRSG4 . You are receiving this because you are subscribed to this thread.Message ID: @.***>
So another option would be to remove the default value here.
Requiring dni_extra
doesn't seem like a burden on the user. As the method's originator, which would you prefer? No default, or default to the solar constant?
My preference is for no default value to be consistent with perez
and perez_driesse
.
Describe the bug The function
ghi_from_poa_driesse_2023
defines the parameterdni_extra
as optional and default to "None", but that causes a runtime error.dni_extra
refers to "Extraterrestrial direct normal irradiance" Function: https://pvlib-python.readthedocs.io/en/stable/reference/generated/pvlib.irradiance.ghi_from_poa_driesse_2023.htmlTo Reproduce
Output of previous code
Expected behavior No need to define "dni_extra", or do not define it as optional
Versions:
pvlib.__version__
: 0.11.1pandas.__version__
: 1.5.2