Skip to content

Commit

Permalink
Merges refactor_plot
Browse files Browse the repository at this point in the history
  • Loading branch information
bt- committed May 5, 2024
2 parents 690a7d9 + 8a61958 commit ea69789
Show file tree
Hide file tree
Showing 18 changed files with 658 additions and 199 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[Unreleased]
### Added
- `load_data` can read site location and system information for generating clear sky irradiance from a json or yaml file.
- New plotting module with a plot function which replaces the CapData.plot method. The new plot function creates a panel dashboard with expanded functionality. Internally, removes
the plotting dependency on the CapData.trans_keys attribute.

### Changed
- `load_data` now checks if any individual files were loaded when loading multiple files from a directory.
Expand Down
Binary file added docs/_images/dboard_groups.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_images/dboard_layout.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_images/dboard_overlay.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions docs/examples/clear_sky.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"metadata": {},
"outputs": [],
"source": [
"meas_nrel.plot(ncols=1, width=800, merge_grps=['irr'], subset=['irr_comb'], use_abrev_name=False)"
"meas_nrel.plot(default_groups=['irr_comb'], combine={'irr_comb':'poa|ghi'})"
]
},
{
Expand Down Expand Up @@ -365,7 +365,7 @@
"metadata": {},
"outputs": [],
"source": [
"meas_nrel_trck.plot(ncols=1, width=800, merge_grps=['irr'], subset=['irr_comb'], use_abrev_name=False)"
"meas_nrel_trck.plot(default_groups=['irr_comb'], combine={'irr_comb':'poa|ghi'})"
]
}
],
Expand All @@ -386,7 +386,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.11"
"version": "3.11.3"
},
"toc": {
"base_numbering": 1,
Expand Down
12 changes: 8 additions & 4 deletions docs/examples/complete_capacity_test.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,11 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"The plot method creates a group of time series plots that are useful for visually inspecting the imported data.\n",
"The plot method creates a dashboard with a group of time series plots that are useful for visually inspecting the imported data.\n",
"\n",
"`plot` uses the structure of the `column_group` attribute to create a layout of plots. A single plot is generated for each measurement type and each column with measurements of that type are plotted as a separate line on the plot. In this example there are two different weather stations, which each have pyranometers measuring plane of array and global horizontal irradiance. This arrangement of sensors results in two plots which each have two lines."
"`plot` uses the structure of the `column_groups` attribute to create a layout of plots. A single plot is generated for each measurement type and each column with measurements of that type are plotted as a separate line on the plot. In this example there are two different weather stations, which each have pyranometers measuring plane of array and global horizontal irradiance. This arrangement of sensors results in two plots which each have two lines.\n",
"\n",
"Note, the full functionality of the dashboard requires a live notebook. Try installing to run or using the launch binder button at the top of the page. "
]
},
{
Expand All @@ -207,7 +209,9 @@
"metadata": {},
"outputs": [],
"source": [
"das.plot(width=900, height=250, ncols=1, use_abrev_name=False)"
"combine = {'inv_sum_mtr_pwr': ['mtr', 'inv.*agg'], 'irr_all':['irr_poa', 'irr_ghi'], 'temp_all':['temp_amb', 'temp_mod']}\n",
"default_groups = ['inv_sum_mtr_pwr', 'irr_all', 'temp_all']\n",
"das.plot(combine=combine, default_groups=default_groups)"
]
},
{
Expand Down Expand Up @@ -694,7 +698,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.11"
"version": "3.11.3"
}
},
"nbformat": 4,
Expand Down
14 changes: 12 additions & 2 deletions docs/examples/concise_capacity_test.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,22 @@
"das.agg_sensors(agg_map={'real_pwr_inv':'sum', 'irr_poa':'mean', 'temp_amb':'mean', 'wind':'mean'})"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Note, the full functionality of the dashboard requires a live notebook. Try installing to run or using the launch binder button at the top of the page. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"das.plot(marker='line', width=900, height=250, ncols=1, use_abrev_name=False)"
"combine = {'inv_sum_mtr_pwr': ['mtr', 'inv.*agg'], 'irr_all':['irr_poa', 'irr_ghi'], 'temp_all':['temp_amb', 'temp_mod']}\n",
"default_groups = ['inv_sum_mtr_pwr', 'irr_all', 'temp_all']\n",
"das.plot(combine=combine, default_groups=default_groups)"
]
},
{
Expand Down Expand Up @@ -158,6 +167,7 @@
"metadata": {},
"outputs": [],
"source": [
"das.data.index.name = 'Timestamp' # bug to be addressed in v0.13.0\n",
"das.timeseries_filters().opts(width=1200)"
]
},
Expand Down Expand Up @@ -336,7 +346,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.11"
"version": "3.11.3"
}
},
"nbformat": 4,
Expand Down
8 changes: 8 additions & 0 deletions docs/source/captest.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ captest.util module
:undoc-members:
:show-inheritance:

