Skip to content

Commit

Permalink
Merge pull request #143 from paulf81/feature/add_ruff_2
Browse files Browse the repository at this point in the history
Add RUFF linting/formatting
  • Loading branch information
paulf81 authored Dec 15, 2023
2 parents eaf6147 + a1eba38 commit 98b8c2b
Show file tree
Hide file tree
Showing 104 changed files with 7,060 additions and 13,217 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ body:
validations:
required: false
required: false
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ blank_issues_enabled: false
contact_links:
- name: GitHub Discussions
url: https://github.com/NREL/flasc/discussions/new
about: Discuss potential issues or ideas here prior to opening a GitHub Issue
about: Discuss potential issues or ideas here prior to opening a GitHub Issue
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/documentation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Documentation
description: Report incorrect documentation or describe new documentation
title: "[Documentation]: <title>"
labels: "Type: Documentation"
body:
body:
- type: textarea
id: doc-issue
attributes:
Expand All @@ -18,4 +18,4 @@ body:
label: URL
description: If this issue references online documentation, enter the complete url here.
placeholder:
https://nrel.github.io/flasc//<full link here>.html
https://nrel.github.io/flasc//<full link here>.html
4 changes: 2 additions & 2 deletions .github/ISSUE_TEMPLATE/feature_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Feature
description: Submit a detailed feature request
title: "[Feature]: <title>"
labels: 'Type: Enhancement'
body:
body:
- type: textarea
id: feature-description
attributes:
Expand All @@ -17,4 +17,4 @@ body:
id: relevant-links
attributes:
label: Related URLs
description: If this feature request is derived from a GitHub Issue or Discussion, enter the url here.
description: If this feature request is derived from a GitHub Issue or Discussion, enter the url here.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
- [ ] docs/source/conf.py
- [ ] flasc/VERSION
- [ ] Create a tag in the NREL/FLASC repository
-->
-->
4 changes: 2 additions & 2 deletions .github/workflows/continuous-integration-workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -e ".[develop]"
- uses: pre-commit/[email protected]
- name: Run tests and collect coverage
run: |
# -rA displays the captured output for all tests after they're run
Expand All @@ -35,11 +36,10 @@ jobs:
pip install pytest
pip install pytest-cov
pytest --cov=./ --cov-report=xml tests/
- name: Upload coverage to Codecov
- name: Upload coverage to Codecov
if: ${{ env.CODECOV_TOKEN }} # Don't attempt to upload if the codecov token is not configured
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
fail_ci_if_error: true

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ _build
docs/build
SMARTEOLE_WakeSteering_ReadMe.xlsx
SMARTEOLE_WakeSteering_Map.pdf
SMARTEOLE-WFC-open-dataset.zip
SMARTEOLE-WFC-open-dataset.zip
26 changes: 26 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

repos:

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-executables-have-shebangs
- id: check-yaml
args: [--unsafe]
- id: check-merge-conflict
- id: check-symlinks
- id: mixed-line-ending

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.1.7
hooks:
# Run the linter.
- id: ruff
types_or: [ python, pyi, jupyter ]
args: [ --fix ]
# Run the formatter.
- id: ruff-format
types_or: [ python, pyi, jupyter ]
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@

## Description

FLASC provides a **rich suite of analysis tools** for SCADA data filtering, analysis,
wind farm model validation, field experiment design, and field experiment monitoring.
FLASC provides a **rich suite of analysis tools** for SCADA data filtering, analysis,
wind farm model validation, field experiment design, and field experiment monitoring.

The repository is centrally built around NRELs in-house ``FLORIS`` wind farm model, available at
**https://github.com/nrel/floris**. FLASC also largely relies on the ``energy ratio``, among others,
to quantify wake losses in synthetic and historical data, to perform turbine northing calibrations,
**https://github.com/nrel/floris**. FLASC also largely relies on the ``energy ratio``, among others,
to quantify wake losses in synthetic and historical data, to perform turbine northing calibrations,
and model parameter estimation.

For technical questions or concerns, please email [email protected].
Expand All @@ -27,7 +27,9 @@ For technical questions or concerns, please email [email protected].
We recommend installing this repository in a separate virtual environment.
After creating a new virtual environment, clone this repository to your local
system and install it locally using ``pip``. The command for this is ``pip install -e flasc``.


If installing for develop, follow the developer [install instructions](https://nrel.github.io/flasc/installation.html)

## Documentation

Documentation is provided via the included examples folders as well as [online documentation](https://nrel.github.io/flasc/).
Expand Down
14 changes: 7 additions & 7 deletions docs/data_processing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ This function also deals with 360-degree wrapping for nacelle headings and
wind direction measurements, as specified by the ``circular_cols`` option.

After each turbine's measurements are sampled onto a common time vector, they
can straightforwardly be appended into a single, wide-formatted table
can straightforwardly be appended into a single, wide-formatted table
(which in Python is a ``pd.DataFrame``). A common way to format a long table
into a wide table, assuming they all share the same ``date`` vector, is:

Expand All @@ -98,7 +98,7 @@ Data filtering
==============

With the SCADA data now in a wide-formatted Pandas DataFrame, the flasc
data filtering tools can readily be applied. The files in
data filtering tools can readily be applied. The files in
``examples_artifical_data/raw_data_processing`` demonstrate how the SCADA data files are
processed.

Expand All @@ -109,7 +109,7 @@ a_00_initial_download.py
The first script, ``a_00_initial_download.py``, simply demonstrates how the raw data is imported. This
basically compromises of the previous two steps, being data downloading and
formatting it into a wide table format. Data is typically saved within flasc
using the
using the
`feather format <https://arrow.apache.org/docs/python/feather.html>`_, which
is known for its excellent IO speed and its efficient storage, being often a
factor 10 smaller than a similar .csv file.
Expand Down Expand Up @@ -317,7 +317,7 @@ turbine 3 and a comparable signal of the met mast. Here, that signal is the
wind direction, which should be comparable between the two turbines.
Note that we have not yet calibrated the turbine's wind direction to
true north, so we may have an offset anywhere between -180 and +180 deg
compared to the met mast signal. The algorithm in
compared to the met mast signal. The algorithm in
``a_06a_determine_timeshift_datasources.py`` accommodates for that by
calculating and subtracting the mean difference in wind directions over
the entire time period. The assign the measurement(s) to compare in
Expand All @@ -338,7 +338,7 @@ a_06b_apply_timeshift_dfs.py (optional)
+++++++++++++++++++++++++++++++++++++++
The optimal time shift found in ``a_06a_determine_timeshift_datasources.py``
is used in this script to shift the time vector of one of the two dataframes
so that they are synchronized with the other dataframe.
so that they are synchronized with the other dataframe.

+++++++++++++++++++++++++++++++++++++
a_07a_estimate_wd_bias_per_turbine.py
Expand Down Expand Up @@ -379,7 +379,7 @@ the average difference between the wind direction signals of the calibrated
turbine and any other (uncalibrated) turbine, and that becomes the bias
correction that the turbine needs. We can determine the shift between
two turbine's wind direction signals using the ``match_y_curves_by_offset``
function, as demonstrated in the example script
function, as demonstrated in the example script
``a_07a_estimate_wd_bias_per_turbine.py``.

For more information how the subtleties about calculating the energy ratio,
Expand Down Expand Up @@ -414,4 +414,4 @@ the example and documentation surrounding the energy ratio analysis suite.
:align: center


.. seealso:: `Return to table of contents <index.html>`_
.. seealso:: `Return to table of contents <index.html>`_
2 changes: 1 addition & 1 deletion docs/energy_ratio.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ Key syntax for computing energy ratios is provided in the examples:
Within the set of analysis of the smarteole dataset are also exmaples of using flasc's energy ratio calculations. See for example:

- [Baseline Energy Ratio Analysis](https://github.com/NREL/flasc/blob/main/examples_smarteole/05_baseline_energy_ratio_analysis.ipynb)
- [Wake Steering Energy Ratio Analysis](https://github.com/NREL/flasc/blob/main/examples_smarteole/06_wake_steering_energy_ratio_analysis.ipynb)
- [Wake Steering Energy Ratio Analysis](https://github.com/NREL/flasc/blob/main/examples_smarteole/06_wake_steering_energy_ratio_analysis.ipynb)
4 changes: 2 additions & 2 deletions docs/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ clock or timezone.
Raw data processing
===================
Once the artificial dataset has been generated, it should be filtered and
postprocessed using the steps described in
postprocessed using the steps described in
`Raw data processing <data_processing.html>`_. This will filter the SCADA data
for measurement outliers and deal with northing calibration.

Expand All @@ -53,4 +53,4 @@ analyses. See `Data analysis <data_analysis.html>`_ for examples on how to
derive useful information from the data, such as for model tuning and model
validation.

.. seealso:: `Return to table of contents <index.html>`_
.. seealso:: `Return to table of contents <index.html>`_
6 changes: 3 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

Welcome to the documentation of the NREL FLASC repository!

FLASC provides a rich suite of analysis tools for SCADA data filtering &
analysis, wind farm model validation, field experiment design, and field
FLASC provides a rich suite of analysis tools for SCADA data filtering &
analysis, wind farm model validation, field experiment design, and field
experiment monitoring. The repository is centrally built around NRELs
in-house [FLORIS](https://github.com/NREL/floris/discussions/)
wake modeling utility.
Expand All @@ -14,4 +14,4 @@ losses in synthetic and historical data, to perform turbine northing
calibrations, and for model parameter estimation.

The FLASC repository is intended as a community driven toolbox, available on
its [GitHub Repository](https://github.com/NREL/flasc).
its [GitHub Repository](https://github.com/NREL/flasc).
39 changes: 39 additions & 0 deletions docs/installation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Installation
-----------------
FLASC is currently not available as a package on any repository manager.
Instead, it must be installed by the user by cloning the GitHub repository.

To download the source code, use `git clone`. Then, add it to
your Python path with the "local editable install" through `pip`.

```bash
# Download the source code.
git clone https://github.com/NREL/flasc.git

# Install into your Python environment
pip install -e flasc

```

If installing FLASC with the intention to develop, some additional configuration is helpful:


Install FLASC in editable mode with the appropriate developer tools

- ``".[develop]"`` is for the linting and code checking tools
- ``".[docs]"`` is for the documentation building tools. Ideally, developers should also be
contributing to the documentation, and therefore checking that the documentation builds locally.

```bash
pip install -e ".[develop, docs]"
```
Turn on the linting and code checking tools

```bash
pre-commit install
```

If everything is configured correctly, any changes made to the source
code will be available directly through your local Python. Remember
to re-import the FLASC module when changes are made if you are working
in an interactive environment like Jupyter.
22 changes: 0 additions & 22 deletions docs/installation.rst

This file was deleted.

2 changes: 1 addition & 1 deletion docs/licensing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ For more information, contact the NREL FLASC team at
limitations under the License.
.. seealso:: `Return to table of contents <index.html>`_
.. seealso:: `Return to table of contents <index.html>`_
4 changes: 2 additions & 2 deletions docs/overview.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Overview

FLASC provides a rich suite of analysis tools for SCADA data filtering &
analysis, wind farm model validation, field experiment design, and field
FLASC provides a rich suite of analysis tools for SCADA data filtering &
analysis, wind farm model validation, field experiment design, and field
experiment monitoring. The repository is centrally built around NRELs
in-house [floris](https://github.com/nrel/floris) wake modeling utility.
FLASC also largely relies on the energy ratio to, among others, quantify wake
Expand Down
6 changes: 3 additions & 3 deletions docs/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ @article{Doekemeijer2022a
note = "In review",
}

@article{Bay2022a,
author={C J Bay and P A Fleming and B M Doekemeijer and J King and M Churchfield and R Mudafort},
@article{Bay2022a,
author={C J Bay and P A Fleming and B M Doekemeijer and J King and M Churchfield and R Mudafort},
TITLE = {Addressing Deep Array Effects and Impacts to Wake Steering with the Cumulative-Curl Wake Model},
JOURNAL = {Wind Energy Science Discussions},
VOLUME = {2022},
Expand All @@ -20,4 +20,4 @@ @article{Bay2022a
__URL = {https://wes.copernicus.org/preprints/wes-2021-32/},
__DOI = {10.5194/wes-2021-32},
note = {In preparation},
}
}
2 changes: 1 addition & 1 deletion docs/total_uplift.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

Total uplift in energy production can be computed from one dataframe to another. It uses a similar input as the [energy ratio](energy_ratio) but returns a single value representing the total uplift, rather then binned by wind direction.

Currently the main example usage of the total uplift function is at the end of [smarteole example 06](https://github.com/NREL/flasc/blob/main/examples_smarteole/06_wake_steering_energy_ratio_analysis.ipynb)
Currently the main example usage of the total uplift function is at the end of [smarteole example 06](https://github.com/NREL/flasc/blob/main/examples_smarteole/06_wake_steering_energy_ratio_analysis.ipynb)
Loading

0 comments on commit 98b8c2b

Please sign in to comment.