Skip to content

Commit

Permalink
Make several undocumented functions private (#1769)
Browse files Browse the repository at this point in the history
* privatize scaling.latlon_to_xy

* privatize iotools.surfrad.format_index

* privatize iotools.srml.format_index and map_columns

* privatize iotools.midc.format_index and format_index_raw

* move calculate_deltat from pvlib.spa to pvlib.solarposition

* rename `spa.py` to `_spa.py`

* update tests

* whatsnew

* Revert "rename `spa.py` to `_spa.py`"

This reverts commit eb2e23a.

* Revert "move calculate_deltat from pvlib.spa to pvlib.solarposition"

This reverts commit f02266f.

* remove SPA mentions from whatsnew

* put back deltaT test

* make `scaling.latlon_to_xy` public again, and include in docs
  • Loading branch information
kandersolar committed Jun 23, 2023
1 parent 948d820 commit 14041cc
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 18 deletions.
1 change: 1 addition & 0 deletions docs/sphinx/source/reference/scaling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ Methods for manipulating irradiance for temporal or spatial considerations
:toctree: generated/

scaling.wvm
scaling.latlon_to_xy
3 changes: 3 additions & 0 deletions docs/sphinx/source/whatsnew/v0.9.6.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ Breaking Changes
(:pull:`1768`)
* For consistency with the rest of pvlib, the ``tilt`` parameter is renamed
to ``surface_tilt`` in :py:func:`pvlib.soiling.hsu`. (:issue:`1717`, :pull:`1738`)
* Several undocumented functions in :py:mod:`pvlib.iotools.midc`,
:py:mod:`pvlib.iotools.srml`, and :py:mod:`pvlib.iotools.surfrad`
are now private. (:issue:`1756`, :pull:`1769`)
* The following, originally deprecated in :ref:`whatsnew_0900`, is now removed: (:pull:`1770`)

- The :py:class:`pvlib.tracking.SingleAxisTracker` class
Expand Down
8 changes: 4 additions & 4 deletions pvlib/iotools/midc.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
}


def format_index(data):
def _format_index(data):
"""Create DatetimeIndex for the Dataframe localized to the timezone provided
as the label of the second (time) column.
Expand All @@ -126,7 +126,7 @@ def format_index(data):
return data


def format_index_raw(data):
def _format_index_raw(data):
"""Create DatetimeIndex for the Dataframe localized to the timezone provided
as the label of the third column.
Expand Down Expand Up @@ -200,9 +200,9 @@ def read_midc(filename, variable_map={}, raw_data=False, **kwargs):
"""
data = pd.read_csv(filename, **kwargs)
if raw_data:
data = format_index_raw(data)
data = _format_index_raw(data)
else:
data = format_index(data)
data = _format_index(data)
data = data.rename(columns=variable_map)
return data

Expand Down
8 changes: 4 additions & 4 deletions pvlib/iotools/srml.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ def read_srml(filename, map_variables=True):
`http://solardat.uoregon.edu/ <http://solardat.uoregon.edu/>`_
"""
tsv_data = pd.read_csv(filename, delimiter='\t')
data = format_index(tsv_data)
data = _format_index(tsv_data)
# Drop day of year and time columns
data = data[data.columns[2:]]

if map_variables:
data = data.rename(columns=map_columns)
data = data.rename(columns=_map_columns)

# Quality flag columns are all labeled 0 in the original data. They
# appear immediately after their associated variable and are suffixed
Expand All @@ -92,7 +92,7 @@ def read_srml(filename, map_variables=True):
return data


def map_columns(col):
def _map_columns(col):
"""Map data element numbers to pvlib names.
Parameters
Expand Down Expand Up @@ -120,7 +120,7 @@ def map_columns(col):
return col


def format_index(df):
def _format_index(df):
"""Create a datetime index from day of year, and time columns.
Parameters
Expand Down
4 changes: 2 additions & 2 deletions pvlib/iotools/surfrad.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def read_surfrad(filename, map_variables=True):
header=None, names=SURFRAD_COLUMNS)
file_buffer.close()

data = format_index(data)
data = _format_index(data)
missing = data == -9999.9
data = data.where(~missing, np.NaN)

Expand All @@ -159,7 +159,7 @@ def read_surfrad(filename, map_variables=True):
return data, metadata


def format_index(data):
def _format_index(data):
"""Create UTC localized DatetimeIndex for the dataframe.
Parameters
Expand Down
12 changes: 6 additions & 6 deletions pvlib/tests/iotools/test_midc.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ def test_mapping():
# '?site=UAT&begin=20181018&end=20181019')


def test_midc_format_index():
def test_midc__format_index():
data = pd.read_csv(MIDC_TESTFILE)
data = midc.format_index(data)
data = midc._format_index(data)
start = pd.Timestamp("20181014 00:00")
start = start.tz_localize("MST")
end = pd.Timestamp("20181014 23:59")
Expand All @@ -39,16 +39,16 @@ def test_midc_format_index():
assert data.index[-1] == end


def test_midc_format_index_tz_conversion():
def test_midc__format_index_tz_conversion():
data = pd.read_csv(MIDC_TESTFILE)
data = data.rename(columns={'MST': 'PST'})
data = midc.format_index(data)
data = midc._format_index(data)
assert data.index[0].tz == pytz.timezone('Etc/GMT+8')


def test_midc_format_index_raw():
def test_midc__format_index_raw():
data = pd.read_csv(MIDC_RAW_TESTFILE)
data = midc.format_index_raw(data)
data = midc._format_index_raw(data)
start = pd.Timestamp('20181018 00:00')
start = start.tz_localize('MST')
end = pd.Timestamp('20181018 23:59')
Expand Down
4 changes: 2 additions & 2 deletions pvlib/tests/iotools/test_srml.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ def test_read_srml_dt_index(url, year, month):
('2001', '2001'),
('2017', 'dni_7')
])
def test_map_columns(column, expected):
assert srml.map_columns(column) == expected
def test__map_columns(column, expected):
assert srml._map_columns(column) == expected


@pytest.mark.remote_data
Expand Down

0 comments on commit 14041cc

Please sign in to comment.