Skip to content

Commit 3ec3cb3

Browse files
authored
Merge branch 'main' into glossary
2 parents 72f2f96 + e77714c commit 3ec3cb3

File tree

8 files changed

+247
-8
lines changed

8 files changed

+247
-8
lines changed

.github/workflows/publish.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,21 @@ jobs:
3333
- name: Build packages
3434
run: python -m build
3535

36+
- name: List distribution file sizes
37+
run: du -h dist/*
38+
3639
- name: Check metadata verification
3740
run: python -m twine check --strict dist/*
3841

42+
- name: Ensure that the wheel installs successfully
43+
run: |
44+
mkdir ./tmp
45+
pip install $(find dist -type f -name "*.whl") --target=./tmp
46+
47+
- name: List installed file sizes
48+
run: du -h pvlib
49+
working-directory: ./tmp
50+
3951
# only publish distribution to PyPI for tagged commits
4052
- name: Publish distribution to PyPI
4153
if: startsWith(github.ref, 'refs/tags/v')

.github/workflows/top-ranked-issues.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
name: Update Top Ranked Issues
22

33
on:
4-
# For testing purposes (can be removed later)
5-
pull_request:
64
schedule:
7-
# # Runs every day at 3:00 AM UTC
8-
# - cron: '0 3 * * *'
9-
- cron: '*/10 * * * *'
5+
# Runs every day at 00:00 AM UTC
6+
- cron: '0 0 * * *'
107

118
jobs:
129
run-script:
1310
runs-on: ubuntu-latest
1411

12+
# Run only if the repository is pvlib/pvlib-python
13+
if: ${{ github.repository == 'pvlib/pvlib-python' }}
14+
1515
env:
1616
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1717

203 KB
Loading

docs/sphinx/source/contributing/style_guide.rst

Lines changed: 186 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,81 @@ the ``docs/readthedocs.org:pvlib-python`` link within the checks
7070
status box at the bottom of the pull request.
7171

7272

73+
.. _references:
74+
75+
References
76+
----------
77+
pvlib-python is transitioning to the `IEEE reference style <https://journals.ieeeauthorcenter.ieee.org/wp-content/uploads/sites/7/IEEE_Reference_Guide.pdf>`_,
78+
which should be used in all new contributions. At minimum, a reference should
79+
include:
80+
81+
* Author list (for more than six authors, list only the first with et al.)
82+
* Publication title
83+
* Publisher (journal title, laboratory name, etc.)
84+
* Year of publication
85+
* DOI (if available)
86+
87+
The recommended citation style for several media types is as follows:
88+
89+
**Journal article**:
90+
91+
Author initials and surname, "Title of article," abbreviated journal
92+
title, vol. number, issue number, page numbers, Abbreviated Month Year.
93+
94+
**Book**:
95+
96+
Author initials. Author Surname, "Chapter title" in Book Title, xth ed.
97+
City of Publisher, (only U.S. State), Country: Abbrev. of Publisher, year,
98+
ch. x, sec. x, pp. xxx–xxx.
99+
100+
**Technical report**:
101+
102+
Author initials. Author Surname, "Report title" Abbrev. publisher name,
103+
City of publisher, Abbrev. State, Country, Rep. xxx, year
104+
105+
The example below shows how to cite material and generate a reference list
106+
using the IEEE style in a docstring::
107+
108+
This is the recommended citation for the pvlib-python project [1]_. There
109+
are also some conference papers linked to pvlib, for example [2]_.
110+
111+
Other types of reference you may find in the pvlib-python documentation
112+
include books [3]_, technical reports [4]_, and websites [5]_.
113+
114+
References
115+
----------
116+
.. [1] K. Anderson, C. Hansen, W. Holmgren, A. Jensen, M. Mikofski,
117+
and A Driesse. "pvlib python: 2023 project update." J. Open Source
118+
Softw. vol. 8, no. 92, pp. 5994, Dec 2023,
119+
:doi:`10.21105/joss.05994`.
120+
121+
.. [2] J. S. Stein, "The Photovoltaic Performance Modeling Collaborative
122+
(PVPMC)," In Proc. 38th IEEE Photovoltaic Specialists Conference
123+
(PVSC), Austin, TX, USA, 2012, pp. 3048-3052,
124+
:doi:`10.1109/PVSC.2012.6318225`.
125+
126+
.. [3] J. A. Duffie and W. A. Beckman, "Solar Radiation" in Solar
127+
Engineering of Thermal Processes, 3rd ed, New York, USA, J. Wiley
128+
and Sons, 2006, ch. 1, sec. 1.5, pp.9-11.
129+
130+
.. [4] R. Bird and C. Riordan, "Simple solar spectral model for direct and
131+
diffuse irradiance on horizontal and tilted planes at the earth’s
132+
surface for cloudless atmospheres", NREL, Golden, CO, USA, Technical
133+
Report TR-215-2436, 1984, :doi:`10.2172/5986936`.
134+
135+
.. [5] "PVPMC Home." Sandia National Laboratories PV Performance Modeling
136+
Collaborative. Accessed: Oct. 17, 2024. [Online.] Available:
137+
<https://pvpmc.sandia.gov/>_
138+
139+
Things to note:
140+
141+
* In-text numeric citations are a number inside square brackets, followed
142+
by an underscore, e.g. ``[1]_``.
143+
* To include a DOI, you can use pvlib's custom ``:doi:``
144+
`Sphinx role <https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html>`_,
145+
followed by the DOI inside a set of backticks.
146+
147+
73148
.. _building-the-documentation:
74149

