11"""Collection of utility functions."""
22
33import pvlib
4+ import numpy as np
45
56
67def _pandas_to_utc (pd_object ):
@@ -39,7 +40,7 @@ def _fractional_hour(times):
3940
4041 Returns
4142 -------
42- fraction of hour
43+ fraction_of_hour : pd.Index
4344 """
4445 hour = (times .hour + (
4546 times .minute + (times .second + times .microsecond * 1e-6 )/ 60 )/ 60 )
@@ -48,39 +49,44 @@ def _fractional_hour(times):
4849
4950def calc_error (zenith_1 , azimuth_1 , zenith_2 , azimuth_2 ):
5051 """
51- Calculate angular difference metrics between two solar positions.
52+ Calculate angular difference metrics between two sets of solar positions.
5253
5354 Parameters
5455 ----------
5556 zenith_1, zenith_2 : array-like
56- Zenith angles for the two solar positions. [degrees]
57+ Zenith angles for the two sets of solar positions. [degrees]
5758 azimuth_1, azimuth_2 : array-like
58- Azimuth angles for the two solar positions . [degrees]
59+ Azimuth angles for the two sets of solar position . [degrees]
5960
6061 Returns
6162 -------
6263 out : dict
6364 Dict with keys:
6465
6566 * zenith_bias, azimuth_bias: average (signed) difference in zenith/azimuth
67+ * zenith_mad, azimuth_mad: mean absolute difference in zenith/azimuth
6668 * zenith_rmsd, azimuth_rmsd: root-mean-squared difference in zenith/azimuth
6769 * combined_rmse: total angular root-mean-squared difference in position
6870 """
6971 zenith_diff = zenith_1 - zenith_2
7072 zenith_bias = zenith_diff .mean ()
73+ zenith_mad = np .abs (zenith_diff ).mean ()
7174 zenith_rmsd = (zenith_diff ** 2 ).mean ()** 0.5
7275
7376 azimuth_diff = (azimuth_1 - azimuth_2 + 180 ) % 360 - 180 # handle 0/360 correctly
7477 azimuth_bias = azimuth_diff .mean ()
78+ azimuth_mad = np .abs (azimuth_diff ).mean ()
7579 azimuth_rmsd = (azimuth_diff ** 2 ).mean ()** 0.5
7680
7781 aoi = pvlib .irradiance .aoi (zenith_1 , azimuth_1 , zenith_2 , azimuth_2 )
7882 combined_rmsd = (aoi ** 2 ).mean ()** 0.5
7983
8084 out = {
8185 'zenith_bias' : zenith_bias ,
86+ 'zenith_mad' : zenith_mad ,
8287 'zenith_rmsd' : zenith_rmsd ,
8388 'azimuth_bias' : azimuth_bias ,
89+ 'azimuth_mad' : azimuth_mad ,
8490 'azimuth_rmsd' : azimuth_rmsd ,
8591 'combined_rmsd' : combined_rmsd ,
8692 }
0 commit comments