File tree Expand file tree Collapse file tree 3 files changed +26
-1
lines changed
docs/sphinx/source/whatsnew Expand file tree Collapse file tree 3 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,8 @@ Enhancements
1919Documentation
2020~~~~~~~~~~~~~
2121* 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 `)
2224
2325Testing
2426~~~~~~~
@@ -31,3 +33,4 @@ Maintenance
3133Contributors
3234~~~~~~~~~~~~
3335* 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):
138138 ape : numeric or pandas.Series
139139 Average Photon Energy [eV].
140140 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``.
142143
143144 Notes
144145 -----
Original file line number Diff line number Diff line change @@ -130,3 +130,24 @@ def test_average_photon_energy_zero_irr():
130130 expected_2 = np .nan
131131 assert_allclose (out_1 , expected_1 , atol = 1e-3 )
132132 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