File tree 3 files changed +26
-1
lines changed
docs/sphinx/source/whatsnew
3 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,8 @@ Enhancements
19
19
Documentation
20
20
~~~~~~~~~~~~~
21
21
* Add a supporting reference to :py:func: `pvlib.atmosphere.get_relative_airmass ` (:issue: `2390 `, :pull: `2424 `)
22
+ * Documented how `np.nan ` values are handled by :py:func: `~pvlib.spectrum.average_photon_energy `
23
+ (:issue: `2423 `, :pull: `2426 `)
22
24
23
25
Testing
24
26
~~~~~~~
@@ -31,3 +33,4 @@ Maintenance
31
33
Contributors
32
34
~~~~~~~~~~~~
33
35
* Cliff Hansen (:ghuser: `cwhanse `)
36
+ * Rajiv Daxini (:ghuser: `RDaxini `)
Original file line number Diff line number Diff line change @@ -138,7 +138,8 @@ def average_photon_energy(spectra):
138
138
ape : numeric or pandas.Series
139
139
Average Photon Energy [eV].
140
140
Note: returns ``np.nan`` in the case of all-zero spectral irradiance
141
- input.
141
+ input, or where one or more spectral irradiance values is
142
+ ``np.nan``.
142
143
143
144
Notes
144
145
-----
Original file line number Diff line number Diff line change @@ -130,3 +130,24 @@ def test_average_photon_energy_zero_irr():
130
130
expected_2 = np .nan
131
131
assert_allclose (out_1 , expected_1 , atol = 1e-3 )
132
132
assert_allclose (out_2 , expected_2 , atol = 1e-3 )
133
+
134
+
135
+ def test_average_photon_energy_nan_irr ():
136
+ # test for handling NaN input
137
+
138
+ spectra_df_nan = spectrum .get_reference_spectra ().T
139
+ spectra_df_nan .loc ["global" , 315.0 ] = np .nan
140
+ spectra_df_nan .loc ['extraterrestrial' , :] = np .nan
141
+
142
+ spectra_series_nan = spectrum .get_reference_spectra ()['global' ]
143
+ spectra_series_singlenan = spectra_series_nan .copy ()
144
+ spectra_series_singlenan .loc [315.0 ] = np .nan
145
+ spectra_series_allnan = spectra_series_nan * np .nan
146
+
147
+ out1 = spectrum .average_photon_energy (spectra_df_nan )
148
+ out2 = spectrum .average_photon_energy (spectra_series_singlenan )
149
+ out3 = spectrum .average_photon_energy (spectra_series_allnan )
150
+
151
+ assert np .all (np .isnan (out1 [['global' , 'extraterrestrial' ]]))
152
+ assert np .all (np .isnan (out2 ))
153
+ assert np .all (np .isnan (out3 ))
You can’t perform that action at this time.
0 commit comments