You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe. TEMPERATURE_MODEL_PARAMETERS is mentioned several times in the docs, but it isn't published in the api
Describe the solution you'd like
add a docstring after the constant definition in temperature.py like this (exact wording tbd):
TEMPERATURE_MODEL_PARAMETERS= {
'sapm': {
'open_rack_glass_glass': {'a': -3.47, 'b': -.0594, 'deltaT': 3},
'close_mount_glass_glass': {'a': -2.98, 'b': -.0471, 'deltaT': 1},
'open_rack_glass_polymer': {'a': -3.56, 'b': -.0750, 'deltaT': 3},
'insulated_back_glass_polymer': {'a': -2.81, 'b': -.0455, 'deltaT': 0},
},
'pvsyst': {'freestanding': {'u_c': 29.0, 'u_v': 0},
'insulated': {'u_c': 15.0, 'u_v': 0}}
}
"""Dictionary of temperature parameters organized by model.There are keys for each model at the top level. Currently there are two models,``sapm`` for the Sandia Array Performance Model, and ``pvsyst``. Each model hasa dictionary of configurations with a dictionary of the model parametersassociated with it. Retrieve a parameters by indexing the model andconfiguration by name.Example-------Retrieve the open rack glass-polymer configuration for SAPM:: from pvlib.temperature import TEMPERATURE_MODEL_PARAMS temp_params = TEMPERATURE_MODEL_PARAMETERS['sapm']['open_rack_glass_polymer']"""
Then somewhere in the docs add an autodata directive to publish the constant data to the api, like this:
Temperature Model Parameters
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. currentmodule:: pvlib.temperature
.. autodata:: TEMPERATURE_MODEL_PARAMETERS
:annotation:
note: remove :annotation: to show the value of the dictionary
depending on where it goes, you might have to return the module namespace to whatever it was before this entry using something like this:
.. currentmodule:: pvlib
to return it to pvlib for example if this was in api.rst
renders like this:
And now it's in the index
and can be referenced everywhere in the docs using:
in api.rst in the subsection called "PV Temperature Models" part of "PV Modeling"
in pvsystem.rst at the end after SAT, in a new section called "temperature"
huh?
Describe alternatives you've considered
instead of using a dictionary, use a constant class and then add it to the temperature section of api.rst after the Faiman model, here's an example:
class_IndexAttrMeta(type):
"""private meta class to index class attributes like a dictionary"""def__getitem__(self, item):
# retrieve items by index like a dictionaryreturngetattr(self, str(item).lower())
classTEMPERATURE_MODEL_PARAMETERS(metaclass=_IndexAttrMeta):
"""Dictionary of temperature parameters organized by model. There are keys for each model at the top level. Currently there are two models, ``sapm`` for the Sandia Array Performance Model, and ``pvsyst``. Each model has a dictionary of configurations with a dictionary of the model parameters associated with it. Retrieve a parameters by indexing the model and configuration by name. Example ------- Retrieve the open rack glass-polymer configuration for SAPM:: from pvlib.temperature import TEMPERATURE_MODEL_PARAMS temp_params = TEMPERATURE_MODEL_PARAMETERS['sapm']['open_rack_glass_polymer'] """# NOTE: only Python-2 uses __metaclass__,# Python-3 passes this to the class as an argument,# see: https://docs.python.org/3/library/2to3.html#2to3fixer-metaclass# __metaclass__ = _IndexAttrMeta#: Sandia Array Performance Modelsapm= {
'open_rack_glass_glass': {'a': -3.47, 'b': -.0594, 'deltaT': 3},
'close_mount_glass_glass': {'a': -2.98, 'b': -.0471, 'deltaT': 1},
'open_rack_glass_polymer': {'a': -3.56, 'b': -.0750, 'deltaT': 3},
'insulated_back_glass_polymer': {'a': -2.81, 'b': -.0455, 'deltaT': 0}}
#: PVSyst modelpvsyst= {'freestanding': {'u_c': 29.0, 'u_v': 0},
'insulated': {'u_c': 15.0, 'u_v': 0}}
and it will be documented on it's own generated page like other functions
currently, I can't figure out how to remove the __init__ method which is not supposed to be documented, but this isn't my first choice anyway, so if this alternate is the way to go, perhaps someone else can figure out how to remove it?
another option would be to just make it a class, but this would require changing TEMPERATURE_MODEL_PARAMETERS usage everywhere to use attributes instead of items, like TEMPERATURE_MODEL_PARAMETERS.sapm. This option is probably the easiest technically, and safest for readability, but requires some grunt work to find all useage and replace indexing with dot notation.
classTEMPERATURE_MODEL_PARAMETERS:
"""Dictionary of temperature parameters organized by model. There are keys for each model at the top level. Currently there are two models, ``sapm`` for the Sandia Array Performance Model, and ``pvsyst``. Each model has a dictionary of configurations with a dictionary of the model parameters associated with it. Retrieve a parameters by indexing the model and configuration by name. Example ------- Retrieve the open rack glass-polymer configuration for SAPM:: from pvlib.temperature import TEMPERATURE_MODEL_PARAMS temp_params = TEMPERATURE_MODEL_PARAMETERS['sapm']['open_rack_glass_polymer'] """#: Sandia Array Performance Modelsapm= {
'open_rack_glass_glass': {'a': -3.47, 'b': -.0594, 'deltaT': 3},
'close_mount_glass_glass': {'a': -2.98, 'b': -.0471, 'deltaT': 1},
'open_rack_glass_polymer': {'a': -3.56, 'b': -.0750, 'deltaT': 3},
'insulated_back_glass_polymer': {'a': -2.81, 'b': -.0455, 'deltaT': 0}}
#: PVSyst modelpvsyst= {'freestanding': {'u_c': 29.0, 'u_v': 0},
'insulated': {'u_c': 15.0, 'u_v': 0}}
even a more complicated option would be to figure out how use properties to make the models immutable, but just like __getitem__, the property decorator only acts on instances so you would have to figure out how to add it to a metaclass, which is really going too far now:
classMeta(type):
@staticmethoddefbind_geta(a):
# bind `a` so it doesn't change in the loopdefgeta(self):
returngetattr(self, a)
# return the bound function `geta`returngetadef__getitem__(self, arg):
returngetattr(self, arg)
def__new__(cls, name, bases, attrs):
forainattrs:
ifa.startswith('__'):
continueifnota.startswith('_'):
# create the property as an attribute of Metasetattr(cls, a[1:], property(Meta.bind_geta(a)))
returnsuper().__new__(cls, name, bases, attrs)
classTEMPERATURE_MODEL_PARAMETERS(metaclass=Meta):
"""Dictionary of temperature parameters organized by model. There are keys for each model at the top level. Currently there are two models, ``sapm`` for the Sandia Array Performance Model, and ``pvsyst``. Each model has a dictionary of configurations with a dictionary of the model parameters associated with it. Retrieve a parameters by indexing the model and configuration by name. Example ------- Retrieve the open rack glass-polymer configuration for SAPM:: from pvlib.temperature import TEMPERATURE_MODEL_PARAMS temp_params = TEMPERATURE_MODEL_PARAMETERS['sapm']['open_rack_glass_polymer'] """_sapm= {
'open_rack_glass_glass': {'a': -3.47, 'b': -.0594, 'deltaT': 3},
'close_mount_glass_glass': {'a': -2.98, 'b': -.0471, 'deltaT': 1},
'open_rack_glass_polymer': {'a': -3.56, 'b': -.0750, 'deltaT': 3},
'insulated_back_glass_polymer': {'a': -2.81, 'b': -.0455, 'deltaT': 0}}
_pvsyst= {'freestanding': {'u_c': 29.0, 'u_v': 0},
'insulated': {'u_c': 15.0, 'u_v': 0}}
Is your feature request related to a problem? Please describe.
TEMPERATURE_MODEL_PARAMETERS
is mentioned several times in the docs, but it isn't published in the apiDescribe the solution you'd like
add a docstring after the constant definition in
temperature.py
like this (exact wording tbd):Then somewhere in the docs add an
autodata
directive to publish the constant data to the api, like this:note: remove
:annotation:
to show the value of the dictionarydepending on where it goes, you might have to return the module namespace to whatever it was before this entry using something like this:
to return it to
pvlib
for example if this was inapi.rst
renders like this:

And now it's in the index

and can be referenced everywhere in the docs using:
Ideas for where to put it?
api.rst
in the subsection called "PV Temperature Models" part of "PV Modeling"pvsystem.rst
at the end after SAT, in a new section called "temperature"Describe alternatives you've considered
api.rst
after the Faiman model, here's an example:So this works just like it did before:
and all of the tests pass
Now just add it to
api.rst
and it will be documented on it's own generated page like other functions


currently, I can't figure out how to remove the
__init__
method which is not supposed to be documented, but this isn't my first choice anyway, so if this alternate is the way to go, perhaps someone else can figure out how to remove it?TEMPERATURE_MODEL_PARAMETERS
usage everywhere to use attributes instead of items, likeTEMPERATURE_MODEL_PARAMETERS.sapm
. This option is probably the easiest technically, and safest for readability, but requires some grunt work to find all useage and replace indexing with dot notation.__getitem__
, the property decorator only acts on instances so you would have to figure out how to add it to a metaclass, which is really going too far now:Additional context
see #938
The text was updated successfully, but these errors were encountered: