Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RUFF linting/formatting #143

Merged
merged 40 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
a040947
Add initial pyproject toml
paulf81 Dec 6, 2023
0d50c20
Further condition ruff
paulf81 Dec 6, 2023
d2d517f
Ruff format and lint
paulf81 Dec 7, 2023
066284d
Ruff format and lint
paulf81 Dec 7, 2023
e141237
ruff format and lint
paulf81 Dec 7, 2023
db1a282
ruff format and lint
paulf81 Dec 7, 2023
ec33932
Ruff format and lint
paulf81 Dec 7, 2023
a6e1ab2
ruff format and linting
paulf81 Dec 8, 2023
6ee5069
ruff format and linting
paulf81 Dec 8, 2023
e00e310
ruff format and linting
paulf81 Dec 8, 2023
7db1fe1
ruff format and lint
paulf81 Dec 8, 2023
fa6210b
Ruff format and linting
paulf81 Dec 8, 2023
b6ab988
Ruff format and linting
paulf81 Dec 8, 2023
1778d73
ruff format and linting
paulf81 Dec 8, 2023
a05baa0
Include notebooks in ruff
paulf81 Dec 8, 2023
c59492b
ruff format and linting
paulf81 Dec 8, 2023
618e478
ruff format and linting
paulf81 Dec 8, 2023
1f0166e
Add ruff pre-commit instructions and documentation
paulf81 Dec 8, 2023
2f6ea17
ruff format init
paulf81 Dec 8, 2023
a5f680f
fix init imports
paulf81 Dec 8, 2023
fdcbbb4
fix long line
paulf81 Dec 8, 2023
423eb78
ignore unused imports in __init__
paulf81 Dec 12, 2023
f0212b9
fix long line
paulf81 Dec 12, 2023
1ba14b3
formatting
paulf81 Dec 12, 2023
a4ca481
update version.py
paulf81 Dec 12, 2023
4371054
disable long line checks
paulf81 Dec 12, 2023
8121ec0
remove l as variable
paulf81 Dec 12, 2023
d497ef3
clean up
paulf81 Dec 12, 2023
88fc151
formatting
paulf81 Dec 12, 2023
f5ea8f9
formatting
paulf81 Dec 12, 2023
6fcefc6
formatting
paulf81 Dec 12, 2023
7995352
ignore long lines
paulf81 Dec 12, 2023
692c3c6
formatting
paulf81 Dec 12, 2023
efaf44c
ruff formatting / linting
paulf81 Dec 12, 2023
20cddf1
Ruff format and linting
paulf81 Dec 12, 2023
723388b
Update version
paulf81 Dec 12, 2023
4c6b835
update ipy
paulf81 Dec 12, 2023
1f8b2eb
exclude notebooks
paulf81 Dec 12, 2023
c0c2ddc
ruff lint format
paulf81 Dec 12, 2023
a1eba38
ruff lint and format
paulf81 Dec 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/action@v3.0.0
- 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 paul.fleming@nrel.gov.
Expand All @@ -27,7 +27,9 @@ For technical questions or concerns, please email paul.fleming@nrel.gov.
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