captest.plotting module
-------------------

.. automodule:: captest.plotting
:members:
:undoc-members:
:show-inheritance:

.. Module contents
.. ---------------
Expand Down
1 change: 1 addition & 0 deletions docs/source/modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ captest
io
prtest
util
plotting
50 changes: 50 additions & 0 deletions docs/user_guide/dataload.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,56 @@ Screenshot of the excel file loaded in the Concise Example Capacity Test showing

The column names in the column groups template excel file are sorted alphabetically after reversing the names, so names with the same ending are grouped together. This is often a good starting point for grouping the columns, but it is not always correct, so review carefully!

Dashboard
---------

The :py:meth:`~captest.capdata.CapData.plot` method of CapData objects will create a `Panel <https://panel.holoviz.org/>`_ dashboard that can be used to explore timeseries plots of the data.

The dashboard contains three tabs: Groups, Layout, and Overlay.

Groups Tab
~~~~~~~~~~
The first tab, Groups, presents a column of plots with a separate plot overlaying the measurements for each group of the :py:attr:`~captest.capdata.CapData.column_groups` attribute. The groups plotted are defined by the ``default_groups`` argument. This is the default tab when the dashboard is first opened.

.. image:: ../_images/dboard_groups.png

The ``default_groups`` argument can be used to specify which groups to plot by passing a list of regular expressions which are used to search the keys of the :py:attr:`~captest.capdata.CapData.column_groups` attribute. The default list of regular expressions attempts to create the following plots:

* Metered power and sum of inverter power, group name is "inv_sum_mtr_pwr"
* Inverter power output - group id must contain "real", "pwr", "inv"
* Metered power output - group id must contain "real", "pwr", "mtr"
* GHI irradiance
* Modeled clear sky POA irradiance
* Modeled clear sky GHI irradiance
* Ambient temperature and BOM temperature - group name is "temp_amb_bom"

The groups names ``inv_sum_mtr_pwr`` and ``temp_amb_bom`` are not keys from :py:attr:`~captest.capdata.CapData.column_groups`, but are created from the dictionary keys of the ``combine`` argument. These labels are for combinations of groups from the ``column_groups`` attribute. The ``combine`` argument can be used to create these combined groups by passing a dictionary of group names and regular expressions. The regular expressions are used to identify groups from :py:attr:`~captest.capdata.CapData.column_groups` and individual tags (columns) of :py:attr:`~captest.capdata.CapData.data` to combine into new groups. The dictionary keys are strings which will be used as the names of new groups. Values should be either a string or a list of two strings. If a string, the string is used as a regex to identify groups to combine. If a list, the first string is used to identify groups to combine and the second is used to identify individual tags (columns) to combine.

See the :py:func:`~captest.plotting.parse_combine` and :py:func:`~captest.plotting.find_default_groups` functions for more details.

The `Layout` and `Overlay` tabs provide the same functionality of combining and selecting groups to be plotted on the `Groups` tab through a GUI without needing to write regular expressions.

Layout Tab
~~~~~~~~~~
The `Layout` tab allows creating a column of plots like the `Groups` tab by selecting groups from the list.

.. image:: ../_images/dboard_layout.png

The button labeled "Set plots to current layout" above the list of groups can be used to replace the figure shown on the `Groups` tab with the current figure on the `Layout` tab. This will save a ``plot_defaults.json`` file in the current working directory that will be used to set the default groups for the `Groups` tab when the :py:meth:`~captest.capdata.CapData.plot` method is called. You will need to rerun the ``plot`` method to see the new defaults.

.. note::

The ``plots_defaults.json`` file will override the ``default_groups`` argument. If you want to use the ``default_groups`` argument, you will need to delete the ``plot_defaults.json`` file.


Overlay Tab
~~~~~~~~~~~
The `Overlay` tab allows picking a group or any combination of individual tags to overlay on a single plot similar to the functionality of the ``combine`` argument.

.. image:: ../_images/dboard_overlay.png

The list of groups and tags can be filtered using regular expressions. The text box at the top left of the tab is used to provide a label for the current overlay, which can be added to the list on the `Layout` tab by clicking the `Update` button.

Identifying Regression Data
---------------------------
To perform the regression pvcaptest uses `statsmodels <https://www.statsmodels.org/stable/index.html>`_, which in turn `relies on patsy <https://www.statsmodels.org/stable/examples/notebooks/generated/formulas.html>`_ to simplify specifying regression equations.
Expand Down
1 change: 1 addition & 0 deletions src/captest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
prtest,
columngroups,
io,
plotting,
)

from captest.io import (
Expand Down
Loading

0 comments on commit ea69789

Please sign in to comment.