Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/pvlib/pvlib-python into sno…
Browse files Browse the repository at this point in the history
…w_depth
  • Loading branch information
cwhanse committed Dec 20, 2024
2 parents d46837c + 9fb2eb3 commit 0ef3d7a
Show file tree
Hide file tree
Showing 15 changed files with 434 additions and 65 deletions.
10 changes: 2 additions & 8 deletions docs/examples/shading/plot_martinez_shade_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.dates import ConciseDateFormatter
from matplotlib.dates import DateFormatter

pitch = 4 # meters
width = 1.5 # meters
Expand Down Expand Up @@ -235,10 +235,6 @@
ax1.plot(times, shade_losses, label=k, linestyle=linestyle)
ax1.legend(loc="upper center")
ax1.grid()
ax1.set_xlabel("Time")
ax1.xaxis.set_major_formatter(
ConciseDateFormatter("%H:%M", tz="Europe/Madrid")
)
ax1.set_ylabel(r"$P_{out}$ losses")
ax1.set_title("Per module")

Expand All @@ -248,9 +244,7 @@
ax2.legend(loc="upper center")
ax2.grid()
ax2.set_xlabel("Time")
ax2.xaxis.set_major_formatter(
ConciseDateFormatter("%H:%M", tz="Europe/Madrid")
)
ax2.xaxis.set_major_formatter(DateFormatter("%H:%M", tz="Europe/Madrid"))
ax2.set_ylabel(r"$P_{out}$ losses")
ax2.set_title("Per row")
fig.tight_layout()
Expand Down
4 changes: 3 additions & 1 deletion docs/sphinx/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@

# Enable hover tooltips
hoverxref_auto_ref = True
hoverxref_roles = ["class", "meth", "func", "ref", "term"]
hoverxref_roles = [
"class", "meth", "func", "ref", "term", "obj", "mod", "data"
]
hoverxref_role_types = dict.fromkeys(hoverxref_roles, "tooltip")
hoverxref_domains = ["py"]
hoverxref_intersphinx = list(intersphinx_mapping.keys())
Expand Down
2 changes: 2 additions & 0 deletions docs/sphinx/source/reference/airmass_atmospheric.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Airmass and atmospheric models
atmosphere.get_relative_airmass
atmosphere.pres2alt
atmosphere.alt2pres
atmosphere.tdew_from_rh
atmosphere.rh_from_tdew
atmosphere.gueymard94_pw
atmosphere.first_solar_spectral_correction
atmosphere.bird_hulstrom80_aod_bb
Expand Down
1 change: 1 addition & 0 deletions docs/sphinx/source/whatsnew.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ What's New

These are new features and improvements of note in each release.

.. include:: whatsnew/v0.11.3.rst
.. include:: whatsnew/v0.11.2.rst
.. include:: whatsnew/v0.11.1.rst
.. include:: whatsnew/v0.11.0.rst
Expand Down
76 changes: 47 additions & 29 deletions docs/sphinx/source/whatsnew/v0.11.2.rst
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
.. _whatsnew_01120:


v0.11.2 (Anticipated December, 2024)
------------------------------------
v0.11.2 (December 16, 2024)
---------------------------

Deprecations
~~~~~~~~~~~~
* Deprecated terms ``dni_clearsky`` and ``clearsky_dni``, replaced with ``dni_clear``.
Affected functions are :py:func:`~pvlib.irradiance.dirindex` and :py:func:`~pvlib.irradiance.dni`.
(:issue:`2272`, :pull:`2274`)

* Deprecate terms ``dni_clearsky`` and ``clearsky_dni``, replace with ``dni_clear`` and ``ghi_clear``.
Affected functions are :py:func:`~pvlib.irradiance.dirindex`, :py:func:`~pvlib.irradiance.dni`
and :py:func:`~pvlib.irradiance.clearsky_index`.

Enhancements
~~~~~~~~~~~~
* Add :py:func:`~pvlib.atmosphere.rh_from_tdew` and :py:func:`~pvlib.atmosphere.tdew_from_rh`.
(:issue:`1744`, :pull:`2286`)
* :py:func:`~pvlib.ivtools.sdm.fit_desoto` now allows input of initial
parameter guesses. (:issue:`1014`, :pull:`2291`)

Expand All @@ -28,49 +29,51 @@ Bug Fixes

Bug fixes
~~~~~~~~~
* Change ``dni_extra`` to a required parameter in :py:func:`pvlib.irradiance.ghi_from_poa_driesse_2023`
(:issue:`2279` :pull:`2331`)
* :py:func:`~pvlib.spa.julian_day_dt` now accounts for the 10 day difference
between Julian and Gregorian calendars prior to the year 1582. (:issue:`2077`, :pull:`2249`)
* Correct sign of temperature coefficient ``dEgdT`` in :py:func:`~pvlib.ivtools.sdm.fit_desoto_sandia`.
Results may differ slightly from previous versions. (:issue:`2311`, :pull:`2322`)

Documentation
~~~~~~~~~~~~~
* Edited docstrings for :py:func:`~pvlib.pvsystem.dc_ohms_from_percent` and
* Edit docstrings for :py:func:`~pvlib.pvsystem.dc_ohms_from_percent` and
:py:func:`~pvlib.pvsystem.dc_ohmic_losses` for clarity. (:issue:`1601`, :pull:`2229`)
* Added 'freestanding' and 'insulated' `racking_model` options for cell
temperature calculation in :py:class:`~pvlib.pvsystem.PVSystem`
* Add 'freestanding' and 'insulated' `racking_model` options for cell
temperature calculation in :py:class:`~pvlib.pvsystem.PVSystem`,
:py:class:`~pvlib.pvsystem.SingleAxisTrackerMount`, and
:py:class:`~pvlib.pvsystem.FixedMount` docstrings. Various formatting edits
for clarity. (:issue:`1942`, :pull:`2232`)
* Added a new citation style guide (:ref:`reference_style`) to the contributing
page. (:issue:`2202`, :pull:`2226`)
* Updated :py:func:`~pvlib.irradiance.reindl` to include definitions of terms
* Update :py:func:`~pvlib.irradiance.reindl` to include definitions of terms
and a new "notes" section (:issue:`2183`, :pull:`2193`)
* Clarified the error message in :py:func:`~pvlib.clearsky.detect_clearsky` when
* Clarify the error message in :py:func:`~pvlib.clearsky.detect_clearsky` when
windows contain fewer than three data points (:issue:`2005`, :pull:`2281`)
* Added a new :ref:`nomenclature` page, in place of the Variables and Symbols
* Clarify mounting cases for parameters for :py:func:`~pvlib.temperature.sapm_module`,
:py:func:`~pvlib.temperature.sapm_cell` and :py:func:`~pvlib.temperature.pvsyst_cell`.
(:issue:`1323`, :pull:`2293`)
* Add an example to :py:func:`~pvlib.pvsystem.retrieve_sam` docstring to
demonstrate how to retrieve a database from the SAM repo. (:pull:`2313`)
* Add a new citation style guide (:ref:`reference_style`) to the contributing
page. (:issue:`2202`, :pull:`2226`)
* Explain how to write docstrings for new functions in :ref:`example-docstring`
(:discuss:`2081`, :pull:`2254`)
* Add a section in the style guide for parameter naming and units best practices.
See :ref:`documentation-units`. (:issue:`2205`, :pull:`2248`)
* Add a new :ref:`nomenclature` page, in place of the Variables and Symbols
page, using the sphinx glossary directive. (:issue:`1421`, :pull:`2234`)
* Explained how to write docstrings for new functions in :ref:`example-docstring`
(:discussion:`2081`, :pull:`2254`)
* Added the following variables to the :ref:`nomenclature` page:
* Add the following variables to the :ref:`nomenclature` page:

- `spectra` and `spectra_components` (:issue:`2150`, :pull:`2264`)

* Added a section in the style guide for parameter naming and units best practices.
See :ref:`documentation-units`. (:issue:`2205`, :pull:`2248`)
* Added a example to :py:func:`~pvlib.pvsystem.retrieve_sam` docstring to
demonstrate how to retrieve a database from the SAM repo. (:pull:`2313`)

Testing
~~~~~~~
* Updated test files to track new PVGIS 5.3 data. (:pull:`2305`)


Requirements
~~~~~~~~~~~~

* Update test files to track new PVGIS 5.3 data. (:pull:`2305`)

Maintenance
~~~~~~~~~~~
* Added a decorator to deprecate renamed keyword arguments in functions,
* Add a decorator to deprecate renamed keyword arguments in functions,
:py:func:`pvlib._deprecation.renamed_kwarg_warning`. (:pull:`2237`)


Expand All @@ -81,7 +84,22 @@ Contributors
* Dave Pitts (:ghuser:`dgapitts`)
* Kurt Rhee (:ghuser:`kurt-rhee`)
* Mark Mikofski (:ghuser:`mikofski`)
* matsuobasho (:ghuser:`matsuobasho`)
* Roma Koulikov (:ghuser:`matsuobasho`)
* Echedey Luis (:ghuser:`echedey-ls`)
* Kevin Anderson (:ghuser:`kandersolar`)
* Scott Nelson (:ghuser:`scttnlsn`)
* Ioannis Sifnaios (:ghuser:`IoannisSifnaios`)
* Adam R. Jensen (:ghuser:`AdamRJensen`)
* Anton Driesse (:ghuser:`adriesse`)
* Will Holmgren (:ghuser:`wholmgren`)
* Umay Akkoseoglu (:ghuser:`uakkoseo`)
* Mark Campanelli (:ghuser:`markcampanelli`)
* :ghuser:`iblasi`
* Hiromasa Ihara (:ghuser:`miettal`)
* Yunho Kee (:ghuser:`yhkee0404`)
* Hamilton Kibbe (:ghuser:`hamiltonkibbe`)
* Felix Korbelius (:ghuser:`FelixKoTU`)
* Michael Deceglie (:ghuser:`mdeceglie`)
* Will Hobbs (:ghuser:`williamhobbs`)
* Todd Karin (:ghuser:`toddkarin`)
* Lucas Schneeberger (:ghuser:`lucasschn`)
30 changes: 30 additions & 0 deletions docs/sphinx/source/whatsnew/v0.11.3.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.. _whatsnew_01130:


v0.11.3 (Anticipated March, 2025)
---------------------------------

Deprecations
~~~~~~~~~~~~


Enhancements
~~~~~~~~~~~~


Documentation
~~~~~~~~~~~~~


Testing
~~~~~~~


Requirements
~~~~~~~~~~~~


Contributors
~~~~~~~~~~~~


79 changes: 79 additions & 0 deletions pvlib/atmosphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,85 @@ def gueymard94_pw(temp_air, relative_humidity):
return pw


def rh_from_tdew(temp_air, temp_dew, coeff=(6.112, 17.62, 243.12)):
"""
Calculate relative humidity from dewpoint temperature using the Magnus
equation.
Parameters
----------
temp_air : numeric
Air temperature (dry-bulb temperature). [°C]
temp_dew : numeric
Dew-point temperature. [°C]
coeff : tuple, default (6.112, 17.62, 243.12)
Magnus equation coefficients (A, B, C). The default values are those
recommended by the WMO [1]_.
Returns
-------
numeric
Relative humidity (0.0-100.0). [%]
References
----------
.. [1] "Guide to Instruments and Methods of Observation",
World Meteorological Organization, WMO-No. 8, 2023.
https://library.wmo.int/idurl/4/68695
"""

# Calculate vapor pressure (e) and saturation vapor pressure (es)
e = coeff[0] * np.exp((coeff[1] * temp_air) / (coeff[2] + temp_air))
es = coeff[0] * np.exp((coeff[1] * temp_dew) / (coeff[2] + temp_dew))

# Calculate relative humidity as percentage
relative_humidity = 100 * (es / e)

return relative_humidity


def tdew_from_rh(temp_air, relative_humidity, coeff=(6.112, 17.62, 243.12)):
"""
Calculate dewpoint temperature using the Magnus equation.
This is a reversal of the calculation in :py:func:`rh_from_tdew`.
Parameters
----------
temp_air : numeric
Air temperature (dry-bulb temperature). [°C]
relative_humidity : numeric
Relative humidity (0-100). [%]
coeff: tuple, default (6.112, 17.62, 243.12)
Magnus equation coefficients (A, B, C). The default values are those
recommended by the WMO [1]_.
Returns
-------
numeric
Dewpoint temperature. [°C]
References
----------
.. [1] "Guide to Instruments and Methods of Observation",
World Meteorological Organization, WMO-No. 8, 2023.
https://library.wmo.int/idurl/4/68695
"""
# Calculate the term inside the log
# From RH = 100 * (es/e), we get es = (RH/100) * e
# Substituting the Magnus equation and solving for dewpoint

# First calculate ln(es/A)
ln_term = (
(coeff[1] * temp_air) / (coeff[2] + temp_air)
+ np.log(relative_humidity/100)
)

# Then solve for dewpoint
dewpoint = coeff[2] * ln_term / (coeff[1] - ln_term)

return dewpoint


first_solar_spectral_correction = deprecated(
since='0.10.0',
alternative='pvlib.spectrum.spectral_factor_firstsolar'
Expand Down
8 changes: 4 additions & 4 deletions pvlib/clearsky.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,13 @@ def haurwitz(apparent_zenith):
'''

cos_zenith = tools.cosd(apparent_zenith.values)
clearsky_ghi = np.zeros_like(apparent_zenith.values)
ghi_clear = np.zeros_like(apparent_zenith.values)
cos_zen_gte_0 = cos_zenith > 0
clearsky_ghi[cos_zen_gte_0] = (1098.0 * cos_zenith[cos_zen_gte_0] *
np.exp(-0.059/cos_zenith[cos_zen_gte_0]))
ghi_clear[cos_zen_gte_0] = (1098.0 * cos_zenith[cos_zen_gte_0] *
np.exp(-0.059/cos_zenith[cos_zen_gte_0]))

df_out = pd.DataFrame(index=apparent_zenith.index,
data=clearsky_ghi,
data=ghi_clear,
columns=['ghi'])

return df_out
Expand Down
Loading

0 comments on commit 0ef3d7a

Please sign in to comment.