Skip to content

Commit

Permalink
Merge pull request #229 from NREL/release/2.0.1
Browse files Browse the repository at this point in the history
Release/2.0.1
  • Loading branch information
mdeceglie authored Oct 30, 2020
2 parents fb0f39f + 5618ab5 commit c6fd05f
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 108 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Deploy Python Package

on:
release:
types: [published]

jobs:
deploy:
name: Deploy to PyPI
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
- uses: actions/upload-artifact@v2
with:
name: dist
path: |
dist/*
35 changes: 35 additions & 0 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: pytest

on: [pull_request, push]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8]
env: [
'-r requirements.txt .[test]',
'-r requirements-min.txt .[test]',
'--upgrade --upgrade-strategy=eager .[test]'
]
exclude:
- python-version: 3.7
env: '-r requirements-min.txt .[test]'
- python-version: 3.8
env: '-r requirements-min.txt .[test]'

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install ${{ matrix.env }}
run: |
python -m pip install --upgrade pip
pip install ${{ matrix.env }}
- name: Test with pytest ${{ matrix.env }}
run: |
pytest
52 changes: 0 additions & 52 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<img src="./docs/sphinx/source/_images/logo_horizontal_highres.png" width="500" alt="RdTools logo"/>

Master branch:
[![Build Status](https://travis-ci.org/NREL/rdtools.svg?branch=master)](https://travis-ci.org/NREL/rdtools)
[![Build Status](https://github.com/NREL/rdtools/workflows/pytest/badge.svg?branch=master)](https://github.com/NREL/rdtools/actions?query=branch%3Amaster)

Development branch:
[![Build Status](https://travis-ci.org/NREL/rdtools.svg?branch=development)](https://travis-ci.org/NREL/rdtools)
[![Build Status](https://github.com/NREL/rdtools/workflows/pytest/badge.svg?branch=development)](https://github.com/NREL/rdtools/actions?query=branch%3Adevelopment)

RdTools is an open-source library to support reproducible technical analysis of
time series data from photovoltaic energy systems. The library aims to provide
Expand Down
25 changes: 2 additions & 23 deletions docs/degradation_and_soiling_example.ipynb

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/sphinx/source/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
RdTools Change Log
==================

.. include:: changelog/v2.0.1.rst
.. include:: changelog/v2.0.0.rst
.. include:: changelog/pre_2.0.0.rst

14 changes: 14 additions & 0 deletions docs/sphinx/source/changelog/v2.0.1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
*************************
v2.0.1 (October 30, 2020)
*************************

Deprecations
------------
* The deprecation of :py:func:`~rdtools.normalization.pvwatts_dc_power`
and :py:func:`~rdtools.normalization.normalize_with_pvwatts` has been reversed.
(:pull:`227`)

Contributors
------------
* Mike Deceglie (:ghuser:`mdeceglie`)
* Kevin Anderson (:ghuser:`kanderso-nrel`)
24 changes: 11 additions & 13 deletions rdtools/normalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
import warnings
from rdtools._deprecation import deprecated


class ConvergenceError(Exception):
'''Rescale optimization did not converge'''
pass


def normalize_with_expected_power(pv, power_expected, poa_global,
pv_input='power'):
'''
Expand Down Expand Up @@ -70,8 +72,6 @@ def normalize_with_expected_power(pv, power_expected, poa_global,
return energy_normalized, insolation


@deprecated(since='2.0.0', removal='3.0.0',
alternative='normalize_with_expected_power')
def pvwatts_dc_power(poa_global, power_dc_rated, temperature_cell=None,
poa_global_ref=1000, temperature_cell_ref=25,
gamma_pdc=None):
Expand Down Expand Up @@ -120,8 +120,6 @@ def pvwatts_dc_power(poa_global, power_dc_rated, temperature_cell=None,
return power_dc


@deprecated(since='2.0.0', removal='3.0.0',
alternative='normalize_with_expected_power')
def normalize_with_pvwatts(energy, pvwatts_kws):
'''
Normalize system AC energy output given measured poa_global and
Expand Down Expand Up @@ -329,7 +327,7 @@ def _delta_index(series):
# Length of each interval calculated by using 'int64' to convert to
# nanoseconds.
deltas = (series.index - series.index.shift(-1)).astype('int64') / \
(10.0**9 * 3600.0)
(10.0**9 * 3600.0)
return deltas, np.mean(deltas.dropna())


Expand Down Expand Up @@ -418,7 +416,7 @@ def _rmse(fact):
return rmse

guess = np.percentile(irrad.dropna(), 90) / \
np.percentile(irrad_sim.dropna(), 90)
np.percentile(irrad_sim.dropna(), 90)
min_result = minimize(_rmse, guess, method='Nelder-Mead')
factor = min_result['x'][0]

Expand Down Expand Up @@ -514,7 +512,7 @@ def energy_from_power(power, target_frequency=None, max_timedelta=None, power_ty
# use the index frequency to determine the appropriate timescale
if power_type == 'instantaneous':
raise ValueError("power_type='instantaneous' is incompatible with single element "
"power. Use power_type='right-labeled'")
"power. Use power_type='right-labeled'")
if target_frequency is None:
if power.index.freq is None:
raise ValueError('Could not determine period of input power')
Expand Down Expand Up @@ -593,19 +591,19 @@ def _aggregate(time_series, target_frequency, max_timedelta, series_type):
will be returned for that interval.
series_type : {'right_labeled', 'instantaneous'}
The labeling convention of time_series
Returns
-------
pd.Series
right-labeled aggregated time_series in _*hours per interval
'''

#series that has same index as desired output
# series that has same index as desired output
output_dummy = time_series.resample(target_frequency,
closed='right',
label='right').sum()

union_index = time_series.index.union(output_dummy.index)
time_series = time_series.dropna()

Expand Down Expand Up @@ -645,14 +643,14 @@ def _aggregate(time_series, target_frequency, max_timedelta, series_type):
series_sum = pd.Series(data=series_sum, index=time_series.index[1:])

aggregated = series_sum.resample(target_frequency,
closed='right',
label='right').sum(min_count=1)
closed='right',
label='right').sum(min_count=1)

return aggregated


def _interpolate_series(time_series, target_index, max_timedelta=None,
warning_threshold=0.1):
warning_threshold=0.1):
'''
Returns an interpolation of time_series onto target_index, NaN is returned
for times associated with gaps in time_series longer than ``max_timedelta``.
Expand Down
22 changes: 6 additions & 16 deletions rdtools/test/normalization_pvwatts_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
from rdtools.normalization import normalize_with_pvwatts
from rdtools.normalization import pvwatts_dc_power

from conftest import fail_on_rdtools_version
from rdtools._deprecation import rdtoolsDeprecationWarning


class PVWattsNormalizationTestCase(unittest.TestCase):
''' Unit tests for energy normalization module. '''
Expand Down Expand Up @@ -61,14 +58,12 @@ def setUp(self):
def tearDown(self):
pass

@fail_on_rdtools_version('3.0.0')
def test_pvwatts_dc_power(self):
''' Test PVWatts DC power caculation. '''

with pytest.warns(rdtoolsDeprecationWarning):
dc_power = pvwatts_dc_power(self.poa_global, self.power,
temperature_cell=self.temp,
gamma_pdc=self.gamma_pdc)
dc_power = pvwatts_dc_power(self.poa_global, self.power,
temperature_cell=self.temp,
gamma_pdc=self.gamma_pdc)

# Assert output has same frequency and length as input
self.assertEqual(self.poa_global.index.freq, dc_power.index.freq)
Expand All @@ -77,8 +72,6 @@ def test_pvwatts_dc_power(self):
# Assert value of output Series is equal to value expected
self.assertTrue((dc_power == 19.75).all())


@fail_on_rdtools_version('3.0.0')
def test_normalization_with_pvw(self):
''' Test PVWatts normalization. '''

Expand All @@ -89,8 +82,7 @@ def test_normalization_with_pvw(self):
'gamma_pdc': self.gamma_pdc,
}

with pytest.warns(rdtoolsDeprecationWarning):
corr_energy, insolation = normalize_with_pvwatts(self.energy, pvw_kws)
corr_energy, insolation = normalize_with_pvwatts(self.energy, pvw_kws)
corr_energy = corr_energy.reindex(self.energy.index)

# Test output is same frequency and length as energy
Expand All @@ -105,16 +97,14 @@ def test_normalization_with_pvw(self):

# Test expected behavior when energy has no explicit frequency
self.energy.index.freq = None
with pytest.warns(rdtoolsDeprecationWarning):
corr_energy, insolation = normalize_with_pvwatts(self.energy, pvw_kws)
corr_energy, insolation = normalize_with_pvwatts(self.energy, pvw_kws)
corr_energy = corr_energy.reindex(self.energy.index)
self.assertTrue(np.isnan(corr_energy.iloc[0])) # first value should be nan
self.assertTrue((corr_energy.iloc[1:] == 1.0).all()) # rest should be 1

# Test for valueError when energy frequency can't be inferred
with self.assertRaises(ValueError):
with pytest.warns(rdtoolsDeprecationWarning):
corr_energy, insolation = normalize_with_pvwatts(self.irregular_timeseries, pvw_kws)
corr_energy, insolation = normalize_with_pvwatts(self.irregular_timeseries, pvw_kws)


if __name__ == '__main__':
Expand Down
4 changes: 2 additions & 2 deletions rdtools/test/soiling_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def test_annual_soiling_ratios(multi_year_profiles):
srr_profiles, insolation = multi_year_profiles
result = annual_soiling_ratios(srr_profiles, insolation)

pd.testing.assert_frame_equal(result, expected)
pd.testing.assert_frame_equal(result, expected, check_dtype=False)


def test_annual_soiling_ratios_confidence_interval(multi_year_profiles):
Expand All @@ -298,7 +298,7 @@ def test_annual_soiling_ratios_confidence_interval(multi_year_profiles):
srr_profiles, insolation = multi_year_profiles
result = annual_soiling_ratios(srr_profiles, insolation, confidence_level=95)

pd.testing.assert_frame_equal(result, expected)
pd.testing.assert_frame_equal(result, expected, check_dtype=False)


def test_annual_soiling_ratios_warning(multi_year_profiles):
Expand Down

0 comments on commit c6fd05f

Please sign in to comment.