Skip to content

Commit 93716bb

Browse files
committed
move racking_model and module_height to the Mounts
1 parent 17195ae commit 93716bb

File tree

1 file changed

+28
-14
lines changed

1 file changed

+28
-14
lines changed

pvlib/pvsystem.py

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import pandas as pd
1414
from dataclasses import dataclass
1515
from abc import ABC, abstractmethod
16+
from typing import Optional
1617

1718
import warnings
1819
from pvlib._deprecation import deprecated, pvlibDeprecationWarning
@@ -200,7 +201,7 @@ def __init__(self,
200201
array_losses_parameters = _build_kwargs(['dc_ohmic_percent'],
201202
losses_parameters)
202203
self.arrays = (Array(
203-
FixedMount(surface_tilt, surface_azimuth),
204+
FixedMount(surface_tilt, surface_azimuth, racking_model),
204205
albedo,
205206
surface_type,
206207
module,
@@ -209,7 +210,6 @@ def __init__(self,
209210
temperature_model_parameters,
210211
modules_per_string,
211212
strings_per_inverter,
212-
racking_model,
213213
array_losses_parameters,
214214
),)
215215
else:
@@ -775,15 +775,22 @@ def fuentes_celltemp(self, poa_global, temp_air, wind_speed,
775775
poa_global = self._validate_per_array(poa_global)
776776
temp_air = self._validate_per_array(temp_air, system_wide=True)
777777
wind_speed = self._validate_per_array(wind_speed, system_wide=True)
778-
surface_tilt = self._validate_per_array(wind_speed, system_wide=True)
778+
surface_tilt = self._validate_per_array(surface_tilt, system_wide=True)
779779

780780
def _build_kwargs_fuentes(array, user_tilt):
781781
kwargs = {'surface_tilt': user_tilt}
782+
if array.mount.module_height is not None:
783+
kwargs['module_height'] = array.mount.module_height
782784
temp_model_kwargs = _build_kwargs([
783-
'noct_installed', 'module_height', 'wind_height', 'emissivity',
785+
'noct_installed', 'wind_height', 'emissivity',
784786
'absorption', 'surface_tilt', 'module_width', 'module_length'],
785787
array.temperature_model_parameters)
786788
kwargs.update(temp_model_kwargs)
789+
if kwargs['surface_tilt'] is None:
790+
raise ValueError(
791+
"surface_tilt must be specified in "
792+
"PVSystem.fuentes_celltemp if not providing a "
793+
"default in the Array's temperature_model_parameters")
787794
return kwargs
788795
return tuple(
789796
temperature.fuentes(
@@ -1145,6 +1152,7 @@ def temperature_model_parameters(self, value):
11451152

11461153
@property
11471154
def surface_tilt(self):
1155+
# TODO: make sure this is merged correctly with #1196
11481156
if len(self.arrays) == 1:
11491157
msg = (
11501158
'PVSystem.surface_tilt attribute is deprecated. '
@@ -1159,6 +1167,7 @@ def surface_tilt(self):
11591167

11601168
@surface_tilt.setter
11611169
def surface_tilt(self, value):
1170+
# TODO: make sure this is merged correctly with #1196
11621171
if len(self.arrays) == 1:
11631172
msg = (
11641173
'PVSystem.surface_tilt attribute is deprecated. '
@@ -1173,6 +1182,7 @@ def surface_tilt(self, value):
11731182

11741183
@property
11751184
def surface_azimuth(self):
1185+
# TODO: make sure this is merged correctly with #1196
11761186
if len(self.arrays) == 1:
11771187
msg = (
11781188
'PVSystem.surface_azimuth attribute is deprecated. '
@@ -1187,6 +1197,7 @@ def surface_azimuth(self):
11871197

11881198
@surface_azimuth.setter
11891199
def surface_azimuth(self, value):
1200+
# TODO: make sure this is merged correctly with #1196
11901201
if len(self.arrays) == 1:
11911202
msg = (
11921203
'PVSystem.surface_azimuth attribute is deprecated. '
@@ -1207,12 +1218,14 @@ def albedo(self):
12071218
@property
12081219
@_unwrap_single_value
12091220
def racking_model(self):
1210-
return tuple(array.racking_model for array in self.arrays)
1221+
# TODO: make sure this is merged correctly with #1196
1222+
return tuple(array.mount.racking_model for array in self.arrays)
12111223

12121224
@racking_model.setter
12131225
def racking_model(self, value):
1226+
# TODO: make sure this is merged correctly with #1196
12141227
for array in self.arrays:
1215-
array.racking_model = value
1228+
array.mount.racking_model = value
12161229

12171230
@property
12181231
@_unwrap_single_value
@@ -1277,13 +1290,11 @@ class Array:
12771290
strings: int, default 1
12781291
Number of parallel strings in the array.
12791292
1280-
racking_model : None or string, default None
1281-
Valid strings are 'open_rack', 'close_mount', and 'insulated_back'.
1282-
Used to identify a parameter set for the SAPM cell temperature model.
1283-
12841293
array_losses_parameters: None, dict or Series, default None.
12851294
Supported keys are 'dc_ohmic_percent'.
12861295
1296+
name: None or str, default None
1297+
Name of Array instance.
12871298
"""
12881299

12891300
def __init__(self, mount,
@@ -1292,7 +1303,7 @@ def __init__(self, mount,
12921303
module_parameters=None,
12931304
temperature_model_parameters=None,
12941305
modules_per_string=1, strings=1,
1295-
racking_model=None, array_losses_parameters=None,
1306+
array_losses_parameters=None,
12961307
name=None):
12971308
self.mount = mount
12981309

@@ -1309,7 +1320,6 @@ def __init__(self, mount,
13091320
self.module_parameters = module_parameters
13101321

13111322
self.module_type = module_type
1312-
self.racking_model = racking_model
13131323

13141324
self.strings = strings
13151325
self.modules_per_string = modules_per_string
@@ -1329,7 +1339,7 @@ def __init__(self, mount,
13291339

13301340
def __repr__(self):
13311341
attrs = ['name', 'mount', 'module',
1332-
'albedo', 'racking_model', 'module_type',
1342+
'albedo', 'module_type',
13331343
'temperature_model_parameters',
13341344
'strings', 'modules_per_string']
13351345

@@ -1340,7 +1350,7 @@ def __repr__(self):
13401350
def _infer_temperature_model_params(self):
13411351
# try to infer temperature model parameters from from racking_model
13421352
# and module_type
1343-
param_set = f'{self.racking_model}_{self.module_type}'
1353+
param_set = f'{self.mount.racking_model}_{self.module_type}'
13441354
if param_set in temperature.TEMPERATURE_MODEL_PARAMETERS['sapm']:
13451355
return temperature._temperature_model_params('sapm', param_set)
13461356
elif 'freestanding' in param_set:
@@ -1625,6 +1635,8 @@ class FixedMount(AbstractMount):
16251635

16261636
surface_tilt: float = 0.0
16271637
surface_azimuth: float = 180.0
1638+
racking_model: Optional[str] = None
1639+
module_height: Optional[float] = None
16281640

16291641
def get_orientation(self, solar_zenith, solar_azimuth):
16301642
# note -- docstring is automatically inherited from AbstractMount
@@ -1686,6 +1698,8 @@ class SingleAxisTrackerMount(AbstractMount):
16861698
backtrack: bool = True
16871699
gcr: float = 2/7
16881700
cross_axis_tilt: float = 0.0
1701+
racking_model: Optional[str] = None
1702+
module_height: Optional[float] = None
16891703

16901704
def get_orientation(self, solar_zenith, solar_azimuth):
16911705
# note -- docstring is automatically inherited from AbstractMount

0 commit comments

Comments
 (0)