{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Reporting Conditions and Predicted Capacities" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import warnings\n", "warnings.filterwarnings('ignore')\n", "import pandas as pd\n", "import matplotlib as plt\n", "import captest as ct" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "First we load the NREL data used for testing and set the translation dictionary." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "meas = ct.load_data('../../tests/data/nrel_data.csv')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "meas.column_groups" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "meas.set_regression_cols(poa='irr_poa_', w_vel='wind__', t_amb='temp__', power='')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "meas.filter_irr(500, 600)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Below is an exmaple of calculating reporting conditions using all defaults, which are set based on the ASTM E2939 standard. The reporting condition method always performs calculations using the filtered dataframe stored in the df_flt attribute.\n", "\n", "- RC_irr 60% percentile\n", "- RC_temp mean\n", "- RC_wind mean\n", "- Calculates values on filtered data\n", "- inplace" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "meas.rep_cond()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Irradiance Balance Method\n", "Setting the `irr_bal` key-word argument to `True` causes the aggregation methods specified with the `func` argument to be ignored and the reporting irradiance is calculated internally by creating an instance of the `ReportingIrradiance` class. This class is intended to implement a strict interpretation of common contract language that specifies the reporting irradiance be determined by finding the irradiance that results in a balance of points within a +/- percent range of the reporting irradiance." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "meas.reset_filter()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "meas.filter_irr(500, 900)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "meas.rep_cond(irr_bal=True, percent_filter=20)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The instance of `ReportingIrradiance` created is stored in the `rc_tool` attribute and additional, so it can be used to access additional documentation of the reporting irradiance calculation. For example, there is a plot method, which marks the reporting irradiance selected on a linked plots showing the count of points above and below the reporting irradiance, the percent of points below the reporting irradiance, and the total points within the specifiec +/- percent band centered on the reporting irradiance." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "meas.rc_tool.plot()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If you have the [Panel](https://panel.holoviz.org/) package installed you can easily obtain an interactive dashboard allowing you to adjust the reporting condition parameters. *Note this dashboard will not work unless you have a live notebook.*" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "meas.rc_tool.dashboard()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The `save_csv` method will save a copy of the following table documenting the possible options for reporting conditions to a csv file." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "meas.rc_tool.poa_flt" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Reporting Conditions spanning New Year Using TMY Data\n", "\n", "The cntg_eoy year function can be used to wrap tmy data around the beginning/end of the year to prepare for calculating reporting conditions using time periods that span the new year." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pvsyst = ct.load_pvsyst('./data/pvsyst_example_HourlyRes_2.CSV')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pvsyst.column_groups" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pvsyst.set_regression_cols(power='real_pwr__', poa='irr_poa_', t_amb='temp_amb_', w_vel='wind__')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pvsyst.df_flt = ct.capdata.wrap_year_end(pvsyst.data_filtered, \n", " pd.Timestamp(year=1989, month=12, day=15),\n", " pd.Timestamp(year=1990, month=1, day=15))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pvsyst.df_flt.head(2)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pvsyst.df_flt.tail(2)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pvsyst.filter_irr(200, 900)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pvsyst.filter_pvsyst()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pvsyst.rep_cond()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Reporting Conditions for Time Periods\n", "\n", "**v0.15.0 Change - This functionality has been moved out of `rep_cond` to the separate `rep_cond_freq` method.**\n", "\n", "The freq option can be used to calculate reporting conditions for groups of time like months or seasons. Any standard aggregation method can be used to calculate the reporting conditions for each group using the func or the irr_bal method options." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pvsyst.reset_filter()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "print(pvsyst.data_filtered.index[0])\n", "print(pvsyst.data_filtered.index[-1])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pvsyst.filter_irr(500, 900)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pvsyst.rep_cond_freq(freq='MS')" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pvsyst.rc" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Using the irr_bal option to calculate reporting conditions for each month of the year results in higher reporting irradiances.\n", "\n", "Note that the with inplace set to False the reporting conditions attribute of the CapData object, pvsyst, is not overwritten." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "ib_rcs = pvsyst.rep_cond_freq(freq='MS', irr_bal=True, percent_filter=20, inplace=False)\n", "ib_rcs" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "(ib_rcs - pvsyst.rc)['poa']" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Predicted Capacities\n", "The `predict_capacities` method will use reporting conditions calculated using the freq option to determine predicted and guaranteed capacities.\n", "\n", "From the previous exercise we still have the montly reporting conditions." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pvsyst.rc" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pvsyst.tolerance = '+/- 7'" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "pvsyst.predict_capacities()" ] } ], "metadata": { "hide_input": false, "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.3" }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": false, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": false, "toc_position": {}, "toc_section_display": true, "toc_window_display": false } }, "nbformat": 4, "nbformat_minor": 4 }