|
| 1 | +""" |
| 2 | +ASV benchmarks for infinite_sheds.py |
| 3 | +""" |
| 4 | + |
| 5 | +import numpy as np |
| 6 | +import pandas as pd |
| 7 | +from pvlib.bifacial import infinite_sheds |
| 8 | +from pvlib import location, tracking |
| 9 | + |
| 10 | + |
| 11 | +class InfiniteSheds: |
| 12 | + |
| 13 | + def setup(self): |
| 14 | + self.times = pd.date_range(start='20180601', freq='1min', |
| 15 | + periods=1440) |
| 16 | + self.location = location.Location(40, -80) |
| 17 | + self.solar_position = self.location.get_solarposition(self.times) |
| 18 | + self.clearsky_irradiance = self.location.get_clearsky( |
| 19 | + self.times, |
| 20 | + solar_position=self.solar_position, |
| 21 | + ) |
| 22 | + self.surface_tilt = 20 |
| 23 | + self.surface_azimuth = 180 |
| 24 | + self.gcr = 0.35 |
| 25 | + self.height = 2.5 |
| 26 | + self.pitch = 5. |
| 27 | + self.albedo = 0.2 |
| 28 | + self.npoints = 100 |
| 29 | + |
| 30 | + with np.errstate(invalid='ignore'): |
| 31 | + self.tracking = tracking.singleaxis( |
| 32 | + self.solar_position['apparent_zenith'], |
| 33 | + self.solar_position['azimuth'], |
| 34 | + axis_tilt=0, |
| 35 | + axis_azimuth=0, |
| 36 | + max_angle=60, |
| 37 | + backtrack=True, |
| 38 | + gcr=self.gcr |
| 39 | + ) |
| 40 | + |
| 41 | + def time_get_irradiance_poa_fixed(self): |
| 42 | + infinite_sheds.get_irradiance_poa( |
| 43 | + surface_tilt=self.surface_tilt, |
| 44 | + surface_azimuth=self.surface_azimuth, |
| 45 | + solar_zenith=self.solar_position['apparent_zenith'], |
| 46 | + solar_azimuth=self.solar_position['azimuth'], |
| 47 | + gcr=self.gcr, |
| 48 | + height=self.height, |
| 49 | + pitch=self.pitch, |
| 50 | + ghi=self.clearsky_irradiance['ghi'], |
| 51 | + dhi=self.clearsky_irradiance['dhi'], |
| 52 | + dni=self.clearsky_irradiance['dni'], |
| 53 | + albedo=self.albedo, |
| 54 | + npoints=self.npoints |
| 55 | + ) |
| 56 | + |
| 57 | + def time_get_irradiance_poa_tracking(self): |
| 58 | + infinite_sheds.get_irradiance_poa( |
| 59 | + surface_tilt=self.tracking['surface_tilt'], |
| 60 | + surface_azimuth=self.tracking['surface_azimuth'], |
| 61 | + solar_zenith=self.solar_position['apparent_zenith'], |
| 62 | + solar_azimuth=self.solar_position['azimuth'], |
| 63 | + gcr=self.gcr, |
| 64 | + height=self.height, |
| 65 | + pitch=self.pitch, |
| 66 | + ghi=self.clearsky_irradiance['ghi'], |
| 67 | + dhi=self.clearsky_irradiance['dhi'], |
| 68 | + dni=self.clearsky_irradiance['dni'], |
| 69 | + albedo=self.albedo, |
| 70 | + npoints=self.npoints |
| 71 | + ) |
| 72 | + |
| 73 | + def time_get_irradiance_fixed(self): |
| 74 | + infinite_sheds.get_irradiance( |
| 75 | + surface_tilt=self.surface_tilt, |
| 76 | + surface_azimuth=self.surface_azimuth, |
| 77 | + solar_zenith=self.solar_position['apparent_zenith'], |
| 78 | + solar_azimuth=self.solar_position['azimuth'], |
| 79 | + gcr=self.gcr, |
| 80 | + height=self.height, |
| 81 | + pitch=self.pitch, |
| 82 | + ghi=self.clearsky_irradiance['ghi'], |
| 83 | + dhi=self.clearsky_irradiance['dhi'], |
| 84 | + dni=self.clearsky_irradiance['dni'], |
| 85 | + albedo=self.albedo, |
| 86 | + npoints=self.npoints |
| 87 | + ) |
| 88 | + |
| 89 | + def time_get_irradiance_tracking(self): |
| 90 | + infinite_sheds.get_irradiance( |
| 91 | + surface_tilt=self.tracking['surface_tilt'], |
| 92 | + surface_azimuth=self.tracking['surface_azimuth'], |
| 93 | + solar_zenith=self.solar_position['apparent_zenith'], |
| 94 | + solar_azimuth=self.solar_position['azimuth'], |
| 95 | + gcr=self.gcr, |
| 96 | + height=self.height, |
| 97 | + pitch=self.pitch, |
| 98 | + ghi=self.clearsky_irradiance['ghi'], |
| 99 | + dhi=self.clearsky_irradiance['dhi'], |
| 100 | + dni=self.clearsky_irradiance['dni'], |
| 101 | + albedo=self.albedo, |
| 102 | + npoints=self.npoints |
| 103 | + ) |
0 commit comments