Description
The table of parameter names in the docs is a bit dusty and doesn't perfectly reflect today's pvlib. To make it easier to figure out where the gaps are, here's a script that scans the package, finds the parameter names currently in use, and compares with that table:
import pvlib
import pandas as pd
from inspect import getmembers, isfunction, ismodule, signature
from collections import defaultdict
skip_modules = ['version', 'forecast', 'iotools', 'location', 'modelchain', 'tools']
def get_parameter_map():
"""
Find all parameter names used in public pvlib functions
"""
parameter_map = defaultdict(set) # map parameter names to functions that use them
for module_name, module in getmembers(pvlib, ismodule):
if module_name in skip_modules or module_name.startswith("_"):
continue
for function_name, function in getmembers(module, isfunction):
if function_name.startswith("_"):
continue
full_function_name = module_name + "." + function_name
parameter_names = signature(function).parameters.keys()
for parameter_name in parameter_names:
parameter_map[parameter_name].add(full_function_name)
return parameter_map
parameter_map = get_parameter_map()
# read the docs variable name table
url = 'https://raw.githubusercontent.com/pvlib/pvlib-python/master/pvlib/data/variables_style_rules.csv'
df = pd.read_csv(url, sep=';')
listed_names = set(df['variable'])
unlisted_names = set(parameter_map.keys()) - listed_names
print(unlisted_names)
unlisted_names
has over 300 elements. I think it makes sense to leave most of them out of the table, for example function-specific names like upper_line_length
and u0
, but a few of the unlisted ones are common enough to warrant inclusion, e.g. albedo
. It also shows a few inconsistencies like delta_t
vs deltaT
and poa_irradiance
vs poa_global
.
An idea, maybe a bad one: once we've figured out which of the unlisted parameter names we don't want to include in the table, put them in an "ignore list" and create a CI check that performs the above scan to check for new parameter names that aren't in the table but maybe should be.