Skip to content

Conversation

@kandersolar
Copy link
Member

As mentioned in #1332, I opted to rework the function to allow scalar orientation inputs instead of editing the docstring to prohibit them. I also did some cleanup in the tests to avoid code duplication.

@kandersolar kandersolar added this to the 0.9.1 milestone Dec 27, 2021
dni = np.array(dni)
dhi = np.array(dhi)
# GH 1127, GH 1332
if np.isscalar(surface_tilt):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use numpy.atleast_1d? It would avoid the if but otherwise I don't know if it's better.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the requirement is that surface_tilt be an array of the same length as the meteo inputs, so np.atleast_1d would still need to be followed by a conditional np.repeat or something.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

full_like docs say it requires a scalar input, but this works:

a = np.array([1,2,3])

np.full_like(a, 7)

array([7, 7, 7])

np.full_like(a, np.array([7,8,9]))

array([7, 8, 9])

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to work with lists and Series too. Always happy to learn a new numpy function :)

dni = np.array(dni)
dhi = np.array(dhi)
# GH 1127, GH 1332
if np.isscalar(surface_tilt):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

full_like docs say it requires a scalar input, but this works:

a = np.array([1,2,3])

np.full_like(a, 7)

array([7, 7, 7])

np.full_like(a, np.array([7,8,9]))

array([7, 8, 9])

@kandersolar
Copy link
Member Author

New test failures are the same as #717 (comment), so ignoring here

@kandersolar kandersolar merged commit 1ab0eb2 into pvlib:master Jan 4, 2022
@kandersolar kandersolar deleted the pvfactors_orientation_fix branch January 4, 2022 01:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pvfactors_timeseries docstring types are incorrect bifacial.pvfactors expects arrays for surface_tilt and surface_azimuth inputs

3 participants