You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We should cast to numpy float to avoid the following error:
In [8]: spa_test.azimuth()
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
AttributeError: 'numpy.float64' object has no attribute 'radians'
The above exception was the direct cause of the following exception:
TypeError Traceback (most recent call last)
Cell In[8], line 1
----> 1 spa_test.azimuth()
File ~/miniconda3/envs/py312/lib/python3.12/site-packages/rex/utilities/solar_position.py:405, in SolarPosition.azimuth(self)
395 @property
396 def azimuth(self):
397 """
398 Solar azimuth angle
399
(...)
403 Solar azimuth angle in degrees
404 """
--> 405 azimuth = self._azimuth(self.time_index, self.latitude, self.longitude)
407 return self._format_output(azimuth)
File ~/miniconda3/envs/py312/lib/python3.12/site-packages/rex/utilities/solar_position.py:316, in SolarPosition._azimuth(time_index, lat, lon)
314 n, zulu = SolarPosition._parse_time(time_index)
315 ra, dec = SolarPosition._calc_sun_pos(n)
--> 316 ha = SolarPosition._calc_hour_angle(n, zulu, ra, lon)
317 azimuth = SolarPosition._calc_azimuth(dec, ha, lat)
318 return azimuth
File ~/miniconda3/envs/py312/lib/python3.12/site-packages/rex/utilities/solar_position.py:175, in SolarPosition._calc_hour_angle(n, zulu, ra, lon)
173 gmst = (6.697375 + 0.06570982441908 * n + 1.00273790935 * zulu) * 15
174 # Local mean sidereal time in radians
--> 175 lmst = np.radians(np.remainder(gmst + lon, 360))
176 # Hour angle in radians
177 ha = lmst - ra
TypeError: loop of ufunc does not support argument 0 of type numpy.float64 which has no callable radians method
Error produced with pandas = 2.2.2, numpy = 1.26.4.
We should cast to numpy float to avoid the following error:
Error produced with pandas = 2.2.2, numpy = 1.26.4.
spa_test = spa.SolarPosition(sam_df['datetime'].values, sites.iloc[0, 1:3].values)
Fixed with
spa_test = spa.SolarPosition(sam_df['datetime'].values, sites.iloc[0, 1:3].values.astype('float64'))
ALSO!
Azimuth calculation implementation is bugged. Missing these lines from the SAM code:
https://github.com/NREL/ssc/blob/20cc2e75b0f5b77aacc9ae3200a327dfe54abf92/shared/lib_irradproc.cpp#L181-L184
This can be fixed on the user side by:
But this should be fixed in the code instead (and add tests for this calculation!)
The text was updated successfully, but these errors were encountered: