Skip to content

Commit 46059b5

Browse files
authored
improve speed of Location.get_airmass (#528)
* PERF speciify time index in location.get_airmass * PERF speciify time index in ModelChain.prepare_inputs * update whatsnew
1 parent 36aec41 commit 46059b5

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

docs/sphinx/source/whatsnew/v0.6.0.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ Enhancements
9393
* Add PVSyst thin-film recombination losses for CdTe and a:Si (:issue:`163`)
9494
* Python 3.7 officially supported. (:issue:`496`)
9595
* Improve performance of solarposition.ephemeris. (:issue:`512`)
96+
* Improve performance of Location.get_airmass. Most noticeable when
97+
solar position is supplied, time index length is less than 10000, and
98+
method is looped over. (:issue:`502`)
9699

97100

98101
Bug fixes

pvlib/location.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def get_airmass(self, times=None, solar_position=None,
271271
airmass_absolute = atmosphere.get_absolute_airmass(airmass_relative,
272272
pressure)
273273

274-
airmass = pd.DataFrame()
274+
airmass = pd.DataFrame(index=solar_position.index)
275275
airmass['airmass_relative'] = airmass_relative
276276
airmass['airmass_absolute'] = airmass_absolute
277277

pvlib/modelchain.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ def prepare_inputs(self, times=None, weather=None):
736736
if weather is not None:
737737
self.weather = weather
738738
if self.weather is None:
739-
self.weather = pd.DataFrame()
739+
self.weather = pd.DataFrame(index=times)
740740

741741
if times is not None:
742742
self.times = times

0 commit comments

Comments
 (0)