Skip to content

Commit 7eae1fc

Browse files
authored
Docstring for ModelChainResult (#1233)
* see how this docstring works * one long sentence * progress * complete draft * adjustments * correct use of tuple * correct func and method references * move _PerArray to module scope * add dataclass docstring * try _typehints * remove _typehints * remove class docstring, add a few See Also to pvsystem * make public
1 parent 0326b6f commit 7eae1fc

File tree

2 files changed

+88
-5
lines changed

2 files changed

+88
-5
lines changed

pvlib/modelchain.py

+80-5
Original file line numberDiff line numberDiff line change
@@ -245,12 +245,15 @@ def get_orientation(strategy, **kwargs):
245245
return surface_tilt, surface_azimuth
246246

247247

248+
# Type for fields that vary between arrays
249+
T = TypeVar('T')
250+
251+
252+
PerArray = Union[T, Tuple[T, ...]]
253+
254+
248255
@dataclass
249256
class ModelChainResult:
250-
_T = TypeVar('T')
251-
PerArray = Union[_T, Tuple[_T, ...]]
252-
"""Type for fields that vary between arrays"""
253-
254257
# these attributes are used in __setattr__ to determine the correct type.
255258
_singleton_tuples: bool = field(default=False)
256259
_per_array_fields = {'total_irrad', 'aoi', 'aoi_modifier',
@@ -260,27 +263,99 @@ class ModelChainResult:
260263

261264
# system-level information
262265
solar_position: Optional[pd.DataFrame] = field(default=None)
266+
"""Solar position in a DataFrame containing columns ``'apparent_zenith'``,
267+
``'zenith'``, ``'apparent_elevation'``, ``'elevation'``, ``'azimuth'``
268+
(all in degrees), with possibly other columns depending on the solar
269+
position method; see :py:func:`~pvlib.solarposition.get_solarposition`
270+
for details."""
271+
263272
airmass: Optional[pd.DataFrame] = field(default=None)
273+
"""Air mass in a DataFrame containing columns ``'airmass_relative'``,
274+
``'airmass_absolute'`` (unitless); see
275+
:py:meth:`~pvlib.location.Location.get_airmass` for details."""
276+
264277
ac: Optional[pd.Series] = field(default=None)
278+
"""AC power from the PV system, in a Series [W]"""
279+
265280
tracking: Optional[pd.DataFrame] = field(default=None)
281+
"""Orientation of modules on a single axis tracker, in a DataFrame with
282+
columns ``'surface_tilt'``, ``'surface_azimuth'``, ``'aoi'``; see
283+
:py:func:`~pvlib.tracking.singleaxis` for details.
284+
"""
285+
286+
losses: Optional[Union[pd.Series, float]] = field(default=None)
287+
"""Series containing DC loss as a fraction of total DC power, as
288+
calculated by ``ModelChain.losses_model``.
289+
"""
266290

267291
# per DC array information
268292
total_irrad: Optional[PerArray[pd.DataFrame]] = field(default=None)
293+
""" DataFrame (or tuple of DataFrame, one for each array) containing
294+
columns ``'poa_global'``, ``'poa_direct'`` ``'poa_diffuse'``,
295+
``poa_sky_diffuse'``, ``'poa_ground_diffuse'`` (W/m2); see
296+
:py:func:`~pvlib.irradiance.get_total_irradiance` for details.
297+
"""
298+
269299
aoi: Optional[PerArray[pd.Series]] = field(default=None)
300+
"""
301+
Series (or tuple of Series, one for each array) containing angle of
302+
incidence (degrees); see :py:func:`~pvlib.irradiance.aoi` for details.
303+
"""
304+
270305
aoi_modifier: Optional[PerArray[Union[pd.Series, float]]] = \
271306
field(default=None)
307+
"""Series (or tuple of Series, one for each array) containing angle of
308+
incidence modifier (unitless) calculated by ``ModelChain.aoi_model``,
309+
which reduces direct irradiance for reflections;
310+
see :py:meth:`~pvlib.pvsystem.PVSystem.get_iam` for details.
311+
"""
312+
272313
spectral_modifier: Optional[PerArray[Union[pd.Series, float]]] = \
273314
field(default=None)
315+
"""Series (or tuple of Series, one for each array) containing spectral
316+
modifier (unitless) calculated by ``ModelChain.spectral_model``, which
317+
adjusts broadband plane-of-array irradiance for spectral content.
318+
"""
319+
274320
cell_temperature: Optional[PerArray[pd.Series]] = field(default=None)
321+
"""Series (or tuple of Series, one for each array) containing cell
322+
temperature (C).
323+
"""
324+
275325
effective_irradiance: Optional[PerArray[pd.Series]] = field(default=None)
326+
"""Series (or tuple of Series, one for each array) containing effective
327+
irradiance (W/m2) which is total plane-of-array irradiance adjusted for
328+
reflections and spectral content.
329+
"""
330+
276331
dc: Optional[PerArray[Union[pd.Series, pd.DataFrame]]] = \
277332
field(default=None)
333+
"""Series or DataFrame (or tuple of Series or DataFrame, one for
334+
each array) containing DC power (W) for each array, calculated by
335+
``ModelChain.dc_model``.
336+
"""
337+
278338
diode_params: Optional[PerArray[pd.DataFrame]] = field(default=None)
339+
"""DataFrame (or tuple of DataFrame, one for each array) containing diode
340+
equation parameters (columns ``'I_L'``, ``'I_o'``, ``'R_s'``, ``'R_sh'``,
341+
``'nNsVth'``, present when ModelChain.dc_model is a single diode model;
342+
see :py:func:`~pvlib.pvsystem.singlediode` for details.
343+
"""
344+
279345
dc_ohmic_losses: Optional[PerArray[pd.Series]] = field(default=None)
280-
losses: Optional[Union[pd.Series, float]] = field(default=None)
346+
"""Series (or tuple of Series, one for each array) containing DC ohmic
347+
loss (W) calculated by ``ModelChain.dc_ohmic_model``.
348+
"""
281349

350+
# copies of input data, for user convenience
282351
weather: Optional[PerArray[pd.DataFrame]] = None
352+
"""DataFrame (or tuple of DataFrame, one for each array) contains a
353+
copy of the input weather data.
354+
"""
355+
283356
times: Optional[pd.DatetimeIndex] = None
357+
"""DatetimeIndex containing a copy of the index of the input weather data.
358+
"""
284359

285360
def _result_type(self, value):
286361
"""Coerce `value` to the correct type according to

pvlib/pvsystem.py

+8
Original file line numberDiff line numberDiff line change
@@ -3074,6 +3074,10 @@ def dc_ohms_from_percent(vmp_ref, imp_ref, dc_ohmic_percent,
30743074
Rw: numeric
30753075
Equivalent resistance [ohm]
30763076
3077+
See Also
3078+
--------
3079+
:py:func:`~pvlib.pvsystem.dc_ohmic_losses`
3080+
30773081
References
30783082
----------
30793083
.. [1] PVsyst 7 Help. "Array ohmic wiring loss".
@@ -3105,6 +3109,10 @@ def dc_ohmic_losses(resistance, current):
31053109
loss: numeric
31063110
Power Loss [W]
31073111
3112+
See Also
3113+
--------
3114+
:py:func:`~pvlib.pvsystem.dc_ohms_from_percent`
3115+
31083116
References
31093117
----------
31103118
.. [1] PVsyst 7 Help. "Array ohmic wiring loss".

0 commit comments

Comments
 (0)