-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Allowing spa_c() to use localized time index #301
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
Conversation
* converting time to 'UTC' if time index is localized
Hi @wholmgren , I just implemented a quick fix for an issue I raised a while back. Let me know what you think! Thanks! |
I don't think the |
@mikofski is correct -- the spa_c algorithm is not tested on travis or appveyor. You can run the tests on your own machine if the spa files are present when you build pvlib python. I don't want to support spa_c at all, but so long as we do, you should probably add a new test. Still, I am ok merging this in any state. Let me know when you want me to go ahead and click the button. I'd still like to know why you Sunpower folks are using nrel_c instead of nrel_numpy or nrel_numba. nrel_c is slower than both on every machine I've tested them on. |
@wholmgren thanks for your reply. |
Good question! I remember discussing this when we added the nrel_num* methods though I can't seem to find it right now. I think the consensus was that we should keep nrel_c since it was already working and some people might prefer nrel_c because the c code was written by the renewable energy gods on the hill in Golden. Maybe we should add a note to the function documentation with the relative speeds. I guess the benchmarks are somewhat buried at the bottom of the solar position jupyter notebook. I'd suggest that you rerun the benchmarks on your own platform, though. In any case, it don't think it hurts to go ahead with this PR since you've already made the change. Up to you. |
I think it's great to have and keep multiple implementations that should and do give the same results. Great confidence booster! You could have a test that runs both and compares. |
Good point on the confidence booster. The test suite does this in a if A=B and A=C then B=C kind of way. The problem is that it's difficult (impossible?) to run those tests via travis/appveyor since we can't redistribute NREL's spa files. I haven't manually run those tests in a long time. |
You can add
#! /usr/env/python
"""
get spa c source from NREL for travis
"""
import requests
import os
import logging
# logger
logging.basicConfig(level=logging.DEBUG)
LOGGER = logging.getLogger(__file__)
# constants
SPAC_URL = r'https://midcdmz.nrel.gov/apps/download.pl' # spa.c source url
# register with NREL to download spa.c source
PAYLOAD = {
'name': 'pvlib-python', # <-- okay to set this
'country': 'US',
'company': 'pvlib, # <-- okay to set this
'software': 'SPA'
}
SPAH_URL = r'http://midcdmz.nrel.gov/spa/spa.h' # spa.h source url
PVLIB_PATH = os.environ['PVLIB_PATH'] # path to PVLIB on travis
SPA_C_FILES = os.path.join(PVLIB_PATH, 'pvlib', 'spa_c_files')
if __name__ == "__main__":
# get spa.c source
LOGGER.debug('post payload to url: %s\n\tpayload:\n%s', SPAC_URL, PAYLOAD)
r = requests.post(SPAC_URL, data=PAYLOAD)
LOGGER.debug('post response: %r', r)
# save spa.c source to PVLIB/SPA_C_FILES folder
with open(os.path.join(SPA_C_FILES, 'spa.c'), 'wb') as f:
f.write(r.content)
LOGGER.debug('saved file: %r', f.name)
# get spa.c source
LOGGER.debug('get url: %s', SPAH_URL)
r = requests.get(SPAH_URL)
LOGGER.debug('get response: %r', r)
# save spa.c source to PVLIB/SPA_C_FILES folder
with open(os.path.join(SPA_C_FILES, 'spa.h'), 'wb') as f:
f.write(r.content)
LOGGER.debug('saved file: %r', f.name)
LOGGER.debug('exiting %s', __file__) # exit
before_script:
- pip install requests cython
- export PVLIB_PATH=/home/travis/build/pvlib/pvlib-python
- echo $PVLIB_PATH
- python /home/travis/build/pvlib/pvlib-python/get_spa.py
- BUILD_DIR=$PWD
- echo leaving $BUILD_DIR
- cd $PVLIB_PATH/pvlib/spa_c_files/
- echo entered $PWD
- python setup.py build_ext --inplace
- cd $BUILD_DIR
- echo entered $PWD These scripts are adapted from UncertaintyWrapper, so they may be some redundancy or require some minor edits. |
Interesting. Up to you all to make it happen if you want it. Not sure if we'd want a separate Travis build for this or not. |
😆 🤣 |
Thanks for all the inputs everybody. Thanks, |
I can merge this if you remove the update to the whatsnew doc. I can update the whatsnew for you when the next file gets into the repository. I don't want to add the travis script at this time. Tracking down errors on the build matrix is already too time consuming for our current level of support. |
No, I was going to make a PR to @anomam's branch, but got distracted. It can go into 0.4.5 if you resolve the conflict ASAP. |
I can't edit @anomam branch, but I think you can edit a pull request, it's like a GitHub option somewhere - https://help.github.com/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork/ - ah looks like Marc would have to allow it. Sorry 😦 |
closing in favor of #333. |
Really sorry about this guys, I hope I didn't block anything and that you were able to do what you needed to do! @wholmgren |
No worries. I should have merged it back when it was easy to do so. The github "squash-and-merge" process dropped your name from the commit for some dumb reason. Sorry. |
Addresses #237 :
spa_c()
's docstring specifies thattime
can be localized, but the code only assumes 'UTC' time.