diff --git a/docs/sphinx/source/whatsnew/v0.6.0.rst b/docs/sphinx/source/whatsnew/v0.6.0.rst index c116fb18c5..7458e3f017 100644 --- a/docs/sphinx/source/whatsnew/v0.6.0.rst +++ b/docs/sphinx/source/whatsnew/v0.6.0.rst @@ -93,6 +93,9 @@ Enhancements * Add PVSyst thin-film recombination losses for CdTe and a:Si (:issue:`163`) * Python 3.7 officially supported. (:issue:`496`) * Improve performance of solarposition.ephemeris. (:issue:`512`) +* Improve performance of Location.get_airmass. Most noticeable when + solar position is supplied, time index length is less than 10000, and + method is looped over. (:issue:`502`) Bug fixes diff --git a/pvlib/location.py b/pvlib/location.py index 1404bb18b0..df02858641 100644 --- a/pvlib/location.py +++ b/pvlib/location.py @@ -271,7 +271,7 @@ def get_airmass(self, times=None, solar_position=None, airmass_absolute = atmosphere.get_absolute_airmass(airmass_relative, pressure) - airmass = pd.DataFrame() + airmass = pd.DataFrame(index=solar_position.index) airmass['airmass_relative'] = airmass_relative airmass['airmass_absolute'] = airmass_absolute diff --git a/pvlib/modelchain.py b/pvlib/modelchain.py index f9beeb684e..0b6f184847 100644 --- a/pvlib/modelchain.py +++ b/pvlib/modelchain.py @@ -736,7 +736,7 @@ def prepare_inputs(self, times=None, weather=None): if weather is not None: self.weather = weather if self.weather is None: - self.weather = pd.DataFrame() + self.weather = pd.DataFrame(index=times) if times is not None: self.times = times