def dni(ghi, dhi, zenith, clearsky_dni=None, clearsky_tolerance=1.1, zenith_threshold_for_zero_dni=88.0, zenith_threshold_for_clearsky_limit=80.0): """ Determine DNI from GHI and DHI.
When calculating the DNI from GHI and DHI the calculated DNI may be unreasonably high or negative for zenith angles close to 90 degrees (sunrise/sunset transitions). This function identifies unreasonable DNI values and sets them to NaN. If the clearsky DNI is given unreasonably high values are cut off.
Parameters ---------- ghi : Series Global horizontal irradiance.
dhi : Series Diffuse horizontal irradiance.
zenith : Series True (not refraction-corrected) zenith angles in decimal degrees. Angles must be >=0 and <=180.
clearsky_dni : None or Series, default None Clearsky direct normal irradiance.
clearsky_tolerance : float, default 1.1 If 'clearsky_dni' is given this parameter can be used to allow a tolerance by how much the calculated DNI value can be greater than the clearsky value before it is identified as an unreasonable value.
zenith_threshold_for_zero_dni : float, default 88.0 Non-zero DNI values for zenith angles greater than or equal to 'zenith_threshold_for_zero_dni' will be set to NaN.
zenith_threshold_for_clearsky_limit : float, default 80.0 DNI values for zenith angles greater than or equal to 'zenith_threshold_for_clearsky_limit' and smaller the 'zenith_threshold_for_zero_dni' that are greater than the clearsky DNI (times allowed tolerance) will be corrected. Only applies if 'clearsky_dni' is not None.
Returns ------- dni : Series The modeled direct normal irradiance. """
# calculate DNI dni = (ghi - dhi) / tools.cosd(zenith)
# cutoff negative values dni[dni < 0] = float('nan')
# set non-zero DNI values for zenith angles >= # zenith_threshold_for_zero_dni to NaN dni[(zenith >= zenith_threshold_for_zero_dni) & (dni != 0)] = float('nan')
# correct DNI values for zenith angles greater or equal to the # zenith_threshold_for_clearsky_limit and smaller than the # upper_cutoff_zenith that are greater than the clearsky DNI (times # clearsky_tolerance) if clearsky_dni is not None: max_dni = clearsky_dni * clearsky_tolerance dni[(zenith >= zenith_threshold_for_clearsky_limit) & (zenith < zenith_threshold_for_zero_dni) & (dni > max_dni)] = max_dni return dni--
You received this message because you are subscribed to the Google Groups "pvlib-python" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pvlib-python...@googlegroups.com.
To post to this group, send email to pvlib-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pvlib-python/12a63961-048b-40ea-ac43-d4c04ffccd87%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to pvlib-...@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "pvlib-python" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pvlib-python/aa-bZPXuohc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pvlib-python...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pvlib-python/901c6a16-3073-47da-884c-49cea3124978%40googlegroups.com.


--
You received this message because you are subscribed to a topic in the Google Groups "pvlib-python" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pvlib-python/aa-bZPXuohc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pvlib-python...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pvlib-python/d1b20ec1-074f-418c-9645-4a36b37670ca%40googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "pvlib-python" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/pvlib-python/aa-bZPXuohc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to pvlib-python...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pvlib-python/a6fc1d84-76a1-4299-bd3a-241777d79053%40googlegroups.com.
Agree with Mark. I would avoid adjusting for DST manually; read in the timestamps and use tz_localize() to set the appropriate timezone.
--
You received this message because you are subscribed to the Google Groups "pvlib-python" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
pvlib-python...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/pvlib-python/CALGe1A0PqMgKcdZY9F5%2Buz_ZF68hd83uBpn3RtrANi43aWQB4g%40mail.gmail.com.