75150
Building the documentation
@@ -88,7 +163,7 @@ An easy way to do this is with::
88163

89164
Note: Anaconda users may have trouble using the above command to update an
90165
older version of docutils. If that happens, you can update it with ``conda``
91-
(e.g. ``conda install docutils=0.15.2``) and run the above command again.
166+
(e.g. ``conda install docutils=0.21``) and run the above command again.
92167

93168
Once the ``doc`` dependencies are installed, navigate to ``/docs/sphinx`` and
94169
execute::
@@ -107,6 +182,116 @@ Note that Windows users need not have the ``make`` utility installed as pvlib
107182
includes a ``make.bat`` batch file that emulates its interface.
108183

109184

185+
.. _example-docstring:
186+
187+
Example Docstring
188+
-----------------
189+
190+
Here is a template for a function docstring that encapsulates the main
191+
features that may be used in any docstring. Note that not all sections are
192+
required for every function.
193+
194+
.. code-block:: python
195+
196+
def example_function(poa_global, exponents, degree_symbol, time_ref='UT',
197+
optional_arg=None):
198+
r"""
199+
One-sentence summary of the function (no citations).
200+
201+
A longer description of the function. This can include citations
202+
(references) to literature [1]_, websites [2]_, and other code elements
203+
such as functions (:py:func:`pvlib.location.lookup_altitude`) and
204+
classes (:py:class:`pvlib.location.Location`).
205+
206+
.. versionadded:: 0.0.1
207+
There are many more purpose-specific directives, admonitions and such
208+
available at `this link <admonitions>`_. E.g.: ``.. versionchanged::``,
209+
``.. deprecated::``, ``.. note::`` and ``.. warning::``.
210+
211+
.. _admonitions: https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#admonitions-messages-and-warnings
212+
213+
Parameters
214+
----------
215+
poa_global : numeric
216+
Plane-of-array global irradiance, see :term:`poa_global`. [Wm⁻²].
217+
exponents : array-like
218+
A list of exponents. [x⁰¹²³⁴⁵⁶⁷⁸⁹⁻].
219+
degree_symbol : pandas.Series or pandas.DataFrame
220+
It's different from superscript zero. [°].
221+
time_ref : ``'UT'`` or ``'TST'``, default: ``'UT'``
222+
``'UT'`` (universal time) or ``'TST'`` (True Solar Time).
223+
optional_arg : integer, optional
224+
A description of ``optional_arg``. [Unitless].
225+
226+
Specify a suitable datatype for each parameter. Other common
227+
data types include ``str``, ``bool``, ``float``, ``numeric``
228+
and ``pandas.DatetimeIndex``.
229+
230+
Returns
231+
-------
232+
name : numeric
233+
A description of the return value.
234+
235+
Raises
236+
------
237+
ValueError
238+
If ``poa_global`` is negative.
239+
KeyError
240+
If ``time_ref`` does not exist.
241+
242+
Notes
243+
-----
244+
This section can include additional information about the function.
245+
246+
For example, an equation using LaTeX markup:
247+
248+
.. math::
249+
250+
a = \left(\frac{b}{c}\right)^2
251+
252+
where :math:`a` is the result of the equation, and :math:`b` and :math:`c`
253+
are inputs.
254+
255+
Or a figure with a caption:
256+
257+
.. figure:: ../../_images/pvlib_logo_horiz.png
258+
:scale: 10%
259+
:alt: alternate text
260+
:align: center
261+
262+
Figure caption.
263+
264+
See Also
265+
--------
266+
pvlib.location.lookup_altitude, pvlib.location.Location
267+
268+
Examples
269+
--------
270+
>>> example_function(1, 1, pd.Series([1]), "TST", 2)
271+
'Something'
272+
273+
References
274+
----------
275+
A IEEE citation to a relevant reference. You may use an automatic
276+
citation generator to format the citation correctly.
277+
278+
.. [1] Anderson, K., Hansen, C., Holmgren, W., Jensen, A., Mikofski, M.,
279+
and Driesse, A. "pvlib python: 2023 project update." Journal of Open
280+
Source Software, 8(92), 5994, (2023). :doi:`10.21105/joss.05994`.
281+
.. [2] J. Smith and J. Doe. "Obama inaugurated as President." CNN.com.
282+
Accessed: Feb. 1, 2009. [Online.]
283+
Available: http://www.cnn.com/POLITICS/01/21/obama_inaugurated/index.html
284+
"""
285+
a = "Some"
286+
b = "thing"
287+
return a + b
288+
289+
A preview of how this docstring would render in the documentation can be seen in the
290+
following file: :download:`Example docstring<../_images/example_function_screenshot.png>`.
291+
292+
Remember that to show the docstring in the documentation, you must list
293+
the function in the appropriate ``.rst`` file in the ``docs/sphinx/source/reference`` folder.
294+
110295
.. _example-gallery:
111296

