Comments (5)
@Calama-Consulting is right to express caution. Maybe we should restrict this sort of function signature to those that build on the core pvlib functionality and leave the core functions alone.
It might be interesting to have df input as an optional input along with the explicit variables (which might have been what you were suggesting), but I wouldn't want to move completely to df input.
In this case the "explicit" variables would probably become kwargs, along with the new df
input. Most of these kwargs would probably be set to None
and then we'd need to make sure that sensible error messages inform the user when something is missing from the sum of kwargs and df inputs.
Another option is to suggest that users unpack DataFrames in the parameter call.
Here's a quick example that uses both of the above:
solpos = pd.DataFrame({'elevation':60,'zenith':30,'azimuth':180,'airmass':2.5}, index=['2015-06-21T12:00'])
def func_with_kwargs(elevation=None, zenith=None, **kwargs):
print(elevation)
print(zenith)
print(kwargs)
func_with_kwargs(**solpos)
2015-06-21T12:00 60
Name: elevation, dtype: int64
2015-06-21T12:00 30
Name: zenith, dtype: int64
{'airmass': 2015-06-21T12:00 2.5
Name: airmass, dtype: float64, 'azimuth': 2015-06-21T12:00 180
Name: azimuth, dtype: int64}
I still get tripped up by the kwargs syntax, so this isn't something for beginners.
from pvlib-python.
My intention was to leave the functions as they are and to develop something like a different api, that uses these functions under the hood. So we agree here, I think.
And I also think that one advantage of pvlib ist, that you can use different data sources and models to calculate whatever you want.
The main advantage of such an api would be that "magical" objects could be implemented (if we use consistent dataframe keys) for standard tasks.
A full syntax example could be something like this:
# this function parses a time series provided e.g. by GeoModel (latitude and longitude,
# time format and timezone, irradiance, ambient temperatur) and "translates" all
# GeoModel variable names to "our" names
# could also be any other data provider: TMY's, meteonorm, ...
tus = Location.from_geomodel('tuscon.tsv')
fr = Location.from_geomodel('freiburg.tsv')
# read and parse the system configuration
system = PVSystem.from_json('system.json')
# set a location for the system
system.set_location(tus)
# "magical" method, that looks at the data available and uses
# a standard modelling chain (tilted irradiance, PV module behaviour,
# Inverter, wiring, transformer, ...) to calculate energy yields.
# The results of all modelling steps are stored in a dataframe.
# By default a standard modelling chain is used, however you can
# pass your own.
tus_results = system.calculate_final_yield()
print(tus_results.columns)
[GHI, DHI, GPOA, E_module, ..., E_inverter, E_final]
# print the mean annual energy yield in kWh per kWp
print(tus_results['E_final'].resample('A').mean())
1500
system.set_location(fr)
fr_results = system.calculate_final_yield()
print(fr_results['E_final'].resample('A').mean())
1200
I am not sure if this is in the scope of pvlib, maybe this could be implemented in a different library or application.
from pvlib-python.
What about adding a new module named "applications.py" containing meta functions. If this is not intended by the pvlib, it could be a good idea to start a 'pvlib_app' repository with these meta functions.
I would prefer adding a module.
from pvlib-python.
I very much think that these high level functions should be a part of pvlib. They'll build upon the core library and illustrate how to use each part of it. IPython notebooks that walk through each step of the function could be interesting and educational. These high level functions would be useful for people like me that are not experts in every step of PV system modeling and would be happy to have somebody else choose some reasonable defaults for them.
Where to put them? Some of my thoughts:
- Functions that apply to only (mostly?) one aspect of modeling should go in an existing module.
- Functions that cut across multiple modules should go in something like
api.py
. - Regardless of where it lives, a function could be imported to the
pvlib
level namespace, so that one could usepvlib.magic_function(df)
. - @bmu's nice "factory" methods should stay attached to their classes.
There was some related discussion at the old Sandia-Labs repository.
But back to the issue title, I think that DataFrame inputs make a lot of sense for some of these high level functions.
from pvlib-python.
I think we've basically implemented this via the PVSystem/Location/ModelChain classes.
from pvlib-python.
Related Issues (20)
- Add new spectral factor models HOT 4
- Gallery examples of ModelChains for the DOE Solar Data Bounty Prize systems HOT 12
- AOI dependence for soiling losses HOT 3
- bug: datetime64[ns] and datetime64[s] HOT 3
- Name field of modelchain.results.dc_ohmic_losses is i_mp, which is not correct
- Add full ASTM G-173-03 tables HOT 9
- CECMod modules return ValueError when run ModelChain HOT 8
- Uncertainty about using timezone locale vs UTC in pandas timestamps for solar position HOT 2
- [BUG]: unused `xtol` argument in `ghi_from_poa_driesse_2023`
- Unable to benchmark functions in pvlib using asv HOT 2
- retire support for python 3.7 HOT 4
- Ambiguous descriptions of axis_azimuth and axis_tilt in pvlib.tracking.singleaxis() docs HOT 11
- Allow arbitrary IAM function in pvlib.iam.marion_diffuse, and possibly improve horizon integral computation. HOT 3
- Function to output exact time, in seconds or microseconds or nanoseconds if possible, of sun reaching specific elevation. HOT 3
- ImportError: cannot import name 'total_irrad' from 'pvlib.irradiance' (/usr/local/lib/python3.10/dist-packages/pvlib/irradiance.py) HOT 2
- Docs improvements tracker and ReadTheDocs warnings
- First Solar CEC modules are inferred to be CIGS instead of CdTe HOT 3
- Whether to consider supporting pv power generation in mountainous scenarios? The mountainous terrain can be an irregular triangular network or elevation point data. HOT 1
- v0.10.4 release planning HOT 3
- Single Diode Model error when low effective irradiance (pvlib==0.10.2) HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pvlib-python.