|
12 | 12 | import numpy as np |
13 | 13 | import pandas as pd |
14 | 14 |
|
15 | | -from pvlib import tools, atmosphere, solarposition, irradiance |
| 15 | +from pvlib import atmosphere, tools |
16 | 16 |
|
17 | 17 |
|
18 | 18 | def ineichen(apparent_zenith, airmass_absolute, linke_turbidity, |
@@ -204,7 +204,8 @@ def lookup_linke_turbidity(time, latitude, longitude, filepath=None, |
204 | 204 |
|
205 | 205 | lt_h5_file = tables.open_file(filepath) |
206 | 206 | try: |
207 | | - lts = lt_h5_file.root.LinkeTurbidity[latitude_index, longitude_index, :] |
| 207 | + lts = lt_h5_file.root.LinkeTurbidity[latitude_index, |
| 208 | + longitude_index, :] |
208 | 209 | except IndexError: |
209 | 210 | raise IndexError('Latitude should be between 90 and -90, ' |
210 | 211 | 'longitude between -180 and 180.') |
@@ -364,8 +365,9 @@ def haurwitz(apparent_zenith): |
364 | 365 |
|
365 | 366 | cos_zenith = tools.cosd(apparent_zenith.values) |
366 | 367 | clearsky_ghi = np.zeros_like(apparent_zenith.values) |
367 | | - clearsky_ghi[cos_zenith>0] = 1098.0 * cos_zenith[cos_zenith>0] * \ |
368 | | - np.exp(-0.059/cos_zenith[cos_zenith>0]) |
| 368 | + cos_zen_gte_0 = cos_zenith > 0 |
| 369 | + clearsky_ghi[cos_zen_gte_0] = (1098.0 * cos_zenith[cos_zen_gte_0] * |
| 370 | + np.exp(-0.059/cos_zenith[cos_zen_gte_0])) |
369 | 371 |
|
370 | 372 | df_out = pd.DataFrame(index=apparent_zenith.index, |
371 | 373 | data=clearsky_ghi, |
@@ -675,14 +677,14 @@ def detect_clearsky(measured, clearsky, times, window_length, |
675 | 677 | if len(unique_deltas) == 1: |
676 | 678 | sample_interval = unique_deltas[0] |
677 | 679 | else: |
678 | | - raise NotImplementedError('algorithm does not yet support unequal ' \ |
| 680 | + raise NotImplementedError('algorithm does not yet support unequal ' |
679 | 681 | 'times. consider resampling your data.') |
680 | 682 |
|
681 | 683 | samples_per_window = int(window_length / sample_interval) |
682 | 684 |
|
683 | 685 | # generate matrix of integers for creating windows with indexing |
684 | 686 | from scipy.linalg import hankel |
685 | | - H = hankel(np.arange(samples_per_window), |
| 687 | + H = hankel(np.arange(samples_per_window), # noqa: N806 |
686 | 688 | np.arange(samples_per_window-1, len(times))) |
687 | 689 |
|
688 | 690 | # calculate measurement statistics |
@@ -729,14 +731,16 @@ def detect_clearsky(measured, clearsky, times, window_length, |
729 | 731 | previous_alpha = alpha |
730 | 732 | clear_meas = measured[clear_samples] |
731 | 733 | clear_clear = clearsky[clear_samples] |
| 734 | + |
732 | 735 | def rmse(alpha): |
733 | 736 | return np.sqrt(np.mean((clear_meas - alpha*clear_clear)**2)) |
| 737 | + |
734 | 738 | alpha = minimize_scalar(rmse).x |
735 | 739 | if round(alpha*10000) == round(previous_alpha*10000): |
736 | 740 | break |
737 | 741 | else: |
738 | 742 | import warnings |
739 | | - warnings.warn('failed to converge after %s iterations' \ |
| 743 | + warnings.warn('failed to converge after %s iterations' |
740 | 744 | % max_iterations, RuntimeWarning) |
741 | 745 |
|
742 | 746 | # be polite about returning the same type as was input |
@@ -765,17 +769,18 @@ def bird(zenith, airmass_relative, aod380, aod500, precipitable_water, |
765 | 769 |
|
766 | 770 | Based on NREL Excel implementation by Daryl R. Myers [1, 2]. |
767 | 771 |
|
768 | | - Bird and Hulstrom define the zenith as the "angle between a line to the sun |
769 | | - and the local zenith". There is no distinction in the paper between solar |
770 | | - zenith and apparent (or refracted) zenith, but the relative airmass is |
771 | | - defined using the Kasten 1966 expression, which requires apparent zenith. |
772 | | - Although the formulation for calculated zenith is never explicitly defined |
773 | | - in the report, since the purpose was to compare existing clear sky models |
774 | | - with "rigorous radiative transfer models" (RTM) it is possible that apparent |
775 | | - zenith was obtained as output from the RTM. However, the implentation |
776 | | - presented in PVLIB is tested against the NREL Excel implementation by Daryl |
777 | | - Myers which uses an analytical expression for solar zenith instead of |
778 | | - apparent zenith. |
| 772 | + Bird and Hulstrom define the zenith as the "angle between a line to |
| 773 | + the sun and the local zenith". There is no distinction in the paper |
| 774 | + between solar zenith and apparent (or refracted) zenith, but the |
| 775 | + relative airmass is defined using the Kasten 1966 expression, which |
| 776 | + requires apparent zenith. Although the formulation for calculated |
| 777 | + zenith is never explicitly defined in the report, since the purpose |
| 778 | + was to compare existing clear sky models with "rigorous radiative |
| 779 | + transfer models" (RTM) it is possible that apparent zenith was |
| 780 | + obtained as output from the RTM. However, the implentation presented |
| 781 | + in PVLIB is tested against the NREL Excel implementation by Daryl |
| 782 | + Myers which uses an analytical expression for solar zenith instead |
| 783 | + of apparent zenith. |
779 | 784 |
|
780 | 785 | Parameters |
781 | 786 | ---------- |
@@ -824,7 +829,8 @@ def bird(zenith, airmass_relative, aod380, aod500, precipitable_water, |
824 | 829 |
|
825 | 830 | `SERI/TR-642-761 <http://rredc.nrel.gov/solar/pubs/pdfs/tr-642-761.pdf>`_ |
826 | 831 |
|
827 | | - `Error Reports <http://rredc.nrel.gov/solar/models/clearsky/error_reports.html>`_ |
| 832 | + `Error Reports |
| 833 | + <http://rredc.nrel.gov/solar/models/clearsky/error_reports.html>`_ |
828 | 834 | """ |
829 | 835 | etr = dni_extra # extraradiation |
830 | 836 | ze_rad = np.deg2rad(zenith) # zenith in radians |
|
0 commit comments