Skip to content

Commit

Permalink
Add 'columns' and 'methods' introspection to RadObj, MetObj and Groun…
Browse files Browse the repository at this point in the history
…dObj
  • Loading branch information
cdeline committed Nov 29, 2023
1 parent 967e848 commit d218698
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
24 changes: 22 additions & 2 deletions bifacial_radiance/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,12 @@ def __init__(self, name=None, path=None, hpc=False):
self._setPath(path)
# load files in the /materials/ directory
self.materialfiles = self.returnMaterialFiles('materials')

# store list of columns and methods for convenience / introspection
# TODO: abstract this by making a super class that this inherits
self.columns = [attr for attr in dir(self) if not (attr.startswith('_') or callable(getattr(self,attr)))]
self.methods = [attr for attr in dir(self) if (not attr.startswith('_') and callable(getattr(self,attr)))]


def _setPath(self, path):
"""
Expand Down Expand Up @@ -3237,6 +3243,11 @@ def __init__(self, materialOrAlbedo=None, material_file=None, silent=False):
except IndexError as e:
print('albedo.shape should be 3 column (N x 3)')
raise e

# store list of columns and methods for convenience / introspection
# TODO: abstract this by making a super class that this inherits
self.columns = [attr for attr in dir(self) if not (attr.startswith('_') or callable(getattr(self,attr)))]
self.methods = [attr for attr in dir(self) if (not attr.startswith('_') and callable(getattr(self,attr)))]

def printGroundMaterials(self, materialString=None):
"""
Expand Down Expand Up @@ -3642,9 +3653,18 @@ class MetObj:
example, TMY3 data is right-labeled, so 11 AM data represents data from
10 to 11, and sun position should be calculated at 10:30 AM. Currently
SAM and PVSyst use left-labeled interval data and NSRDB uses centered.
Once initialized, the following parameters are available in the MetObj:
-latitude, longitude, elevation, timezone, city [scalar values]
-datetime, ghi, dhi, dni, albedo, dewpoint, pressure, temp_air,
wind_speed, meastracker_angle [numpy.array]
-solpos [pandas dataframe of solar position]
"""

def __repr__(self):
return str(self.__dict__)
def __init__(self, tmydata, metadata, label = 'right'):

import pytz
Expand Down Expand Up @@ -3778,7 +3798,7 @@ def __init__(self, tmydata, metadata, label = 'right'):
self.solpos = pvlib.irradiance.solarposition.get_solarposition(sunup['corrected_timestamp'],lat,lon,elev)
self.sunrisesetdata=sunup
self.label = label

self.columns = [attr for attr in dir(self) if not attr.startswith('_')]

def _set1axis(self, azimuth=180, limit_angle=45, angledelta=None,
backtrack=True, gcr=1.0/3.0, cumulativesky=True,
Expand Down
2 changes: 1 addition & 1 deletion docs/sphinx/source/whatsnew/pending.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ API Changes

Enhancements
~~~~~~~~~~~~

* :py:class:`~bifacial_radiance.RadianceObj` and :py:class:`~bifacial_radiance.GroundObj` and :py:class:`~bifacial_radiance.MetObj` now have `self.columns` and `self.methods` introspection to list data columsn and methods available



Expand Down

0 comments on commit d218698

Please sign in to comment.