8000 add SingleAxisArray. Array to BaseArray, FixedTiltArray by wholmgren · Pull Request #1146 · pvlib/pvlib-python · GitHub
[go: up one dir, main page]

Skip to content

add SingleAxisArray. Array to BaseArray, FixedTiltArray #1146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension 8000

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
reprs
  • Loading branch information
wholmgren committed Jan 26, 2021
commit 07e47eccfa04b9d28fd6f807fa94937e5d01a86a
26 changes: 15 additions & 11 deletions pvlib/pvsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from pvlib._deprecation import deprecated

from pvlib import (atmosphere, iam, inverter, irradiance,
singlediode as _singlediode, temperature, tracking)
singlediode as _singlediode, temperature, tools)
from pvlib.tools import _build_kwargs
from pvlib._deprecation import pvlibDeprecationWarning

Expand Down Expand Up @@ -1129,14 +1129,12 @@ def __init__(self,

self.name = name

def __repr__(self):
def __repr__(self, name='BaseArray'):
attrs = ['name', 'module',
'albedo', 'racking_model', 'module_type',
'temperature_model_parameters',
'strings', 'modules_per_string']
return 'BaseArray:\n ' + '\n '.join(
f'{attr}: {getattr(self, attr)}' for attr in attrs
)
return tools.repr(self, attrs, name=name, level=1)

def _extend_repr(self, name, attributes):
"""refactor into non-cringy super() gymnastics"""
Expand Down Expand Up @@ -1321,7 +1319,7 @@ def __init__(
racking_model=None,
name=None
):

self.name = name
self.surface_tilt = surface_tilt
self.surface_azimuth = surface_azimuth

Expand All @@ -1339,8 +1337,10 @@ def __init__(
)

def __repr__(self):
attrs = ['surface_tilt', 'surface_azimuth']
return self._extend_repr('FixedTiltArray', attrs)
parent_repr = super().__repr__(name='FixedArray')
attrs = ['name', 'surface_tilt', 'surface_azimuth']
this_repr = tools.repr(self, attrs, level=1)
return parent_repr + '\n' + this_repr

def get_aoi(self, solar_zenith, solar_azimuth):
"""
Expand Down Expand Up @@ -1521,6 +1521,7 @@ def __init__(
name=None
):

self.name = name
self.axis_tilt = axis_tilt
self.axis_azimuth = axis_azimuth
self.max_angle = max_angle
Expand All @@ -1542,9 +1543,11 @@ def __init__(
)

def __repr__(self):
attrs = ['axis_tilt', 'axis_azimuth', 'max_angle', 'backtrack', 'gcr',
'cross_axis_tilt']
return self._extend_repr('SingleAxisArray', attrs)
parent_repr = super().__repr__(name='SingleAxisArray')
attrs = ['name', 'axis_tilt', 'axis_azimuth', 'max_angle', 'backtrack',
'gcr', 'cross_axis_tilt']
this_repr = tools.repr(self, attrs, level=1)
return parent_repr + '\n' + this_repr

def singleaxis(self, apparent_zenith, apparent_azimuth):
"""
Expand All @@ -1563,6 +1566,7 @@ def singleaxis(self, apparent_zenith, apparent_azimuth):
-------
tracking data
"""
from pvlib import tracking
tracking_data = tracking.singleaxis(
apparent_zenith, apparent_azimuth,
self.axis_tilt, self.axis_azimuth,
Expand Down
12 changes: 12 additions & 0 deletions pvlib/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,3 +318,15 @@ def _golden_sect_DataFrame(params, VL, VH, func):
raise Exception("EXCEPTION:iterations exceeded maximum (50)")

return func(df, 'V1'), df['V1']


def repr(obj, attributes, name=None, level=1):
if name is not None:
prefix = ' ' * (level - 1)
this_repr = f'{prefix}{name}:\n'
else:
this_repr = ''
indent = ' ' * level
this_repr += '\n'.join(
f'{indent}{attr}: {getattr(obj, attr)}' for attr in attributes)
return this_repr
0