112297
Example Gallery

docs/sphinx/source/whatsnew/v0.11.2.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,23 @@ Enhancements
1212
~~~~~~~~~~~~
1313

1414

15+
Bug fixes
16+
~~~~~~~~~
17+
* :py:func:`~pvlib.spa.julian_day_dt` now accounts for the 10 day difference
18+
between Julian and Gregorian calendars prior to the year 1582. (:issue:`2077`, :pull:`2249`)
19+
1520
Documentation
1621
~~~~~~~~~~~~~
1722
* Edited docstrings for :py:func:`~pvlib.pvsystem.dc_ohms_from_percent` and
1823
:py:func:`~pvlib.pvsystem.dc_ohmic_losses` for clarity. (:issue:`1601`, :pull:`2229`)
24+
* Added a new citation style guide (:ref:`references`) to the contributing
25+
page. (:issue:`2202`, :pull:`2226`)
1926
* Updated :py:func:`~pvlib.irradiance.reindl` to include definitions of terms
2027
and a new "notes" section (:issue:`2183`, :pull:`2193`)
2128
* Added a new :ref:`nomenclature` page, in place of the Variables and Symbols
2229
page, using the sphinx glossary directive. (:issue:`1421`, :pull:`2234`)
30+
* Explained how to write docstrings for new functions in :ref:`example-docstring`
31+
(:discussion:`2081`, :pull:`2254`)
2332

2433
Testing
2534
~~~~~~~
@@ -39,6 +48,8 @@ Contributors
3948
~~~~~~~~~~~~
4049
* Cliff Hansen (:ghuser:`cwhanse`)
4150
* Rajiv Daxini (:ghuser:`RDaxini`)
51+
* Dave Pitts (:ghuser:`dgapitts`)
52+
* Kurt Rhee (:ghuser:`kurt-rhee`)
4253
* Mark Mikofski (:ghuser:`mikofski`)
4354
* matsuobasho (:ghuser:`matsuobasho`)
4455
* Echedey Luis (:ghuser:`echedey-ls`)
-231 KB
Binary file not shown.

pvlib/spa.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,10 @@ def julian_day_dt(year, month, day, hour, minute, second, microsecond):
413413
frac_of_day = (microsecond / 1e6 + (second + minute * 60 + hour * 3600)
414414
) * 1.0 / (3600*24)
415415
d = day + frac_of_day
416-
jd = (int(365.25 * (year + 4716)) + int(30.6001 * (month + 1)) + d +
417-
b - 1524.5)
416+
jd = int(365.25 * (year + 4716)) + int(30.6001 * (month + 1)) + d - 1524.5
417+
if jd > 2299160.0:
418+
jd += b
419+
418420
return jd
419421

420422

pvlib/tests/test_spa.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import os
22
import datetime as dt
33
import warnings
4+
import pytest
5+
import pvlib
46

57
try:
68
from importlib import reload
@@ -423,3 +425,30 @@ def test_solar_position_multithreaded(self):
423425
nresult, self.spa.solar_position(
424426
times, lat, lon, elev, pressure, temp, delta_t,
425427
atmos_refract, numthreads=3, sst=True)[:3], 5)
428+
429+
430+
# Define extra test cases for issue #2077
431+
test_cases_issue_2207 = [
432+
((2000, 1, 1, 12, 0, 0), 2451545.0),
433+
((1999, 1, 1, 0, 0, 0), 2451179.5),
434+
((1987, 1, 27, 0, 0, 0), 2446822.5),
435+
((1987, 6, 19, 12, 0, 0), 2446966.0),
436+
((1988, 1, 27, 0, 0, 0), 2447187.5),
437+
((1988, 6, 19, 12, 0, 0), 2447332.0),
438+
((1900, 1, 1, 0, 0, 0), 2415020.5),
439+
((1600, 1, 1, 0, 0, 0), 2305447.5),
440+
((1600, 12, 31, 0, 0, 0), 2305812.5),
441+
((837, 4, 10, 7, 12, 0), 2026871.8),
442+
((-123, 12, 31, 0, 0, 0), 1676496.5),
443+
((-122, 1, 1, 0, 0, 0), 1676497.5),
444+
((-1000, 7, 12, 12, 0, 0), 1356001.0),
445+
((-1000, 2, 29, 0, 0, 0), 1355866.5),
446+
((-1001, 8, 17, 21, 36, 0), 1355671.4),
447+
((-4712, 1, 1, 12, 0, 0), 0.0),
448+
]
449+
450+
451+
@pytest.mark.parametrize("inputs, expected", test_cases_issue_2207)
452+
def test_julian_day_issue_2207(inputs, expected):
453+
result = pvlib.spa.julian_day_dt(*inputs, microsecond=0)
454+
assert result == expected, f"Failed for inputs {inputs}"

0 commit comments

Comments
 (0)