-
Notifications
You must be signed in to change notification settings - Fork 1.1k
"Numpy-isation" of irradiance decomposition functions #1456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
pvlib/irradiance.py
Outdated
# this is the I0 calculation from the reference | ||
# SSC uses solar constant = 1367.0 (checked 2018 08 15) | ||
I0 = get_extra_radiation(datetime_or_doy, 1370., 'spencer') | ||
|
||
# Considering the extra radiation is only time dependent, broadcast it to ghi's dimensions | ||
I0 = np.broadcast_to(I0, ghi.shape).astype(np.float32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't believe that all pvlib users would prefer to use float32 - this seems to be a specific requirement of your use case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any downside to using float32 here? Is I0
known with sufficient accuracy to justify float64?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR @alexisstgc. This seems like a good start. Have you checked out the test failures?
pvlib/irradiance.py
Outdated
# this is the I0 calculation from the reference | ||
# SSC uses solar constant = 1367.0 (checked 2018 08 15) | ||
I0 = get_extra_radiation(datetime_or_doy, 1370., 'spencer') | ||
|
||
# Considering the extra radiation is only time dependent, broadcast it to ghi's dimensions | ||
I0 = np.broadcast_to(I0, ghi.shape).astype(np.float32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any downside to using float32 here? Is I0
known with sufficient accuracy to justify float64?
Probably not because the range of
Some upsides:
|
@mikofski I added the option of specifying the dtype of these variables as a environment variable 'PVLIB_IRR_DTYPE' which defaults to np.float64. This way, it is transparent for users who do not need to reduce the precision. |
@alexisstgc can you provide a simplified example of how you're calling this function? I think we can avoid the explicit casting with some care for the input dtypes. |
@wholmgren Here below is my "example". I compute a series of GHI maps, contained in a 3D
|
docs/sphinx/source/reference
for API changes.docs/sphinx/source/whatsnew
for all changes. Includes link to the GitHub Issue with:issue:`num`
or this Pull Request with:pull:`num`
. Includes contributor name and/or GitHub username (link with:ghuser:`user`
).